app.js 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128
  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 buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1574. /*!*****************************************************!*\
  1575. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1576. \*****************************************************/
  1577. /*! no static exports found */
  1578. /***/ (function(module, exports, __webpack_require__) {
  1579. /*!
  1580. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1581. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1582. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1583. */
  1584. (function (global, factory) {
  1585. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1586. undefined;
  1587. }(this, (function (exports, $, Popper) { 'use strict';
  1588. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1589. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1590. function _defineProperties(target, props) {
  1591. for (var i = 0; i < props.length; i++) {
  1592. var descriptor = props[i];
  1593. descriptor.enumerable = descriptor.enumerable || false;
  1594. descriptor.configurable = true;
  1595. if ("value" in descriptor) descriptor.writable = true;
  1596. Object.defineProperty(target, descriptor.key, descriptor);
  1597. }
  1598. }
  1599. function _createClass(Constructor, protoProps, staticProps) {
  1600. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1601. if (staticProps) _defineProperties(Constructor, staticProps);
  1602. return Constructor;
  1603. }
  1604. function _defineProperty(obj, key, value) {
  1605. if (key in obj) {
  1606. Object.defineProperty(obj, key, {
  1607. value: value,
  1608. enumerable: true,
  1609. configurable: true,
  1610. writable: true
  1611. });
  1612. } else {
  1613. obj[key] = value;
  1614. }
  1615. return obj;
  1616. }
  1617. function ownKeys(object, enumerableOnly) {
  1618. var keys = Object.keys(object);
  1619. if (Object.getOwnPropertySymbols) {
  1620. var symbols = Object.getOwnPropertySymbols(object);
  1621. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1622. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1623. });
  1624. keys.push.apply(keys, symbols);
  1625. }
  1626. return keys;
  1627. }
  1628. function _objectSpread2(target) {
  1629. for (var i = 1; i < arguments.length; i++) {
  1630. var source = arguments[i] != null ? arguments[i] : {};
  1631. if (i % 2) {
  1632. ownKeys(Object(source), true).forEach(function (key) {
  1633. _defineProperty(target, key, source[key]);
  1634. });
  1635. } else if (Object.getOwnPropertyDescriptors) {
  1636. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1637. } else {
  1638. ownKeys(Object(source)).forEach(function (key) {
  1639. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1640. });
  1641. }
  1642. }
  1643. return target;
  1644. }
  1645. function _inheritsLoose(subClass, superClass) {
  1646. subClass.prototype = Object.create(superClass.prototype);
  1647. subClass.prototype.constructor = subClass;
  1648. subClass.__proto__ = superClass;
  1649. }
  1650. /**
  1651. * --------------------------------------------------------------------------
  1652. * Bootstrap (v4.4.1): util.js
  1653. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1654. * --------------------------------------------------------------------------
  1655. */
  1656. /**
  1657. * ------------------------------------------------------------------------
  1658. * Private TransitionEnd Helpers
  1659. * ------------------------------------------------------------------------
  1660. */
  1661. var TRANSITION_END = 'transitionend';
  1662. var MAX_UID = 1000000;
  1663. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1664. function toType(obj) {
  1665. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1666. }
  1667. function getSpecialTransitionEndEvent() {
  1668. return {
  1669. bindType: TRANSITION_END,
  1670. delegateType: TRANSITION_END,
  1671. handle: function handle(event) {
  1672. if ($(event.target).is(this)) {
  1673. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1674. }
  1675. return undefined; // eslint-disable-line no-undefined
  1676. }
  1677. };
  1678. }
  1679. function transitionEndEmulator(duration) {
  1680. var _this = this;
  1681. var called = false;
  1682. $(this).one(Util.TRANSITION_END, function () {
  1683. called = true;
  1684. });
  1685. setTimeout(function () {
  1686. if (!called) {
  1687. Util.triggerTransitionEnd(_this);
  1688. }
  1689. }, duration);
  1690. return this;
  1691. }
  1692. function setTransitionEndSupport() {
  1693. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1694. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1695. }
  1696. /**
  1697. * --------------------------------------------------------------------------
  1698. * Public Util Api
  1699. * --------------------------------------------------------------------------
  1700. */
  1701. var Util = {
  1702. TRANSITION_END: 'bsTransitionEnd',
  1703. getUID: function getUID(prefix) {
  1704. do {
  1705. // eslint-disable-next-line no-bitwise
  1706. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1707. } while (document.getElementById(prefix));
  1708. return prefix;
  1709. },
  1710. getSelectorFromElement: function getSelectorFromElement(element) {
  1711. var selector = element.getAttribute('data-target');
  1712. if (!selector || selector === '#') {
  1713. var hrefAttr = element.getAttribute('href');
  1714. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1715. }
  1716. try {
  1717. return document.querySelector(selector) ? selector : null;
  1718. } catch (err) {
  1719. return null;
  1720. }
  1721. },
  1722. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1723. if (!element) {
  1724. return 0;
  1725. } // Get transition-duration of the element
  1726. var transitionDuration = $(element).css('transition-duration');
  1727. var transitionDelay = $(element).css('transition-delay');
  1728. var floatTransitionDuration = parseFloat(transitionDuration);
  1729. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1730. if (!floatTransitionDuration && !floatTransitionDelay) {
  1731. return 0;
  1732. } // If multiple durations are defined, take the first
  1733. transitionDuration = transitionDuration.split(',')[0];
  1734. transitionDelay = transitionDelay.split(',')[0];
  1735. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1736. },
  1737. reflow: function reflow(element) {
  1738. return element.offsetHeight;
  1739. },
  1740. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1741. $(element).trigger(TRANSITION_END);
  1742. },
  1743. // TODO: Remove in v5
  1744. supportsTransitionEnd: function supportsTransitionEnd() {
  1745. return Boolean(TRANSITION_END);
  1746. },
  1747. isElement: function isElement(obj) {
  1748. return (obj[0] || obj).nodeType;
  1749. },
  1750. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1751. for (var property in configTypes) {
  1752. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1753. var expectedTypes = configTypes[property];
  1754. var value = config[property];
  1755. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1756. if (!new RegExp(expectedTypes).test(valueType)) {
  1757. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1758. }
  1759. }
  1760. }
  1761. },
  1762. findShadowRoot: function findShadowRoot(element) {
  1763. if (!document.documentElement.attachShadow) {
  1764. return null;
  1765. } // Can find the shadow root otherwise it'll return the document
  1766. if (typeof element.getRootNode === 'function') {
  1767. var root = element.getRootNode();
  1768. return root instanceof ShadowRoot ? root : null;
  1769. }
  1770. if (element instanceof ShadowRoot) {
  1771. return element;
  1772. } // when we don't find a shadow root
  1773. if (!element.parentNode) {
  1774. return null;
  1775. }
  1776. return Util.findShadowRoot(element.parentNode);
  1777. },
  1778. jQueryDetection: function jQueryDetection() {
  1779. if (typeof $ === 'undefined') {
  1780. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  1781. }
  1782. var version = $.fn.jquery.split(' ')[0].split('.');
  1783. var minMajor = 1;
  1784. var ltMajor = 2;
  1785. var minMinor = 9;
  1786. var minPatch = 1;
  1787. var maxMajor = 4;
  1788. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  1789. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  1790. }
  1791. }
  1792. };
  1793. Util.jQueryDetection();
  1794. setTransitionEndSupport();
  1795. /**
  1796. * ------------------------------------------------------------------------
  1797. * Constants
  1798. * ------------------------------------------------------------------------
  1799. */
  1800. var NAME = 'alert';
  1801. var VERSION = '4.4.1';
  1802. var DATA_KEY = 'bs.alert';
  1803. var EVENT_KEY = "." + DATA_KEY;
  1804. var DATA_API_KEY = '.data-api';
  1805. var JQUERY_NO_CONFLICT = $.fn[NAME];
  1806. var Selector = {
  1807. DISMISS: '[data-dismiss="alert"]'
  1808. };
  1809. var Event = {
  1810. CLOSE: "close" + EVENT_KEY,
  1811. CLOSED: "closed" + EVENT_KEY,
  1812. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  1813. };
  1814. var ClassName = {
  1815. ALERT: 'alert',
  1816. FADE: 'fade',
  1817. SHOW: 'show'
  1818. };
  1819. /**
  1820. * ------------------------------------------------------------------------
  1821. * Class Definition
  1822. * ------------------------------------------------------------------------
  1823. */
  1824. var Alert =
  1825. /*#__PURE__*/
  1826. function () {
  1827. function Alert(element) {
  1828. this._element = element;
  1829. } // Getters
  1830. var _proto = Alert.prototype;
  1831. // Public
  1832. _proto.close = function close(element) {
  1833. var rootElement = this._element;
  1834. if (element) {
  1835. rootElement = this._getRootElement(element);
  1836. }
  1837. var customEvent = this._triggerCloseEvent(rootElement);
  1838. if (customEvent.isDefaultPrevented()) {
  1839. return;
  1840. }
  1841. this._removeElement(rootElement);
  1842. };
  1843. _proto.dispose = function dispose() {
  1844. $.removeData(this._element, DATA_KEY);
  1845. this._element = null;
  1846. } // Private
  1847. ;
  1848. _proto._getRootElement = function _getRootElement(element) {
  1849. var selector = Util.getSelectorFromElement(element);
  1850. var parent = false;
  1851. if (selector) {
  1852. parent = document.querySelector(selector);
  1853. }
  1854. if (!parent) {
  1855. parent = $(element).closest("." + ClassName.ALERT)[0];
  1856. }
  1857. return parent;
  1858. };
  1859. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  1860. var closeEvent = $.Event(Event.CLOSE);
  1861. $(element).trigger(closeEvent);
  1862. return closeEvent;
  1863. };
  1864. _proto._removeElement = function _removeElement(element) {
  1865. var _this = this;
  1866. $(element).removeClass(ClassName.SHOW);
  1867. if (!$(element).hasClass(ClassName.FADE)) {
  1868. this._destroyElement(element);
  1869. return;
  1870. }
  1871. var transitionDuration = Util.getTransitionDurationFromElement(element);
  1872. $(element).one(Util.TRANSITION_END, function (event) {
  1873. return _this._destroyElement(element, event);
  1874. }).emulateTransitionEnd(transitionDuration);
  1875. };
  1876. _proto._destroyElement = function _destroyElement(element) {
  1877. $(element).detach().trigger(Event.CLOSED).remove();
  1878. } // Static
  1879. ;
  1880. Alert._jQueryInterface = function _jQueryInterface(config) {
  1881. return this.each(function () {
  1882. var $element = $(this);
  1883. var data = $element.data(DATA_KEY);
  1884. if (!data) {
  1885. data = new Alert(this);
  1886. $element.data(DATA_KEY, data);
  1887. }
  1888. if (config === 'close') {
  1889. data[config](this);
  1890. }
  1891. });
  1892. };
  1893. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  1894. return function (event) {
  1895. if (event) {
  1896. event.preventDefault();
  1897. }
  1898. alertInstance.close(this);
  1899. };
  1900. };
  1901. _createClass(Alert, null, [{
  1902. key: "VERSION",
  1903. get: function get() {
  1904. return VERSION;
  1905. }
  1906. }]);
  1907. return Alert;
  1908. }();
  1909. /**
  1910. * ------------------------------------------------------------------------
  1911. * Data Api implementation
  1912. * ------------------------------------------------------------------------
  1913. */
  1914. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  1915. /**
  1916. * ------------------------------------------------------------------------
  1917. * jQuery
  1918. * ------------------------------------------------------------------------
  1919. */
  1920. $.fn[NAME] = Alert._jQueryInterface;
  1921. $.fn[NAME].Constructor = Alert;
  1922. $.fn[NAME].noConflict = function () {
  1923. $.fn[NAME] = JQUERY_NO_CONFLICT;
  1924. return Alert._jQueryInterface;
  1925. };
  1926. /**
  1927. * ------------------------------------------------------------------------
  1928. * Constants
  1929. * ------------------------------------------------------------------------
  1930. */
  1931. var NAME$1 = 'button';
  1932. var VERSION$1 = '4.4.1';
  1933. var DATA_KEY$1 = 'bs.button';
  1934. var EVENT_KEY$1 = "." + DATA_KEY$1;
  1935. var DATA_API_KEY$1 = '.data-api';
  1936. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  1937. var ClassName$1 = {
  1938. ACTIVE: 'active',
  1939. BUTTON: 'btn',
  1940. FOCUS: 'focus'
  1941. };
  1942. var Selector$1 = {
  1943. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  1944. DATA_TOGGLES: '[data-toggle="buttons"]',
  1945. DATA_TOGGLE: '[data-toggle="button"]',
  1946. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  1947. INPUT: 'input:not([type="hidden"])',
  1948. ACTIVE: '.active',
  1949. BUTTON: '.btn'
  1950. };
  1951. var Event$1 = {
  1952. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  1953. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  1954. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  1955. };
  1956. /**
  1957. * ------------------------------------------------------------------------
  1958. * Class Definition
  1959. * ------------------------------------------------------------------------
  1960. */
  1961. var Button =
  1962. /*#__PURE__*/
  1963. function () {
  1964. function Button(element) {
  1965. this._element = element;
  1966. } // Getters
  1967. var _proto = Button.prototype;
  1968. // Public
  1969. _proto.toggle = function toggle() {
  1970. var triggerChangeEvent = true;
  1971. var addAriaPressed = true;
  1972. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  1973. if (rootElement) {
  1974. var input = this._element.querySelector(Selector$1.INPUT);
  1975. if (input) {
  1976. if (input.type === 'radio') {
  1977. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  1978. triggerChangeEvent = false;
  1979. } else {
  1980. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  1981. if (activeElement) {
  1982. $(activeElement).removeClass(ClassName$1.ACTIVE);
  1983. }
  1984. }
  1985. } else if (input.type === 'checkbox') {
  1986. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  1987. triggerChangeEvent = false;
  1988. }
  1989. } else {
  1990. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  1991. triggerChangeEvent = false;
  1992. }
  1993. if (triggerChangeEvent) {
  1994. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  1995. $(input).trigger('change');
  1996. }
  1997. input.focus();
  1998. addAriaPressed = false;
  1999. }
  2000. }
  2001. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2002. if (addAriaPressed) {
  2003. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2004. }
  2005. if (triggerChangeEvent) {
  2006. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2007. }
  2008. }
  2009. };
  2010. _proto.dispose = function dispose() {
  2011. $.removeData(this._element, DATA_KEY$1);
  2012. this._element = null;
  2013. } // Static
  2014. ;
  2015. Button._jQueryInterface = function _jQueryInterface(config) {
  2016. return this.each(function () {
  2017. var data = $(this).data(DATA_KEY$1);
  2018. if (!data) {
  2019. data = new Button(this);
  2020. $(this).data(DATA_KEY$1, data);
  2021. }
  2022. if (config === 'toggle') {
  2023. data[config]();
  2024. }
  2025. });
  2026. };
  2027. _createClass(Button, null, [{
  2028. key: "VERSION",
  2029. get: function get() {
  2030. return VERSION$1;
  2031. }
  2032. }]);
  2033. return Button;
  2034. }();
  2035. /**
  2036. * ------------------------------------------------------------------------
  2037. * Data Api implementation
  2038. * ------------------------------------------------------------------------
  2039. */
  2040. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2041. var button = event.target;
  2042. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2043. button = $(button).closest(Selector$1.BUTTON)[0];
  2044. }
  2045. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2046. event.preventDefault(); // work around Firefox bug #1540995
  2047. } else {
  2048. var inputBtn = button.querySelector(Selector$1.INPUT);
  2049. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2050. event.preventDefault(); // work around Firefox bug #1540995
  2051. return;
  2052. }
  2053. Button._jQueryInterface.call($(button), 'toggle');
  2054. }
  2055. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2056. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2057. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2058. });
  2059. $(window).on(Event$1.LOAD_DATA_API, function () {
  2060. // ensure correct active class is set to match the controls' actual values/states
  2061. // find all checkboxes/readio buttons inside data-toggle groups
  2062. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2063. for (var i = 0, len = buttons.length; i < len; i++) {
  2064. var button = buttons[i];
  2065. var input = button.querySelector(Selector$1.INPUT);
  2066. if (input.checked || input.hasAttribute('checked')) {
  2067. button.classList.add(ClassName$1.ACTIVE);
  2068. } else {
  2069. button.classList.remove(ClassName$1.ACTIVE);
  2070. }
  2071. } // find all button toggles
  2072. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2073. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2074. var _button = buttons[_i];
  2075. if (_button.getAttribute('aria-pressed') === 'true') {
  2076. _button.classList.add(ClassName$1.ACTIVE);
  2077. } else {
  2078. _button.classList.remove(ClassName$1.ACTIVE);
  2079. }
  2080. }
  2081. });
  2082. /**
  2083. * ------------------------------------------------------------------------
  2084. * jQuery
  2085. * ------------------------------------------------------------------------
  2086. */
  2087. $.fn[NAME$1] = Button._jQueryInterface;
  2088. $.fn[NAME$1].Constructor = Button;
  2089. $.fn[NAME$1].noConflict = function () {
  2090. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2091. return Button._jQueryInterface;
  2092. };
  2093. /**
  2094. * ------------------------------------------------------------------------
  2095. * Constants
  2096. * ------------------------------------------------------------------------
  2097. */
  2098. var NAME$2 = 'carousel';
  2099. var VERSION$2 = '4.4.1';
  2100. var DATA_KEY$2 = 'bs.carousel';
  2101. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2102. var DATA_API_KEY$2 = '.data-api';
  2103. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2104. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2105. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2106. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2107. var SWIPE_THRESHOLD = 40;
  2108. var Default = {
  2109. interval: 5000,
  2110. keyboard: true,
  2111. slide: false,
  2112. pause: 'hover',
  2113. wrap: true,
  2114. touch: true
  2115. };
  2116. var DefaultType = {
  2117. interval: '(number|boolean)',
  2118. keyboard: 'boolean',
  2119. slide: '(boolean|string)',
  2120. pause: '(string|boolean)',
  2121. wrap: 'boolean',
  2122. touch: 'boolean'
  2123. };
  2124. var Direction = {
  2125. NEXT: 'next',
  2126. PREV: 'prev',
  2127. LEFT: 'left',
  2128. RIGHT: 'right'
  2129. };
  2130. var Event$2 = {
  2131. SLIDE: "slide" + EVENT_KEY$2,
  2132. SLID: "slid" + EVENT_KEY$2,
  2133. KEYDOWN: "keydown" + EVENT_KEY$2,
  2134. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2135. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2136. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2137. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2138. TOUCHEND: "touchend" + EVENT_KEY$2,
  2139. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2140. POINTERUP: "pointerup" + EVENT_KEY$2,
  2141. DRAG_START: "dragstart" + EVENT_KEY$2,
  2142. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2143. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2144. };
  2145. var ClassName$2 = {
  2146. CAROUSEL: 'carousel',
  2147. ACTIVE: 'active',
  2148. SLIDE: 'slide',
  2149. RIGHT: 'carousel-item-right',
  2150. LEFT: 'carousel-item-left',
  2151. NEXT: 'carousel-item-next',
  2152. PREV: 'carousel-item-prev',
  2153. ITEM: 'carousel-item',
  2154. POINTER_EVENT: 'pointer-event'
  2155. };
  2156. var Selector$2 = {
  2157. ACTIVE: '.active',
  2158. ACTIVE_ITEM: '.active.carousel-item',
  2159. ITEM: '.carousel-item',
  2160. ITEM_IMG: '.carousel-item img',
  2161. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2162. INDICATORS: '.carousel-indicators',
  2163. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2164. DATA_RIDE: '[data-ride="carousel"]'
  2165. };
  2166. var PointerType = {
  2167. TOUCH: 'touch',
  2168. PEN: 'pen'
  2169. };
  2170. /**
  2171. * ------------------------------------------------------------------------
  2172. * Class Definition
  2173. * ------------------------------------------------------------------------
  2174. */
  2175. var Carousel =
  2176. /*#__PURE__*/
  2177. function () {
  2178. function Carousel(element, config) {
  2179. this._items = null;
  2180. this._interval = null;
  2181. this._activeElement = null;
  2182. this._isPaused = false;
  2183. this._isSliding = false;
  2184. this.touchTimeout = null;
  2185. this.touchStartX = 0;
  2186. this.touchDeltaX = 0;
  2187. this._config = this._getConfig(config);
  2188. this._element = element;
  2189. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2190. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2191. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2192. this._addEventListeners();
  2193. } // Getters
  2194. var _proto = Carousel.prototype;
  2195. // Public
  2196. _proto.next = function next() {
  2197. if (!this._isSliding) {
  2198. this._slide(Direction.NEXT);
  2199. }
  2200. };
  2201. _proto.nextWhenVisible = function nextWhenVisible() {
  2202. // Don't call next when the page isn't visible
  2203. // or the carousel or its parent isn't visible
  2204. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2205. this.next();
  2206. }
  2207. };
  2208. _proto.prev = function prev() {
  2209. if (!this._isSliding) {
  2210. this._slide(Direction.PREV);
  2211. }
  2212. };
  2213. _proto.pause = function pause(event) {
  2214. if (!event) {
  2215. this._isPaused = true;
  2216. }
  2217. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2218. Util.triggerTransitionEnd(this._element);
  2219. this.cycle(true);
  2220. }
  2221. clearInterval(this._interval);
  2222. this._interval = null;
  2223. };
  2224. _proto.cycle = function cycle(event) {
  2225. if (!event) {
  2226. this._isPaused = false;
  2227. }
  2228. if (this._interval) {
  2229. clearInterval(this._interval);
  2230. this._interval = null;
  2231. }
  2232. if (this._config.interval && !this._isPaused) {
  2233. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2234. }
  2235. };
  2236. _proto.to = function to(index) {
  2237. var _this = this;
  2238. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2239. var activeIndex = this._getItemIndex(this._activeElement);
  2240. if (index > this._items.length - 1 || index < 0) {
  2241. return;
  2242. }
  2243. if (this._isSliding) {
  2244. $(this._element).one(Event$2.SLID, function () {
  2245. return _this.to(index);
  2246. });
  2247. return;
  2248. }
  2249. if (activeIndex === index) {
  2250. this.pause();
  2251. this.cycle();
  2252. return;
  2253. }
  2254. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2255. this._slide(direction, this._items[index]);
  2256. };
  2257. _proto.dispose = function dispose() {
  2258. $(this._element).off(EVENT_KEY$2);
  2259. $.removeData(this._element, DATA_KEY$2);
  2260. this._items = null;
  2261. this._config = null;
  2262. this._element = null;
  2263. this._interval = null;
  2264. this._isPaused = null;
  2265. this._isSliding = null;
  2266. this._activeElement = null;
  2267. this._indicatorsElement = null;
  2268. } // Private
  2269. ;
  2270. _proto._getConfig = function _getConfig(config) {
  2271. config = _objectSpread2({}, Default, {}, config);
  2272. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2273. return config;
  2274. };
  2275. _proto._handleSwipe = function _handleSwipe() {
  2276. var absDeltax = Math.abs(this.touchDeltaX);
  2277. if (absDeltax <= SWIPE_THRESHOLD) {
  2278. return;
  2279. }
  2280. var direction = absDeltax / this.touchDeltaX;
  2281. this.touchDeltaX = 0; // swipe left
  2282. if (direction > 0) {
  2283. this.prev();
  2284. } // swipe right
  2285. if (direction < 0) {
  2286. this.next();
  2287. }
  2288. };
  2289. _proto._addEventListeners = function _addEventListeners() {
  2290. var _this2 = this;
  2291. if (this._config.keyboard) {
  2292. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2293. return _this2._keydown(event);
  2294. });
  2295. }
  2296. if (this._config.pause === 'hover') {
  2297. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2298. return _this2.pause(event);
  2299. }).on(Event$2.MOUSELEAVE, function (event) {
  2300. return _this2.cycle(event);
  2301. });
  2302. }
  2303. if (this._config.touch) {
  2304. this._addTouchEventListeners();
  2305. }
  2306. };
  2307. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2308. var _this3 = this;
  2309. if (!this._touchSupported) {
  2310. return;
  2311. }
  2312. var start = function start(event) {
  2313. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2314. _this3.touchStartX = event.originalEvent.clientX;
  2315. } else if (!_this3._pointerEvent) {
  2316. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2317. }
  2318. };
  2319. var move = function move(event) {
  2320. // ensure swiping with one touch and not pinching
  2321. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2322. _this3.touchDeltaX = 0;
  2323. } else {
  2324. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2325. }
  2326. };
  2327. var end = function end(event) {
  2328. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2329. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2330. }
  2331. _this3._handleSwipe();
  2332. if (_this3._config.pause === 'hover') {
  2333. // If it's a touch-enabled device, mouseenter/leave are fired as
  2334. // part of the mouse compatibility events on first tap - the carousel
  2335. // would stop cycling until user tapped out of it;
  2336. // here, we listen for touchend, explicitly pause the carousel
  2337. // (as if it's the second time we tap on it, mouseenter compat event
  2338. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2339. // events to fire) we explicitly restart cycling
  2340. _this3.pause();
  2341. if (_this3.touchTimeout) {
  2342. clearTimeout(_this3.touchTimeout);
  2343. }
  2344. _this3.touchTimeout = setTimeout(function (event) {
  2345. return _this3.cycle(event);
  2346. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2347. }
  2348. };
  2349. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2350. return e.preventDefault();
  2351. });
  2352. if (this._pointerEvent) {
  2353. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2354. return start(event);
  2355. });
  2356. $(this._element).on(Event$2.POINTERUP, function (event) {
  2357. return end(event);
  2358. });
  2359. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2360. } else {
  2361. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2362. return start(event);
  2363. });
  2364. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2365. return move(event);
  2366. });
  2367. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2368. return end(event);
  2369. });
  2370. }
  2371. };
  2372. _proto._keydown = function _keydown(event) {
  2373. if (/input|textarea/i.test(event.target.tagName)) {
  2374. return;
  2375. }
  2376. switch (event.which) {
  2377. case ARROW_LEFT_KEYCODE:
  2378. event.preventDefault();
  2379. this.prev();
  2380. break;
  2381. case ARROW_RIGHT_KEYCODE:
  2382. event.preventDefault();
  2383. this.next();
  2384. break;
  2385. }
  2386. };
  2387. _proto._getItemIndex = function _getItemIndex(element) {
  2388. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2389. return this._items.indexOf(element);
  2390. };
  2391. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2392. var isNextDirection = direction === Direction.NEXT;
  2393. var isPrevDirection = direction === Direction.PREV;
  2394. var activeIndex = this._getItemIndex(activeElement);
  2395. var lastItemIndex = this._items.length - 1;
  2396. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2397. if (isGoingToWrap && !this._config.wrap) {
  2398. return activeElement;
  2399. }
  2400. var delta = direction === Direction.PREV ? -1 : 1;
  2401. var itemIndex = (activeIndex + delta) % this._items.length;
  2402. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2403. };
  2404. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2405. var targetIndex = this._getItemIndex(relatedTarget);
  2406. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2407. var slideEvent = $.Event(Event$2.SLIDE, {
  2408. relatedTarget: relatedTarget,
  2409. direction: eventDirectionName,
  2410. from: fromIndex,
  2411. to: targetIndex
  2412. });
  2413. $(this._element).trigger(slideEvent);
  2414. return slideEvent;
  2415. };
  2416. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2417. if (this._indicatorsElement) {
  2418. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2419. $(indicators).removeClass(ClassName$2.ACTIVE);
  2420. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2421. if (nextIndicator) {
  2422. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2423. }
  2424. }
  2425. };
  2426. _proto._slide = function _slide(direction, element) {
  2427. var _this4 = this;
  2428. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2429. var activeElementIndex = this._getItemIndex(activeElement);
  2430. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2431. var nextElementIndex = this._getItemIndex(nextElement);
  2432. var isCycling = Boolean(this._interval);
  2433. var directionalClassName;
  2434. var orderClassName;
  2435. var eventDirectionName;
  2436. if (direction === Direction.NEXT) {
  2437. directionalClassName = ClassName$2.LEFT;
  2438. orderClassName = ClassName$2.NEXT;
  2439. eventDirectionName = Direction.LEFT;
  2440. } else {
  2441. directionalClassName = ClassName$2.RIGHT;
  2442. orderClassName = ClassName$2.PREV;
  2443. eventDirectionName = Direction.RIGHT;
  2444. }
  2445. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2446. this._isSliding = false;
  2447. return;
  2448. }
  2449. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2450. if (slideEvent.isDefaultPrevented()) {
  2451. return;
  2452. }
  2453. if (!activeElement || !nextElement) {
  2454. // Some weirdness is happening, so we bail
  2455. return;
  2456. }
  2457. this._isSliding = true;
  2458. if (isCycling) {
  2459. this.pause();
  2460. }
  2461. this._setActiveIndicatorElement(nextElement);
  2462. var slidEvent = $.Event(Event$2.SLID, {
  2463. relatedTarget: nextElement,
  2464. direction: eventDirectionName,
  2465. from: activeElementIndex,
  2466. to: nextElementIndex
  2467. });
  2468. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2469. $(nextElement).addClass(orderClassName);
  2470. Util.reflow(nextElement);
  2471. $(activeElement).addClass(directionalClassName);
  2472. $(nextElement).addClass(directionalClassName);
  2473. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2474. if (nextElementInterval) {
  2475. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2476. this._config.interval = nextElementInterval;
  2477. } else {
  2478. this._config.interval = this._config.defaultInterval || this._config.interval;
  2479. }
  2480. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2481. $(activeElement).one(Util.TRANSITION_END, function () {
  2482. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2483. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2484. _this4._isSliding = false;
  2485. setTimeout(function () {
  2486. return $(_this4._element).trigger(slidEvent);
  2487. }, 0);
  2488. }).emulateTransitionEnd(transitionDuration);
  2489. } else {
  2490. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2491. $(nextElement).addClass(ClassName$2.ACTIVE);
  2492. this._isSliding = false;
  2493. $(this._element).trigger(slidEvent);
  2494. }
  2495. if (isCycling) {
  2496. this.cycle();
  2497. }
  2498. } // Static
  2499. ;
  2500. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2501. return this.each(function () {
  2502. var data = $(this).data(DATA_KEY$2);
  2503. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2504. if (typeof config === 'object') {
  2505. _config = _objectSpread2({}, _config, {}, config);
  2506. }
  2507. var action = typeof config === 'string' ? config : _config.slide;
  2508. if (!data) {
  2509. data = new Carousel(this, _config);
  2510. $(this).data(DATA_KEY$2, data);
  2511. }
  2512. if (typeof config === 'number') {
  2513. data.to(config);
  2514. } else if (typeof action === 'string') {
  2515. if (typeof data[action] === 'undefined') {
  2516. throw new TypeError("No method named \"" + action + "\"");
  2517. }
  2518. data[action]();
  2519. } else if (_config.interval && _config.ride) {
  2520. data.pause();
  2521. data.cycle();
  2522. }
  2523. });
  2524. };
  2525. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2526. var selector = Util.getSelectorFromElement(this);
  2527. if (!selector) {
  2528. return;
  2529. }
  2530. var target = $(selector)[0];
  2531. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2532. return;
  2533. }
  2534. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2535. var slideIndex = this.getAttribute('data-slide-to');
  2536. if (slideIndex) {
  2537. config.interval = false;
  2538. }
  2539. Carousel._jQueryInterface.call($(target), config);
  2540. if (slideIndex) {
  2541. $(target).data(DATA_KEY$2).to(slideIndex);
  2542. }
  2543. event.preventDefault();
  2544. };
  2545. _createClass(Carousel, null, [{
  2546. key: "VERSION",
  2547. get: function get() {
  2548. return VERSION$2;
  2549. }
  2550. }, {
  2551. key: "Default",
  2552. get: function get() {
  2553. return Default;
  2554. }
  2555. }]);
  2556. return Carousel;
  2557. }();
  2558. /**
  2559. * ------------------------------------------------------------------------
  2560. * Data Api implementation
  2561. * ------------------------------------------------------------------------
  2562. */
  2563. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2564. $(window).on(Event$2.LOAD_DATA_API, function () {
  2565. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2566. for (var i = 0, len = carousels.length; i < len; i++) {
  2567. var $carousel = $(carousels[i]);
  2568. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2569. }
  2570. });
  2571. /**
  2572. * ------------------------------------------------------------------------
  2573. * jQuery
  2574. * ------------------------------------------------------------------------
  2575. */
  2576. $.fn[NAME$2] = Carousel._jQueryInterface;
  2577. $.fn[NAME$2].Constructor = Carousel;
  2578. $.fn[NAME$2].noConflict = function () {
  2579. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2580. return Carousel._jQueryInterface;
  2581. };
  2582. /**
  2583. * ------------------------------------------------------------------------
  2584. * Constants
  2585. * ------------------------------------------------------------------------
  2586. */
  2587. var NAME$3 = 'collapse';
  2588. var VERSION$3 = '4.4.1';
  2589. var DATA_KEY$3 = 'bs.collapse';
  2590. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2591. var DATA_API_KEY$3 = '.data-api';
  2592. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2593. var Default$1 = {
  2594. toggle: true,
  2595. parent: ''
  2596. };
  2597. var DefaultType$1 = {
  2598. toggle: 'boolean',
  2599. parent: '(string|element)'
  2600. };
  2601. var Event$3 = {
  2602. SHOW: "show" + EVENT_KEY$3,
  2603. SHOWN: "shown" + EVENT_KEY$3,
  2604. HIDE: "hide" + EVENT_KEY$3,
  2605. HIDDEN: "hidden" + EVENT_KEY$3,
  2606. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2607. };
  2608. var ClassName$3 = {
  2609. SHOW: 'show',
  2610. COLLAPSE: 'collapse',
  2611. COLLAPSING: 'collapsing',
  2612. COLLAPSED: 'collapsed'
  2613. };
  2614. var Dimension = {
  2615. WIDTH: 'width',
  2616. HEIGHT: 'height'
  2617. };
  2618. var Selector$3 = {
  2619. ACTIVES: '.show, .collapsing',
  2620. DATA_TOGGLE: '[data-toggle="collapse"]'
  2621. };
  2622. /**
  2623. * ------------------------------------------------------------------------
  2624. * Class Definition
  2625. * ------------------------------------------------------------------------
  2626. */
  2627. var Collapse =
  2628. /*#__PURE__*/
  2629. function () {
  2630. function Collapse(element, config) {
  2631. this._isTransitioning = false;
  2632. this._element = element;
  2633. this._config = this._getConfig(config);
  2634. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2635. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2636. for (var i = 0, len = toggleList.length; i < len; i++) {
  2637. var elem = toggleList[i];
  2638. var selector = Util.getSelectorFromElement(elem);
  2639. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2640. return foundElem === element;
  2641. });
  2642. if (selector !== null && filterElement.length > 0) {
  2643. this._selector = selector;
  2644. this._triggerArray.push(elem);
  2645. }
  2646. }
  2647. this._parent = this._config.parent ? this._getParent() : null;
  2648. if (!this._config.parent) {
  2649. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2650. }
  2651. if (this._config.toggle) {
  2652. this.toggle();
  2653. }
  2654. } // Getters
  2655. var _proto = Collapse.prototype;
  2656. // Public
  2657. _proto.toggle = function toggle() {
  2658. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2659. this.hide();
  2660. } else {
  2661. this.show();
  2662. }
  2663. };
  2664. _proto.show = function show() {
  2665. var _this = this;
  2666. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2667. return;
  2668. }
  2669. var actives;
  2670. var activesData;
  2671. if (this._parent) {
  2672. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2673. if (typeof _this._config.parent === 'string') {
  2674. return elem.getAttribute('data-parent') === _this._config.parent;
  2675. }
  2676. return elem.classList.contains(ClassName$3.COLLAPSE);
  2677. });
  2678. if (actives.length === 0) {
  2679. actives = null;
  2680. }
  2681. }
  2682. if (actives) {
  2683. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2684. if (activesData && activesData._isTransitioning) {
  2685. return;
  2686. }
  2687. }
  2688. var startEvent = $.Event(Event$3.SHOW);
  2689. $(this._element).trigger(startEvent);
  2690. if (startEvent.isDefaultPrevented()) {
  2691. return;
  2692. }
  2693. if (actives) {
  2694. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2695. if (!activesData) {
  2696. $(actives).data(DATA_KEY$3, null);
  2697. }
  2698. }
  2699. var dimension = this._getDimension();
  2700. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2701. this._element.style[dimension] = 0;
  2702. if (this._triggerArray.length) {
  2703. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2704. }
  2705. this.setTransitioning(true);
  2706. var complete = function complete() {
  2707. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2708. _this._element.style[dimension] = '';
  2709. _this.setTransitioning(false);
  2710. $(_this._element).trigger(Event$3.SHOWN);
  2711. };
  2712. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2713. var scrollSize = "scroll" + capitalizedDimension;
  2714. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2715. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2716. this._element.style[dimension] = this._element[scrollSize] + "px";
  2717. };
  2718. _proto.hide = function hide() {
  2719. var _this2 = this;
  2720. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2721. return;
  2722. }
  2723. var startEvent = $.Event(Event$3.HIDE);
  2724. $(this._element).trigger(startEvent);
  2725. if (startEvent.isDefaultPrevented()) {
  2726. return;
  2727. }
  2728. var dimension = this._getDimension();
  2729. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2730. Util.reflow(this._element);
  2731. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2732. var triggerArrayLength = this._triggerArray.length;
  2733. if (triggerArrayLength > 0) {
  2734. for (var i = 0; i < triggerArrayLength; i++) {
  2735. var trigger = this._triggerArray[i];
  2736. var selector = Util.getSelectorFromElement(trigger);
  2737. if (selector !== null) {
  2738. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2739. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2740. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2741. }
  2742. }
  2743. }
  2744. }
  2745. this.setTransitioning(true);
  2746. var complete = function complete() {
  2747. _this2.setTransitioning(false);
  2748. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2749. };
  2750. this._element.style[dimension] = '';
  2751. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2752. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2753. };
  2754. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2755. this._isTransitioning = isTransitioning;
  2756. };
  2757. _proto.dispose = function dispose() {
  2758. $.removeData(this._element, DATA_KEY$3);
  2759. this._config = null;
  2760. this._parent = null;
  2761. this._element = null;
  2762. this._triggerArray = null;
  2763. this._isTransitioning = null;
  2764. } // Private
  2765. ;
  2766. _proto._getConfig = function _getConfig(config) {
  2767. config = _objectSpread2({}, Default$1, {}, config);
  2768. config.toggle = Boolean(config.toggle); // Coerce string values
  2769. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2770. return config;
  2771. };
  2772. _proto._getDimension = function _getDimension() {
  2773. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  2774. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  2775. };
  2776. _proto._getParent = function _getParent() {
  2777. var _this3 = this;
  2778. var parent;
  2779. if (Util.isElement(this._config.parent)) {
  2780. parent = this._config.parent; // It's a jQuery object
  2781. if (typeof this._config.parent.jquery !== 'undefined') {
  2782. parent = this._config.parent[0];
  2783. }
  2784. } else {
  2785. parent = document.querySelector(this._config.parent);
  2786. }
  2787. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  2788. var children = [].slice.call(parent.querySelectorAll(selector));
  2789. $(children).each(function (i, element) {
  2790. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  2791. });
  2792. return parent;
  2793. };
  2794. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  2795. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  2796. if (triggerArray.length) {
  2797. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  2798. }
  2799. } // Static
  2800. ;
  2801. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  2802. var selector = Util.getSelectorFromElement(element);
  2803. return selector ? document.querySelector(selector) : null;
  2804. };
  2805. Collapse._jQueryInterface = function _jQueryInterface(config) {
  2806. return this.each(function () {
  2807. var $this = $(this);
  2808. var data = $this.data(DATA_KEY$3);
  2809. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  2810. if (!data && _config.toggle && /show|hide/.test(_config)) {
  2811. _config.toggle = false;
  2812. }
  2813. if (!data) {
  2814. data = new Collapse(this, _config);
  2815. $this.data(DATA_KEY$3, data);
  2816. }
  2817. if (typeof config === 'string') {
  2818. if (typeof data[config] === 'undefined') {
  2819. throw new TypeError("No method named \"" + config + "\"");
  2820. }
  2821. data[config]();
  2822. }
  2823. });
  2824. };
  2825. _createClass(Collapse, null, [{
  2826. key: "VERSION",
  2827. get: function get() {
  2828. return VERSION$3;
  2829. }
  2830. }, {
  2831. key: "Default",
  2832. get: function get() {
  2833. return Default$1;
  2834. }
  2835. }]);
  2836. return Collapse;
  2837. }();
  2838. /**
  2839. * ------------------------------------------------------------------------
  2840. * Data Api implementation
  2841. * ------------------------------------------------------------------------
  2842. */
  2843. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  2844. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  2845. if (event.currentTarget.tagName === 'A') {
  2846. event.preventDefault();
  2847. }
  2848. var $trigger = $(this);
  2849. var selector = Util.getSelectorFromElement(this);
  2850. var selectors = [].slice.call(document.querySelectorAll(selector));
  2851. $(selectors).each(function () {
  2852. var $target = $(this);
  2853. var data = $target.data(DATA_KEY$3);
  2854. var config = data ? 'toggle' : $trigger.data();
  2855. Collapse._jQueryInterface.call($target, config);
  2856. });
  2857. });
  2858. /**
  2859. * ------------------------------------------------------------------------
  2860. * jQuery
  2861. * ------------------------------------------------------------------------
  2862. */
  2863. $.fn[NAME$3] = Collapse._jQueryInterface;
  2864. $.fn[NAME$3].Constructor = Collapse;
  2865. $.fn[NAME$3].noConflict = function () {
  2866. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  2867. return Collapse._jQueryInterface;
  2868. };
  2869. /**
  2870. * ------------------------------------------------------------------------
  2871. * Constants
  2872. * ------------------------------------------------------------------------
  2873. */
  2874. var NAME$4 = 'dropdown';
  2875. var VERSION$4 = '4.4.1';
  2876. var DATA_KEY$4 = 'bs.dropdown';
  2877. var EVENT_KEY$4 = "." + DATA_KEY$4;
  2878. var DATA_API_KEY$4 = '.data-api';
  2879. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  2880. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  2881. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  2882. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  2883. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  2884. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  2885. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  2886. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  2887. var Event$4 = {
  2888. HIDE: "hide" + EVENT_KEY$4,
  2889. HIDDEN: "hidden" + EVENT_KEY$4,
  2890. SHOW: "show" + EVENT_KEY$4,
  2891. SHOWN: "shown" + EVENT_KEY$4,
  2892. CLICK: "click" + EVENT_KEY$4,
  2893. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  2894. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  2895. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  2896. };
  2897. var ClassName$4 = {
  2898. DISABLED: 'disabled',
  2899. SHOW: 'show',
  2900. DROPUP: 'dropup',
  2901. DROPRIGHT: 'dropright',
  2902. DROPLEFT: 'dropleft',
  2903. MENURIGHT: 'dropdown-menu-right',
  2904. MENULEFT: 'dropdown-menu-left',
  2905. POSITION_STATIC: 'position-static'
  2906. };
  2907. var Selector$4 = {
  2908. DATA_TOGGLE: '[data-toggle="dropdown"]',
  2909. FORM_CHILD: '.dropdown form',
  2910. MENU: '.dropdown-menu',
  2911. NAVBAR_NAV: '.navbar-nav',
  2912. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  2913. };
  2914. var AttachmentMap = {
  2915. TOP: 'top-start',
  2916. TOPEND: 'top-end',
  2917. BOTTOM: 'bottom-start',
  2918. BOTTOMEND: 'bottom-end',
  2919. RIGHT: 'right-start',
  2920. RIGHTEND: 'right-end',
  2921. LEFT: 'left-start',
  2922. LEFTEND: 'left-end'
  2923. };
  2924. var Default$2 = {
  2925. offset: 0,
  2926. flip: true,
  2927. boundary: 'scrollParent',
  2928. reference: 'toggle',
  2929. display: 'dynamic',
  2930. popperConfig: null
  2931. };
  2932. var DefaultType$2 = {
  2933. offset: '(number|string|function)',
  2934. flip: 'boolean',
  2935. boundary: '(string|element)',
  2936. reference: '(string|element)',
  2937. display: 'string',
  2938. popperConfig: '(null|object)'
  2939. };
  2940. /**
  2941. * ------------------------------------------------------------------------
  2942. * Class Definition
  2943. * ------------------------------------------------------------------------
  2944. */
  2945. var Dropdown =
  2946. /*#__PURE__*/
  2947. function () {
  2948. function Dropdown(element, config) {
  2949. this._element = element;
  2950. this._popper = null;
  2951. this._config = this._getConfig(config);
  2952. this._menu = this._getMenuElement();
  2953. this._inNavbar = this._detectNavbar();
  2954. this._addEventListeners();
  2955. } // Getters
  2956. var _proto = Dropdown.prototype;
  2957. // Public
  2958. _proto.toggle = function toggle() {
  2959. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  2960. return;
  2961. }
  2962. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  2963. Dropdown._clearMenus();
  2964. if (isActive) {
  2965. return;
  2966. }
  2967. this.show(true);
  2968. };
  2969. _proto.show = function show(usePopper) {
  2970. if (usePopper === void 0) {
  2971. usePopper = false;
  2972. }
  2973. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  2974. return;
  2975. }
  2976. var relatedTarget = {
  2977. relatedTarget: this._element
  2978. };
  2979. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  2980. var parent = Dropdown._getParentFromElement(this._element);
  2981. $(parent).trigger(showEvent);
  2982. if (showEvent.isDefaultPrevented()) {
  2983. return;
  2984. } // Disable totally Popper.js for Dropdown in Navbar
  2985. if (!this._inNavbar && usePopper) {
  2986. /**
  2987. * Check for Popper dependency
  2988. * Popper - https://popper.js.org
  2989. */
  2990. if (typeof Popper === 'undefined') {
  2991. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  2992. }
  2993. var referenceElement = this._element;
  2994. if (this._config.reference === 'parent') {
  2995. referenceElement = parent;
  2996. } else if (Util.isElement(this._config.reference)) {
  2997. referenceElement = this._config.reference; // Check if it's jQuery element
  2998. if (typeof this._config.reference.jquery !== 'undefined') {
  2999. referenceElement = this._config.reference[0];
  3000. }
  3001. } // If boundary is not `scrollParent`, then set position to `static`
  3002. // to allow the menu to "escape" the scroll parent's boundaries
  3003. // https://github.com/twbs/bootstrap/issues/24251
  3004. if (this._config.boundary !== 'scrollParent') {
  3005. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3006. }
  3007. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3008. } // If this is a touch-enabled device we add extra
  3009. // empty mouseover listeners to the body's immediate children;
  3010. // only needed because of broken event delegation on iOS
  3011. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3012. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3013. $(document.body).children().on('mouseover', null, $.noop);
  3014. }
  3015. this._element.focus();
  3016. this._element.setAttribute('aria-expanded', true);
  3017. $(this._menu).toggleClass(ClassName$4.SHOW);
  3018. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3019. };
  3020. _proto.hide = function hide() {
  3021. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3022. return;
  3023. }
  3024. var relatedTarget = {
  3025. relatedTarget: this._element
  3026. };
  3027. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3028. var parent = Dropdown._getParentFromElement(this._element);
  3029. $(parent).trigger(hideEvent);
  3030. if (hideEvent.isDefaultPrevented()) {
  3031. return;
  3032. }
  3033. if (this._popper) {
  3034. this._popper.destroy();
  3035. }
  3036. $(this._menu).toggleClass(ClassName$4.SHOW);
  3037. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3038. };
  3039. _proto.dispose = function dispose() {
  3040. $.removeData(this._element, DATA_KEY$4);
  3041. $(this._element).off(EVENT_KEY$4);
  3042. this._element = null;
  3043. this._menu = null;
  3044. if (this._popper !== null) {
  3045. this._popper.destroy();
  3046. this._popper = null;
  3047. }
  3048. };
  3049. _proto.update = function update() {
  3050. this._inNavbar = this._detectNavbar();
  3051. if (this._popper !== null) {
  3052. this._popper.scheduleUpdate();
  3053. }
  3054. } // Private
  3055. ;
  3056. _proto._addEventListeners = function _addEventListeners() {
  3057. var _this = this;
  3058. $(this._element).on(Event$4.CLICK, function (event) {
  3059. event.preventDefault();
  3060. event.stopPropagation();
  3061. _this.toggle();
  3062. });
  3063. };
  3064. _proto._getConfig = function _getConfig(config) {
  3065. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3066. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3067. return config;
  3068. };
  3069. _proto._getMenuElement = function _getMenuElement() {
  3070. if (!this._menu) {
  3071. var parent = Dropdown._getParentFromElement(this._element);
  3072. if (parent) {
  3073. this._menu = parent.querySelector(Selector$4.MENU);
  3074. }
  3075. }
  3076. return this._menu;
  3077. };
  3078. _proto._getPlacement = function _getPlacement() {
  3079. var $parentDropdown = $(this._element.parentNode);
  3080. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3081. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3082. placement = AttachmentMap.TOP;
  3083. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3084. placement = AttachmentMap.TOPEND;
  3085. }
  3086. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3087. placement = AttachmentMap.RIGHT;
  3088. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3089. placement = AttachmentMap.LEFT;
  3090. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3091. placement = AttachmentMap.BOTTOMEND;
  3092. }
  3093. return placement;
  3094. };
  3095. _proto._detectNavbar = function _detectNavbar() {
  3096. return $(this._element).closest('.navbar').length > 0;
  3097. };
  3098. _proto._getOffset = function _getOffset() {
  3099. var _this2 = this;
  3100. var offset = {};
  3101. if (typeof this._config.offset === 'function') {
  3102. offset.fn = function (data) {
  3103. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3104. return data;
  3105. };
  3106. } else {
  3107. offset.offset = this._config.offset;
  3108. }
  3109. return offset;
  3110. };
  3111. _proto._getPopperConfig = function _getPopperConfig() {
  3112. var popperConfig = {
  3113. placement: this._getPlacement(),
  3114. modifiers: {
  3115. offset: this._getOffset(),
  3116. flip: {
  3117. enabled: this._config.flip
  3118. },
  3119. preventOverflow: {
  3120. boundariesElement: this._config.boundary
  3121. }
  3122. }
  3123. }; // Disable Popper.js if we have a static display
  3124. if (this._config.display === 'static') {
  3125. popperConfig.modifiers.applyStyle = {
  3126. enabled: false
  3127. };
  3128. }
  3129. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3130. } // Static
  3131. ;
  3132. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3133. return this.each(function () {
  3134. var data = $(this).data(DATA_KEY$4);
  3135. var _config = typeof config === 'object' ? config : null;
  3136. if (!data) {
  3137. data = new Dropdown(this, _config);
  3138. $(this).data(DATA_KEY$4, data);
  3139. }
  3140. if (typeof config === 'string') {
  3141. if (typeof data[config] === 'undefined') {
  3142. throw new TypeError("No method named \"" + config + "\"");
  3143. }
  3144. data[config]();
  3145. }
  3146. });
  3147. };
  3148. Dropdown._clearMenus = function _clearMenus(event) {
  3149. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3150. return;
  3151. }
  3152. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3153. for (var i = 0, len = toggles.length; i < len; i++) {
  3154. var parent = Dropdown._getParentFromElement(toggles[i]);
  3155. var context = $(toggles[i]).data(DATA_KEY$4);
  3156. var relatedTarget = {
  3157. relatedTarget: toggles[i]
  3158. };
  3159. if (event && event.type === 'click') {
  3160. relatedTarget.clickEvent = event;
  3161. }
  3162. if (!context) {
  3163. continue;
  3164. }
  3165. var dropdownMenu = context._menu;
  3166. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3167. continue;
  3168. }
  3169. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3170. continue;
  3171. }
  3172. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3173. $(parent).trigger(hideEvent);
  3174. if (hideEvent.isDefaultPrevented()) {
  3175. continue;
  3176. } // If this is a touch-enabled device we remove the extra
  3177. // empty mouseover listeners we added for iOS support
  3178. if ('ontouchstart' in document.documentElement) {
  3179. $(document.body).children().off('mouseover', null, $.noop);
  3180. }
  3181. toggles[i].setAttribute('aria-expanded', 'false');
  3182. if (context._popper) {
  3183. context._popper.destroy();
  3184. }
  3185. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3186. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3187. }
  3188. };
  3189. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3190. var parent;
  3191. var selector = Util.getSelectorFromElement(element);
  3192. if (selector) {
  3193. parent = document.querySelector(selector);
  3194. }
  3195. return parent || element.parentNode;
  3196. } // eslint-disable-next-line complexity
  3197. ;
  3198. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3199. // If not input/textarea:
  3200. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3201. // If input/textarea:
  3202. // - If space key => not a dropdown command
  3203. // - If key is other than escape
  3204. // - If key is not up or down => not a dropdown command
  3205. // - If trigger inside the menu => not a dropdown command
  3206. 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)) {
  3207. return;
  3208. }
  3209. event.preventDefault();
  3210. event.stopPropagation();
  3211. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3212. return;
  3213. }
  3214. var parent = Dropdown._getParentFromElement(this);
  3215. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3216. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3217. return;
  3218. }
  3219. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3220. if (event.which === ESCAPE_KEYCODE) {
  3221. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3222. $(toggle).trigger('focus');
  3223. }
  3224. $(this).trigger('click');
  3225. return;
  3226. }
  3227. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3228. return $(item).is(':visible');
  3229. });
  3230. if (items.length === 0) {
  3231. return;
  3232. }
  3233. var index = items.indexOf(event.target);
  3234. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3235. // Up
  3236. index--;
  3237. }
  3238. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3239. // Down
  3240. index++;
  3241. }
  3242. if (index < 0) {
  3243. index = 0;
  3244. }
  3245. items[index].focus();
  3246. };
  3247. _createClass(Dropdown, null, [{
  3248. key: "VERSION",
  3249. get: function get() {
  3250. return VERSION$4;
  3251. }
  3252. }, {
  3253. key: "Default",
  3254. get: function get() {
  3255. return Default$2;
  3256. }
  3257. }, {
  3258. key: "DefaultType",
  3259. get: function get() {
  3260. return DefaultType$2;
  3261. }
  3262. }]);
  3263. return Dropdown;
  3264. }();
  3265. /**
  3266. * ------------------------------------------------------------------------
  3267. * Data Api implementation
  3268. * ------------------------------------------------------------------------
  3269. */
  3270. $(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) {
  3271. event.preventDefault();
  3272. event.stopPropagation();
  3273. Dropdown._jQueryInterface.call($(this), 'toggle');
  3274. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3275. e.stopPropagation();
  3276. });
  3277. /**
  3278. * ------------------------------------------------------------------------
  3279. * jQuery
  3280. * ------------------------------------------------------------------------
  3281. */
  3282. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3283. $.fn[NAME$4].Constructor = Dropdown;
  3284. $.fn[NAME$4].noConflict = function () {
  3285. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3286. return Dropdown._jQueryInterface;
  3287. };
  3288. /**
  3289. * ------------------------------------------------------------------------
  3290. * Constants
  3291. * ------------------------------------------------------------------------
  3292. */
  3293. var NAME$5 = 'modal';
  3294. var VERSION$5 = '4.4.1';
  3295. var DATA_KEY$5 = 'bs.modal';
  3296. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3297. var DATA_API_KEY$5 = '.data-api';
  3298. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3299. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3300. var Default$3 = {
  3301. backdrop: true,
  3302. keyboard: true,
  3303. focus: true,
  3304. show: true
  3305. };
  3306. var DefaultType$3 = {
  3307. backdrop: '(boolean|string)',
  3308. keyboard: 'boolean',
  3309. focus: 'boolean',
  3310. show: 'boolean'
  3311. };
  3312. var Event$5 = {
  3313. HIDE: "hide" + EVENT_KEY$5,
  3314. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3315. HIDDEN: "hidden" + EVENT_KEY$5,
  3316. SHOW: "show" + EVENT_KEY$5,
  3317. SHOWN: "shown" + EVENT_KEY$5,
  3318. FOCUSIN: "focusin" + EVENT_KEY$5,
  3319. RESIZE: "resize" + EVENT_KEY$5,
  3320. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3321. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3322. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3323. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3324. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3325. };
  3326. var ClassName$5 = {
  3327. SCROLLABLE: 'modal-dialog-scrollable',
  3328. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3329. BACKDROP: 'modal-backdrop',
  3330. OPEN: 'modal-open',
  3331. FADE: 'fade',
  3332. SHOW: 'show',
  3333. STATIC: 'modal-static'
  3334. };
  3335. var Selector$5 = {
  3336. DIALOG: '.modal-dialog',
  3337. MODAL_BODY: '.modal-body',
  3338. DATA_TOGGLE: '[data-toggle="modal"]',
  3339. DATA_DISMISS: '[data-dismiss="modal"]',
  3340. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3341. STICKY_CONTENT: '.sticky-top'
  3342. };
  3343. /**
  3344. * ------------------------------------------------------------------------
  3345. * Class Definition
  3346. * ------------------------------------------------------------------------
  3347. */
  3348. var Modal =
  3349. /*#__PURE__*/
  3350. function () {
  3351. function Modal(element, config) {
  3352. this._config = this._getConfig(config);
  3353. this._element = element;
  3354. this._dialog = element.querySelector(Selector$5.DIALOG);
  3355. this._backdrop = null;
  3356. this._isShown = false;
  3357. this._isBodyOverflowing = false;
  3358. this._ignoreBackdropClick = false;
  3359. this._isTransitioning = false;
  3360. this._scrollbarWidth = 0;
  3361. } // Getters
  3362. var _proto = Modal.prototype;
  3363. // Public
  3364. _proto.toggle = function toggle(relatedTarget) {
  3365. return this._isShown ? this.hide() : this.show(relatedTarget);
  3366. };
  3367. _proto.show = function show(relatedTarget) {
  3368. var _this = this;
  3369. if (this._isShown || this._isTransitioning) {
  3370. return;
  3371. }
  3372. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3373. this._isTransitioning = true;
  3374. }
  3375. var showEvent = $.Event(Event$5.SHOW, {
  3376. relatedTarget: relatedTarget
  3377. });
  3378. $(this._element).trigger(showEvent);
  3379. if (this._isShown || showEvent.isDefaultPrevented()) {
  3380. return;
  3381. }
  3382. this._isShown = true;
  3383. this._checkScrollbar();
  3384. this._setScrollbar();
  3385. this._adjustDialog();
  3386. this._setEscapeEvent();
  3387. this._setResizeEvent();
  3388. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3389. return _this.hide(event);
  3390. });
  3391. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3392. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3393. if ($(event.target).is(_this._element)) {
  3394. _this._ignoreBackdropClick = true;
  3395. }
  3396. });
  3397. });
  3398. this._showBackdrop(function () {
  3399. return _this._showElement(relatedTarget);
  3400. });
  3401. };
  3402. _proto.hide = function hide(event) {
  3403. var _this2 = this;
  3404. if (event) {
  3405. event.preventDefault();
  3406. }
  3407. if (!this._isShown || this._isTransitioning) {
  3408. return;
  3409. }
  3410. var hideEvent = $.Event(Event$5.HIDE);
  3411. $(this._element).trigger(hideEvent);
  3412. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3413. return;
  3414. }
  3415. this._isShown = false;
  3416. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3417. if (transition) {
  3418. this._isTransitioning = true;
  3419. }
  3420. this._setEscapeEvent();
  3421. this._setResizeEvent();
  3422. $(document).off(Event$5.FOCUSIN);
  3423. $(this._element).removeClass(ClassName$5.SHOW);
  3424. $(this._element).off(Event$5.CLICK_DISMISS);
  3425. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3426. if (transition) {
  3427. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3428. $(this._element).one(Util.TRANSITION_END, function (event) {
  3429. return _this2._hideModal(event);
  3430. }).emulateTransitionEnd(transitionDuration);
  3431. } else {
  3432. this._hideModal();
  3433. }
  3434. };
  3435. _proto.dispose = function dispose() {
  3436. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3437. return $(htmlElement).off(EVENT_KEY$5);
  3438. });
  3439. /**
  3440. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3441. * Do not move `document` in `htmlElements` array
  3442. * It will remove `Event.CLICK_DATA_API` event that should remain
  3443. */
  3444. $(document).off(Event$5.FOCUSIN);
  3445. $.removeData(this._element, DATA_KEY$5);
  3446. this._config = null;
  3447. this._element = null;
  3448. this._dialog = null;
  3449. this._backdrop = null;
  3450. this._isShown = null;
  3451. this._isBodyOverflowing = null;
  3452. this._ignoreBackdropClick = null;
  3453. this._isTransitioning = null;
  3454. this._scrollbarWidth = null;
  3455. };
  3456. _proto.handleUpdate = function handleUpdate() {
  3457. this._adjustDialog();
  3458. } // Private
  3459. ;
  3460. _proto._getConfig = function _getConfig(config) {
  3461. config = _objectSpread2({}, Default$3, {}, config);
  3462. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3463. return config;
  3464. };
  3465. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3466. var _this3 = this;
  3467. if (this._config.backdrop === 'static') {
  3468. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3469. $(this._element).trigger(hideEventPrevented);
  3470. if (hideEventPrevented.defaultPrevented) {
  3471. return;
  3472. }
  3473. this._element.classList.add(ClassName$5.STATIC);
  3474. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3475. $(this._element).one(Util.TRANSITION_END, function () {
  3476. _this3._element.classList.remove(ClassName$5.STATIC);
  3477. }).emulateTransitionEnd(modalTransitionDuration);
  3478. this._element.focus();
  3479. } else {
  3480. this.hide();
  3481. }
  3482. };
  3483. _proto._showElement = function _showElement(relatedTarget) {
  3484. var _this4 = this;
  3485. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3486. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3487. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3488. // Don't move modal's DOM position
  3489. document.body.appendChild(this._element);
  3490. }
  3491. this._element.style.display = 'block';
  3492. this._element.removeAttribute('aria-hidden');
  3493. this._element.setAttribute('aria-modal', true);
  3494. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3495. modalBody.scrollTop = 0;
  3496. } else {
  3497. this._element.scrollTop = 0;
  3498. }
  3499. if (transition) {
  3500. Util.reflow(this._element);
  3501. }
  3502. $(this._element).addClass(ClassName$5.SHOW);
  3503. if (this._config.focus) {
  3504. this._enforceFocus();
  3505. }
  3506. var shownEvent = $.Event(Event$5.SHOWN, {
  3507. relatedTarget: relatedTarget
  3508. });
  3509. var transitionComplete = function transitionComplete() {
  3510. if (_this4._config.focus) {
  3511. _this4._element.focus();
  3512. }
  3513. _this4._isTransitioning = false;
  3514. $(_this4._element).trigger(shownEvent);
  3515. };
  3516. if (transition) {
  3517. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3518. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3519. } else {
  3520. transitionComplete();
  3521. }
  3522. };
  3523. _proto._enforceFocus = function _enforceFocus() {
  3524. var _this5 = this;
  3525. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3526. .on(Event$5.FOCUSIN, function (event) {
  3527. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3528. _this5._element.focus();
  3529. }
  3530. });
  3531. };
  3532. _proto._setEscapeEvent = function _setEscapeEvent() {
  3533. var _this6 = this;
  3534. if (this._isShown && this._config.keyboard) {
  3535. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3536. if (event.which === ESCAPE_KEYCODE$1) {
  3537. _this6._triggerBackdropTransition();
  3538. }
  3539. });
  3540. } else if (!this._isShown) {
  3541. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3542. }
  3543. };
  3544. _proto._setResizeEvent = function _setResizeEvent() {
  3545. var _this7 = this;
  3546. if (this._isShown) {
  3547. $(window).on(Event$5.RESIZE, function (event) {
  3548. return _this7.handleUpdate(event);
  3549. });
  3550. } else {
  3551. $(window).off(Event$5.RESIZE);
  3552. }
  3553. };
  3554. _proto._hideModal = function _hideModal() {
  3555. var _this8 = this;
  3556. this._element.style.display = 'none';
  3557. this._element.setAttribute('aria-hidden', true);
  3558. this._element.removeAttribute('aria-modal');
  3559. this._isTransitioning = false;
  3560. this._showBackdrop(function () {
  3561. $(document.body).removeClass(ClassName$5.OPEN);
  3562. _this8._resetAdjustments();
  3563. _this8._resetScrollbar();
  3564. $(_this8._element).trigger(Event$5.HIDDEN);
  3565. });
  3566. };
  3567. _proto._removeBackdrop = function _removeBackdrop() {
  3568. if (this._backdrop) {
  3569. $(this._backdrop).remove();
  3570. this._backdrop = null;
  3571. }
  3572. };
  3573. _proto._showBackdrop = function _showBackdrop(callback) {
  3574. var _this9 = this;
  3575. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3576. if (this._isShown && this._config.backdrop) {
  3577. this._backdrop = document.createElement('div');
  3578. this._backdrop.className = ClassName$5.BACKDROP;
  3579. if (animate) {
  3580. this._backdrop.classList.add(animate);
  3581. }
  3582. $(this._backdrop).appendTo(document.body);
  3583. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3584. if (_this9._ignoreBackdropClick) {
  3585. _this9._ignoreBackdropClick = false;
  3586. return;
  3587. }
  3588. if (event.target !== event.currentTarget) {
  3589. return;
  3590. }
  3591. _this9._triggerBackdropTransition();
  3592. });
  3593. if (animate) {
  3594. Util.reflow(this._backdrop);
  3595. }
  3596. $(this._backdrop).addClass(ClassName$5.SHOW);
  3597. if (!callback) {
  3598. return;
  3599. }
  3600. if (!animate) {
  3601. callback();
  3602. return;
  3603. }
  3604. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3605. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3606. } else if (!this._isShown && this._backdrop) {
  3607. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3608. var callbackRemove = function callbackRemove() {
  3609. _this9._removeBackdrop();
  3610. if (callback) {
  3611. callback();
  3612. }
  3613. };
  3614. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3615. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3616. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3617. } else {
  3618. callbackRemove();
  3619. }
  3620. } else if (callback) {
  3621. callback();
  3622. }
  3623. } // ----------------------------------------------------------------------
  3624. // the following methods are used to handle overflowing modals
  3625. // todo (fat): these should probably be refactored out of modal.js
  3626. // ----------------------------------------------------------------------
  3627. ;
  3628. _proto._adjustDialog = function _adjustDialog() {
  3629. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3630. if (!this._isBodyOverflowing && isModalOverflowing) {
  3631. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3632. }
  3633. if (this._isBodyOverflowing && !isModalOverflowing) {
  3634. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3635. }
  3636. };
  3637. _proto._resetAdjustments = function _resetAdjustments() {
  3638. this._element.style.paddingLeft = '';
  3639. this._element.style.paddingRight = '';
  3640. };
  3641. _proto._checkScrollbar = function _checkScrollbar() {
  3642. var rect = document.body.getBoundingClientRect();
  3643. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3644. this._scrollbarWidth = this._getScrollbarWidth();
  3645. };
  3646. _proto._setScrollbar = function _setScrollbar() {
  3647. var _this10 = this;
  3648. if (this._isBodyOverflowing) {
  3649. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3650. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3651. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3652. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3653. $(fixedContent).each(function (index, element) {
  3654. var actualPadding = element.style.paddingRight;
  3655. var calculatedPadding = $(element).css('padding-right');
  3656. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3657. }); // Adjust sticky content margin
  3658. $(stickyContent).each(function (index, element) {
  3659. var actualMargin = element.style.marginRight;
  3660. var calculatedMargin = $(element).css('margin-right');
  3661. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3662. }); // Adjust body padding
  3663. var actualPadding = document.body.style.paddingRight;
  3664. var calculatedPadding = $(document.body).css('padding-right');
  3665. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3666. }
  3667. $(document.body).addClass(ClassName$5.OPEN);
  3668. };
  3669. _proto._resetScrollbar = function _resetScrollbar() {
  3670. // Restore fixed content padding
  3671. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3672. $(fixedContent).each(function (index, element) {
  3673. var padding = $(element).data('padding-right');
  3674. $(element).removeData('padding-right');
  3675. element.style.paddingRight = padding ? padding : '';
  3676. }); // Restore sticky content
  3677. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3678. $(elements).each(function (index, element) {
  3679. var margin = $(element).data('margin-right');
  3680. if (typeof margin !== 'undefined') {
  3681. $(element).css('margin-right', margin).removeData('margin-right');
  3682. }
  3683. }); // Restore body padding
  3684. var padding = $(document.body).data('padding-right');
  3685. $(document.body).removeData('padding-right');
  3686. document.body.style.paddingRight = padding ? padding : '';
  3687. };
  3688. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3689. // thx d.walsh
  3690. var scrollDiv = document.createElement('div');
  3691. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3692. document.body.appendChild(scrollDiv);
  3693. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3694. document.body.removeChild(scrollDiv);
  3695. return scrollbarWidth;
  3696. } // Static
  3697. ;
  3698. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3699. return this.each(function () {
  3700. var data = $(this).data(DATA_KEY$5);
  3701. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3702. if (!data) {
  3703. data = new Modal(this, _config);
  3704. $(this).data(DATA_KEY$5, data);
  3705. }
  3706. if (typeof config === 'string') {
  3707. if (typeof data[config] === 'undefined') {
  3708. throw new TypeError("No method named \"" + config + "\"");
  3709. }
  3710. data[config](relatedTarget);
  3711. } else if (_config.show) {
  3712. data.show(relatedTarget);
  3713. }
  3714. });
  3715. };
  3716. _createClass(Modal, null, [{
  3717. key: "VERSION",
  3718. get: function get() {
  3719. return VERSION$5;
  3720. }
  3721. }, {
  3722. key: "Default",
  3723. get: function get() {
  3724. return Default$3;
  3725. }
  3726. }]);
  3727. return Modal;
  3728. }();
  3729. /**
  3730. * ------------------------------------------------------------------------
  3731. * Data Api implementation
  3732. * ------------------------------------------------------------------------
  3733. */
  3734. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3735. var _this11 = this;
  3736. var target;
  3737. var selector = Util.getSelectorFromElement(this);
  3738. if (selector) {
  3739. target = document.querySelector(selector);
  3740. }
  3741. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3742. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3743. event.preventDefault();
  3744. }
  3745. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3746. if (showEvent.isDefaultPrevented()) {
  3747. // Only register focus restorer if modal will actually get shown
  3748. return;
  3749. }
  3750. $target.one(Event$5.HIDDEN, function () {
  3751. if ($(_this11).is(':visible')) {
  3752. _this11.focus();
  3753. }
  3754. });
  3755. });
  3756. Modal._jQueryInterface.call($(target), config, this);
  3757. });
  3758. /**
  3759. * ------------------------------------------------------------------------
  3760. * jQuery
  3761. * ------------------------------------------------------------------------
  3762. */
  3763. $.fn[NAME$5] = Modal._jQueryInterface;
  3764. $.fn[NAME$5].Constructor = Modal;
  3765. $.fn[NAME$5].noConflict = function () {
  3766. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3767. return Modal._jQueryInterface;
  3768. };
  3769. /**
  3770. * --------------------------------------------------------------------------
  3771. * Bootstrap (v4.4.1): tools/sanitizer.js
  3772. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  3773. * --------------------------------------------------------------------------
  3774. */
  3775. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  3776. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  3777. var DefaultWhitelist = {
  3778. // Global attributes allowed on any supplied element below.
  3779. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  3780. a: ['target', 'href', 'title', 'rel'],
  3781. area: [],
  3782. b: [],
  3783. br: [],
  3784. col: [],
  3785. code: [],
  3786. div: [],
  3787. em: [],
  3788. hr: [],
  3789. h1: [],
  3790. h2: [],
  3791. h3: [],
  3792. h4: [],
  3793. h5: [],
  3794. h6: [],
  3795. i: [],
  3796. img: ['src', 'alt', 'title', 'width', 'height'],
  3797. li: [],
  3798. ol: [],
  3799. p: [],
  3800. pre: [],
  3801. s: [],
  3802. small: [],
  3803. span: [],
  3804. sub: [],
  3805. sup: [],
  3806. strong: [],
  3807. u: [],
  3808. ul: []
  3809. };
  3810. /**
  3811. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  3812. *
  3813. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3814. */
  3815. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  3816. /**
  3817. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  3818. *
  3819. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3820. */
  3821. 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;
  3822. function allowedAttribute(attr, allowedAttributeList) {
  3823. var attrName = attr.nodeName.toLowerCase();
  3824. if (allowedAttributeList.indexOf(attrName) !== -1) {
  3825. if (uriAttrs.indexOf(attrName) !== -1) {
  3826. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  3827. }
  3828. return true;
  3829. }
  3830. var regExp = allowedAttributeList.filter(function (attrRegex) {
  3831. return attrRegex instanceof RegExp;
  3832. }); // Check if a regular expression validates the attribute.
  3833. for (var i = 0, l = regExp.length; i < l; i++) {
  3834. if (attrName.match(regExp[i])) {
  3835. return true;
  3836. }
  3837. }
  3838. return false;
  3839. }
  3840. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  3841. if (unsafeHtml.length === 0) {
  3842. return unsafeHtml;
  3843. }
  3844. if (sanitizeFn && typeof sanitizeFn === 'function') {
  3845. return sanitizeFn(unsafeHtml);
  3846. }
  3847. var domParser = new window.DOMParser();
  3848. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  3849. var whitelistKeys = Object.keys(whiteList);
  3850. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  3851. var _loop = function _loop(i, len) {
  3852. var el = elements[i];
  3853. var elName = el.nodeName.toLowerCase();
  3854. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  3855. el.parentNode.removeChild(el);
  3856. return "continue";
  3857. }
  3858. var attributeList = [].slice.call(el.attributes);
  3859. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  3860. attributeList.forEach(function (attr) {
  3861. if (!allowedAttribute(attr, whitelistedAttributes)) {
  3862. el.removeAttribute(attr.nodeName);
  3863. }
  3864. });
  3865. };
  3866. for (var i = 0, len = elements.length; i < len; i++) {
  3867. var _ret = _loop(i);
  3868. if (_ret === "continue") continue;
  3869. }
  3870. return createdDocument.body.innerHTML;
  3871. }
  3872. /**
  3873. * ------------------------------------------------------------------------
  3874. * Constants
  3875. * ------------------------------------------------------------------------
  3876. */
  3877. var NAME$6 = 'tooltip';
  3878. var VERSION$6 = '4.4.1';
  3879. var DATA_KEY$6 = 'bs.tooltip';
  3880. var EVENT_KEY$6 = "." + DATA_KEY$6;
  3881. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  3882. var CLASS_PREFIX = 'bs-tooltip';
  3883. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  3884. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  3885. var DefaultType$4 = {
  3886. animation: 'boolean',
  3887. template: 'string',
  3888. title: '(string|element|function)',
  3889. trigger: 'string',
  3890. delay: '(number|object)',
  3891. html: 'boolean',
  3892. selector: '(string|boolean)',
  3893. placement: '(string|function)',
  3894. offset: '(number|string|function)',
  3895. container: '(string|element|boolean)',
  3896. fallbackPlacement: '(string|array)',
  3897. boundary: '(string|element)',
  3898. sanitize: 'boolean',
  3899. sanitizeFn: '(null|function)',
  3900. whiteList: 'object',
  3901. popperConfig: '(null|object)'
  3902. };
  3903. var AttachmentMap$1 = {
  3904. AUTO: 'auto',
  3905. TOP: 'top',
  3906. RIGHT: 'right',
  3907. BOTTOM: 'bottom',
  3908. LEFT: 'left'
  3909. };
  3910. var Default$4 = {
  3911. animation: true,
  3912. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  3913. trigger: 'hover focus',
  3914. title: '',
  3915. delay: 0,
  3916. html: false,
  3917. selector: false,
  3918. placement: 'top',
  3919. offset: 0,
  3920. container: false,
  3921. fallbackPlacement: 'flip',
  3922. boundary: 'scrollParent',
  3923. sanitize: true,
  3924. sanitizeFn: null,
  3925. whiteList: DefaultWhitelist,
  3926. popperConfig: null
  3927. };
  3928. var HoverState = {
  3929. SHOW: 'show',
  3930. OUT: 'out'
  3931. };
  3932. var Event$6 = {
  3933. HIDE: "hide" + EVENT_KEY$6,
  3934. HIDDEN: "hidden" + EVENT_KEY$6,
  3935. SHOW: "show" + EVENT_KEY$6,
  3936. SHOWN: "shown" + EVENT_KEY$6,
  3937. INSERTED: "inserted" + EVENT_KEY$6,
  3938. CLICK: "click" + EVENT_KEY$6,
  3939. FOCUSIN: "focusin" + EVENT_KEY$6,
  3940. FOCUSOUT: "focusout" + EVENT_KEY$6,
  3941. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  3942. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  3943. };
  3944. var ClassName$6 = {
  3945. FADE: 'fade',
  3946. SHOW: 'show'
  3947. };
  3948. var Selector$6 = {
  3949. TOOLTIP: '.tooltip',
  3950. TOOLTIP_INNER: '.tooltip-inner',
  3951. ARROW: '.arrow'
  3952. };
  3953. var Trigger = {
  3954. HOVER: 'hover',
  3955. FOCUS: 'focus',
  3956. CLICK: 'click',
  3957. MANUAL: 'manual'
  3958. };
  3959. /**
  3960. * ------------------------------------------------------------------------
  3961. * Class Definition
  3962. * ------------------------------------------------------------------------
  3963. */
  3964. var Tooltip =
  3965. /*#__PURE__*/
  3966. function () {
  3967. function Tooltip(element, config) {
  3968. if (typeof Popper === 'undefined') {
  3969. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  3970. } // private
  3971. this._isEnabled = true;
  3972. this._timeout = 0;
  3973. this._hoverState = '';
  3974. this._activeTrigger = {};
  3975. this._popper = null; // Protected
  3976. this.element = element;
  3977. this.config = this._getConfig(config);
  3978. this.tip = null;
  3979. this._setListeners();
  3980. } // Getters
  3981. var _proto = Tooltip.prototype;
  3982. // Public
  3983. _proto.enable = function enable() {
  3984. this._isEnabled = true;
  3985. };
  3986. _proto.disable = function disable() {
  3987. this._isEnabled = false;
  3988. };
  3989. _proto.toggleEnabled = function toggleEnabled() {
  3990. this._isEnabled = !this._isEnabled;
  3991. };
  3992. _proto.toggle = function toggle(event) {
  3993. if (!this._isEnabled) {
  3994. return;
  3995. }
  3996. if (event) {
  3997. var dataKey = this.constructor.DATA_KEY;
  3998. var context = $(event.currentTarget).data(dataKey);
  3999. if (!context) {
  4000. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4001. $(event.currentTarget).data(dataKey, context);
  4002. }
  4003. context._activeTrigger.click = !context._activeTrigger.click;
  4004. if (context._isWithActiveTrigger()) {
  4005. context._enter(null, context);
  4006. } else {
  4007. context._leave(null, context);
  4008. }
  4009. } else {
  4010. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4011. this._leave(null, this);
  4012. return;
  4013. }
  4014. this._enter(null, this);
  4015. }
  4016. };
  4017. _proto.dispose = function dispose() {
  4018. clearTimeout(this._timeout);
  4019. $.removeData(this.element, this.constructor.DATA_KEY);
  4020. $(this.element).off(this.constructor.EVENT_KEY);
  4021. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4022. if (this.tip) {
  4023. $(this.tip).remove();
  4024. }
  4025. this._isEnabled = null;
  4026. this._timeout = null;
  4027. this._hoverState = null;
  4028. this._activeTrigger = null;
  4029. if (this._popper) {
  4030. this._popper.destroy();
  4031. }
  4032. this._popper = null;
  4033. this.element = null;
  4034. this.config = null;
  4035. this.tip = null;
  4036. };
  4037. _proto.show = function show() {
  4038. var _this = this;
  4039. if ($(this.element).css('display') === 'none') {
  4040. throw new Error('Please use show on visible elements');
  4041. }
  4042. var showEvent = $.Event(this.constructor.Event.SHOW);
  4043. if (this.isWithContent() && this._isEnabled) {
  4044. $(this.element).trigger(showEvent);
  4045. var shadowRoot = Util.findShadowRoot(this.element);
  4046. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4047. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4048. return;
  4049. }
  4050. var tip = this.getTipElement();
  4051. var tipId = Util.getUID(this.constructor.NAME);
  4052. tip.setAttribute('id', tipId);
  4053. this.element.setAttribute('aria-describedby', tipId);
  4054. this.setContent();
  4055. if (this.config.animation) {
  4056. $(tip).addClass(ClassName$6.FADE);
  4057. }
  4058. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4059. var attachment = this._getAttachment(placement);
  4060. this.addAttachmentClass(attachment);
  4061. var container = this._getContainer();
  4062. $(tip).data(this.constructor.DATA_KEY, this);
  4063. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4064. $(tip).appendTo(container);
  4065. }
  4066. $(this.element).trigger(this.constructor.Event.INSERTED);
  4067. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4068. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4069. // empty mouseover listeners to the body's immediate children;
  4070. // only needed because of broken event delegation on iOS
  4071. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4072. if ('ontouchstart' in document.documentElement) {
  4073. $(document.body).children().on('mouseover', null, $.noop);
  4074. }
  4075. var complete = function complete() {
  4076. if (_this.config.animation) {
  4077. _this._fixTransition();
  4078. }
  4079. var prevHoverState = _this._hoverState;
  4080. _this._hoverState = null;
  4081. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4082. if (prevHoverState === HoverState.OUT) {
  4083. _this._leave(null, _this);
  4084. }
  4085. };
  4086. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4087. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4088. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4089. } else {
  4090. complete();
  4091. }
  4092. }
  4093. };
  4094. _proto.hide = function hide(callback) {
  4095. var _this2 = this;
  4096. var tip = this.getTipElement();
  4097. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4098. var complete = function complete() {
  4099. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4100. tip.parentNode.removeChild(tip);
  4101. }
  4102. _this2._cleanTipClass();
  4103. _this2.element.removeAttribute('aria-describedby');
  4104. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4105. if (_this2._popper !== null) {
  4106. _this2._popper.destroy();
  4107. }
  4108. if (callback) {
  4109. callback();
  4110. }
  4111. };
  4112. $(this.element).trigger(hideEvent);
  4113. if (hideEvent.isDefaultPrevented()) {
  4114. return;
  4115. }
  4116. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4117. // empty mouseover listeners we added for iOS support
  4118. if ('ontouchstart' in document.documentElement) {
  4119. $(document.body).children().off('mouseover', null, $.noop);
  4120. }
  4121. this._activeTrigger[Trigger.CLICK] = false;
  4122. this._activeTrigger[Trigger.FOCUS] = false;
  4123. this._activeTrigger[Trigger.HOVER] = false;
  4124. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4125. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4126. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4127. } else {
  4128. complete();
  4129. }
  4130. this._hoverState = '';
  4131. };
  4132. _proto.update = function update() {
  4133. if (this._popper !== null) {
  4134. this._popper.scheduleUpdate();
  4135. }
  4136. } // Protected
  4137. ;
  4138. _proto.isWithContent = function isWithContent() {
  4139. return Boolean(this.getTitle());
  4140. };
  4141. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4142. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4143. };
  4144. _proto.getTipElement = function getTipElement() {
  4145. this.tip = this.tip || $(this.config.template)[0];
  4146. return this.tip;
  4147. };
  4148. _proto.setContent = function setContent() {
  4149. var tip = this.getTipElement();
  4150. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4151. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4152. };
  4153. _proto.setElementContent = function setElementContent($element, content) {
  4154. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4155. // Content is a DOM node or a jQuery
  4156. if (this.config.html) {
  4157. if (!$(content).parent().is($element)) {
  4158. $element.empty().append(content);
  4159. }
  4160. } else {
  4161. $element.text($(content).text());
  4162. }
  4163. return;
  4164. }
  4165. if (this.config.html) {
  4166. if (this.config.sanitize) {
  4167. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4168. }
  4169. $element.html(content);
  4170. } else {
  4171. $element.text(content);
  4172. }
  4173. };
  4174. _proto.getTitle = function getTitle() {
  4175. var title = this.element.getAttribute('data-original-title');
  4176. if (!title) {
  4177. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4178. }
  4179. return title;
  4180. } // Private
  4181. ;
  4182. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4183. var _this3 = this;
  4184. var defaultBsConfig = {
  4185. placement: attachment,
  4186. modifiers: {
  4187. offset: this._getOffset(),
  4188. flip: {
  4189. behavior: this.config.fallbackPlacement
  4190. },
  4191. arrow: {
  4192. element: Selector$6.ARROW
  4193. },
  4194. preventOverflow: {
  4195. boundariesElement: this.config.boundary
  4196. }
  4197. },
  4198. onCreate: function onCreate(data) {
  4199. if (data.originalPlacement !== data.placement) {
  4200. _this3._handlePopperPlacementChange(data);
  4201. }
  4202. },
  4203. onUpdate: function onUpdate(data) {
  4204. return _this3._handlePopperPlacementChange(data);
  4205. }
  4206. };
  4207. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4208. };
  4209. _proto._getOffset = function _getOffset() {
  4210. var _this4 = this;
  4211. var offset = {};
  4212. if (typeof this.config.offset === 'function') {
  4213. offset.fn = function (data) {
  4214. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4215. return data;
  4216. };
  4217. } else {
  4218. offset.offset = this.config.offset;
  4219. }
  4220. return offset;
  4221. };
  4222. _proto._getContainer = function _getContainer() {
  4223. if (this.config.container === false) {
  4224. return document.body;
  4225. }
  4226. if (Util.isElement(this.config.container)) {
  4227. return $(this.config.container);
  4228. }
  4229. return $(document).find(this.config.container);
  4230. };
  4231. _proto._getAttachment = function _getAttachment(placement) {
  4232. return AttachmentMap$1[placement.toUpperCase()];
  4233. };
  4234. _proto._setListeners = function _setListeners() {
  4235. var _this5 = this;
  4236. var triggers = this.config.trigger.split(' ');
  4237. triggers.forEach(function (trigger) {
  4238. if (trigger === 'click') {
  4239. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4240. return _this5.toggle(event);
  4241. });
  4242. } else if (trigger !== Trigger.MANUAL) {
  4243. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4244. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4245. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4246. return _this5._enter(event);
  4247. }).on(eventOut, _this5.config.selector, function (event) {
  4248. return _this5._leave(event);
  4249. });
  4250. }
  4251. });
  4252. this._hideModalHandler = function () {
  4253. if (_this5.element) {
  4254. _this5.hide();
  4255. }
  4256. };
  4257. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4258. if (this.config.selector) {
  4259. this.config = _objectSpread2({}, this.config, {
  4260. trigger: 'manual',
  4261. selector: ''
  4262. });
  4263. } else {
  4264. this._fixTitle();
  4265. }
  4266. };
  4267. _proto._fixTitle = function _fixTitle() {
  4268. var titleType = typeof this.element.getAttribute('data-original-title');
  4269. if (this.element.getAttribute('title') || titleType !== 'string') {
  4270. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4271. this.element.setAttribute('title', '');
  4272. }
  4273. };
  4274. _proto._enter = function _enter(event, context) {
  4275. var dataKey = this.constructor.DATA_KEY;
  4276. context = context || $(event.currentTarget).data(dataKey);
  4277. if (!context) {
  4278. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4279. $(event.currentTarget).data(dataKey, context);
  4280. }
  4281. if (event) {
  4282. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4283. }
  4284. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4285. context._hoverState = HoverState.SHOW;
  4286. return;
  4287. }
  4288. clearTimeout(context._timeout);
  4289. context._hoverState = HoverState.SHOW;
  4290. if (!context.config.delay || !context.config.delay.show) {
  4291. context.show();
  4292. return;
  4293. }
  4294. context._timeout = setTimeout(function () {
  4295. if (context._hoverState === HoverState.SHOW) {
  4296. context.show();
  4297. }
  4298. }, context.config.delay.show);
  4299. };
  4300. _proto._leave = function _leave(event, context) {
  4301. var dataKey = this.constructor.DATA_KEY;
  4302. context = context || $(event.currentTarget).data(dataKey);
  4303. if (!context) {
  4304. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4305. $(event.currentTarget).data(dataKey, context);
  4306. }
  4307. if (event) {
  4308. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4309. }
  4310. if (context._isWithActiveTrigger()) {
  4311. return;
  4312. }
  4313. clearTimeout(context._timeout);
  4314. context._hoverState = HoverState.OUT;
  4315. if (!context.config.delay || !context.config.delay.hide) {
  4316. context.hide();
  4317. return;
  4318. }
  4319. context._timeout = setTimeout(function () {
  4320. if (context._hoverState === HoverState.OUT) {
  4321. context.hide();
  4322. }
  4323. }, context.config.delay.hide);
  4324. };
  4325. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4326. for (var trigger in this._activeTrigger) {
  4327. if (this._activeTrigger[trigger]) {
  4328. return true;
  4329. }
  4330. }
  4331. return false;
  4332. };
  4333. _proto._getConfig = function _getConfig(config) {
  4334. var dataAttributes = $(this.element).data();
  4335. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4336. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4337. delete dataAttributes[dataAttr];
  4338. }
  4339. });
  4340. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4341. if (typeof config.delay === 'number') {
  4342. config.delay = {
  4343. show: config.delay,
  4344. hide: config.delay
  4345. };
  4346. }
  4347. if (typeof config.title === 'number') {
  4348. config.title = config.title.toString();
  4349. }
  4350. if (typeof config.content === 'number') {
  4351. config.content = config.content.toString();
  4352. }
  4353. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4354. if (config.sanitize) {
  4355. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4356. }
  4357. return config;
  4358. };
  4359. _proto._getDelegateConfig = function _getDelegateConfig() {
  4360. var config = {};
  4361. if (this.config) {
  4362. for (var key in this.config) {
  4363. if (this.constructor.Default[key] !== this.config[key]) {
  4364. config[key] = this.config[key];
  4365. }
  4366. }
  4367. }
  4368. return config;
  4369. };
  4370. _proto._cleanTipClass = function _cleanTipClass() {
  4371. var $tip = $(this.getTipElement());
  4372. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4373. if (tabClass !== null && tabClass.length) {
  4374. $tip.removeClass(tabClass.join(''));
  4375. }
  4376. };
  4377. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4378. var popperInstance = popperData.instance;
  4379. this.tip = popperInstance.popper;
  4380. this._cleanTipClass();
  4381. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4382. };
  4383. _proto._fixTransition = function _fixTransition() {
  4384. var tip = this.getTipElement();
  4385. var initConfigAnimation = this.config.animation;
  4386. if (tip.getAttribute('x-placement') !== null) {
  4387. return;
  4388. }
  4389. $(tip).removeClass(ClassName$6.FADE);
  4390. this.config.animation = false;
  4391. this.hide();
  4392. this.show();
  4393. this.config.animation = initConfigAnimation;
  4394. } // Static
  4395. ;
  4396. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4397. return this.each(function () {
  4398. var data = $(this).data(DATA_KEY$6);
  4399. var _config = typeof config === 'object' && config;
  4400. if (!data && /dispose|hide/.test(config)) {
  4401. return;
  4402. }
  4403. if (!data) {
  4404. data = new Tooltip(this, _config);
  4405. $(this).data(DATA_KEY$6, data);
  4406. }
  4407. if (typeof config === 'string') {
  4408. if (typeof data[config] === 'undefined') {
  4409. throw new TypeError("No method named \"" + config + "\"");
  4410. }
  4411. data[config]();
  4412. }
  4413. });
  4414. };
  4415. _createClass(Tooltip, null, [{
  4416. key: "VERSION",
  4417. get: function get() {
  4418. return VERSION$6;
  4419. }
  4420. }, {
  4421. key: "Default",
  4422. get: function get() {
  4423. return Default$4;
  4424. }
  4425. }, {
  4426. key: "NAME",
  4427. get: function get() {
  4428. return NAME$6;
  4429. }
  4430. }, {
  4431. key: "DATA_KEY",
  4432. get: function get() {
  4433. return DATA_KEY$6;
  4434. }
  4435. }, {
  4436. key: "Event",
  4437. get: function get() {
  4438. return Event$6;
  4439. }
  4440. }, {
  4441. key: "EVENT_KEY",
  4442. get: function get() {
  4443. return EVENT_KEY$6;
  4444. }
  4445. }, {
  4446. key: "DefaultType",
  4447. get: function get() {
  4448. return DefaultType$4;
  4449. }
  4450. }]);
  4451. return Tooltip;
  4452. }();
  4453. /**
  4454. * ------------------------------------------------------------------------
  4455. * jQuery
  4456. * ------------------------------------------------------------------------
  4457. */
  4458. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4459. $.fn[NAME$6].Constructor = Tooltip;
  4460. $.fn[NAME$6].noConflict = function () {
  4461. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4462. return Tooltip._jQueryInterface;
  4463. };
  4464. /**
  4465. * ------------------------------------------------------------------------
  4466. * Constants
  4467. * ------------------------------------------------------------------------
  4468. */
  4469. var NAME$7 = 'popover';
  4470. var VERSION$7 = '4.4.1';
  4471. var DATA_KEY$7 = 'bs.popover';
  4472. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4473. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4474. var CLASS_PREFIX$1 = 'bs-popover';
  4475. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4476. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4477. placement: 'right',
  4478. trigger: 'click',
  4479. content: '',
  4480. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4481. });
  4482. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4483. content: '(string|element|function)'
  4484. });
  4485. var ClassName$7 = {
  4486. FADE: 'fade',
  4487. SHOW: 'show'
  4488. };
  4489. var Selector$7 = {
  4490. TITLE: '.popover-header',
  4491. CONTENT: '.popover-body'
  4492. };
  4493. var Event$7 = {
  4494. HIDE: "hide" + EVENT_KEY$7,
  4495. HIDDEN: "hidden" + EVENT_KEY$7,
  4496. SHOW: "show" + EVENT_KEY$7,
  4497. SHOWN: "shown" + EVENT_KEY$7,
  4498. INSERTED: "inserted" + EVENT_KEY$7,
  4499. CLICK: "click" + EVENT_KEY$7,
  4500. FOCUSIN: "focusin" + EVENT_KEY$7,
  4501. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4502. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4503. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4504. };
  4505. /**
  4506. * ------------------------------------------------------------------------
  4507. * Class Definition
  4508. * ------------------------------------------------------------------------
  4509. */
  4510. var Popover =
  4511. /*#__PURE__*/
  4512. function (_Tooltip) {
  4513. _inheritsLoose(Popover, _Tooltip);
  4514. function Popover() {
  4515. return _Tooltip.apply(this, arguments) || this;
  4516. }
  4517. var _proto = Popover.prototype;
  4518. // Overrides
  4519. _proto.isWithContent = function isWithContent() {
  4520. return this.getTitle() || this._getContent();
  4521. };
  4522. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4523. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4524. };
  4525. _proto.getTipElement = function getTipElement() {
  4526. this.tip = this.tip || $(this.config.template)[0];
  4527. return this.tip;
  4528. };
  4529. _proto.setContent = function setContent() {
  4530. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4531. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4532. var content = this._getContent();
  4533. if (typeof content === 'function') {
  4534. content = content.call(this.element);
  4535. }
  4536. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4537. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4538. } // Private
  4539. ;
  4540. _proto._getContent = function _getContent() {
  4541. return this.element.getAttribute('data-content') || this.config.content;
  4542. };
  4543. _proto._cleanTipClass = function _cleanTipClass() {
  4544. var $tip = $(this.getTipElement());
  4545. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4546. if (tabClass !== null && tabClass.length > 0) {
  4547. $tip.removeClass(tabClass.join(''));
  4548. }
  4549. } // Static
  4550. ;
  4551. Popover._jQueryInterface = function _jQueryInterface(config) {
  4552. return this.each(function () {
  4553. var data = $(this).data(DATA_KEY$7);
  4554. var _config = typeof config === 'object' ? config : null;
  4555. if (!data && /dispose|hide/.test(config)) {
  4556. return;
  4557. }
  4558. if (!data) {
  4559. data = new Popover(this, _config);
  4560. $(this).data(DATA_KEY$7, data);
  4561. }
  4562. if (typeof config === 'string') {
  4563. if (typeof data[config] === 'undefined') {
  4564. throw new TypeError("No method named \"" + config + "\"");
  4565. }
  4566. data[config]();
  4567. }
  4568. });
  4569. };
  4570. _createClass(Popover, null, [{
  4571. key: "VERSION",
  4572. // Getters
  4573. get: function get() {
  4574. return VERSION$7;
  4575. }
  4576. }, {
  4577. key: "Default",
  4578. get: function get() {
  4579. return Default$5;
  4580. }
  4581. }, {
  4582. key: "NAME",
  4583. get: function get() {
  4584. return NAME$7;
  4585. }
  4586. }, {
  4587. key: "DATA_KEY",
  4588. get: function get() {
  4589. return DATA_KEY$7;
  4590. }
  4591. }, {
  4592. key: "Event",
  4593. get: function get() {
  4594. return Event$7;
  4595. }
  4596. }, {
  4597. key: "EVENT_KEY",
  4598. get: function get() {
  4599. return EVENT_KEY$7;
  4600. }
  4601. }, {
  4602. key: "DefaultType",
  4603. get: function get() {
  4604. return DefaultType$5;
  4605. }
  4606. }]);
  4607. return Popover;
  4608. }(Tooltip);
  4609. /**
  4610. * ------------------------------------------------------------------------
  4611. * jQuery
  4612. * ------------------------------------------------------------------------
  4613. */
  4614. $.fn[NAME$7] = Popover._jQueryInterface;
  4615. $.fn[NAME$7].Constructor = Popover;
  4616. $.fn[NAME$7].noConflict = function () {
  4617. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4618. return Popover._jQueryInterface;
  4619. };
  4620. /**
  4621. * ------------------------------------------------------------------------
  4622. * Constants
  4623. * ------------------------------------------------------------------------
  4624. */
  4625. var NAME$8 = 'scrollspy';
  4626. var VERSION$8 = '4.4.1';
  4627. var DATA_KEY$8 = 'bs.scrollspy';
  4628. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4629. var DATA_API_KEY$6 = '.data-api';
  4630. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4631. var Default$6 = {
  4632. offset: 10,
  4633. method: 'auto',
  4634. target: ''
  4635. };
  4636. var DefaultType$6 = {
  4637. offset: 'number',
  4638. method: 'string',
  4639. target: '(string|element)'
  4640. };
  4641. var Event$8 = {
  4642. ACTIVATE: "activate" + EVENT_KEY$8,
  4643. SCROLL: "scroll" + EVENT_KEY$8,
  4644. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4645. };
  4646. var ClassName$8 = {
  4647. DROPDOWN_ITEM: 'dropdown-item',
  4648. DROPDOWN_MENU: 'dropdown-menu',
  4649. ACTIVE: 'active'
  4650. };
  4651. var Selector$8 = {
  4652. DATA_SPY: '[data-spy="scroll"]',
  4653. ACTIVE: '.active',
  4654. NAV_LIST_GROUP: '.nav, .list-group',
  4655. NAV_LINKS: '.nav-link',
  4656. NAV_ITEMS: '.nav-item',
  4657. LIST_ITEMS: '.list-group-item',
  4658. DROPDOWN: '.dropdown',
  4659. DROPDOWN_ITEMS: '.dropdown-item',
  4660. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4661. };
  4662. var OffsetMethod = {
  4663. OFFSET: 'offset',
  4664. POSITION: 'position'
  4665. };
  4666. /**
  4667. * ------------------------------------------------------------------------
  4668. * Class Definition
  4669. * ------------------------------------------------------------------------
  4670. */
  4671. var ScrollSpy =
  4672. /*#__PURE__*/
  4673. function () {
  4674. function ScrollSpy(element, config) {
  4675. var _this = this;
  4676. this._element = element;
  4677. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4678. this._config = this._getConfig(config);
  4679. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4680. this._offsets = [];
  4681. this._targets = [];
  4682. this._activeTarget = null;
  4683. this._scrollHeight = 0;
  4684. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4685. return _this._process(event);
  4686. });
  4687. this.refresh();
  4688. this._process();
  4689. } // Getters
  4690. var _proto = ScrollSpy.prototype;
  4691. // Public
  4692. _proto.refresh = function refresh() {
  4693. var _this2 = this;
  4694. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4695. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4696. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4697. this._offsets = [];
  4698. this._targets = [];
  4699. this._scrollHeight = this._getScrollHeight();
  4700. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4701. targets.map(function (element) {
  4702. var target;
  4703. var targetSelector = Util.getSelectorFromElement(element);
  4704. if (targetSelector) {
  4705. target = document.querySelector(targetSelector);
  4706. }
  4707. if (target) {
  4708. var targetBCR = target.getBoundingClientRect();
  4709. if (targetBCR.width || targetBCR.height) {
  4710. // TODO (fat): remove sketch reliance on jQuery position/offset
  4711. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4712. }
  4713. }
  4714. return null;
  4715. }).filter(function (item) {
  4716. return item;
  4717. }).sort(function (a, b) {
  4718. return a[0] - b[0];
  4719. }).forEach(function (item) {
  4720. _this2._offsets.push(item[0]);
  4721. _this2._targets.push(item[1]);
  4722. });
  4723. };
  4724. _proto.dispose = function dispose() {
  4725. $.removeData(this._element, DATA_KEY$8);
  4726. $(this._scrollElement).off(EVENT_KEY$8);
  4727. this._element = null;
  4728. this._scrollElement = null;
  4729. this._config = null;
  4730. this._selector = null;
  4731. this._offsets = null;
  4732. this._targets = null;
  4733. this._activeTarget = null;
  4734. this._scrollHeight = null;
  4735. } // Private
  4736. ;
  4737. _proto._getConfig = function _getConfig(config) {
  4738. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4739. if (typeof config.target !== 'string') {
  4740. var id = $(config.target).attr('id');
  4741. if (!id) {
  4742. id = Util.getUID(NAME$8);
  4743. $(config.target).attr('id', id);
  4744. }
  4745. config.target = "#" + id;
  4746. }
  4747. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4748. return config;
  4749. };
  4750. _proto._getScrollTop = function _getScrollTop() {
  4751. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4752. };
  4753. _proto._getScrollHeight = function _getScrollHeight() {
  4754. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4755. };
  4756. _proto._getOffsetHeight = function _getOffsetHeight() {
  4757. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4758. };
  4759. _proto._process = function _process() {
  4760. var scrollTop = this._getScrollTop() + this._config.offset;
  4761. var scrollHeight = this._getScrollHeight();
  4762. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4763. if (this._scrollHeight !== scrollHeight) {
  4764. this.refresh();
  4765. }
  4766. if (scrollTop >= maxScroll) {
  4767. var target = this._targets[this._targets.length - 1];
  4768. if (this._activeTarget !== target) {
  4769. this._activate(target);
  4770. }
  4771. return;
  4772. }
  4773. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  4774. this._activeTarget = null;
  4775. this._clear();
  4776. return;
  4777. }
  4778. var offsetLength = this._offsets.length;
  4779. for (var i = offsetLength; i--;) {
  4780. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  4781. if (isActiveTarget) {
  4782. this._activate(this._targets[i]);
  4783. }
  4784. }
  4785. };
  4786. _proto._activate = function _activate(target) {
  4787. this._activeTarget = target;
  4788. this._clear();
  4789. var queries = this._selector.split(',').map(function (selector) {
  4790. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  4791. });
  4792. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  4793. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  4794. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  4795. $link.addClass(ClassName$8.ACTIVE);
  4796. } else {
  4797. // Set triggered link as active
  4798. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  4799. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  4800. $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
  4801. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  4802. }
  4803. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  4804. relatedTarget: target
  4805. });
  4806. };
  4807. _proto._clear = function _clear() {
  4808. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  4809. return node.classList.contains(ClassName$8.ACTIVE);
  4810. }).forEach(function (node) {
  4811. return node.classList.remove(ClassName$8.ACTIVE);
  4812. });
  4813. } // Static
  4814. ;
  4815. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  4816. return this.each(function () {
  4817. var data = $(this).data(DATA_KEY$8);
  4818. var _config = typeof config === 'object' && config;
  4819. if (!data) {
  4820. data = new ScrollSpy(this, _config);
  4821. $(this).data(DATA_KEY$8, data);
  4822. }
  4823. if (typeof config === 'string') {
  4824. if (typeof data[config] === 'undefined') {
  4825. throw new TypeError("No method named \"" + config + "\"");
  4826. }
  4827. data[config]();
  4828. }
  4829. });
  4830. };
  4831. _createClass(ScrollSpy, null, [{
  4832. key: "VERSION",
  4833. get: function get() {
  4834. return VERSION$8;
  4835. }
  4836. }, {
  4837. key: "Default",
  4838. get: function get() {
  4839. return Default$6;
  4840. }
  4841. }]);
  4842. return ScrollSpy;
  4843. }();
  4844. /**
  4845. * ------------------------------------------------------------------------
  4846. * Data Api implementation
  4847. * ------------------------------------------------------------------------
  4848. */
  4849. $(window).on(Event$8.LOAD_DATA_API, function () {
  4850. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  4851. var scrollSpysLength = scrollSpys.length;
  4852. for (var i = scrollSpysLength; i--;) {
  4853. var $spy = $(scrollSpys[i]);
  4854. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  4855. }
  4856. });
  4857. /**
  4858. * ------------------------------------------------------------------------
  4859. * jQuery
  4860. * ------------------------------------------------------------------------
  4861. */
  4862. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  4863. $.fn[NAME$8].Constructor = ScrollSpy;
  4864. $.fn[NAME$8].noConflict = function () {
  4865. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  4866. return ScrollSpy._jQueryInterface;
  4867. };
  4868. /**
  4869. * ------------------------------------------------------------------------
  4870. * Constants
  4871. * ------------------------------------------------------------------------
  4872. */
  4873. var NAME$9 = 'tab';
  4874. var VERSION$9 = '4.4.1';
  4875. var DATA_KEY$9 = 'bs.tab';
  4876. var EVENT_KEY$9 = "." + DATA_KEY$9;
  4877. var DATA_API_KEY$7 = '.data-api';
  4878. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  4879. var Event$9 = {
  4880. HIDE: "hide" + EVENT_KEY$9,
  4881. HIDDEN: "hidden" + EVENT_KEY$9,
  4882. SHOW: "show" + EVENT_KEY$9,
  4883. SHOWN: "shown" + EVENT_KEY$9,
  4884. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  4885. };
  4886. var ClassName$9 = {
  4887. DROPDOWN_MENU: 'dropdown-menu',
  4888. ACTIVE: 'active',
  4889. DISABLED: 'disabled',
  4890. FADE: 'fade',
  4891. SHOW: 'show'
  4892. };
  4893. var Selector$9 = {
  4894. DROPDOWN: '.dropdown',
  4895. NAV_LIST_GROUP: '.nav, .list-group',
  4896. ACTIVE: '.active',
  4897. ACTIVE_UL: '> li > .active',
  4898. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  4899. DROPDOWN_TOGGLE: '.dropdown-toggle',
  4900. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  4901. };
  4902. /**
  4903. * ------------------------------------------------------------------------
  4904. * Class Definition
  4905. * ------------------------------------------------------------------------
  4906. */
  4907. var Tab =
  4908. /*#__PURE__*/
  4909. function () {
  4910. function Tab(element) {
  4911. this._element = element;
  4912. } // Getters
  4913. var _proto = Tab.prototype;
  4914. // Public
  4915. _proto.show = function show() {
  4916. var _this = this;
  4917. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  4918. return;
  4919. }
  4920. var target;
  4921. var previous;
  4922. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  4923. var selector = Util.getSelectorFromElement(this._element);
  4924. if (listElement) {
  4925. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  4926. previous = $.makeArray($(listElement).find(itemSelector));
  4927. previous = previous[previous.length - 1];
  4928. }
  4929. var hideEvent = $.Event(Event$9.HIDE, {
  4930. relatedTarget: this._element
  4931. });
  4932. var showEvent = $.Event(Event$9.SHOW, {
  4933. relatedTarget: previous
  4934. });
  4935. if (previous) {
  4936. $(previous).trigger(hideEvent);
  4937. }
  4938. $(this._element).trigger(showEvent);
  4939. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  4940. return;
  4941. }
  4942. if (selector) {
  4943. target = document.querySelector(selector);
  4944. }
  4945. this._activate(this._element, listElement);
  4946. var complete = function complete() {
  4947. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  4948. relatedTarget: _this._element
  4949. });
  4950. var shownEvent = $.Event(Event$9.SHOWN, {
  4951. relatedTarget: previous
  4952. });
  4953. $(previous).trigger(hiddenEvent);
  4954. $(_this._element).trigger(shownEvent);
  4955. };
  4956. if (target) {
  4957. this._activate(target, target.parentNode, complete);
  4958. } else {
  4959. complete();
  4960. }
  4961. };
  4962. _proto.dispose = function dispose() {
  4963. $.removeData(this._element, DATA_KEY$9);
  4964. this._element = null;
  4965. } // Private
  4966. ;
  4967. _proto._activate = function _activate(element, container, callback) {
  4968. var _this2 = this;
  4969. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  4970. var active = activeElements[0];
  4971. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  4972. var complete = function complete() {
  4973. return _this2._transitionComplete(element, active, callback);
  4974. };
  4975. if (active && isTransitioning) {
  4976. var transitionDuration = Util.getTransitionDurationFromElement(active);
  4977. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4978. } else {
  4979. complete();
  4980. }
  4981. };
  4982. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  4983. if (active) {
  4984. $(active).removeClass(ClassName$9.ACTIVE);
  4985. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  4986. if (dropdownChild) {
  4987. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  4988. }
  4989. if (active.getAttribute('role') === 'tab') {
  4990. active.setAttribute('aria-selected', false);
  4991. }
  4992. }
  4993. $(element).addClass(ClassName$9.ACTIVE);
  4994. if (element.getAttribute('role') === 'tab') {
  4995. element.setAttribute('aria-selected', true);
  4996. }
  4997. Util.reflow(element);
  4998. if (element.classList.contains(ClassName$9.FADE)) {
  4999. element.classList.add(ClassName$9.SHOW);
  5000. }
  5001. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5002. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5003. if (dropdownElement) {
  5004. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5005. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5006. }
  5007. element.setAttribute('aria-expanded', true);
  5008. }
  5009. if (callback) {
  5010. callback();
  5011. }
  5012. } // Static
  5013. ;
  5014. Tab._jQueryInterface = function _jQueryInterface(config) {
  5015. return this.each(function () {
  5016. var $this = $(this);
  5017. var data = $this.data(DATA_KEY$9);
  5018. if (!data) {
  5019. data = new Tab(this);
  5020. $this.data(DATA_KEY$9, data);
  5021. }
  5022. if (typeof config === 'string') {
  5023. if (typeof data[config] === 'undefined') {
  5024. throw new TypeError("No method named \"" + config + "\"");
  5025. }
  5026. data[config]();
  5027. }
  5028. });
  5029. };
  5030. _createClass(Tab, null, [{
  5031. key: "VERSION",
  5032. get: function get() {
  5033. return VERSION$9;
  5034. }
  5035. }]);
  5036. return Tab;
  5037. }();
  5038. /**
  5039. * ------------------------------------------------------------------------
  5040. * Data Api implementation
  5041. * ------------------------------------------------------------------------
  5042. */
  5043. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5044. event.preventDefault();
  5045. Tab._jQueryInterface.call($(this), 'show');
  5046. });
  5047. /**
  5048. * ------------------------------------------------------------------------
  5049. * jQuery
  5050. * ------------------------------------------------------------------------
  5051. */
  5052. $.fn[NAME$9] = Tab._jQueryInterface;
  5053. $.fn[NAME$9].Constructor = Tab;
  5054. $.fn[NAME$9].noConflict = function () {
  5055. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5056. return Tab._jQueryInterface;
  5057. };
  5058. /**
  5059. * ------------------------------------------------------------------------
  5060. * Constants
  5061. * ------------------------------------------------------------------------
  5062. */
  5063. var NAME$a = 'toast';
  5064. var VERSION$a = '4.4.1';
  5065. var DATA_KEY$a = 'bs.toast';
  5066. var EVENT_KEY$a = "." + DATA_KEY$a;
  5067. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5068. var Event$a = {
  5069. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5070. HIDE: "hide" + EVENT_KEY$a,
  5071. HIDDEN: "hidden" + EVENT_KEY$a,
  5072. SHOW: "show" + EVENT_KEY$a,
  5073. SHOWN: "shown" + EVENT_KEY$a
  5074. };
  5075. var ClassName$a = {
  5076. FADE: 'fade',
  5077. HIDE: 'hide',
  5078. SHOW: 'show',
  5079. SHOWING: 'showing'
  5080. };
  5081. var DefaultType$7 = {
  5082. animation: 'boolean',
  5083. autohide: 'boolean',
  5084. delay: 'number'
  5085. };
  5086. var Default$7 = {
  5087. animation: true,
  5088. autohide: true,
  5089. delay: 500
  5090. };
  5091. var Selector$a = {
  5092. DATA_DISMISS: '[data-dismiss="toast"]'
  5093. };
  5094. /**
  5095. * ------------------------------------------------------------------------
  5096. * Class Definition
  5097. * ------------------------------------------------------------------------
  5098. */
  5099. var Toast =
  5100. /*#__PURE__*/
  5101. function () {
  5102. function Toast(element, config) {
  5103. this._element = element;
  5104. this._config = this._getConfig(config);
  5105. this._timeout = null;
  5106. this._setListeners();
  5107. } // Getters
  5108. var _proto = Toast.prototype;
  5109. // Public
  5110. _proto.show = function show() {
  5111. var _this = this;
  5112. var showEvent = $.Event(Event$a.SHOW);
  5113. $(this._element).trigger(showEvent);
  5114. if (showEvent.isDefaultPrevented()) {
  5115. return;
  5116. }
  5117. if (this._config.animation) {
  5118. this._element.classList.add(ClassName$a.FADE);
  5119. }
  5120. var complete = function complete() {
  5121. _this._element.classList.remove(ClassName$a.SHOWING);
  5122. _this._element.classList.add(ClassName$a.SHOW);
  5123. $(_this._element).trigger(Event$a.SHOWN);
  5124. if (_this._config.autohide) {
  5125. _this._timeout = setTimeout(function () {
  5126. _this.hide();
  5127. }, _this._config.delay);
  5128. }
  5129. };
  5130. this._element.classList.remove(ClassName$a.HIDE);
  5131. Util.reflow(this._element);
  5132. this._element.classList.add(ClassName$a.SHOWING);
  5133. if (this._config.animation) {
  5134. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5135. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5136. } else {
  5137. complete();
  5138. }
  5139. };
  5140. _proto.hide = function hide() {
  5141. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5142. return;
  5143. }
  5144. var hideEvent = $.Event(Event$a.HIDE);
  5145. $(this._element).trigger(hideEvent);
  5146. if (hideEvent.isDefaultPrevented()) {
  5147. return;
  5148. }
  5149. this._close();
  5150. };
  5151. _proto.dispose = function dispose() {
  5152. clearTimeout(this._timeout);
  5153. this._timeout = null;
  5154. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5155. this._element.classList.remove(ClassName$a.SHOW);
  5156. }
  5157. $(this._element).off(Event$a.CLICK_DISMISS);
  5158. $.removeData(this._element, DATA_KEY$a);
  5159. this._element = null;
  5160. this._config = null;
  5161. } // Private
  5162. ;
  5163. _proto._getConfig = function _getConfig(config) {
  5164. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5165. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5166. return config;
  5167. };
  5168. _proto._setListeners = function _setListeners() {
  5169. var _this2 = this;
  5170. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5171. return _this2.hide();
  5172. });
  5173. };
  5174. _proto._close = function _close() {
  5175. var _this3 = this;
  5176. var complete = function complete() {
  5177. _this3._element.classList.add(ClassName$a.HIDE);
  5178. $(_this3._element).trigger(Event$a.HIDDEN);
  5179. };
  5180. this._element.classList.remove(ClassName$a.SHOW);
  5181. if (this._config.animation) {
  5182. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5183. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5184. } else {
  5185. complete();
  5186. }
  5187. } // Static
  5188. ;
  5189. Toast._jQueryInterface = function _jQueryInterface(config) {
  5190. return this.each(function () {
  5191. var $element = $(this);
  5192. var data = $element.data(DATA_KEY$a);
  5193. var _config = typeof config === 'object' && config;
  5194. if (!data) {
  5195. data = new Toast(this, _config);
  5196. $element.data(DATA_KEY$a, data);
  5197. }
  5198. if (typeof config === 'string') {
  5199. if (typeof data[config] === 'undefined') {
  5200. throw new TypeError("No method named \"" + config + "\"");
  5201. }
  5202. data[config](this);
  5203. }
  5204. });
  5205. };
  5206. _createClass(Toast, null, [{
  5207. key: "VERSION",
  5208. get: function get() {
  5209. return VERSION$a;
  5210. }
  5211. }, {
  5212. key: "DefaultType",
  5213. get: function get() {
  5214. return DefaultType$7;
  5215. }
  5216. }, {
  5217. key: "Default",
  5218. get: function get() {
  5219. return Default$7;
  5220. }
  5221. }]);
  5222. return Toast;
  5223. }();
  5224. /**
  5225. * ------------------------------------------------------------------------
  5226. * jQuery
  5227. * ------------------------------------------------------------------------
  5228. */
  5229. $.fn[NAME$a] = Toast._jQueryInterface;
  5230. $.fn[NAME$a].Constructor = Toast;
  5231. $.fn[NAME$a].noConflict = function () {
  5232. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5233. return Toast._jQueryInterface;
  5234. };
  5235. exports.Alert = Alert;
  5236. exports.Button = Button;
  5237. exports.Carousel = Carousel;
  5238. exports.Collapse = Collapse;
  5239. exports.Dropdown = Dropdown;
  5240. exports.Modal = Modal;
  5241. exports.Popover = Popover;
  5242. exports.Scrollspy = ScrollSpy;
  5243. exports.Tab = Tab;
  5244. exports.Toast = Toast;
  5245. exports.Tooltip = Tooltip;
  5246. exports.Util = Util;
  5247. Object.defineProperty(exports, '__esModule', { value: true });
  5248. })));
  5249. //# sourceMappingURL=bootstrap.js.map
  5250. /***/ }),
  5251. /***/ "./node_modules/jquery/dist/jquery.js":
  5252. /*!********************************************!*\
  5253. !*** ./node_modules/jquery/dist/jquery.js ***!
  5254. \********************************************/
  5255. /*! no static exports found */
  5256. /***/ (function(module, exports, __webpack_require__) {
  5257. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  5258. * jQuery JavaScript Library v3.4.1
  5259. * https://jquery.com/
  5260. *
  5261. * Includes Sizzle.js
  5262. * https://sizzlejs.com/
  5263. *
  5264. * Copyright JS Foundation and other contributors
  5265. * Released under the MIT license
  5266. * https://jquery.org/license
  5267. *
  5268. * Date: 2019-05-01T21:04Z
  5269. */
  5270. ( function( global, factory ) {
  5271. "use strict";
  5272. if ( true && typeof module.exports === "object" ) {
  5273. // For CommonJS and CommonJS-like environments where a proper `window`
  5274. // is present, execute the factory and get jQuery.
  5275. // For environments that do not have a `window` with a `document`
  5276. // (such as Node.js), expose a factory as module.exports.
  5277. // This accentuates the need for the creation of a real `window`.
  5278. // e.g. var jQuery = require("jquery")(window);
  5279. // See ticket #14549 for more info.
  5280. module.exports = global.document ?
  5281. factory( global, true ) :
  5282. function( w ) {
  5283. if ( !w.document ) {
  5284. throw new Error( "jQuery requires a window with a document" );
  5285. }
  5286. return factory( w );
  5287. };
  5288. } else {
  5289. factory( global );
  5290. }
  5291. // Pass this if window is not defined yet
  5292. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  5293. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  5294. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  5295. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  5296. // enough that all such attempts are guarded in a try block.
  5297. "use strict";
  5298. var arr = [];
  5299. var document = window.document;
  5300. var getProto = Object.getPrototypeOf;
  5301. var slice = arr.slice;
  5302. var concat = arr.concat;
  5303. var push = arr.push;
  5304. var indexOf = arr.indexOf;
  5305. var class2type = {};
  5306. var toString = class2type.toString;
  5307. var hasOwn = class2type.hasOwnProperty;
  5308. var fnToString = hasOwn.toString;
  5309. var ObjectFunctionString = fnToString.call( Object );
  5310. var support = {};
  5311. var isFunction = function isFunction( obj ) {
  5312. // Support: Chrome <=57, Firefox <=52
  5313. // In some browsers, typeof returns "function" for HTML <object> elements
  5314. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  5315. // We don't want to classify *any* DOM node as a function.
  5316. return typeof obj === "function" && typeof obj.nodeType !== "number";
  5317. };
  5318. var isWindow = function isWindow( obj ) {
  5319. return obj != null && obj === obj.window;
  5320. };
  5321. var preservedScriptAttributes = {
  5322. type: true,
  5323. src: true,
  5324. nonce: true,
  5325. noModule: true
  5326. };
  5327. function DOMEval( code, node, doc ) {
  5328. doc = doc || document;
  5329. var i, val,
  5330. script = doc.createElement( "script" );
  5331. script.text = code;
  5332. if ( node ) {
  5333. for ( i in preservedScriptAttributes ) {
  5334. // Support: Firefox 64+, Edge 18+
  5335. // Some browsers don't support the "nonce" property on scripts.
  5336. // On the other hand, just using `getAttribute` is not enough as
  5337. // the `nonce` attribute is reset to an empty string whenever it
  5338. // becomes browsing-context connected.
  5339. // See https://github.com/whatwg/html/issues/2369
  5340. // See https://html.spec.whatwg.org/#nonce-attributes
  5341. // The `node.getAttribute` check was added for the sake of
  5342. // `jQuery.globalEval` so that it can fake a nonce-containing node
  5343. // via an object.
  5344. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  5345. if ( val ) {
  5346. script.setAttribute( i, val );
  5347. }
  5348. }
  5349. }
  5350. doc.head.appendChild( script ).parentNode.removeChild( script );
  5351. }
  5352. function toType( obj ) {
  5353. if ( obj == null ) {
  5354. return obj + "";
  5355. }
  5356. // Support: Android <=2.3 only (functionish RegExp)
  5357. return typeof obj === "object" || typeof obj === "function" ?
  5358. class2type[ toString.call( obj ) ] || "object" :
  5359. typeof obj;
  5360. }
  5361. /* global Symbol */
  5362. // Defining this global in .eslintrc.json would create a danger of using the global
  5363. // unguarded in another place, it seems safer to define global only for this module
  5364. var
  5365. version = "3.4.1",
  5366. // Define a local copy of jQuery
  5367. jQuery = function( selector, context ) {
  5368. // The jQuery object is actually just the init constructor 'enhanced'
  5369. // Need init if jQuery is called (just allow error to be thrown if not included)
  5370. return new jQuery.fn.init( selector, context );
  5371. },
  5372. // Support: Android <=4.0 only
  5373. // Make sure we trim BOM and NBSP
  5374. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  5375. jQuery.fn = jQuery.prototype = {
  5376. // The current version of jQuery being used
  5377. jquery: version,
  5378. constructor: jQuery,
  5379. // The default length of a jQuery object is 0
  5380. length: 0,
  5381. toArray: function() {
  5382. return slice.call( this );
  5383. },
  5384. // Get the Nth element in the matched element set OR
  5385. // Get the whole matched element set as a clean array
  5386. get: function( num ) {
  5387. // Return all the elements in a clean array
  5388. if ( num == null ) {
  5389. return slice.call( this );
  5390. }
  5391. // Return just the one element from the set
  5392. return num < 0 ? this[ num + this.length ] : this[ num ];
  5393. },
  5394. // Take an array of elements and push it onto the stack
  5395. // (returning the new matched element set)
  5396. pushStack: function( elems ) {
  5397. // Build a new jQuery matched element set
  5398. var ret = jQuery.merge( this.constructor(), elems );
  5399. // Add the old object onto the stack (as a reference)
  5400. ret.prevObject = this;
  5401. // Return the newly-formed element set
  5402. return ret;
  5403. },
  5404. // Execute a callback for every element in the matched set.
  5405. each: function( callback ) {
  5406. return jQuery.each( this, callback );
  5407. },
  5408. map: function( callback ) {
  5409. return this.pushStack( jQuery.map( this, function( elem, i ) {
  5410. return callback.call( elem, i, elem );
  5411. } ) );
  5412. },
  5413. slice: function() {
  5414. return this.pushStack( slice.apply( this, arguments ) );
  5415. },
  5416. first: function() {
  5417. return this.eq( 0 );
  5418. },
  5419. last: function() {
  5420. return this.eq( -1 );
  5421. },
  5422. eq: function( i ) {
  5423. var len = this.length,
  5424. j = +i + ( i < 0 ? len : 0 );
  5425. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  5426. },
  5427. end: function() {
  5428. return this.prevObject || this.constructor();
  5429. },
  5430. // For internal use only.
  5431. // Behaves like an Array's method, not like a jQuery method.
  5432. push: push,
  5433. sort: arr.sort,
  5434. splice: arr.splice
  5435. };
  5436. jQuery.extend = jQuery.fn.extend = function() {
  5437. var options, name, src, copy, copyIsArray, clone,
  5438. target = arguments[ 0 ] || {},
  5439. i = 1,
  5440. length = arguments.length,
  5441. deep = false;
  5442. // Handle a deep copy situation
  5443. if ( typeof target === "boolean" ) {
  5444. deep = target;
  5445. // Skip the boolean and the target
  5446. target = arguments[ i ] || {};
  5447. i++;
  5448. }
  5449. // Handle case when target is a string or something (possible in deep copy)
  5450. if ( typeof target !== "object" && !isFunction( target ) ) {
  5451. target = {};
  5452. }
  5453. // Extend jQuery itself if only one argument is passed
  5454. if ( i === length ) {
  5455. target = this;
  5456. i--;
  5457. }
  5458. for ( ; i < length; i++ ) {
  5459. // Only deal with non-null/undefined values
  5460. if ( ( options = arguments[ i ] ) != null ) {
  5461. // Extend the base object
  5462. for ( name in options ) {
  5463. copy = options[ name ];
  5464. // Prevent Object.prototype pollution
  5465. // Prevent never-ending loop
  5466. if ( name === "__proto__" || target === copy ) {
  5467. continue;
  5468. }
  5469. // Recurse if we're merging plain objects or arrays
  5470. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  5471. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  5472. src = target[ name ];
  5473. // Ensure proper type for the source value
  5474. if ( copyIsArray && !Array.isArray( src ) ) {
  5475. clone = [];
  5476. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  5477. clone = {};
  5478. } else {
  5479. clone = src;
  5480. }
  5481. copyIsArray = false;
  5482. // Never move original objects, clone them
  5483. target[ name ] = jQuery.extend( deep, clone, copy );
  5484. // Don't bring in undefined values
  5485. } else if ( copy !== undefined ) {
  5486. target[ name ] = copy;
  5487. }
  5488. }
  5489. }
  5490. }
  5491. // Return the modified object
  5492. return target;
  5493. };
  5494. jQuery.extend( {
  5495. // Unique for each copy of jQuery on the page
  5496. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  5497. // Assume jQuery is ready without the ready module
  5498. isReady: true,
  5499. error: function( msg ) {
  5500. throw new Error( msg );
  5501. },
  5502. noop: function() {},
  5503. isPlainObject: function( obj ) {
  5504. var proto, Ctor;
  5505. // Detect obvious negatives
  5506. // Use toString instead of jQuery.type to catch host objects
  5507. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  5508. return false;
  5509. }
  5510. proto = getProto( obj );
  5511. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  5512. if ( !proto ) {
  5513. return true;
  5514. }
  5515. // Objects with prototype are plain iff they were constructed by a global Object function
  5516. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  5517. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  5518. },
  5519. isEmptyObject: function( obj ) {
  5520. var name;
  5521. for ( name in obj ) {
  5522. return false;
  5523. }
  5524. return true;
  5525. },
  5526. // Evaluates a script in a global context
  5527. globalEval: function( code, options ) {
  5528. DOMEval( code, { nonce: options && options.nonce } );
  5529. },
  5530. each: function( obj, callback ) {
  5531. var length, i = 0;
  5532. if ( isArrayLike( obj ) ) {
  5533. length = obj.length;
  5534. for ( ; i < length; i++ ) {
  5535. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5536. break;
  5537. }
  5538. }
  5539. } else {
  5540. for ( i in obj ) {
  5541. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5542. break;
  5543. }
  5544. }
  5545. }
  5546. return obj;
  5547. },
  5548. // Support: Android <=4.0 only
  5549. trim: function( text ) {
  5550. return text == null ?
  5551. "" :
  5552. ( text + "" ).replace( rtrim, "" );
  5553. },
  5554. // results is for internal usage only
  5555. makeArray: function( arr, results ) {
  5556. var ret = results || [];
  5557. if ( arr != null ) {
  5558. if ( isArrayLike( Object( arr ) ) ) {
  5559. jQuery.merge( ret,
  5560. typeof arr === "string" ?
  5561. [ arr ] : arr
  5562. );
  5563. } else {
  5564. push.call( ret, arr );
  5565. }
  5566. }
  5567. return ret;
  5568. },
  5569. inArray: function( elem, arr, i ) {
  5570. return arr == null ? -1 : indexOf.call( arr, elem, i );
  5571. },
  5572. // Support: Android <=4.0 only, PhantomJS 1 only
  5573. // push.apply(_, arraylike) throws on ancient WebKit
  5574. merge: function( first, second ) {
  5575. var len = +second.length,
  5576. j = 0,
  5577. i = first.length;
  5578. for ( ; j < len; j++ ) {
  5579. first[ i++ ] = second[ j ];
  5580. }
  5581. first.length = i;
  5582. return first;
  5583. },
  5584. grep: function( elems, callback, invert ) {
  5585. var callbackInverse,
  5586. matches = [],
  5587. i = 0,
  5588. length = elems.length,
  5589. callbackExpect = !invert;
  5590. // Go through the array, only saving the items
  5591. // that pass the validator function
  5592. for ( ; i < length; i++ ) {
  5593. callbackInverse = !callback( elems[ i ], i );
  5594. if ( callbackInverse !== callbackExpect ) {
  5595. matches.push( elems[ i ] );
  5596. }
  5597. }
  5598. return matches;
  5599. },
  5600. // arg is for internal usage only
  5601. map: function( elems, callback, arg ) {
  5602. var length, value,
  5603. i = 0,
  5604. ret = [];
  5605. // Go through the array, translating each of the items to their new values
  5606. if ( isArrayLike( elems ) ) {
  5607. length = elems.length;
  5608. for ( ; i < length; i++ ) {
  5609. value = callback( elems[ i ], i, arg );
  5610. if ( value != null ) {
  5611. ret.push( value );
  5612. }
  5613. }
  5614. // Go through every key on the object,
  5615. } else {
  5616. for ( i in elems ) {
  5617. value = callback( elems[ i ], i, arg );
  5618. if ( value != null ) {
  5619. ret.push( value );
  5620. }
  5621. }
  5622. }
  5623. // Flatten any nested arrays
  5624. return concat.apply( [], ret );
  5625. },
  5626. // A global GUID counter for objects
  5627. guid: 1,
  5628. // jQuery.support is not used in Core but other projects attach their
  5629. // properties to it so it needs to exist.
  5630. support: support
  5631. } );
  5632. if ( typeof Symbol === "function" ) {
  5633. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  5634. }
  5635. // Populate the class2type map
  5636. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  5637. function( i, name ) {
  5638. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  5639. } );
  5640. function isArrayLike( obj ) {
  5641. // Support: real iOS 8.2 only (not reproducible in simulator)
  5642. // `in` check used to prevent JIT error (gh-2145)
  5643. // hasOwn isn't used here due to false negatives
  5644. // regarding Nodelist length in IE
  5645. var length = !!obj && "length" in obj && obj.length,
  5646. type = toType( obj );
  5647. if ( isFunction( obj ) || isWindow( obj ) ) {
  5648. return false;
  5649. }
  5650. return type === "array" || length === 0 ||
  5651. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  5652. }
  5653. var Sizzle =
  5654. /*!
  5655. * Sizzle CSS Selector Engine v2.3.4
  5656. * https://sizzlejs.com/
  5657. *
  5658. * Copyright JS Foundation and other contributors
  5659. * Released under the MIT license
  5660. * https://js.foundation/
  5661. *
  5662. * Date: 2019-04-08
  5663. */
  5664. (function( window ) {
  5665. var i,
  5666. support,
  5667. Expr,
  5668. getText,
  5669. isXML,
  5670. tokenize,
  5671. compile,
  5672. select,
  5673. outermostContext,
  5674. sortInput,
  5675. hasDuplicate,
  5676. // Local document vars
  5677. setDocument,
  5678. document,
  5679. docElem,
  5680. documentIsHTML,
  5681. rbuggyQSA,
  5682. rbuggyMatches,
  5683. matches,
  5684. contains,
  5685. // Instance-specific data
  5686. expando = "sizzle" + 1 * new Date(),
  5687. preferredDoc = window.document,
  5688. dirruns = 0,
  5689. done = 0,
  5690. classCache = createCache(),
  5691. tokenCache = createCache(),
  5692. compilerCache = createCache(),
  5693. nonnativeSelectorCache = createCache(),
  5694. sortOrder = function( a, b ) {
  5695. if ( a === b ) {
  5696. hasDuplicate = true;
  5697. }
  5698. return 0;
  5699. },
  5700. // Instance methods
  5701. hasOwn = ({}).hasOwnProperty,
  5702. arr = [],
  5703. pop = arr.pop,
  5704. push_native = arr.push,
  5705. push = arr.push,
  5706. slice = arr.slice,
  5707. // Use a stripped-down indexOf as it's faster than native
  5708. // https://jsperf.com/thor-indexof-vs-for/5
  5709. indexOf = function( list, elem ) {
  5710. var i = 0,
  5711. len = list.length;
  5712. for ( ; i < len; i++ ) {
  5713. if ( list[i] === elem ) {
  5714. return i;
  5715. }
  5716. }
  5717. return -1;
  5718. },
  5719. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  5720. // Regular expressions
  5721. // http://www.w3.org/TR/css3-selectors/#whitespace
  5722. whitespace = "[\\x20\\t\\r\\n\\f]",
  5723. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  5724. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  5725. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  5726. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  5727. // Operator (capture 2)
  5728. "*([*^$|!~]?=)" + whitespace +
  5729. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  5730. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  5731. "*\\]",
  5732. pseudos = ":(" + identifier + ")(?:\\((" +
  5733. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  5734. // 1. quoted (capture 3; capture 4 or capture 5)
  5735. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  5736. // 2. simple (capture 6)
  5737. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  5738. // 3. anything else (capture 2)
  5739. ".*" +
  5740. ")\\)|)",
  5741. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  5742. rwhitespace = new RegExp( whitespace + "+", "g" ),
  5743. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  5744. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  5745. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  5746. rdescend = new RegExp( whitespace + "|>" ),
  5747. rpseudo = new RegExp( pseudos ),
  5748. ridentifier = new RegExp( "^" + identifier + "$" ),
  5749. matchExpr = {
  5750. "ID": new RegExp( "^#(" + identifier + ")" ),
  5751. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  5752. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  5753. "ATTR": new RegExp( "^" + attributes ),
  5754. "PSEUDO": new RegExp( "^" + pseudos ),
  5755. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  5756. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  5757. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  5758. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  5759. // For use in libraries implementing .is()
  5760. // We use this for POS matching in `select`
  5761. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  5762. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  5763. },
  5764. rhtml = /HTML$/i,
  5765. rinputs = /^(?:input|select|textarea|button)$/i,
  5766. rheader = /^h\d$/i,
  5767. rnative = /^[^{]+\{\s*\[native \w/,
  5768. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  5769. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  5770. rsibling = /[+~]/,
  5771. // CSS escapes
  5772. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  5773. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  5774. funescape = function( _, escaped, escapedWhitespace ) {
  5775. var high = "0x" + escaped - 0x10000;
  5776. // NaN means non-codepoint
  5777. // Support: Firefox<24
  5778. // Workaround erroneous numeric interpretation of +"0x"
  5779. return high !== high || escapedWhitespace ?
  5780. escaped :
  5781. high < 0 ?
  5782. // BMP codepoint
  5783. String.fromCharCode( high + 0x10000 ) :
  5784. // Supplemental Plane codepoint (surrogate pair)
  5785. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  5786. },
  5787. // CSS string/identifier serialization
  5788. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  5789. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  5790. fcssescape = function( ch, asCodePoint ) {
  5791. if ( asCodePoint ) {
  5792. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  5793. if ( ch === "\0" ) {
  5794. return "\uFFFD";
  5795. }
  5796. // Control characters and (dependent upon position) numbers get escaped as code points
  5797. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  5798. }
  5799. // Other potentially-special ASCII characters get backslash-escaped
  5800. return "\\" + ch;
  5801. },
  5802. // Used for iframes
  5803. // See setDocument()
  5804. // Removing the function wrapper causes a "Permission Denied"
  5805. // error in IE
  5806. unloadHandler = function() {
  5807. setDocument();
  5808. },
  5809. inDisabledFieldset = addCombinator(
  5810. function( elem ) {
  5811. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  5812. },
  5813. { dir: "parentNode", next: "legend" }
  5814. );
  5815. // Optimize for push.apply( _, NodeList )
  5816. try {
  5817. push.apply(
  5818. (arr = slice.call( preferredDoc.childNodes )),
  5819. preferredDoc.childNodes
  5820. );
  5821. // Support: Android<4.0
  5822. // Detect silently failing push.apply
  5823. arr[ preferredDoc.childNodes.length ].nodeType;
  5824. } catch ( e ) {
  5825. push = { apply: arr.length ?
  5826. // Leverage slice if possible
  5827. function( target, els ) {
  5828. push_native.apply( target, slice.call(els) );
  5829. } :
  5830. // Support: IE<9
  5831. // Otherwise append directly
  5832. function( target, els ) {
  5833. var j = target.length,
  5834. i = 0;
  5835. // Can't trust NodeList.length
  5836. while ( (target[j++] = els[i++]) ) {}
  5837. target.length = j - 1;
  5838. }
  5839. };
  5840. }
  5841. function Sizzle( selector, context, results, seed ) {
  5842. var m, i, elem, nid, match, groups, newSelector,
  5843. newContext = context && context.ownerDocument,
  5844. // nodeType defaults to 9, since context defaults to document
  5845. nodeType = context ? context.nodeType : 9;
  5846. results = results || [];
  5847. // Return early from calls with invalid selector or context
  5848. if ( typeof selector !== "string" || !selector ||
  5849. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  5850. return results;
  5851. }
  5852. // Try to shortcut find operations (as opposed to filters) in HTML documents
  5853. if ( !seed ) {
  5854. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  5855. setDocument( context );
  5856. }
  5857. context = context || document;
  5858. if ( documentIsHTML ) {
  5859. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  5860. // (excepting DocumentFragment context, where the methods don't exist)
  5861. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  5862. // ID selector
  5863. if ( (m = match[1]) ) {
  5864. // Document context
  5865. if ( nodeType === 9 ) {
  5866. if ( (elem = context.getElementById( m )) ) {
  5867. // Support: IE, Opera, Webkit
  5868. // TODO: identify versions
  5869. // getElementById can match elements by name instead of ID
  5870. if ( elem.id === m ) {
  5871. results.push( elem );
  5872. return results;
  5873. }
  5874. } else {
  5875. return results;
  5876. }
  5877. // Element context
  5878. } else {
  5879. // Support: IE, Opera, Webkit
  5880. // TODO: identify versions
  5881. // getElementById can match elements by name instead of ID
  5882. if ( newContext && (elem = newContext.getElementById( m )) &&
  5883. contains( context, elem ) &&
  5884. elem.id === m ) {
  5885. results.push( elem );
  5886. return results;
  5887. }
  5888. }
  5889. // Type selector
  5890. } else if ( match[2] ) {
  5891. push.apply( results, context.getElementsByTagName( selector ) );
  5892. return results;
  5893. // Class selector
  5894. } else if ( (m = match[3]) && support.getElementsByClassName &&
  5895. context.getElementsByClassName ) {
  5896. push.apply( results, context.getElementsByClassName( m ) );
  5897. return results;
  5898. }
  5899. }
  5900. // Take advantage of querySelectorAll
  5901. if ( support.qsa &&
  5902. !nonnativeSelectorCache[ selector + " " ] &&
  5903. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  5904. // Support: IE 8 only
  5905. // Exclude object elements
  5906. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  5907. newSelector = selector;
  5908. newContext = context;
  5909. // qSA considers elements outside a scoping root when evaluating child or
  5910. // descendant combinators, which is not what we want.
  5911. // In such cases, we work around the behavior by prefixing every selector in the
  5912. // list with an ID selector referencing the scope context.
  5913. // Thanks to Andrew Dupont for this technique.
  5914. if ( nodeType === 1 && rdescend.test( selector ) ) {
  5915. // Capture the context ID, setting it first if necessary
  5916. if ( (nid = context.getAttribute( "id" )) ) {
  5917. nid = nid.replace( rcssescape, fcssescape );
  5918. } else {
  5919. context.setAttribute( "id", (nid = expando) );
  5920. }
  5921. // Prefix every selector in the list
  5922. groups = tokenize( selector );
  5923. i = groups.length;
  5924. while ( i-- ) {
  5925. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  5926. }
  5927. newSelector = groups.join( "," );
  5928. // Expand context for sibling selectors
  5929. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  5930. context;
  5931. }
  5932. try {
  5933. push.apply( results,
  5934. newContext.querySelectorAll( newSelector )
  5935. );
  5936. return results;
  5937. } catch ( qsaError ) {
  5938. nonnativeSelectorCache( selector, true );
  5939. } finally {
  5940. if ( nid === expando ) {
  5941. context.removeAttribute( "id" );
  5942. }
  5943. }
  5944. }
  5945. }
  5946. }
  5947. // All others
  5948. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  5949. }
  5950. /**
  5951. * Create key-value caches of limited size
  5952. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  5953. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  5954. * deleting the oldest entry
  5955. */
  5956. function createCache() {
  5957. var keys = [];
  5958. function cache( key, value ) {
  5959. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  5960. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  5961. // Only keep the most recent entries
  5962. delete cache[ keys.shift() ];
  5963. }
  5964. return (cache[ key + " " ] = value);
  5965. }
  5966. return cache;
  5967. }
  5968. /**
  5969. * Mark a function for special use by Sizzle
  5970. * @param {Function} fn The function to mark
  5971. */
  5972. function markFunction( fn ) {
  5973. fn[ expando ] = true;
  5974. return fn;
  5975. }
  5976. /**
  5977. * Support testing using an element
  5978. * @param {Function} fn Passed the created element and returns a boolean result
  5979. */
  5980. function assert( fn ) {
  5981. var el = document.createElement("fieldset");
  5982. try {
  5983. return !!fn( el );
  5984. } catch (e) {
  5985. return false;
  5986. } finally {
  5987. // Remove from its parent by default
  5988. if ( el.parentNode ) {
  5989. el.parentNode.removeChild( el );
  5990. }
  5991. // release memory in IE
  5992. el = null;
  5993. }
  5994. }
  5995. /**
  5996. * Adds the same handler for all of the specified attrs
  5997. * @param {String} attrs Pipe-separated list of attributes
  5998. * @param {Function} handler The method that will be applied
  5999. */
  6000. function addHandle( attrs, handler ) {
  6001. var arr = attrs.split("|"),
  6002. i = arr.length;
  6003. while ( i-- ) {
  6004. Expr.attrHandle[ arr[i] ] = handler;
  6005. }
  6006. }
  6007. /**
  6008. * Checks document order of two siblings
  6009. * @param {Element} a
  6010. * @param {Element} b
  6011. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  6012. */
  6013. function siblingCheck( a, b ) {
  6014. var cur = b && a,
  6015. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  6016. a.sourceIndex - b.sourceIndex;
  6017. // Use IE sourceIndex if available on both nodes
  6018. if ( diff ) {
  6019. return diff;
  6020. }
  6021. // Check if b follows a
  6022. if ( cur ) {
  6023. while ( (cur = cur.nextSibling) ) {
  6024. if ( cur === b ) {
  6025. return -1;
  6026. }
  6027. }
  6028. }
  6029. return a ? 1 : -1;
  6030. }
  6031. /**
  6032. * Returns a function to use in pseudos for input types
  6033. * @param {String} type
  6034. */
  6035. function createInputPseudo( type ) {
  6036. return function( elem ) {
  6037. var name = elem.nodeName.toLowerCase();
  6038. return name === "input" && elem.type === type;
  6039. };
  6040. }
  6041. /**
  6042. * Returns a function to use in pseudos for buttons
  6043. * @param {String} type
  6044. */
  6045. function createButtonPseudo( type ) {
  6046. return function( elem ) {
  6047. var name = elem.nodeName.toLowerCase();
  6048. return (name === "input" || name === "button") && elem.type === type;
  6049. };
  6050. }
  6051. /**
  6052. * Returns a function to use in pseudos for :enabled/:disabled
  6053. * @param {Boolean} disabled true for :disabled; false for :enabled
  6054. */
  6055. function createDisabledPseudo( disabled ) {
  6056. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  6057. return function( elem ) {
  6058. // Only certain elements can match :enabled or :disabled
  6059. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  6060. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  6061. if ( "form" in elem ) {
  6062. // Check for inherited disabledness on relevant non-disabled elements:
  6063. // * listed form-associated elements in a disabled fieldset
  6064. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  6065. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  6066. // * option elements in a disabled optgroup
  6067. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  6068. // All such elements have a "form" property.
  6069. if ( elem.parentNode && elem.disabled === false ) {
  6070. // Option elements defer to a parent optgroup if present
  6071. if ( "label" in elem ) {
  6072. if ( "label" in elem.parentNode ) {
  6073. return elem.parentNode.disabled === disabled;
  6074. } else {
  6075. return elem.disabled === disabled;
  6076. }
  6077. }
  6078. // Support: IE 6 - 11
  6079. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  6080. return elem.isDisabled === disabled ||
  6081. // Where there is no isDisabled, check manually
  6082. /* jshint -W018 */
  6083. elem.isDisabled !== !disabled &&
  6084. inDisabledFieldset( elem ) === disabled;
  6085. }
  6086. return elem.disabled === disabled;
  6087. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  6088. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  6089. // even exist on them, let alone have a boolean value.
  6090. } else if ( "label" in elem ) {
  6091. return elem.disabled === disabled;
  6092. }
  6093. // Remaining elements are neither :enabled nor :disabled
  6094. return false;
  6095. };
  6096. }
  6097. /**
  6098. * Returns a function to use in pseudos for positionals
  6099. * @param {Function} fn
  6100. */
  6101. function createPositionalPseudo( fn ) {
  6102. return markFunction(function( argument ) {
  6103. argument = +argument;
  6104. return markFunction(function( seed, matches ) {
  6105. var j,
  6106. matchIndexes = fn( [], seed.length, argument ),
  6107. i = matchIndexes.length;
  6108. // Match elements found at the specified indexes
  6109. while ( i-- ) {
  6110. if ( seed[ (j = matchIndexes[i]) ] ) {
  6111. seed[j] = !(matches[j] = seed[j]);
  6112. }
  6113. }
  6114. });
  6115. });
  6116. }
  6117. /**
  6118. * Checks a node for validity as a Sizzle context
  6119. * @param {Element|Object=} context
  6120. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  6121. */
  6122. function testContext( context ) {
  6123. return context && typeof context.getElementsByTagName !== "undefined" && context;
  6124. }
  6125. // Expose support vars for convenience
  6126. support = Sizzle.support = {};
  6127. /**
  6128. * Detects XML nodes
  6129. * @param {Element|Object} elem An element or a document
  6130. * @returns {Boolean} True iff elem is a non-HTML XML node
  6131. */
  6132. isXML = Sizzle.isXML = function( elem ) {
  6133. var namespace = elem.namespaceURI,
  6134. docElem = (elem.ownerDocument || elem).documentElement;
  6135. // Support: IE <=8
  6136. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  6137. // https://bugs.jquery.com/ticket/4833
  6138. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  6139. };
  6140. /**
  6141. * Sets document-related variables once based on the current document
  6142. * @param {Element|Object} [doc] An element or document object to use to set the document
  6143. * @returns {Object} Returns the current document
  6144. */
  6145. setDocument = Sizzle.setDocument = function( node ) {
  6146. var hasCompare, subWindow,
  6147. doc = node ? node.ownerDocument || node : preferredDoc;
  6148. // Return early if doc is invalid or already selected
  6149. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  6150. return document;
  6151. }
  6152. // Update global variables
  6153. document = doc;
  6154. docElem = document.documentElement;
  6155. documentIsHTML = !isXML( document );
  6156. // Support: IE 9-11, Edge
  6157. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  6158. if ( preferredDoc !== document &&
  6159. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  6160. // Support: IE 11, Edge
  6161. if ( subWindow.addEventListener ) {
  6162. subWindow.addEventListener( "unload", unloadHandler, false );
  6163. // Support: IE 9 - 10 only
  6164. } else if ( subWindow.attachEvent ) {
  6165. subWindow.attachEvent( "onunload", unloadHandler );
  6166. }
  6167. }
  6168. /* Attributes
  6169. ---------------------------------------------------------------------- */
  6170. // Support: IE<8
  6171. // Verify that getAttribute really returns attributes and not properties
  6172. // (excepting IE8 booleans)
  6173. support.attributes = assert(function( el ) {
  6174. el.className = "i";
  6175. return !el.getAttribute("className");
  6176. });
  6177. /* getElement(s)By*
  6178. ---------------------------------------------------------------------- */
  6179. // Check if getElementsByTagName("*") returns only elements
  6180. support.getElementsByTagName = assert(function( el ) {
  6181. el.appendChild( document.createComment("") );
  6182. return !el.getElementsByTagName("*").length;
  6183. });
  6184. // Support: IE<9
  6185. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  6186. // Support: IE<10
  6187. // Check if getElementById returns elements by name
  6188. // The broken getElementById methods don't pick up programmatically-set names,
  6189. // so use a roundabout getElementsByName test
  6190. support.getById = assert(function( el ) {
  6191. docElem.appendChild( el ).id = expando;
  6192. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  6193. });
  6194. // ID filter and find
  6195. if ( support.getById ) {
  6196. Expr.filter["ID"] = function( id ) {
  6197. var attrId = id.replace( runescape, funescape );
  6198. return function( elem ) {
  6199. return elem.getAttribute("id") === attrId;
  6200. };
  6201. };
  6202. Expr.find["ID"] = function( id, context ) {
  6203. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6204. var elem = context.getElementById( id );
  6205. return elem ? [ elem ] : [];
  6206. }
  6207. };
  6208. } else {
  6209. Expr.filter["ID"] = function( id ) {
  6210. var attrId = id.replace( runescape, funescape );
  6211. return function( elem ) {
  6212. var node = typeof elem.getAttributeNode !== "undefined" &&
  6213. elem.getAttributeNode("id");
  6214. return node && node.value === attrId;
  6215. };
  6216. };
  6217. // Support: IE 6 - 7 only
  6218. // getElementById is not reliable as a find shortcut
  6219. Expr.find["ID"] = function( id, context ) {
  6220. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6221. var node, i, elems,
  6222. elem = context.getElementById( id );
  6223. if ( elem ) {
  6224. // Verify the id attribute
  6225. node = elem.getAttributeNode("id");
  6226. if ( node && node.value === id ) {
  6227. return [ elem ];
  6228. }
  6229. // Fall back on getElementsByName
  6230. elems = context.getElementsByName( id );
  6231. i = 0;
  6232. while ( (elem = elems[i++]) ) {
  6233. node = elem.getAttributeNode("id");
  6234. if ( node && node.value === id ) {
  6235. return [ elem ];
  6236. }
  6237. }
  6238. }
  6239. return [];
  6240. }
  6241. };
  6242. }
  6243. // Tag
  6244. Expr.find["TAG"] = support.getElementsByTagName ?
  6245. function( tag, context ) {
  6246. if ( typeof context.getElementsByTagName !== "undefined" ) {
  6247. return context.getElementsByTagName( tag );
  6248. // DocumentFragment nodes don't have gEBTN
  6249. } else if ( support.qsa ) {
  6250. return context.querySelectorAll( tag );
  6251. }
  6252. } :
  6253. function( tag, context ) {
  6254. var elem,
  6255. tmp = [],
  6256. i = 0,
  6257. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  6258. results = context.getElementsByTagName( tag );
  6259. // Filter out possible comments
  6260. if ( tag === "*" ) {
  6261. while ( (elem = results[i++]) ) {
  6262. if ( elem.nodeType === 1 ) {
  6263. tmp.push( elem );
  6264. }
  6265. }
  6266. return tmp;
  6267. }
  6268. return results;
  6269. };
  6270. // Class
  6271. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  6272. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  6273. return context.getElementsByClassName( className );
  6274. }
  6275. };
  6276. /* QSA/matchesSelector
  6277. ---------------------------------------------------------------------- */
  6278. // QSA and matchesSelector support
  6279. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  6280. rbuggyMatches = [];
  6281. // qSa(:focus) reports false when true (Chrome 21)
  6282. // We allow this because of a bug in IE8/9 that throws an error
  6283. // whenever `document.activeElement` is accessed on an iframe
  6284. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  6285. // See https://bugs.jquery.com/ticket/13378
  6286. rbuggyQSA = [];
  6287. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  6288. // Build QSA regex
  6289. // Regex strategy adopted from Diego Perini
  6290. assert(function( el ) {
  6291. // Select is set to empty string on purpose
  6292. // This is to test IE's treatment of not explicitly
  6293. // setting a boolean content attribute,
  6294. // since its presence should be enough
  6295. // https://bugs.jquery.com/ticket/12359
  6296. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  6297. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  6298. "<option selected=''></option></select>";
  6299. // Support: IE8, Opera 11-12.16
  6300. // Nothing should be selected when empty strings follow ^= or $= or *=
  6301. // The test attribute must be unknown in Opera but "safe" for WinRT
  6302. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  6303. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  6304. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  6305. }
  6306. // Support: IE8
  6307. // Boolean attributes and "value" are not treated correctly
  6308. if ( !el.querySelectorAll("[selected]").length ) {
  6309. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  6310. }
  6311. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  6312. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  6313. rbuggyQSA.push("~=");
  6314. }
  6315. // Webkit/Opera - :checked should return selected option elements
  6316. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6317. // IE8 throws error here and will not see later tests
  6318. if ( !el.querySelectorAll(":checked").length ) {
  6319. rbuggyQSA.push(":checked");
  6320. }
  6321. // Support: Safari 8+, iOS 8+
  6322. // https://bugs.webkit.org/show_bug.cgi?id=136851
  6323. // In-page `selector#id sibling-combinator selector` fails
  6324. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  6325. rbuggyQSA.push(".#.+[+~]");
  6326. }
  6327. });
  6328. assert(function( el ) {
  6329. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  6330. "<select disabled='disabled'><option/></select>";
  6331. // Support: Windows 8 Native Apps
  6332. // The type and name attributes are restricted during .innerHTML assignment
  6333. var input = document.createElement("input");
  6334. input.setAttribute( "type", "hidden" );
  6335. el.appendChild( input ).setAttribute( "name", "D" );
  6336. // Support: IE8
  6337. // Enforce case-sensitivity of name attribute
  6338. if ( el.querySelectorAll("[name=d]").length ) {
  6339. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  6340. }
  6341. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  6342. // IE8 throws error here and will not see later tests
  6343. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  6344. rbuggyQSA.push( ":enabled", ":disabled" );
  6345. }
  6346. // Support: IE9-11+
  6347. // IE's :disabled selector does not pick up the children of disabled fieldsets
  6348. docElem.appendChild( el ).disabled = true;
  6349. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  6350. rbuggyQSA.push( ":enabled", ":disabled" );
  6351. }
  6352. // Opera 10-11 does not throw on post-comma invalid pseudos
  6353. el.querySelectorAll("*,:x");
  6354. rbuggyQSA.push(",.*:");
  6355. });
  6356. }
  6357. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  6358. docElem.webkitMatchesSelector ||
  6359. docElem.mozMatchesSelector ||
  6360. docElem.oMatchesSelector ||
  6361. docElem.msMatchesSelector) )) ) {
  6362. assert(function( el ) {
  6363. // Check to see if it's possible to do matchesSelector
  6364. // on a disconnected node (IE 9)
  6365. support.disconnectedMatch = matches.call( el, "*" );
  6366. // This should fail with an exception
  6367. // Gecko does not error, returns false instead
  6368. matches.call( el, "[s!='']:x" );
  6369. rbuggyMatches.push( "!=", pseudos );
  6370. });
  6371. }
  6372. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  6373. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  6374. /* Contains
  6375. ---------------------------------------------------------------------- */
  6376. hasCompare = rnative.test( docElem.compareDocumentPosition );
  6377. // Element contains another
  6378. // Purposefully self-exclusive
  6379. // As in, an element does not contain itself
  6380. contains = hasCompare || rnative.test( docElem.contains ) ?
  6381. function( a, b ) {
  6382. var adown = a.nodeType === 9 ? a.documentElement : a,
  6383. bup = b && b.parentNode;
  6384. return a === bup || !!( bup && bup.nodeType === 1 && (
  6385. adown.contains ?
  6386. adown.contains( bup ) :
  6387. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  6388. ));
  6389. } :
  6390. function( a, b ) {
  6391. if ( b ) {
  6392. while ( (b = b.parentNode) ) {
  6393. if ( b === a ) {
  6394. return true;
  6395. }
  6396. }
  6397. }
  6398. return false;
  6399. };
  6400. /* Sorting
  6401. ---------------------------------------------------------------------- */
  6402. // Document order sorting
  6403. sortOrder = hasCompare ?
  6404. function( a, b ) {
  6405. // Flag for duplicate removal
  6406. if ( a === b ) {
  6407. hasDuplicate = true;
  6408. return 0;
  6409. }
  6410. // Sort on method existence if only one input has compareDocumentPosition
  6411. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  6412. if ( compare ) {
  6413. return compare;
  6414. }
  6415. // Calculate position if both inputs belong to the same document
  6416. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  6417. a.compareDocumentPosition( b ) :
  6418. // Otherwise we know they are disconnected
  6419. 1;
  6420. // Disconnected nodes
  6421. if ( compare & 1 ||
  6422. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  6423. // Choose the first element that is related to our preferred document
  6424. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  6425. return -1;
  6426. }
  6427. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  6428. return 1;
  6429. }
  6430. // Maintain original order
  6431. return sortInput ?
  6432. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6433. 0;
  6434. }
  6435. return compare & 4 ? -1 : 1;
  6436. } :
  6437. function( a, b ) {
  6438. // Exit early if the nodes are identical
  6439. if ( a === b ) {
  6440. hasDuplicate = true;
  6441. return 0;
  6442. }
  6443. var cur,
  6444. i = 0,
  6445. aup = a.parentNode,
  6446. bup = b.parentNode,
  6447. ap = [ a ],
  6448. bp = [ b ];
  6449. // Parentless nodes are either documents or disconnected
  6450. if ( !aup || !bup ) {
  6451. return a === document ? -1 :
  6452. b === document ? 1 :
  6453. aup ? -1 :
  6454. bup ? 1 :
  6455. sortInput ?
  6456. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6457. 0;
  6458. // If the nodes are siblings, we can do a quick check
  6459. } else if ( aup === bup ) {
  6460. return siblingCheck( a, b );
  6461. }
  6462. // Otherwise we need full lists of their ancestors for comparison
  6463. cur = a;
  6464. while ( (cur = cur.parentNode) ) {
  6465. ap.unshift( cur );
  6466. }
  6467. cur = b;
  6468. while ( (cur = cur.parentNode) ) {
  6469. bp.unshift( cur );
  6470. }
  6471. // Walk down the tree looking for a discrepancy
  6472. while ( ap[i] === bp[i] ) {
  6473. i++;
  6474. }
  6475. return i ?
  6476. // Do a sibling check if the nodes have a common ancestor
  6477. siblingCheck( ap[i], bp[i] ) :
  6478. // Otherwise nodes in our document sort first
  6479. ap[i] === preferredDoc ? -1 :
  6480. bp[i] === preferredDoc ? 1 :
  6481. 0;
  6482. };
  6483. return document;
  6484. };
  6485. Sizzle.matches = function( expr, elements ) {
  6486. return Sizzle( expr, null, null, elements );
  6487. };
  6488. Sizzle.matchesSelector = function( elem, expr ) {
  6489. // Set document vars if needed
  6490. if ( ( elem.ownerDocument || elem ) !== document ) {
  6491. setDocument( elem );
  6492. }
  6493. if ( support.matchesSelector && documentIsHTML &&
  6494. !nonnativeSelectorCache[ expr + " " ] &&
  6495. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  6496. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  6497. try {
  6498. var ret = matches.call( elem, expr );
  6499. // IE 9's matchesSelector returns false on disconnected nodes
  6500. if ( ret || support.disconnectedMatch ||
  6501. // As well, disconnected nodes are said to be in a document
  6502. // fragment in IE 9
  6503. elem.document && elem.document.nodeType !== 11 ) {
  6504. return ret;
  6505. }
  6506. } catch (e) {
  6507. nonnativeSelectorCache( expr, true );
  6508. }
  6509. }
  6510. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  6511. };
  6512. Sizzle.contains = function( context, elem ) {
  6513. // Set document vars if needed
  6514. if ( ( context.ownerDocument || context ) !== document ) {
  6515. setDocument( context );
  6516. }
  6517. return contains( context, elem );
  6518. };
  6519. Sizzle.attr = function( elem, name ) {
  6520. // Set document vars if needed
  6521. if ( ( elem.ownerDocument || elem ) !== document ) {
  6522. setDocument( elem );
  6523. }
  6524. var fn = Expr.attrHandle[ name.toLowerCase() ],
  6525. // Don't get fooled by Object.prototype properties (jQuery #13807)
  6526. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  6527. fn( elem, name, !documentIsHTML ) :
  6528. undefined;
  6529. return val !== undefined ?
  6530. val :
  6531. support.attributes || !documentIsHTML ?
  6532. elem.getAttribute( name ) :
  6533. (val = elem.getAttributeNode(name)) && val.specified ?
  6534. val.value :
  6535. null;
  6536. };
  6537. Sizzle.escape = function( sel ) {
  6538. return (sel + "").replace( rcssescape, fcssescape );
  6539. };
  6540. Sizzle.error = function( msg ) {
  6541. throw new Error( "Syntax error, unrecognized expression: " + msg );
  6542. };
  6543. /**
  6544. * Document sorting and removing duplicates
  6545. * @param {ArrayLike} results
  6546. */
  6547. Sizzle.uniqueSort = function( results ) {
  6548. var elem,
  6549. duplicates = [],
  6550. j = 0,
  6551. i = 0;
  6552. // Unless we *know* we can detect duplicates, assume their presence
  6553. hasDuplicate = !support.detectDuplicates;
  6554. sortInput = !support.sortStable && results.slice( 0 );
  6555. results.sort( sortOrder );
  6556. if ( hasDuplicate ) {
  6557. while ( (elem = results[i++]) ) {
  6558. if ( elem === results[ i ] ) {
  6559. j = duplicates.push( i );
  6560. }
  6561. }
  6562. while ( j-- ) {
  6563. results.splice( duplicates[ j ], 1 );
  6564. }
  6565. }
  6566. // Clear input after sorting to release objects
  6567. // See https://github.com/jquery/sizzle/pull/225
  6568. sortInput = null;
  6569. return results;
  6570. };
  6571. /**
  6572. * Utility function for retrieving the text value of an array of DOM nodes
  6573. * @param {Array|Element} elem
  6574. */
  6575. getText = Sizzle.getText = function( elem ) {
  6576. var node,
  6577. ret = "",
  6578. i = 0,
  6579. nodeType = elem.nodeType;
  6580. if ( !nodeType ) {
  6581. // If no nodeType, this is expected to be an array
  6582. while ( (node = elem[i++]) ) {
  6583. // Do not traverse comment nodes
  6584. ret += getText( node );
  6585. }
  6586. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  6587. // Use textContent for elements
  6588. // innerText usage removed for consistency of new lines (jQuery #11153)
  6589. if ( typeof elem.textContent === "string" ) {
  6590. return elem.textContent;
  6591. } else {
  6592. // Traverse its children
  6593. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6594. ret += getText( elem );
  6595. }
  6596. }
  6597. } else if ( nodeType === 3 || nodeType === 4 ) {
  6598. return elem.nodeValue;
  6599. }
  6600. // Do not include comment or processing instruction nodes
  6601. return ret;
  6602. };
  6603. Expr = Sizzle.selectors = {
  6604. // Can be adjusted by the user
  6605. cacheLength: 50,
  6606. createPseudo: markFunction,
  6607. match: matchExpr,
  6608. attrHandle: {},
  6609. find: {},
  6610. relative: {
  6611. ">": { dir: "parentNode", first: true },
  6612. " ": { dir: "parentNode" },
  6613. "+": { dir: "previousSibling", first: true },
  6614. "~": { dir: "previousSibling" }
  6615. },
  6616. preFilter: {
  6617. "ATTR": function( match ) {
  6618. match[1] = match[1].replace( runescape, funescape );
  6619. // Move the given value to match[3] whether quoted or unquoted
  6620. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  6621. if ( match[2] === "~=" ) {
  6622. match[3] = " " + match[3] + " ";
  6623. }
  6624. return match.slice( 0, 4 );
  6625. },
  6626. "CHILD": function( match ) {
  6627. /* matches from matchExpr["CHILD"]
  6628. 1 type (only|nth|...)
  6629. 2 what (child|of-type)
  6630. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  6631. 4 xn-component of xn+y argument ([+-]?\d*n|)
  6632. 5 sign of xn-component
  6633. 6 x of xn-component
  6634. 7 sign of y-component
  6635. 8 y of y-component
  6636. */
  6637. match[1] = match[1].toLowerCase();
  6638. if ( match[1].slice( 0, 3 ) === "nth" ) {
  6639. // nth-* requires argument
  6640. if ( !match[3] ) {
  6641. Sizzle.error( match[0] );
  6642. }
  6643. // numeric x and y parameters for Expr.filter.CHILD
  6644. // remember that false/true cast respectively to 0/1
  6645. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  6646. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  6647. // other types prohibit arguments
  6648. } else if ( match[3] ) {
  6649. Sizzle.error( match[0] );
  6650. }
  6651. return match;
  6652. },
  6653. "PSEUDO": function( match ) {
  6654. var excess,
  6655. unquoted = !match[6] && match[2];
  6656. if ( matchExpr["CHILD"].test( match[0] ) ) {
  6657. return null;
  6658. }
  6659. // Accept quoted arguments as-is
  6660. if ( match[3] ) {
  6661. match[2] = match[4] || match[5] || "";
  6662. // Strip excess characters from unquoted arguments
  6663. } else if ( unquoted && rpseudo.test( unquoted ) &&
  6664. // Get excess from tokenize (recursively)
  6665. (excess = tokenize( unquoted, true )) &&
  6666. // advance to the next closing parenthesis
  6667. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  6668. // excess is a negative index
  6669. match[0] = match[0].slice( 0, excess );
  6670. match[2] = unquoted.slice( 0, excess );
  6671. }
  6672. // Return only captures needed by the pseudo filter method (type and argument)
  6673. return match.slice( 0, 3 );
  6674. }
  6675. },
  6676. filter: {
  6677. "TAG": function( nodeNameSelector ) {
  6678. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  6679. return nodeNameSelector === "*" ?
  6680. function() { return true; } :
  6681. function( elem ) {
  6682. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  6683. };
  6684. },
  6685. "CLASS": function( className ) {
  6686. var pattern = classCache[ className + " " ];
  6687. return pattern ||
  6688. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  6689. classCache( className, function( elem ) {
  6690. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  6691. });
  6692. },
  6693. "ATTR": function( name, operator, check ) {
  6694. return function( elem ) {
  6695. var result = Sizzle.attr( elem, name );
  6696. if ( result == null ) {
  6697. return operator === "!=";
  6698. }
  6699. if ( !operator ) {
  6700. return true;
  6701. }
  6702. result += "";
  6703. return operator === "=" ? result === check :
  6704. operator === "!=" ? result !== check :
  6705. operator === "^=" ? check && result.indexOf( check ) === 0 :
  6706. operator === "*=" ? check && result.indexOf( check ) > -1 :
  6707. operator === "$=" ? check && result.slice( -check.length ) === check :
  6708. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  6709. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  6710. false;
  6711. };
  6712. },
  6713. "CHILD": function( type, what, argument, first, last ) {
  6714. var simple = type.slice( 0, 3 ) !== "nth",
  6715. forward = type.slice( -4 ) !== "last",
  6716. ofType = what === "of-type";
  6717. return first === 1 && last === 0 ?
  6718. // Shortcut for :nth-*(n)
  6719. function( elem ) {
  6720. return !!elem.parentNode;
  6721. } :
  6722. function( elem, context, xml ) {
  6723. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  6724. dir = simple !== forward ? "nextSibling" : "previousSibling",
  6725. parent = elem.parentNode,
  6726. name = ofType && elem.nodeName.toLowerCase(),
  6727. useCache = !xml && !ofType,
  6728. diff = false;
  6729. if ( parent ) {
  6730. // :(first|last|only)-(child|of-type)
  6731. if ( simple ) {
  6732. while ( dir ) {
  6733. node = elem;
  6734. while ( (node = node[ dir ]) ) {
  6735. if ( ofType ?
  6736. node.nodeName.toLowerCase() === name :
  6737. node.nodeType === 1 ) {
  6738. return false;
  6739. }
  6740. }
  6741. // Reverse direction for :only-* (if we haven't yet done so)
  6742. start = dir = type === "only" && !start && "nextSibling";
  6743. }
  6744. return true;
  6745. }
  6746. start = [ forward ? parent.firstChild : parent.lastChild ];
  6747. // non-xml :nth-child(...) stores cache data on `parent`
  6748. if ( forward && useCache ) {
  6749. // Seek `elem` from a previously-cached index
  6750. // ...in a gzip-friendly way
  6751. node = parent;
  6752. outerCache = node[ expando ] || (node[ expando ] = {});
  6753. // Support: IE <9 only
  6754. // Defend against cloned attroperties (jQuery gh-1709)
  6755. uniqueCache = outerCache[ node.uniqueID ] ||
  6756. (outerCache[ node.uniqueID ] = {});
  6757. cache = uniqueCache[ type ] || [];
  6758. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6759. diff = nodeIndex && cache[ 2 ];
  6760. node = nodeIndex && parent.childNodes[ nodeIndex ];
  6761. while ( (node = ++nodeIndex && node && node[ dir ] ||
  6762. // Fallback to seeking `elem` from the start
  6763. (diff = nodeIndex = 0) || start.pop()) ) {
  6764. // When found, cache indexes on `parent` and break
  6765. if ( node.nodeType === 1 && ++diff && node === elem ) {
  6766. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  6767. break;
  6768. }
  6769. }
  6770. } else {
  6771. // Use previously-cached element index if available
  6772. if ( useCache ) {
  6773. // ...in a gzip-friendly way
  6774. node = elem;
  6775. outerCache = node[ expando ] || (node[ expando ] = {});
  6776. // Support: IE <9 only
  6777. // Defend against cloned attroperties (jQuery gh-1709)
  6778. uniqueCache = outerCache[ node.uniqueID ] ||
  6779. (outerCache[ node.uniqueID ] = {});
  6780. cache = uniqueCache[ type ] || [];
  6781. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6782. diff = nodeIndex;
  6783. }
  6784. // xml :nth-child(...)
  6785. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  6786. if ( diff === false ) {
  6787. // Use the same loop as above to seek `elem` from the start
  6788. while ( (node = ++nodeIndex && node && node[ dir ] ||
  6789. (diff = nodeIndex = 0) || start.pop()) ) {
  6790. if ( ( ofType ?
  6791. node.nodeName.toLowerCase() === name :
  6792. node.nodeType === 1 ) &&
  6793. ++diff ) {
  6794. // Cache the index of each encountered element
  6795. if ( useCache ) {
  6796. outerCache = node[ expando ] || (node[ expando ] = {});
  6797. // Support: IE <9 only
  6798. // Defend against cloned attroperties (jQuery gh-1709)
  6799. uniqueCache = outerCache[ node.uniqueID ] ||
  6800. (outerCache[ node.uniqueID ] = {});
  6801. uniqueCache[ type ] = [ dirruns, diff ];
  6802. }
  6803. if ( node === elem ) {
  6804. break;
  6805. }
  6806. }
  6807. }
  6808. }
  6809. }
  6810. // Incorporate the offset, then check against cycle size
  6811. diff -= last;
  6812. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  6813. }
  6814. };
  6815. },
  6816. "PSEUDO": function( pseudo, argument ) {
  6817. // pseudo-class names are case-insensitive
  6818. // http://www.w3.org/TR/selectors/#pseudo-classes
  6819. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  6820. // Remember that setFilters inherits from pseudos
  6821. var args,
  6822. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  6823. Sizzle.error( "unsupported pseudo: " + pseudo );
  6824. // The user may use createPseudo to indicate that
  6825. // arguments are needed to create the filter function
  6826. // just as Sizzle does
  6827. if ( fn[ expando ] ) {
  6828. return fn( argument );
  6829. }
  6830. // But maintain support for old signatures
  6831. if ( fn.length > 1 ) {
  6832. args = [ pseudo, pseudo, "", argument ];
  6833. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  6834. markFunction(function( seed, matches ) {
  6835. var idx,
  6836. matched = fn( seed, argument ),
  6837. i = matched.length;
  6838. while ( i-- ) {
  6839. idx = indexOf( seed, matched[i] );
  6840. seed[ idx ] = !( matches[ idx ] = matched[i] );
  6841. }
  6842. }) :
  6843. function( elem ) {
  6844. return fn( elem, 0, args );
  6845. };
  6846. }
  6847. return fn;
  6848. }
  6849. },
  6850. pseudos: {
  6851. // Potentially complex pseudos
  6852. "not": markFunction(function( selector ) {
  6853. // Trim the selector passed to compile
  6854. // to avoid treating leading and trailing
  6855. // spaces as combinators
  6856. var input = [],
  6857. results = [],
  6858. matcher = compile( selector.replace( rtrim, "$1" ) );
  6859. return matcher[ expando ] ?
  6860. markFunction(function( seed, matches, context, xml ) {
  6861. var elem,
  6862. unmatched = matcher( seed, null, xml, [] ),
  6863. i = seed.length;
  6864. // Match elements unmatched by `matcher`
  6865. while ( i-- ) {
  6866. if ( (elem = unmatched[i]) ) {
  6867. seed[i] = !(matches[i] = elem);
  6868. }
  6869. }
  6870. }) :
  6871. function( elem, context, xml ) {
  6872. input[0] = elem;
  6873. matcher( input, null, xml, results );
  6874. // Don't keep the element (issue #299)
  6875. input[0] = null;
  6876. return !results.pop();
  6877. };
  6878. }),
  6879. "has": markFunction(function( selector ) {
  6880. return function( elem ) {
  6881. return Sizzle( selector, elem ).length > 0;
  6882. };
  6883. }),
  6884. "contains": markFunction(function( text ) {
  6885. text = text.replace( runescape, funescape );
  6886. return function( elem ) {
  6887. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  6888. };
  6889. }),
  6890. // "Whether an element is represented by a :lang() selector
  6891. // is based solely on the element's language value
  6892. // being equal to the identifier C,
  6893. // or beginning with the identifier C immediately followed by "-".
  6894. // The matching of C against the element's language value is performed case-insensitively.
  6895. // The identifier C does not have to be a valid language name."
  6896. // http://www.w3.org/TR/selectors/#lang-pseudo
  6897. "lang": markFunction( function( lang ) {
  6898. // lang value must be a valid identifier
  6899. if ( !ridentifier.test(lang || "") ) {
  6900. Sizzle.error( "unsupported lang: " + lang );
  6901. }
  6902. lang = lang.replace( runescape, funescape ).toLowerCase();
  6903. return function( elem ) {
  6904. var elemLang;
  6905. do {
  6906. if ( (elemLang = documentIsHTML ?
  6907. elem.lang :
  6908. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  6909. elemLang = elemLang.toLowerCase();
  6910. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  6911. }
  6912. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  6913. return false;
  6914. };
  6915. }),
  6916. // Miscellaneous
  6917. "target": function( elem ) {
  6918. var hash = window.location && window.location.hash;
  6919. return hash && hash.slice( 1 ) === elem.id;
  6920. },
  6921. "root": function( elem ) {
  6922. return elem === docElem;
  6923. },
  6924. "focus": function( elem ) {
  6925. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  6926. },
  6927. // Boolean properties
  6928. "enabled": createDisabledPseudo( false ),
  6929. "disabled": createDisabledPseudo( true ),
  6930. "checked": function( elem ) {
  6931. // In CSS3, :checked should return both checked and selected elements
  6932. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6933. var nodeName = elem.nodeName.toLowerCase();
  6934. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  6935. },
  6936. "selected": function( elem ) {
  6937. // Accessing this property makes selected-by-default
  6938. // options in Safari work properly
  6939. if ( elem.parentNode ) {
  6940. elem.parentNode.selectedIndex;
  6941. }
  6942. return elem.selected === true;
  6943. },
  6944. // Contents
  6945. "empty": function( elem ) {
  6946. // http://www.w3.org/TR/selectors/#empty-pseudo
  6947. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  6948. // but not by others (comment: 8; processing instruction: 7; etc.)
  6949. // nodeType < 6 works because attributes (2) do not appear as children
  6950. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6951. if ( elem.nodeType < 6 ) {
  6952. return false;
  6953. }
  6954. }
  6955. return true;
  6956. },
  6957. "parent": function( elem ) {
  6958. return !Expr.pseudos["empty"]( elem );
  6959. },
  6960. // Element/input types
  6961. "header": function( elem ) {
  6962. return rheader.test( elem.nodeName );
  6963. },
  6964. "input": function( elem ) {
  6965. return rinputs.test( elem.nodeName );
  6966. },
  6967. "button": function( elem ) {
  6968. var name = elem.nodeName.toLowerCase();
  6969. return name === "input" && elem.type === "button" || name === "button";
  6970. },
  6971. "text": function( elem ) {
  6972. var attr;
  6973. return elem.nodeName.toLowerCase() === "input" &&
  6974. elem.type === "text" &&
  6975. // Support: IE<8
  6976. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  6977. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  6978. },
  6979. // Position-in-collection
  6980. "first": createPositionalPseudo(function() {
  6981. return [ 0 ];
  6982. }),
  6983. "last": createPositionalPseudo(function( matchIndexes, length ) {
  6984. return [ length - 1 ];
  6985. }),
  6986. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  6987. return [ argument < 0 ? argument + length : argument ];
  6988. }),
  6989. "even": createPositionalPseudo(function( matchIndexes, length ) {
  6990. var i = 0;
  6991. for ( ; i < length; i += 2 ) {
  6992. matchIndexes.push( i );
  6993. }
  6994. return matchIndexes;
  6995. }),
  6996. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  6997. var i = 1;
  6998. for ( ; i < length; i += 2 ) {
  6999. matchIndexes.push( i );
  7000. }
  7001. return matchIndexes;
  7002. }),
  7003. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  7004. var i = argument < 0 ?
  7005. argument + length :
  7006. argument > length ?
  7007. length :
  7008. argument;
  7009. for ( ; --i >= 0; ) {
  7010. matchIndexes.push( i );
  7011. }
  7012. return matchIndexes;
  7013. }),
  7014. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  7015. var i = argument < 0 ? argument + length : argument;
  7016. for ( ; ++i < length; ) {
  7017. matchIndexes.push( i );
  7018. }
  7019. return matchIndexes;
  7020. })
  7021. }
  7022. };
  7023. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  7024. // Add button/input type pseudos
  7025. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  7026. Expr.pseudos[ i ] = createInputPseudo( i );
  7027. }
  7028. for ( i in { submit: true, reset: true } ) {
  7029. Expr.pseudos[ i ] = createButtonPseudo( i );
  7030. }
  7031. // Easy API for creating new setFilters
  7032. function setFilters() {}
  7033. setFilters.prototype = Expr.filters = Expr.pseudos;
  7034. Expr.setFilters = new setFilters();
  7035. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  7036. var matched, match, tokens, type,
  7037. soFar, groups, preFilters,
  7038. cached = tokenCache[ selector + " " ];
  7039. if ( cached ) {
  7040. return parseOnly ? 0 : cached.slice( 0 );
  7041. }
  7042. soFar = selector;
  7043. groups = [];
  7044. preFilters = Expr.preFilter;
  7045. while ( soFar ) {
  7046. // Comma and first run
  7047. if ( !matched || (match = rcomma.exec( soFar )) ) {
  7048. if ( match ) {
  7049. // Don't consume trailing commas as valid
  7050. soFar = soFar.slice( match[0].length ) || soFar;
  7051. }
  7052. groups.push( (tokens = []) );
  7053. }
  7054. matched = false;
  7055. // Combinators
  7056. if ( (match = rcombinators.exec( soFar )) ) {
  7057. matched = match.shift();
  7058. tokens.push({
  7059. value: matched,
  7060. // Cast descendant combinators to space
  7061. type: match[0].replace( rtrim, " " )
  7062. });
  7063. soFar = soFar.slice( matched.length );
  7064. }
  7065. // Filters
  7066. for ( type in Expr.filter ) {
  7067. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  7068. (match = preFilters[ type ]( match ))) ) {
  7069. matched = match.shift();
  7070. tokens.push({
  7071. value: matched,
  7072. type: type,
  7073. matches: match
  7074. });
  7075. soFar = soFar.slice( matched.length );
  7076. }
  7077. }
  7078. if ( !matched ) {
  7079. break;
  7080. }
  7081. }
  7082. // Return the length of the invalid excess
  7083. // if we're just parsing
  7084. // Otherwise, throw an error or return tokens
  7085. return parseOnly ?
  7086. soFar.length :
  7087. soFar ?
  7088. Sizzle.error( selector ) :
  7089. // Cache the tokens
  7090. tokenCache( selector, groups ).slice( 0 );
  7091. };
  7092. function toSelector( tokens ) {
  7093. var i = 0,
  7094. len = tokens.length,
  7095. selector = "";
  7096. for ( ; i < len; i++ ) {
  7097. selector += tokens[i].value;
  7098. }
  7099. return selector;
  7100. }
  7101. function addCombinator( matcher, combinator, base ) {
  7102. var dir = combinator.dir,
  7103. skip = combinator.next,
  7104. key = skip || dir,
  7105. checkNonElements = base && key === "parentNode",
  7106. doneName = done++;
  7107. return combinator.first ?
  7108. // Check against closest ancestor/preceding element
  7109. function( elem, context, xml ) {
  7110. while ( (elem = elem[ dir ]) ) {
  7111. if ( elem.nodeType === 1 || checkNonElements ) {
  7112. return matcher( elem, context, xml );
  7113. }
  7114. }
  7115. return false;
  7116. } :
  7117. // Check against all ancestor/preceding elements
  7118. function( elem, context, xml ) {
  7119. var oldCache, uniqueCache, outerCache,
  7120. newCache = [ dirruns, doneName ];
  7121. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  7122. if ( xml ) {
  7123. while ( (elem = elem[ dir ]) ) {
  7124. if ( elem.nodeType === 1 || checkNonElements ) {
  7125. if ( matcher( elem, context, xml ) ) {
  7126. return true;
  7127. }
  7128. }
  7129. }
  7130. } else {
  7131. while ( (elem = elem[ dir ]) ) {
  7132. if ( elem.nodeType === 1 || checkNonElements ) {
  7133. outerCache = elem[ expando ] || (elem[ expando ] = {});
  7134. // Support: IE <9 only
  7135. // Defend against cloned attroperties (jQuery gh-1709)
  7136. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  7137. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  7138. elem = elem[ dir ] || elem;
  7139. } else if ( (oldCache = uniqueCache[ key ]) &&
  7140. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  7141. // Assign to newCache so results back-propagate to previous elements
  7142. return (newCache[ 2 ] = oldCache[ 2 ]);
  7143. } else {
  7144. // Reuse newcache so results back-propagate to previous elements
  7145. uniqueCache[ key ] = newCache;
  7146. // A match means we're done; a fail means we have to keep checking
  7147. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  7148. return true;
  7149. }
  7150. }
  7151. }
  7152. }
  7153. }
  7154. return false;
  7155. };
  7156. }
  7157. function elementMatcher( matchers ) {
  7158. return matchers.length > 1 ?
  7159. function( elem, context, xml ) {
  7160. var i = matchers.length;
  7161. while ( i-- ) {
  7162. if ( !matchers[i]( elem, context, xml ) ) {
  7163. return false;
  7164. }
  7165. }
  7166. return true;
  7167. } :
  7168. matchers[0];
  7169. }
  7170. function multipleContexts( selector, contexts, results ) {
  7171. var i = 0,
  7172. len = contexts.length;
  7173. for ( ; i < len; i++ ) {
  7174. Sizzle( selector, contexts[i], results );
  7175. }
  7176. return results;
  7177. }
  7178. function condense( unmatched, map, filter, context, xml ) {
  7179. var elem,
  7180. newUnmatched = [],
  7181. i = 0,
  7182. len = unmatched.length,
  7183. mapped = map != null;
  7184. for ( ; i < len; i++ ) {
  7185. if ( (elem = unmatched[i]) ) {
  7186. if ( !filter || filter( elem, context, xml ) ) {
  7187. newUnmatched.push( elem );
  7188. if ( mapped ) {
  7189. map.push( i );
  7190. }
  7191. }
  7192. }
  7193. }
  7194. return newUnmatched;
  7195. }
  7196. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  7197. if ( postFilter && !postFilter[ expando ] ) {
  7198. postFilter = setMatcher( postFilter );
  7199. }
  7200. if ( postFinder && !postFinder[ expando ] ) {
  7201. postFinder = setMatcher( postFinder, postSelector );
  7202. }
  7203. return markFunction(function( seed, results, context, xml ) {
  7204. var temp, i, elem,
  7205. preMap = [],
  7206. postMap = [],
  7207. preexisting = results.length,
  7208. // Get initial elements from seed or context
  7209. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  7210. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  7211. matcherIn = preFilter && ( seed || !selector ) ?
  7212. condense( elems, preMap, preFilter, context, xml ) :
  7213. elems,
  7214. matcherOut = matcher ?
  7215. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  7216. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  7217. // ...intermediate processing is necessary
  7218. [] :
  7219. // ...otherwise use results directly
  7220. results :
  7221. matcherIn;
  7222. // Find primary matches
  7223. if ( matcher ) {
  7224. matcher( matcherIn, matcherOut, context, xml );
  7225. }
  7226. // Apply postFilter
  7227. if ( postFilter ) {
  7228. temp = condense( matcherOut, postMap );
  7229. postFilter( temp, [], context, xml );
  7230. // Un-match failing elements by moving them back to matcherIn
  7231. i = temp.length;
  7232. while ( i-- ) {
  7233. if ( (elem = temp[i]) ) {
  7234. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  7235. }
  7236. }
  7237. }
  7238. if ( seed ) {
  7239. if ( postFinder || preFilter ) {
  7240. if ( postFinder ) {
  7241. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  7242. temp = [];
  7243. i = matcherOut.length;
  7244. while ( i-- ) {
  7245. if ( (elem = matcherOut[i]) ) {
  7246. // Restore matcherIn since elem is not yet a final match
  7247. temp.push( (matcherIn[i] = elem) );
  7248. }
  7249. }
  7250. postFinder( null, (matcherOut = []), temp, xml );
  7251. }
  7252. // Move matched elements from seed to results to keep them synchronized
  7253. i = matcherOut.length;
  7254. while ( i-- ) {
  7255. if ( (elem = matcherOut[i]) &&
  7256. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  7257. seed[temp] = !(results[temp] = elem);
  7258. }
  7259. }
  7260. }
  7261. // Add elements to results, through postFinder if defined
  7262. } else {
  7263. matcherOut = condense(
  7264. matcherOut === results ?
  7265. matcherOut.splice( preexisting, matcherOut.length ) :
  7266. matcherOut
  7267. );
  7268. if ( postFinder ) {
  7269. postFinder( null, results, matcherOut, xml );
  7270. } else {
  7271. push.apply( results, matcherOut );
  7272. }
  7273. }
  7274. });
  7275. }
  7276. function matcherFromTokens( tokens ) {
  7277. var checkContext, matcher, j,
  7278. len = tokens.length,
  7279. leadingRelative = Expr.relative[ tokens[0].type ],
  7280. implicitRelative = leadingRelative || Expr.relative[" "],
  7281. i = leadingRelative ? 1 : 0,
  7282. // The foundational matcher ensures that elements are reachable from top-level context(s)
  7283. matchContext = addCombinator( function( elem ) {
  7284. return elem === checkContext;
  7285. }, implicitRelative, true ),
  7286. matchAnyContext = addCombinator( function( elem ) {
  7287. return indexOf( checkContext, elem ) > -1;
  7288. }, implicitRelative, true ),
  7289. matchers = [ function( elem, context, xml ) {
  7290. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  7291. (checkContext = context).nodeType ?
  7292. matchContext( elem, context, xml ) :
  7293. matchAnyContext( elem, context, xml ) );
  7294. // Avoid hanging onto element (issue #299)
  7295. checkContext = null;
  7296. return ret;
  7297. } ];
  7298. for ( ; i < len; i++ ) {
  7299. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  7300. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  7301. } else {
  7302. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  7303. // Return special upon seeing a positional matcher
  7304. if ( matcher[ expando ] ) {
  7305. // Find the next relative operator (if any) for proper handling
  7306. j = ++i;
  7307. for ( ; j < len; j++ ) {
  7308. if ( Expr.relative[ tokens[j].type ] ) {
  7309. break;
  7310. }
  7311. }
  7312. return setMatcher(
  7313. i > 1 && elementMatcher( matchers ),
  7314. i > 1 && toSelector(
  7315. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  7316. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  7317. ).replace( rtrim, "$1" ),
  7318. matcher,
  7319. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  7320. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  7321. j < len && toSelector( tokens )
  7322. );
  7323. }
  7324. matchers.push( matcher );
  7325. }
  7326. }
  7327. return elementMatcher( matchers );
  7328. }
  7329. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  7330. var bySet = setMatchers.length > 0,
  7331. byElement = elementMatchers.length > 0,
  7332. superMatcher = function( seed, context, xml, results, outermost ) {
  7333. var elem, j, matcher,
  7334. matchedCount = 0,
  7335. i = "0",
  7336. unmatched = seed && [],
  7337. setMatched = [],
  7338. contextBackup = outermostContext,
  7339. // We must always have either seed elements or outermost context
  7340. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  7341. // Use integer dirruns iff this is the outermost matcher
  7342. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  7343. len = elems.length;
  7344. if ( outermost ) {
  7345. outermostContext = context === document || context || outermost;
  7346. }
  7347. // Add elements passing elementMatchers directly to results
  7348. // Support: IE<9, Safari
  7349. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  7350. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  7351. if ( byElement && elem ) {
  7352. j = 0;
  7353. if ( !context && elem.ownerDocument !== document ) {
  7354. setDocument( elem );
  7355. xml = !documentIsHTML;
  7356. }
  7357. while ( (matcher = elementMatchers[j++]) ) {
  7358. if ( matcher( elem, context || document, xml) ) {
  7359. results.push( elem );
  7360. break;
  7361. }
  7362. }
  7363. if ( outermost ) {
  7364. dirruns = dirrunsUnique;
  7365. }
  7366. }
  7367. // Track unmatched elements for set filters
  7368. if ( bySet ) {
  7369. // They will have gone through all possible matchers
  7370. if ( (elem = !matcher && elem) ) {
  7371. matchedCount--;
  7372. }
  7373. // Lengthen the array for every element, matched or not
  7374. if ( seed ) {
  7375. unmatched.push( elem );
  7376. }
  7377. }
  7378. }
  7379. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  7380. // makes the latter nonnegative.
  7381. matchedCount += i;
  7382. // Apply set filters to unmatched elements
  7383. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  7384. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  7385. // no element matchers and no seed.
  7386. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  7387. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  7388. // numerically zero.
  7389. if ( bySet && i !== matchedCount ) {
  7390. j = 0;
  7391. while ( (matcher = setMatchers[j++]) ) {
  7392. matcher( unmatched, setMatched, context, xml );
  7393. }
  7394. if ( seed ) {
  7395. // Reintegrate element matches to eliminate the need for sorting
  7396. if ( matchedCount > 0 ) {
  7397. while ( i-- ) {
  7398. if ( !(unmatched[i] || setMatched[i]) ) {
  7399. setMatched[i] = pop.call( results );
  7400. }
  7401. }
  7402. }
  7403. // Discard index placeholder values to get only actual matches
  7404. setMatched = condense( setMatched );
  7405. }
  7406. // Add matches to results
  7407. push.apply( results, setMatched );
  7408. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  7409. if ( outermost && !seed && setMatched.length > 0 &&
  7410. ( matchedCount + setMatchers.length ) > 1 ) {
  7411. Sizzle.uniqueSort( results );
  7412. }
  7413. }
  7414. // Override manipulation of globals by nested matchers
  7415. if ( outermost ) {
  7416. dirruns = dirrunsUnique;
  7417. outermostContext = contextBackup;
  7418. }
  7419. return unmatched;
  7420. };
  7421. return bySet ?
  7422. markFunction( superMatcher ) :
  7423. superMatcher;
  7424. }
  7425. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  7426. var i,
  7427. setMatchers = [],
  7428. elementMatchers = [],
  7429. cached = compilerCache[ selector + " " ];
  7430. if ( !cached ) {
  7431. // Generate a function of recursive functions that can be used to check each element
  7432. if ( !match ) {
  7433. match = tokenize( selector );
  7434. }
  7435. i = match.length;
  7436. while ( i-- ) {
  7437. cached = matcherFromTokens( match[i] );
  7438. if ( cached[ expando ] ) {
  7439. setMatchers.push( cached );
  7440. } else {
  7441. elementMatchers.push( cached );
  7442. }
  7443. }
  7444. // Cache the compiled function
  7445. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  7446. // Save selector and tokenization
  7447. cached.selector = selector;
  7448. }
  7449. return cached;
  7450. };
  7451. /**
  7452. * A low-level selection function that works with Sizzle's compiled
  7453. * selector functions
  7454. * @param {String|Function} selector A selector or a pre-compiled
  7455. * selector function built with Sizzle.compile
  7456. * @param {Element} context
  7457. * @param {Array} [results]
  7458. * @param {Array} [seed] A set of elements to match against
  7459. */
  7460. select = Sizzle.select = function( selector, context, results, seed ) {
  7461. var i, tokens, token, type, find,
  7462. compiled = typeof selector === "function" && selector,
  7463. match = !seed && tokenize( (selector = compiled.selector || selector) );
  7464. results = results || [];
  7465. // Try to minimize operations if there is only one selector in the list and no seed
  7466. // (the latter of which guarantees us context)
  7467. if ( match.length === 1 ) {
  7468. // Reduce context if the leading compound selector is an ID
  7469. tokens = match[0] = match[0].slice( 0 );
  7470. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  7471. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  7472. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  7473. if ( !context ) {
  7474. return results;
  7475. // Precompiled matchers will still verify ancestry, so step up a level
  7476. } else if ( compiled ) {
  7477. context = context.parentNode;
  7478. }
  7479. selector = selector.slice( tokens.shift().value.length );
  7480. }
  7481. // Fetch a seed set for right-to-left matching
  7482. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  7483. while ( i-- ) {
  7484. token = tokens[i];
  7485. // Abort if we hit a combinator
  7486. if ( Expr.relative[ (type = token.type) ] ) {
  7487. break;
  7488. }
  7489. if ( (find = Expr.find[ type ]) ) {
  7490. // Search, expanding context for leading sibling combinators
  7491. if ( (seed = find(
  7492. token.matches[0].replace( runescape, funescape ),
  7493. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  7494. )) ) {
  7495. // If seed is empty or no tokens remain, we can return early
  7496. tokens.splice( i, 1 );
  7497. selector = seed.length && toSelector( tokens );
  7498. if ( !selector ) {
  7499. push.apply( results, seed );
  7500. return results;
  7501. }
  7502. break;
  7503. }
  7504. }
  7505. }
  7506. }
  7507. // Compile and execute a filtering function if one is not provided
  7508. // Provide `match` to avoid retokenization if we modified the selector above
  7509. ( compiled || compile( selector, match ) )(
  7510. seed,
  7511. context,
  7512. !documentIsHTML,
  7513. results,
  7514. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  7515. );
  7516. return results;
  7517. };
  7518. // One-time assignments
  7519. // Sort stability
  7520. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  7521. // Support: Chrome 14-35+
  7522. // Always assume duplicates if they aren't passed to the comparison function
  7523. support.detectDuplicates = !!hasDuplicate;
  7524. // Initialize against the default document
  7525. setDocument();
  7526. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  7527. // Detached nodes confoundingly follow *each other*
  7528. support.sortDetached = assert(function( el ) {
  7529. // Should return 1, but returns 4 (following)
  7530. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  7531. });
  7532. // Support: IE<8
  7533. // Prevent attribute/property "interpolation"
  7534. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  7535. if ( !assert(function( el ) {
  7536. el.innerHTML = "<a href='#'></a>";
  7537. return el.firstChild.getAttribute("href") === "#" ;
  7538. }) ) {
  7539. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  7540. if ( !isXML ) {
  7541. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  7542. }
  7543. });
  7544. }
  7545. // Support: IE<9
  7546. // Use defaultValue in place of getAttribute("value")
  7547. if ( !support.attributes || !assert(function( el ) {
  7548. el.innerHTML = "<input/>";
  7549. el.firstChild.setAttribute( "value", "" );
  7550. return el.firstChild.getAttribute( "value" ) === "";
  7551. }) ) {
  7552. addHandle( "value", function( elem, name, isXML ) {
  7553. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  7554. return elem.defaultValue;
  7555. }
  7556. });
  7557. }
  7558. // Support: IE<9
  7559. // Use getAttributeNode to fetch booleans when getAttribute lies
  7560. if ( !assert(function( el ) {
  7561. return el.getAttribute("disabled") == null;
  7562. }) ) {
  7563. addHandle( booleans, function( elem, name, isXML ) {
  7564. var val;
  7565. if ( !isXML ) {
  7566. return elem[ name ] === true ? name.toLowerCase() :
  7567. (val = elem.getAttributeNode( name )) && val.specified ?
  7568. val.value :
  7569. null;
  7570. }
  7571. });
  7572. }
  7573. return Sizzle;
  7574. })( window );
  7575. jQuery.find = Sizzle;
  7576. jQuery.expr = Sizzle.selectors;
  7577. // Deprecated
  7578. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  7579. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  7580. jQuery.text = Sizzle.getText;
  7581. jQuery.isXMLDoc = Sizzle.isXML;
  7582. jQuery.contains = Sizzle.contains;
  7583. jQuery.escapeSelector = Sizzle.escape;
  7584. var dir = function( elem, dir, until ) {
  7585. var matched = [],
  7586. truncate = until !== undefined;
  7587. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  7588. if ( elem.nodeType === 1 ) {
  7589. if ( truncate && jQuery( elem ).is( until ) ) {
  7590. break;
  7591. }
  7592. matched.push( elem );
  7593. }
  7594. }
  7595. return matched;
  7596. };
  7597. var siblings = function( n, elem ) {
  7598. var matched = [];
  7599. for ( ; n; n = n.nextSibling ) {
  7600. if ( n.nodeType === 1 && n !== elem ) {
  7601. matched.push( n );
  7602. }
  7603. }
  7604. return matched;
  7605. };
  7606. var rneedsContext = jQuery.expr.match.needsContext;
  7607. function nodeName( elem, name ) {
  7608. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  7609. };
  7610. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  7611. // Implement the identical functionality for filter and not
  7612. function winnow( elements, qualifier, not ) {
  7613. if ( isFunction( qualifier ) ) {
  7614. return jQuery.grep( elements, function( elem, i ) {
  7615. return !!qualifier.call( elem, i, elem ) !== not;
  7616. } );
  7617. }
  7618. // Single element
  7619. if ( qualifier.nodeType ) {
  7620. return jQuery.grep( elements, function( elem ) {
  7621. return ( elem === qualifier ) !== not;
  7622. } );
  7623. }
  7624. // Arraylike of elements (jQuery, arguments, Array)
  7625. if ( typeof qualifier !== "string" ) {
  7626. return jQuery.grep( elements, function( elem ) {
  7627. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  7628. } );
  7629. }
  7630. // Filtered directly for both simple and complex selectors
  7631. return jQuery.filter( qualifier, elements, not );
  7632. }
  7633. jQuery.filter = function( expr, elems, not ) {
  7634. var elem = elems[ 0 ];
  7635. if ( not ) {
  7636. expr = ":not(" + expr + ")";
  7637. }
  7638. if ( elems.length === 1 && elem.nodeType === 1 ) {
  7639. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  7640. }
  7641. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  7642. return elem.nodeType === 1;
  7643. } ) );
  7644. };
  7645. jQuery.fn.extend( {
  7646. find: function( selector ) {
  7647. var i, ret,
  7648. len = this.length,
  7649. self = this;
  7650. if ( typeof selector !== "string" ) {
  7651. return this.pushStack( jQuery( selector ).filter( function() {
  7652. for ( i = 0; i < len; i++ ) {
  7653. if ( jQuery.contains( self[ i ], this ) ) {
  7654. return true;
  7655. }
  7656. }
  7657. } ) );
  7658. }
  7659. ret = this.pushStack( [] );
  7660. for ( i = 0; i < len; i++ ) {
  7661. jQuery.find( selector, self[ i ], ret );
  7662. }
  7663. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  7664. },
  7665. filter: function( selector ) {
  7666. return this.pushStack( winnow( this, selector || [], false ) );
  7667. },
  7668. not: function( selector ) {
  7669. return this.pushStack( winnow( this, selector || [], true ) );
  7670. },
  7671. is: function( selector ) {
  7672. return !!winnow(
  7673. this,
  7674. // If this is a positional/relative selector, check membership in the returned set
  7675. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  7676. typeof selector === "string" && rneedsContext.test( selector ) ?
  7677. jQuery( selector ) :
  7678. selector || [],
  7679. false
  7680. ).length;
  7681. }
  7682. } );
  7683. // Initialize a jQuery object
  7684. // A central reference to the root jQuery(document)
  7685. var rootjQuery,
  7686. // A simple way to check for HTML strings
  7687. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  7688. // Strict HTML recognition (#11290: must start with <)
  7689. // Shortcut simple #id case for speed
  7690. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  7691. init = jQuery.fn.init = function( selector, context, root ) {
  7692. var match, elem;
  7693. // HANDLE: $(""), $(null), $(undefined), $(false)
  7694. if ( !selector ) {
  7695. return this;
  7696. }
  7697. // Method init() accepts an alternate rootjQuery
  7698. // so migrate can support jQuery.sub (gh-2101)
  7699. root = root || rootjQuery;
  7700. // Handle HTML strings
  7701. if ( typeof selector === "string" ) {
  7702. if ( selector[ 0 ] === "<" &&
  7703. selector[ selector.length - 1 ] === ">" &&
  7704. selector.length >= 3 ) {
  7705. // Assume that strings that start and end with <> are HTML and skip the regex check
  7706. match = [ null, selector, null ];
  7707. } else {
  7708. match = rquickExpr.exec( selector );
  7709. }
  7710. // Match html or make sure no context is specified for #id
  7711. if ( match && ( match[ 1 ] || !context ) ) {
  7712. // HANDLE: $(html) -> $(array)
  7713. if ( match[ 1 ] ) {
  7714. context = context instanceof jQuery ? context[ 0 ] : context;
  7715. // Option to run scripts is true for back-compat
  7716. // Intentionally let the error be thrown if parseHTML is not present
  7717. jQuery.merge( this, jQuery.parseHTML(
  7718. match[ 1 ],
  7719. context && context.nodeType ? context.ownerDocument || context : document,
  7720. true
  7721. ) );
  7722. // HANDLE: $(html, props)
  7723. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  7724. for ( match in context ) {
  7725. // Properties of context are called as methods if possible
  7726. if ( isFunction( this[ match ] ) ) {
  7727. this[ match ]( context[ match ] );
  7728. // ...and otherwise set as attributes
  7729. } else {
  7730. this.attr( match, context[ match ] );
  7731. }
  7732. }
  7733. }
  7734. return this;
  7735. // HANDLE: $(#id)
  7736. } else {
  7737. elem = document.getElementById( match[ 2 ] );
  7738. if ( elem ) {
  7739. // Inject the element directly into the jQuery object
  7740. this[ 0 ] = elem;
  7741. this.length = 1;
  7742. }
  7743. return this;
  7744. }
  7745. // HANDLE: $(expr, $(...))
  7746. } else if ( !context || context.jquery ) {
  7747. return ( context || root ).find( selector );
  7748. // HANDLE: $(expr, context)
  7749. // (which is just equivalent to: $(context).find(expr)
  7750. } else {
  7751. return this.constructor( context ).find( selector );
  7752. }
  7753. // HANDLE: $(DOMElement)
  7754. } else if ( selector.nodeType ) {
  7755. this[ 0 ] = selector;
  7756. this.length = 1;
  7757. return this;
  7758. // HANDLE: $(function)
  7759. // Shortcut for document ready
  7760. } else if ( isFunction( selector ) ) {
  7761. return root.ready !== undefined ?
  7762. root.ready( selector ) :
  7763. // Execute immediately if ready is not present
  7764. selector( jQuery );
  7765. }
  7766. return jQuery.makeArray( selector, this );
  7767. };
  7768. // Give the init function the jQuery prototype for later instantiation
  7769. init.prototype = jQuery.fn;
  7770. // Initialize central reference
  7771. rootjQuery = jQuery( document );
  7772. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  7773. // Methods guaranteed to produce a unique set when starting from a unique set
  7774. guaranteedUnique = {
  7775. children: true,
  7776. contents: true,
  7777. next: true,
  7778. prev: true
  7779. };
  7780. jQuery.fn.extend( {
  7781. has: function( target ) {
  7782. var targets = jQuery( target, this ),
  7783. l = targets.length;
  7784. return this.filter( function() {
  7785. var i = 0;
  7786. for ( ; i < l; i++ ) {
  7787. if ( jQuery.contains( this, targets[ i ] ) ) {
  7788. return true;
  7789. }
  7790. }
  7791. } );
  7792. },
  7793. closest: function( selectors, context ) {
  7794. var cur,
  7795. i = 0,
  7796. l = this.length,
  7797. matched = [],
  7798. targets = typeof selectors !== "string" && jQuery( selectors );
  7799. // Positional selectors never match, since there's no _selection_ context
  7800. if ( !rneedsContext.test( selectors ) ) {
  7801. for ( ; i < l; i++ ) {
  7802. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  7803. // Always skip document fragments
  7804. if ( cur.nodeType < 11 && ( targets ?
  7805. targets.index( cur ) > -1 :
  7806. // Don't pass non-elements to Sizzle
  7807. cur.nodeType === 1 &&
  7808. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  7809. matched.push( cur );
  7810. break;
  7811. }
  7812. }
  7813. }
  7814. }
  7815. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  7816. },
  7817. // Determine the position of an element within the set
  7818. index: function( elem ) {
  7819. // No argument, return index in parent
  7820. if ( !elem ) {
  7821. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  7822. }
  7823. // Index in selector
  7824. if ( typeof elem === "string" ) {
  7825. return indexOf.call( jQuery( elem ), this[ 0 ] );
  7826. }
  7827. // Locate the position of the desired element
  7828. return indexOf.call( this,
  7829. // If it receives a jQuery object, the first element is used
  7830. elem.jquery ? elem[ 0 ] : elem
  7831. );
  7832. },
  7833. add: function( selector, context ) {
  7834. return this.pushStack(
  7835. jQuery.uniqueSort(
  7836. jQuery.merge( this.get(), jQuery( selector, context ) )
  7837. )
  7838. );
  7839. },
  7840. addBack: function( selector ) {
  7841. return this.add( selector == null ?
  7842. this.prevObject : this.prevObject.filter( selector )
  7843. );
  7844. }
  7845. } );
  7846. function sibling( cur, dir ) {
  7847. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  7848. return cur;
  7849. }
  7850. jQuery.each( {
  7851. parent: function( elem ) {
  7852. var parent = elem.parentNode;
  7853. return parent && parent.nodeType !== 11 ? parent : null;
  7854. },
  7855. parents: function( elem ) {
  7856. return dir( elem, "parentNode" );
  7857. },
  7858. parentsUntil: function( elem, i, until ) {
  7859. return dir( elem, "parentNode", until );
  7860. },
  7861. next: function( elem ) {
  7862. return sibling( elem, "nextSibling" );
  7863. },
  7864. prev: function( elem ) {
  7865. return sibling( elem, "previousSibling" );
  7866. },
  7867. nextAll: function( elem ) {
  7868. return dir( elem, "nextSibling" );
  7869. },
  7870. prevAll: function( elem ) {
  7871. return dir( elem, "previousSibling" );
  7872. },
  7873. nextUntil: function( elem, i, until ) {
  7874. return dir( elem, "nextSibling", until );
  7875. },
  7876. prevUntil: function( elem, i, until ) {
  7877. return dir( elem, "previousSibling", until );
  7878. },
  7879. siblings: function( elem ) {
  7880. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  7881. },
  7882. children: function( elem ) {
  7883. return siblings( elem.firstChild );
  7884. },
  7885. contents: function( elem ) {
  7886. if ( typeof elem.contentDocument !== "undefined" ) {
  7887. return elem.contentDocument;
  7888. }
  7889. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  7890. // Treat the template element as a regular one in browsers that
  7891. // don't support it.
  7892. if ( nodeName( elem, "template" ) ) {
  7893. elem = elem.content || elem;
  7894. }
  7895. return jQuery.merge( [], elem.childNodes );
  7896. }
  7897. }, function( name, fn ) {
  7898. jQuery.fn[ name ] = function( until, selector ) {
  7899. var matched = jQuery.map( this, fn, until );
  7900. if ( name.slice( -5 ) !== "Until" ) {
  7901. selector = until;
  7902. }
  7903. if ( selector && typeof selector === "string" ) {
  7904. matched = jQuery.filter( selector, matched );
  7905. }
  7906. if ( this.length > 1 ) {
  7907. // Remove duplicates
  7908. if ( !guaranteedUnique[ name ] ) {
  7909. jQuery.uniqueSort( matched );
  7910. }
  7911. // Reverse order for parents* and prev-derivatives
  7912. if ( rparentsprev.test( name ) ) {
  7913. matched.reverse();
  7914. }
  7915. }
  7916. return this.pushStack( matched );
  7917. };
  7918. } );
  7919. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  7920. // Convert String-formatted options into Object-formatted ones
  7921. function createOptions( options ) {
  7922. var object = {};
  7923. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  7924. object[ flag ] = true;
  7925. } );
  7926. return object;
  7927. }
  7928. /*
  7929. * Create a callback list using the following parameters:
  7930. *
  7931. * options: an optional list of space-separated options that will change how
  7932. * the callback list behaves or a more traditional option object
  7933. *
  7934. * By default a callback list will act like an event callback list and can be
  7935. * "fired" multiple times.
  7936. *
  7937. * Possible options:
  7938. *
  7939. * once: will ensure the callback list can only be fired once (like a Deferred)
  7940. *
  7941. * memory: will keep track of previous values and will call any callback added
  7942. * after the list has been fired right away with the latest "memorized"
  7943. * values (like a Deferred)
  7944. *
  7945. * unique: will ensure a callback can only be added once (no duplicate in the list)
  7946. *
  7947. * stopOnFalse: interrupt callings when a callback returns false
  7948. *
  7949. */
  7950. jQuery.Callbacks = function( options ) {
  7951. // Convert options from String-formatted to Object-formatted if needed
  7952. // (we check in cache first)
  7953. options = typeof options === "string" ?
  7954. createOptions( options ) :
  7955. jQuery.extend( {}, options );
  7956. var // Flag to know if list is currently firing
  7957. firing,
  7958. // Last fire value for non-forgettable lists
  7959. memory,
  7960. // Flag to know if list was already fired
  7961. fired,
  7962. // Flag to prevent firing
  7963. locked,
  7964. // Actual callback list
  7965. list = [],
  7966. // Queue of execution data for repeatable lists
  7967. queue = [],
  7968. // Index of currently firing callback (modified by add/remove as needed)
  7969. firingIndex = -1,
  7970. // Fire callbacks
  7971. fire = function() {
  7972. // Enforce single-firing
  7973. locked = locked || options.once;
  7974. // Execute callbacks for all pending executions,
  7975. // respecting firingIndex overrides and runtime changes
  7976. fired = firing = true;
  7977. for ( ; queue.length; firingIndex = -1 ) {
  7978. memory = queue.shift();
  7979. while ( ++firingIndex < list.length ) {
  7980. // Run callback and check for early termination
  7981. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  7982. options.stopOnFalse ) {
  7983. // Jump to end and forget the data so .add doesn't re-fire
  7984. firingIndex = list.length;
  7985. memory = false;
  7986. }
  7987. }
  7988. }
  7989. // Forget the data if we're done with it
  7990. if ( !options.memory ) {
  7991. memory = false;
  7992. }
  7993. firing = false;
  7994. // Clean up if we're done firing for good
  7995. if ( locked ) {
  7996. // Keep an empty list if we have data for future add calls
  7997. if ( memory ) {
  7998. list = [];
  7999. // Otherwise, this object is spent
  8000. } else {
  8001. list = "";
  8002. }
  8003. }
  8004. },
  8005. // Actual Callbacks object
  8006. self = {
  8007. // Add a callback or a collection of callbacks to the list
  8008. add: function() {
  8009. if ( list ) {
  8010. // If we have memory from a past run, we should fire after adding
  8011. if ( memory && !firing ) {
  8012. firingIndex = list.length - 1;
  8013. queue.push( memory );
  8014. }
  8015. ( function add( args ) {
  8016. jQuery.each( args, function( _, arg ) {
  8017. if ( isFunction( arg ) ) {
  8018. if ( !options.unique || !self.has( arg ) ) {
  8019. list.push( arg );
  8020. }
  8021. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  8022. // Inspect recursively
  8023. add( arg );
  8024. }
  8025. } );
  8026. } )( arguments );
  8027. if ( memory && !firing ) {
  8028. fire();
  8029. }
  8030. }
  8031. return this;
  8032. },
  8033. // Remove a callback from the list
  8034. remove: function() {
  8035. jQuery.each( arguments, function( _, arg ) {
  8036. var index;
  8037. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  8038. list.splice( index, 1 );
  8039. // Handle firing indexes
  8040. if ( index <= firingIndex ) {
  8041. firingIndex--;
  8042. }
  8043. }
  8044. } );
  8045. return this;
  8046. },
  8047. // Check if a given callback is in the list.
  8048. // If no argument is given, return whether or not list has callbacks attached.
  8049. has: function( fn ) {
  8050. return fn ?
  8051. jQuery.inArray( fn, list ) > -1 :
  8052. list.length > 0;
  8053. },
  8054. // Remove all callbacks from the list
  8055. empty: function() {
  8056. if ( list ) {
  8057. list = [];
  8058. }
  8059. return this;
  8060. },
  8061. // Disable .fire and .add
  8062. // Abort any current/pending executions
  8063. // Clear all callbacks and values
  8064. disable: function() {
  8065. locked = queue = [];
  8066. list = memory = "";
  8067. return this;
  8068. },
  8069. disabled: function() {
  8070. return !list;
  8071. },
  8072. // Disable .fire
  8073. // Also disable .add unless we have memory (since it would have no effect)
  8074. // Abort any pending executions
  8075. lock: function() {
  8076. locked = queue = [];
  8077. if ( !memory && !firing ) {
  8078. list = memory = "";
  8079. }
  8080. return this;
  8081. },
  8082. locked: function() {
  8083. return !!locked;
  8084. },
  8085. // Call all callbacks with the given context and arguments
  8086. fireWith: function( context, args ) {
  8087. if ( !locked ) {
  8088. args = args || [];
  8089. args = [ context, args.slice ? args.slice() : args ];
  8090. queue.push( args );
  8091. if ( !firing ) {
  8092. fire();
  8093. }
  8094. }
  8095. return this;
  8096. },
  8097. // Call all the callbacks with the given arguments
  8098. fire: function() {
  8099. self.fireWith( this, arguments );
  8100. return this;
  8101. },
  8102. // To know if the callbacks have already been called at least once
  8103. fired: function() {
  8104. return !!fired;
  8105. }
  8106. };
  8107. return self;
  8108. };
  8109. function Identity( v ) {
  8110. return v;
  8111. }
  8112. function Thrower( ex ) {
  8113. throw ex;
  8114. }
  8115. function adoptValue( value, resolve, reject, noValue ) {
  8116. var method;
  8117. try {
  8118. // Check for promise aspect first to privilege synchronous behavior
  8119. if ( value && isFunction( ( method = value.promise ) ) ) {
  8120. method.call( value ).done( resolve ).fail( reject );
  8121. // Other thenables
  8122. } else if ( value && isFunction( ( method = value.then ) ) ) {
  8123. method.call( value, resolve, reject );
  8124. // Other non-thenables
  8125. } else {
  8126. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  8127. // * false: [ value ].slice( 0 ) => resolve( value )
  8128. // * true: [ value ].slice( 1 ) => resolve()
  8129. resolve.apply( undefined, [ value ].slice( noValue ) );
  8130. }
  8131. // For Promises/A+, convert exceptions into rejections
  8132. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  8133. // Deferred#then to conditionally suppress rejection.
  8134. } catch ( value ) {
  8135. // Support: Android 4.0 only
  8136. // Strict mode functions invoked without .call/.apply get global-object context
  8137. reject.apply( undefined, [ value ] );
  8138. }
  8139. }
  8140. jQuery.extend( {
  8141. Deferred: function( func ) {
  8142. var tuples = [
  8143. // action, add listener, callbacks,
  8144. // ... .then handlers, argument index, [final state]
  8145. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  8146. jQuery.Callbacks( "memory" ), 2 ],
  8147. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  8148. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  8149. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  8150. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  8151. ],
  8152. state = "pending",
  8153. promise = {
  8154. state: function() {
  8155. return state;
  8156. },
  8157. always: function() {
  8158. deferred.done( arguments ).fail( arguments );
  8159. return this;
  8160. },
  8161. "catch": function( fn ) {
  8162. return promise.then( null, fn );
  8163. },
  8164. // Keep pipe for back-compat
  8165. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  8166. var fns = arguments;
  8167. return jQuery.Deferred( function( newDefer ) {
  8168. jQuery.each( tuples, function( i, tuple ) {
  8169. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  8170. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  8171. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  8172. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  8173. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  8174. deferred[ tuple[ 1 ] ]( function() {
  8175. var returned = fn && fn.apply( this, arguments );
  8176. if ( returned && isFunction( returned.promise ) ) {
  8177. returned.promise()
  8178. .progress( newDefer.notify )
  8179. .done( newDefer.resolve )
  8180. .fail( newDefer.reject );
  8181. } else {
  8182. newDefer[ tuple[ 0 ] + "With" ](
  8183. this,
  8184. fn ? [ returned ] : arguments
  8185. );
  8186. }
  8187. } );
  8188. } );
  8189. fns = null;
  8190. } ).promise();
  8191. },
  8192. then: function( onFulfilled, onRejected, onProgress ) {
  8193. var maxDepth = 0;
  8194. function resolve( depth, deferred, handler, special ) {
  8195. return function() {
  8196. var that = this,
  8197. args = arguments,
  8198. mightThrow = function() {
  8199. var returned, then;
  8200. // Support: Promises/A+ section 2.3.3.3.3
  8201. // https://promisesaplus.com/#point-59
  8202. // Ignore double-resolution attempts
  8203. if ( depth < maxDepth ) {
  8204. return;
  8205. }
  8206. returned = handler.apply( that, args );
  8207. // Support: Promises/A+ section 2.3.1
  8208. // https://promisesaplus.com/#point-48
  8209. if ( returned === deferred.promise() ) {
  8210. throw new TypeError( "Thenable self-resolution" );
  8211. }
  8212. // Support: Promises/A+ sections 2.3.3.1, 3.5
  8213. // https://promisesaplus.com/#point-54
  8214. // https://promisesaplus.com/#point-75
  8215. // Retrieve `then` only once
  8216. then = returned &&
  8217. // Support: Promises/A+ section 2.3.4
  8218. // https://promisesaplus.com/#point-64
  8219. // Only check objects and functions for thenability
  8220. ( typeof returned === "object" ||
  8221. typeof returned === "function" ) &&
  8222. returned.then;
  8223. // Handle a returned thenable
  8224. if ( isFunction( then ) ) {
  8225. // Special processors (notify) just wait for resolution
  8226. if ( special ) {
  8227. then.call(
  8228. returned,
  8229. resolve( maxDepth, deferred, Identity, special ),
  8230. resolve( maxDepth, deferred, Thrower, special )
  8231. );
  8232. // Normal processors (resolve) also hook into progress
  8233. } else {
  8234. // ...and disregard older resolution values
  8235. maxDepth++;
  8236. then.call(
  8237. returned,
  8238. resolve( maxDepth, deferred, Identity, special ),
  8239. resolve( maxDepth, deferred, Thrower, special ),
  8240. resolve( maxDepth, deferred, Identity,
  8241. deferred.notifyWith )
  8242. );
  8243. }
  8244. // Handle all other returned values
  8245. } else {
  8246. // Only substitute handlers pass on context
  8247. // and multiple values (non-spec behavior)
  8248. if ( handler !== Identity ) {
  8249. that = undefined;
  8250. args = [ returned ];
  8251. }
  8252. // Process the value(s)
  8253. // Default process is resolve
  8254. ( special || deferred.resolveWith )( that, args );
  8255. }
  8256. },
  8257. // Only normal processors (resolve) catch and reject exceptions
  8258. process = special ?
  8259. mightThrow :
  8260. function() {
  8261. try {
  8262. mightThrow();
  8263. } catch ( e ) {
  8264. if ( jQuery.Deferred.exceptionHook ) {
  8265. jQuery.Deferred.exceptionHook( e,
  8266. process.stackTrace );
  8267. }
  8268. // Support: Promises/A+ section 2.3.3.3.4.1
  8269. // https://promisesaplus.com/#point-61
  8270. // Ignore post-resolution exceptions
  8271. if ( depth + 1 >= maxDepth ) {
  8272. // Only substitute handlers pass on context
  8273. // and multiple values (non-spec behavior)
  8274. if ( handler !== Thrower ) {
  8275. that = undefined;
  8276. args = [ e ];
  8277. }
  8278. deferred.rejectWith( that, args );
  8279. }
  8280. }
  8281. };
  8282. // Support: Promises/A+ section 2.3.3.3.1
  8283. // https://promisesaplus.com/#point-57
  8284. // Re-resolve promises immediately to dodge false rejection from
  8285. // subsequent errors
  8286. if ( depth ) {
  8287. process();
  8288. } else {
  8289. // Call an optional hook to record the stack, in case of exception
  8290. // since it's otherwise lost when execution goes async
  8291. if ( jQuery.Deferred.getStackHook ) {
  8292. process.stackTrace = jQuery.Deferred.getStackHook();
  8293. }
  8294. window.setTimeout( process );
  8295. }
  8296. };
  8297. }
  8298. return jQuery.Deferred( function( newDefer ) {
  8299. // progress_handlers.add( ... )
  8300. tuples[ 0 ][ 3 ].add(
  8301. resolve(
  8302. 0,
  8303. newDefer,
  8304. isFunction( onProgress ) ?
  8305. onProgress :
  8306. Identity,
  8307. newDefer.notifyWith
  8308. )
  8309. );
  8310. // fulfilled_handlers.add( ... )
  8311. tuples[ 1 ][ 3 ].add(
  8312. resolve(
  8313. 0,
  8314. newDefer,
  8315. isFunction( onFulfilled ) ?
  8316. onFulfilled :
  8317. Identity
  8318. )
  8319. );
  8320. // rejected_handlers.add( ... )
  8321. tuples[ 2 ][ 3 ].add(
  8322. resolve(
  8323. 0,
  8324. newDefer,
  8325. isFunction( onRejected ) ?
  8326. onRejected :
  8327. Thrower
  8328. )
  8329. );
  8330. } ).promise();
  8331. },
  8332. // Get a promise for this deferred
  8333. // If obj is provided, the promise aspect is added to the object
  8334. promise: function( obj ) {
  8335. return obj != null ? jQuery.extend( obj, promise ) : promise;
  8336. }
  8337. },
  8338. deferred = {};
  8339. // Add list-specific methods
  8340. jQuery.each( tuples, function( i, tuple ) {
  8341. var list = tuple[ 2 ],
  8342. stateString = tuple[ 5 ];
  8343. // promise.progress = list.add
  8344. // promise.done = list.add
  8345. // promise.fail = list.add
  8346. promise[ tuple[ 1 ] ] = list.add;
  8347. // Handle state
  8348. if ( stateString ) {
  8349. list.add(
  8350. function() {
  8351. // state = "resolved" (i.e., fulfilled)
  8352. // state = "rejected"
  8353. state = stateString;
  8354. },
  8355. // rejected_callbacks.disable
  8356. // fulfilled_callbacks.disable
  8357. tuples[ 3 - i ][ 2 ].disable,
  8358. // rejected_handlers.disable
  8359. // fulfilled_handlers.disable
  8360. tuples[ 3 - i ][ 3 ].disable,
  8361. // progress_callbacks.lock
  8362. tuples[ 0 ][ 2 ].lock,
  8363. // progress_handlers.lock
  8364. tuples[ 0 ][ 3 ].lock
  8365. );
  8366. }
  8367. // progress_handlers.fire
  8368. // fulfilled_handlers.fire
  8369. // rejected_handlers.fire
  8370. list.add( tuple[ 3 ].fire );
  8371. // deferred.notify = function() { deferred.notifyWith(...) }
  8372. // deferred.resolve = function() { deferred.resolveWith(...) }
  8373. // deferred.reject = function() { deferred.rejectWith(...) }
  8374. deferred[ tuple[ 0 ] ] = function() {
  8375. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  8376. return this;
  8377. };
  8378. // deferred.notifyWith = list.fireWith
  8379. // deferred.resolveWith = list.fireWith
  8380. // deferred.rejectWith = list.fireWith
  8381. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  8382. } );
  8383. // Make the deferred a promise
  8384. promise.promise( deferred );
  8385. // Call given func if any
  8386. if ( func ) {
  8387. func.call( deferred, deferred );
  8388. }
  8389. // All done!
  8390. return deferred;
  8391. },
  8392. // Deferred helper
  8393. when: function( singleValue ) {
  8394. var
  8395. // count of uncompleted subordinates
  8396. remaining = arguments.length,
  8397. // count of unprocessed arguments
  8398. i = remaining,
  8399. // subordinate fulfillment data
  8400. resolveContexts = Array( i ),
  8401. resolveValues = slice.call( arguments ),
  8402. // the master Deferred
  8403. master = jQuery.Deferred(),
  8404. // subordinate callback factory
  8405. updateFunc = function( i ) {
  8406. return function( value ) {
  8407. resolveContexts[ i ] = this;
  8408. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  8409. if ( !( --remaining ) ) {
  8410. master.resolveWith( resolveContexts, resolveValues );
  8411. }
  8412. };
  8413. };
  8414. // Single- and empty arguments are adopted like Promise.resolve
  8415. if ( remaining <= 1 ) {
  8416. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  8417. !remaining );
  8418. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  8419. if ( master.state() === "pending" ||
  8420. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  8421. return master.then();
  8422. }
  8423. }
  8424. // Multiple arguments are aggregated like Promise.all array elements
  8425. while ( i-- ) {
  8426. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  8427. }
  8428. return master.promise();
  8429. }
  8430. } );
  8431. // These usually indicate a programmer mistake during development,
  8432. // warn about them ASAP rather than swallowing them by default.
  8433. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  8434. jQuery.Deferred.exceptionHook = function( error, stack ) {
  8435. // Support: IE 8 - 9 only
  8436. // Console exists when dev tools are open, which can happen at any time
  8437. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  8438. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  8439. }
  8440. };
  8441. jQuery.readyException = function( error ) {
  8442. window.setTimeout( function() {
  8443. throw error;
  8444. } );
  8445. };
  8446. // The deferred used on DOM ready
  8447. var readyList = jQuery.Deferred();
  8448. jQuery.fn.ready = function( fn ) {
  8449. readyList
  8450. .then( fn )
  8451. // Wrap jQuery.readyException in a function so that the lookup
  8452. // happens at the time of error handling instead of callback
  8453. // registration.
  8454. .catch( function( error ) {
  8455. jQuery.readyException( error );
  8456. } );
  8457. return this;
  8458. };
  8459. jQuery.extend( {
  8460. // Is the DOM ready to be used? Set to true once it occurs.
  8461. isReady: false,
  8462. // A counter to track how many items to wait for before
  8463. // the ready event fires. See #6781
  8464. readyWait: 1,
  8465. // Handle when the DOM is ready
  8466. ready: function( wait ) {
  8467. // Abort if there are pending holds or we're already ready
  8468. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  8469. return;
  8470. }
  8471. // Remember that the DOM is ready
  8472. jQuery.isReady = true;
  8473. // If a normal DOM Ready event fired, decrement, and wait if need be
  8474. if ( wait !== true && --jQuery.readyWait > 0 ) {
  8475. return;
  8476. }
  8477. // If there are functions bound, to execute
  8478. readyList.resolveWith( document, [ jQuery ] );
  8479. }
  8480. } );
  8481. jQuery.ready.then = readyList.then;
  8482. // The ready event handler and self cleanup method
  8483. function completed() {
  8484. document.removeEventListener( "DOMContentLoaded", completed );
  8485. window.removeEventListener( "load", completed );
  8486. jQuery.ready();
  8487. }
  8488. // Catch cases where $(document).ready() is called
  8489. // after the browser event has already occurred.
  8490. // Support: IE <=9 - 10 only
  8491. // Older IE sometimes signals "interactive" too soon
  8492. if ( document.readyState === "complete" ||
  8493. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  8494. // Handle it asynchronously to allow scripts the opportunity to delay ready
  8495. window.setTimeout( jQuery.ready );
  8496. } else {
  8497. // Use the handy event callback
  8498. document.addEventListener( "DOMContentLoaded", completed );
  8499. // A fallback to window.onload, that will always work
  8500. window.addEventListener( "load", completed );
  8501. }
  8502. // Multifunctional method to get and set values of a collection
  8503. // The value/s can optionally be executed if it's a function
  8504. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  8505. var i = 0,
  8506. len = elems.length,
  8507. bulk = key == null;
  8508. // Sets many values
  8509. if ( toType( key ) === "object" ) {
  8510. chainable = true;
  8511. for ( i in key ) {
  8512. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  8513. }
  8514. // Sets one value
  8515. } else if ( value !== undefined ) {
  8516. chainable = true;
  8517. if ( !isFunction( value ) ) {
  8518. raw = true;
  8519. }
  8520. if ( bulk ) {
  8521. // Bulk operations run against the entire set
  8522. if ( raw ) {
  8523. fn.call( elems, value );
  8524. fn = null;
  8525. // ...except when executing function values
  8526. } else {
  8527. bulk = fn;
  8528. fn = function( elem, key, value ) {
  8529. return bulk.call( jQuery( elem ), value );
  8530. };
  8531. }
  8532. }
  8533. if ( fn ) {
  8534. for ( ; i < len; i++ ) {
  8535. fn(
  8536. elems[ i ], key, raw ?
  8537. value :
  8538. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  8539. );
  8540. }
  8541. }
  8542. }
  8543. if ( chainable ) {
  8544. return elems;
  8545. }
  8546. // Gets
  8547. if ( bulk ) {
  8548. return fn.call( elems );
  8549. }
  8550. return len ? fn( elems[ 0 ], key ) : emptyGet;
  8551. };
  8552. // Matches dashed string for camelizing
  8553. var rmsPrefix = /^-ms-/,
  8554. rdashAlpha = /-([a-z])/g;
  8555. // Used by camelCase as callback to replace()
  8556. function fcamelCase( all, letter ) {
  8557. return letter.toUpperCase();
  8558. }
  8559. // Convert dashed to camelCase; used by the css and data modules
  8560. // Support: IE <=9 - 11, Edge 12 - 15
  8561. // Microsoft forgot to hump their vendor prefix (#9572)
  8562. function camelCase( string ) {
  8563. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  8564. }
  8565. var acceptData = function( owner ) {
  8566. // Accepts only:
  8567. // - Node
  8568. // - Node.ELEMENT_NODE
  8569. // - Node.DOCUMENT_NODE
  8570. // - Object
  8571. // - Any
  8572. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  8573. };
  8574. function Data() {
  8575. this.expando = jQuery.expando + Data.uid++;
  8576. }
  8577. Data.uid = 1;
  8578. Data.prototype = {
  8579. cache: function( owner ) {
  8580. // Check if the owner object already has a cache
  8581. var value = owner[ this.expando ];
  8582. // If not, create one
  8583. if ( !value ) {
  8584. value = {};
  8585. // We can accept data for non-element nodes in modern browsers,
  8586. // but we should not, see #8335.
  8587. // Always return an empty object.
  8588. if ( acceptData( owner ) ) {
  8589. // If it is a node unlikely to be stringify-ed or looped over
  8590. // use plain assignment
  8591. if ( owner.nodeType ) {
  8592. owner[ this.expando ] = value;
  8593. // Otherwise secure it in a non-enumerable property
  8594. // configurable must be true to allow the property to be
  8595. // deleted when data is removed
  8596. } else {
  8597. Object.defineProperty( owner, this.expando, {
  8598. value: value,
  8599. configurable: true
  8600. } );
  8601. }
  8602. }
  8603. }
  8604. return value;
  8605. },
  8606. set: function( owner, data, value ) {
  8607. var prop,
  8608. cache = this.cache( owner );
  8609. // Handle: [ owner, key, value ] args
  8610. // Always use camelCase key (gh-2257)
  8611. if ( typeof data === "string" ) {
  8612. cache[ camelCase( data ) ] = value;
  8613. // Handle: [ owner, { properties } ] args
  8614. } else {
  8615. // Copy the properties one-by-one to the cache object
  8616. for ( prop in data ) {
  8617. cache[ camelCase( prop ) ] = data[ prop ];
  8618. }
  8619. }
  8620. return cache;
  8621. },
  8622. get: function( owner, key ) {
  8623. return key === undefined ?
  8624. this.cache( owner ) :
  8625. // Always use camelCase key (gh-2257)
  8626. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  8627. },
  8628. access: function( owner, key, value ) {
  8629. // In cases where either:
  8630. //
  8631. // 1. No key was specified
  8632. // 2. A string key was specified, but no value provided
  8633. //
  8634. // Take the "read" path and allow the get method to determine
  8635. // which value to return, respectively either:
  8636. //
  8637. // 1. The entire cache object
  8638. // 2. The data stored at the key
  8639. //
  8640. if ( key === undefined ||
  8641. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  8642. return this.get( owner, key );
  8643. }
  8644. // When the key is not a string, or both a key and value
  8645. // are specified, set or extend (existing objects) with either:
  8646. //
  8647. // 1. An object of properties
  8648. // 2. A key and value
  8649. //
  8650. this.set( owner, key, value );
  8651. // Since the "set" path can have two possible entry points
  8652. // return the expected data based on which path was taken[*]
  8653. return value !== undefined ? value : key;
  8654. },
  8655. remove: function( owner, key ) {
  8656. var i,
  8657. cache = owner[ this.expando ];
  8658. if ( cache === undefined ) {
  8659. return;
  8660. }
  8661. if ( key !== undefined ) {
  8662. // Support array or space separated string of keys
  8663. if ( Array.isArray( key ) ) {
  8664. // If key is an array of keys...
  8665. // We always set camelCase keys, so remove that.
  8666. key = key.map( camelCase );
  8667. } else {
  8668. key = camelCase( key );
  8669. // If a key with the spaces exists, use it.
  8670. // Otherwise, create an array by matching non-whitespace
  8671. key = key in cache ?
  8672. [ key ] :
  8673. ( key.match( rnothtmlwhite ) || [] );
  8674. }
  8675. i = key.length;
  8676. while ( i-- ) {
  8677. delete cache[ key[ i ] ];
  8678. }
  8679. }
  8680. // Remove the expando if there's no more data
  8681. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  8682. // Support: Chrome <=35 - 45
  8683. // Webkit & Blink performance suffers when deleting properties
  8684. // from DOM nodes, so set to undefined instead
  8685. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  8686. if ( owner.nodeType ) {
  8687. owner[ this.expando ] = undefined;
  8688. } else {
  8689. delete owner[ this.expando ];
  8690. }
  8691. }
  8692. },
  8693. hasData: function( owner ) {
  8694. var cache = owner[ this.expando ];
  8695. return cache !== undefined && !jQuery.isEmptyObject( cache );
  8696. }
  8697. };
  8698. var dataPriv = new Data();
  8699. var dataUser = new Data();
  8700. // Implementation Summary
  8701. //
  8702. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  8703. // 2. Improve the module's maintainability by reducing the storage
  8704. // paths to a single mechanism.
  8705. // 3. Use the same single mechanism to support "private" and "user" data.
  8706. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  8707. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  8708. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  8709. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  8710. rmultiDash = /[A-Z]/g;
  8711. function getData( data ) {
  8712. if ( data === "true" ) {
  8713. return true;
  8714. }
  8715. if ( data === "false" ) {
  8716. return false;
  8717. }
  8718. if ( data === "null" ) {
  8719. return null;
  8720. }
  8721. // Only convert to a number if it doesn't change the string
  8722. if ( data === +data + "" ) {
  8723. return +data;
  8724. }
  8725. if ( rbrace.test( data ) ) {
  8726. return JSON.parse( data );
  8727. }
  8728. return data;
  8729. }
  8730. function dataAttr( elem, key, data ) {
  8731. var name;
  8732. // If nothing was found internally, try to fetch any
  8733. // data from the HTML5 data-* attribute
  8734. if ( data === undefined && elem.nodeType === 1 ) {
  8735. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  8736. data = elem.getAttribute( name );
  8737. if ( typeof data === "string" ) {
  8738. try {
  8739. data = getData( data );
  8740. } catch ( e ) {}
  8741. // Make sure we set the data so it isn't changed later
  8742. dataUser.set( elem, key, data );
  8743. } else {
  8744. data = undefined;
  8745. }
  8746. }
  8747. return data;
  8748. }
  8749. jQuery.extend( {
  8750. hasData: function( elem ) {
  8751. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  8752. },
  8753. data: function( elem, name, data ) {
  8754. return dataUser.access( elem, name, data );
  8755. },
  8756. removeData: function( elem, name ) {
  8757. dataUser.remove( elem, name );
  8758. },
  8759. // TODO: Now that all calls to _data and _removeData have been replaced
  8760. // with direct calls to dataPriv methods, these can be deprecated.
  8761. _data: function( elem, name, data ) {
  8762. return dataPriv.access( elem, name, data );
  8763. },
  8764. _removeData: function( elem, name ) {
  8765. dataPriv.remove( elem, name );
  8766. }
  8767. } );
  8768. jQuery.fn.extend( {
  8769. data: function( key, value ) {
  8770. var i, name, data,
  8771. elem = this[ 0 ],
  8772. attrs = elem && elem.attributes;
  8773. // Gets all values
  8774. if ( key === undefined ) {
  8775. if ( this.length ) {
  8776. data = dataUser.get( elem );
  8777. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  8778. i = attrs.length;
  8779. while ( i-- ) {
  8780. // Support: IE 11 only
  8781. // The attrs elements can be null (#14894)
  8782. if ( attrs[ i ] ) {
  8783. name = attrs[ i ].name;
  8784. if ( name.indexOf( "data-" ) === 0 ) {
  8785. name = camelCase( name.slice( 5 ) );
  8786. dataAttr( elem, name, data[ name ] );
  8787. }
  8788. }
  8789. }
  8790. dataPriv.set( elem, "hasDataAttrs", true );
  8791. }
  8792. }
  8793. return data;
  8794. }
  8795. // Sets multiple values
  8796. if ( typeof key === "object" ) {
  8797. return this.each( function() {
  8798. dataUser.set( this, key );
  8799. } );
  8800. }
  8801. return access( this, function( value ) {
  8802. var data;
  8803. // The calling jQuery object (element matches) is not empty
  8804. // (and therefore has an element appears at this[ 0 ]) and the
  8805. // `value` parameter was not undefined. An empty jQuery object
  8806. // will result in `undefined` for elem = this[ 0 ] which will
  8807. // throw an exception if an attempt to read a data cache is made.
  8808. if ( elem && value === undefined ) {
  8809. // Attempt to get data from the cache
  8810. // The key will always be camelCased in Data
  8811. data = dataUser.get( elem, key );
  8812. if ( data !== undefined ) {
  8813. return data;
  8814. }
  8815. // Attempt to "discover" the data in
  8816. // HTML5 custom data-* attrs
  8817. data = dataAttr( elem, key );
  8818. if ( data !== undefined ) {
  8819. return data;
  8820. }
  8821. // We tried really hard, but the data doesn't exist.
  8822. return;
  8823. }
  8824. // Set the data...
  8825. this.each( function() {
  8826. // We always store the camelCased key
  8827. dataUser.set( this, key, value );
  8828. } );
  8829. }, null, value, arguments.length > 1, null, true );
  8830. },
  8831. removeData: function( key ) {
  8832. return this.each( function() {
  8833. dataUser.remove( this, key );
  8834. } );
  8835. }
  8836. } );
  8837. jQuery.extend( {
  8838. queue: function( elem, type, data ) {
  8839. var queue;
  8840. if ( elem ) {
  8841. type = ( type || "fx" ) + "queue";
  8842. queue = dataPriv.get( elem, type );
  8843. // Speed up dequeue by getting out quickly if this is just a lookup
  8844. if ( data ) {
  8845. if ( !queue || Array.isArray( data ) ) {
  8846. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  8847. } else {
  8848. queue.push( data );
  8849. }
  8850. }
  8851. return queue || [];
  8852. }
  8853. },
  8854. dequeue: function( elem, type ) {
  8855. type = type || "fx";
  8856. var queue = jQuery.queue( elem, type ),
  8857. startLength = queue.length,
  8858. fn = queue.shift(),
  8859. hooks = jQuery._queueHooks( elem, type ),
  8860. next = function() {
  8861. jQuery.dequeue( elem, type );
  8862. };
  8863. // If the fx queue is dequeued, always remove the progress sentinel
  8864. if ( fn === "inprogress" ) {
  8865. fn = queue.shift();
  8866. startLength--;
  8867. }
  8868. if ( fn ) {
  8869. // Add a progress sentinel to prevent the fx queue from being
  8870. // automatically dequeued
  8871. if ( type === "fx" ) {
  8872. queue.unshift( "inprogress" );
  8873. }
  8874. // Clear up the last queue stop function
  8875. delete hooks.stop;
  8876. fn.call( elem, next, hooks );
  8877. }
  8878. if ( !startLength && hooks ) {
  8879. hooks.empty.fire();
  8880. }
  8881. },
  8882. // Not public - generate a queueHooks object, or return the current one
  8883. _queueHooks: function( elem, type ) {
  8884. var key = type + "queueHooks";
  8885. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  8886. empty: jQuery.Callbacks( "once memory" ).add( function() {
  8887. dataPriv.remove( elem, [ type + "queue", key ] );
  8888. } )
  8889. } );
  8890. }
  8891. } );
  8892. jQuery.fn.extend( {
  8893. queue: function( type, data ) {
  8894. var setter = 2;
  8895. if ( typeof type !== "string" ) {
  8896. data = type;
  8897. type = "fx";
  8898. setter--;
  8899. }
  8900. if ( arguments.length < setter ) {
  8901. return jQuery.queue( this[ 0 ], type );
  8902. }
  8903. return data === undefined ?
  8904. this :
  8905. this.each( function() {
  8906. var queue = jQuery.queue( this, type, data );
  8907. // Ensure a hooks for this queue
  8908. jQuery._queueHooks( this, type );
  8909. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  8910. jQuery.dequeue( this, type );
  8911. }
  8912. } );
  8913. },
  8914. dequeue: function( type ) {
  8915. return this.each( function() {
  8916. jQuery.dequeue( this, type );
  8917. } );
  8918. },
  8919. clearQueue: function( type ) {
  8920. return this.queue( type || "fx", [] );
  8921. },
  8922. // Get a promise resolved when queues of a certain type
  8923. // are emptied (fx is the type by default)
  8924. promise: function( type, obj ) {
  8925. var tmp,
  8926. count = 1,
  8927. defer = jQuery.Deferred(),
  8928. elements = this,
  8929. i = this.length,
  8930. resolve = function() {
  8931. if ( !( --count ) ) {
  8932. defer.resolveWith( elements, [ elements ] );
  8933. }
  8934. };
  8935. if ( typeof type !== "string" ) {
  8936. obj = type;
  8937. type = undefined;
  8938. }
  8939. type = type || "fx";
  8940. while ( i-- ) {
  8941. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  8942. if ( tmp && tmp.empty ) {
  8943. count++;
  8944. tmp.empty.add( resolve );
  8945. }
  8946. }
  8947. resolve();
  8948. return defer.promise( obj );
  8949. }
  8950. } );
  8951. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  8952. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  8953. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  8954. var documentElement = document.documentElement;
  8955. var isAttached = function( elem ) {
  8956. return jQuery.contains( elem.ownerDocument, elem );
  8957. },
  8958. composed = { composed: true };
  8959. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  8960. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  8961. // Support: iOS 10.0-10.2 only
  8962. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  8963. // leading to errors. We need to check for `getRootNode`.
  8964. if ( documentElement.getRootNode ) {
  8965. isAttached = function( elem ) {
  8966. return jQuery.contains( elem.ownerDocument, elem ) ||
  8967. elem.getRootNode( composed ) === elem.ownerDocument;
  8968. };
  8969. }
  8970. var isHiddenWithinTree = function( elem, el ) {
  8971. // isHiddenWithinTree might be called from jQuery#filter function;
  8972. // in that case, element will be second argument
  8973. elem = el || elem;
  8974. // Inline style trumps all
  8975. return elem.style.display === "none" ||
  8976. elem.style.display === "" &&
  8977. // Otherwise, check computed style
  8978. // Support: Firefox <=43 - 45
  8979. // Disconnected elements can have computed display: none, so first confirm that elem is
  8980. // in the document.
  8981. isAttached( elem ) &&
  8982. jQuery.css( elem, "display" ) === "none";
  8983. };
  8984. var swap = function( elem, options, callback, args ) {
  8985. var ret, name,
  8986. old = {};
  8987. // Remember the old values, and insert the new ones
  8988. for ( name in options ) {
  8989. old[ name ] = elem.style[ name ];
  8990. elem.style[ name ] = options[ name ];
  8991. }
  8992. ret = callback.apply( elem, args || [] );
  8993. // Revert the old values
  8994. for ( name in options ) {
  8995. elem.style[ name ] = old[ name ];
  8996. }
  8997. return ret;
  8998. };
  8999. function adjustCSS( elem, prop, valueParts, tween ) {
  9000. var adjusted, scale,
  9001. maxIterations = 20,
  9002. currentValue = tween ?
  9003. function() {
  9004. return tween.cur();
  9005. } :
  9006. function() {
  9007. return jQuery.css( elem, prop, "" );
  9008. },
  9009. initial = currentValue(),
  9010. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  9011. // Starting value computation is required for potential unit mismatches
  9012. initialInUnit = elem.nodeType &&
  9013. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  9014. rcssNum.exec( jQuery.css( elem, prop ) );
  9015. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  9016. // Support: Firefox <=54
  9017. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  9018. initial = initial / 2;
  9019. // Trust units reported by jQuery.css
  9020. unit = unit || initialInUnit[ 3 ];
  9021. // Iteratively approximate from a nonzero starting point
  9022. initialInUnit = +initial || 1;
  9023. while ( maxIterations-- ) {
  9024. // Evaluate and update our best guess (doubling guesses that zero out).
  9025. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  9026. jQuery.style( elem, prop, initialInUnit + unit );
  9027. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  9028. maxIterations = 0;
  9029. }
  9030. initialInUnit = initialInUnit / scale;
  9031. }
  9032. initialInUnit = initialInUnit * 2;
  9033. jQuery.style( elem, prop, initialInUnit + unit );
  9034. // Make sure we update the tween properties later on
  9035. valueParts = valueParts || [];
  9036. }
  9037. if ( valueParts ) {
  9038. initialInUnit = +initialInUnit || +initial || 0;
  9039. // Apply relative offset (+=/-=) if specified
  9040. adjusted = valueParts[ 1 ] ?
  9041. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  9042. +valueParts[ 2 ];
  9043. if ( tween ) {
  9044. tween.unit = unit;
  9045. tween.start = initialInUnit;
  9046. tween.end = adjusted;
  9047. }
  9048. }
  9049. return adjusted;
  9050. }
  9051. var defaultDisplayMap = {};
  9052. function getDefaultDisplay( elem ) {
  9053. var temp,
  9054. doc = elem.ownerDocument,
  9055. nodeName = elem.nodeName,
  9056. display = defaultDisplayMap[ nodeName ];
  9057. if ( display ) {
  9058. return display;
  9059. }
  9060. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  9061. display = jQuery.css( temp, "display" );
  9062. temp.parentNode.removeChild( temp );
  9063. if ( display === "none" ) {
  9064. display = "block";
  9065. }
  9066. defaultDisplayMap[ nodeName ] = display;
  9067. return display;
  9068. }
  9069. function showHide( elements, show ) {
  9070. var display, elem,
  9071. values = [],
  9072. index = 0,
  9073. length = elements.length;
  9074. // Determine new display value for elements that need to change
  9075. for ( ; index < length; index++ ) {
  9076. elem = elements[ index ];
  9077. if ( !elem.style ) {
  9078. continue;
  9079. }
  9080. display = elem.style.display;
  9081. if ( show ) {
  9082. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  9083. // check is required in this first loop unless we have a nonempty display value (either
  9084. // inline or about-to-be-restored)
  9085. if ( display === "none" ) {
  9086. values[ index ] = dataPriv.get( elem, "display" ) || null;
  9087. if ( !values[ index ] ) {
  9088. elem.style.display = "";
  9089. }
  9090. }
  9091. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  9092. values[ index ] = getDefaultDisplay( elem );
  9093. }
  9094. } else {
  9095. if ( display !== "none" ) {
  9096. values[ index ] = "none";
  9097. // Remember what we're overwriting
  9098. dataPriv.set( elem, "display", display );
  9099. }
  9100. }
  9101. }
  9102. // Set the display of the elements in a second loop to avoid constant reflow
  9103. for ( index = 0; index < length; index++ ) {
  9104. if ( values[ index ] != null ) {
  9105. elements[ index ].style.display = values[ index ];
  9106. }
  9107. }
  9108. return elements;
  9109. }
  9110. jQuery.fn.extend( {
  9111. show: function() {
  9112. return showHide( this, true );
  9113. },
  9114. hide: function() {
  9115. return showHide( this );
  9116. },
  9117. toggle: function( state ) {
  9118. if ( typeof state === "boolean" ) {
  9119. return state ? this.show() : this.hide();
  9120. }
  9121. return this.each( function() {
  9122. if ( isHiddenWithinTree( this ) ) {
  9123. jQuery( this ).show();
  9124. } else {
  9125. jQuery( this ).hide();
  9126. }
  9127. } );
  9128. }
  9129. } );
  9130. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  9131. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  9132. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  9133. // We have to close these tags to support XHTML (#13200)
  9134. var wrapMap = {
  9135. // Support: IE <=9 only
  9136. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  9137. // XHTML parsers do not magically insert elements in the
  9138. // same way that tag soup parsers do. So we cannot shorten
  9139. // this by omitting <tbody> or other required elements.
  9140. thead: [ 1, "<table>", "</table>" ],
  9141. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  9142. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  9143. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  9144. _default: [ 0, "", "" ]
  9145. };
  9146. // Support: IE <=9 only
  9147. wrapMap.optgroup = wrapMap.option;
  9148. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  9149. wrapMap.th = wrapMap.td;
  9150. function getAll( context, tag ) {
  9151. // Support: IE <=9 - 11 only
  9152. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  9153. var ret;
  9154. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9155. ret = context.getElementsByTagName( tag || "*" );
  9156. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  9157. ret = context.querySelectorAll( tag || "*" );
  9158. } else {
  9159. ret = [];
  9160. }
  9161. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  9162. return jQuery.merge( [ context ], ret );
  9163. }
  9164. return ret;
  9165. }
  9166. // Mark scripts as having already been evaluated
  9167. function setGlobalEval( elems, refElements ) {
  9168. var i = 0,
  9169. l = elems.length;
  9170. for ( ; i < l; i++ ) {
  9171. dataPriv.set(
  9172. elems[ i ],
  9173. "globalEval",
  9174. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  9175. );
  9176. }
  9177. }
  9178. var rhtml = /<|&#?\w+;/;
  9179. function buildFragment( elems, context, scripts, selection, ignored ) {
  9180. var elem, tmp, tag, wrap, attached, j,
  9181. fragment = context.createDocumentFragment(),
  9182. nodes = [],
  9183. i = 0,
  9184. l = elems.length;
  9185. for ( ; i < l; i++ ) {
  9186. elem = elems[ i ];
  9187. if ( elem || elem === 0 ) {
  9188. // Add nodes directly
  9189. if ( toType( elem ) === "object" ) {
  9190. // Support: Android <=4.0 only, PhantomJS 1 only
  9191. // push.apply(_, arraylike) throws on ancient WebKit
  9192. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  9193. // Convert non-html into a text node
  9194. } else if ( !rhtml.test( elem ) ) {
  9195. nodes.push( context.createTextNode( elem ) );
  9196. // Convert html into DOM nodes
  9197. } else {
  9198. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  9199. // Deserialize a standard representation
  9200. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  9201. wrap = wrapMap[ tag ] || wrapMap._default;
  9202. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  9203. // Descend through wrappers to the right content
  9204. j = wrap[ 0 ];
  9205. while ( j-- ) {
  9206. tmp = tmp.lastChild;
  9207. }
  9208. // Support: Android <=4.0 only, PhantomJS 1 only
  9209. // push.apply(_, arraylike) throws on ancient WebKit
  9210. jQuery.merge( nodes, tmp.childNodes );
  9211. // Remember the top-level container
  9212. tmp = fragment.firstChild;
  9213. // Ensure the created nodes are orphaned (#12392)
  9214. tmp.textContent = "";
  9215. }
  9216. }
  9217. }
  9218. // Remove wrapper from fragment
  9219. fragment.textContent = "";
  9220. i = 0;
  9221. while ( ( elem = nodes[ i++ ] ) ) {
  9222. // Skip elements already in the context collection (trac-4087)
  9223. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  9224. if ( ignored ) {
  9225. ignored.push( elem );
  9226. }
  9227. continue;
  9228. }
  9229. attached = isAttached( elem );
  9230. // Append to fragment
  9231. tmp = getAll( fragment.appendChild( elem ), "script" );
  9232. // Preserve script evaluation history
  9233. if ( attached ) {
  9234. setGlobalEval( tmp );
  9235. }
  9236. // Capture executables
  9237. if ( scripts ) {
  9238. j = 0;
  9239. while ( ( elem = tmp[ j++ ] ) ) {
  9240. if ( rscriptType.test( elem.type || "" ) ) {
  9241. scripts.push( elem );
  9242. }
  9243. }
  9244. }
  9245. }
  9246. return fragment;
  9247. }
  9248. ( function() {
  9249. var fragment = document.createDocumentFragment(),
  9250. div = fragment.appendChild( document.createElement( "div" ) ),
  9251. input = document.createElement( "input" );
  9252. // Support: Android 4.0 - 4.3 only
  9253. // Check state lost if the name is set (#11217)
  9254. // Support: Windows Web Apps (WWA)
  9255. // `name` and `type` must use .setAttribute for WWA (#14901)
  9256. input.setAttribute( "type", "radio" );
  9257. input.setAttribute( "checked", "checked" );
  9258. input.setAttribute( "name", "t" );
  9259. div.appendChild( input );
  9260. // Support: Android <=4.1 only
  9261. // Older WebKit doesn't clone checked state correctly in fragments
  9262. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  9263. // Support: IE <=11 only
  9264. // Make sure textarea (and checkbox) defaultValue is properly cloned
  9265. div.innerHTML = "<textarea>x</textarea>";
  9266. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  9267. } )();
  9268. var
  9269. rkeyEvent = /^key/,
  9270. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  9271. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  9272. function returnTrue() {
  9273. return true;
  9274. }
  9275. function returnFalse() {
  9276. return false;
  9277. }
  9278. // Support: IE <=9 - 11+
  9279. // focus() and blur() are asynchronous, except when they are no-op.
  9280. // So expect focus to be synchronous when the element is already active,
  9281. // and blur to be synchronous when the element is not already active.
  9282. // (focus and blur are always synchronous in other supported browsers,
  9283. // this just defines when we can count on it).
  9284. function expectSync( elem, type ) {
  9285. return ( elem === safeActiveElement() ) === ( type === "focus" );
  9286. }
  9287. // Support: IE <=9 only
  9288. // Accessing document.activeElement can throw unexpectedly
  9289. // https://bugs.jquery.com/ticket/13393
  9290. function safeActiveElement() {
  9291. try {
  9292. return document.activeElement;
  9293. } catch ( err ) { }
  9294. }
  9295. function on( elem, types, selector, data, fn, one ) {
  9296. var origFn, type;
  9297. // Types can be a map of types/handlers
  9298. if ( typeof types === "object" ) {
  9299. // ( types-Object, selector, data )
  9300. if ( typeof selector !== "string" ) {
  9301. // ( types-Object, data )
  9302. data = data || selector;
  9303. selector = undefined;
  9304. }
  9305. for ( type in types ) {
  9306. on( elem, type, selector, data, types[ type ], one );
  9307. }
  9308. return elem;
  9309. }
  9310. if ( data == null && fn == null ) {
  9311. // ( types, fn )
  9312. fn = selector;
  9313. data = selector = undefined;
  9314. } else if ( fn == null ) {
  9315. if ( typeof selector === "string" ) {
  9316. // ( types, selector, fn )
  9317. fn = data;
  9318. data = undefined;
  9319. } else {
  9320. // ( types, data, fn )
  9321. fn = data;
  9322. data = selector;
  9323. selector = undefined;
  9324. }
  9325. }
  9326. if ( fn === false ) {
  9327. fn = returnFalse;
  9328. } else if ( !fn ) {
  9329. return elem;
  9330. }
  9331. if ( one === 1 ) {
  9332. origFn = fn;
  9333. fn = function( event ) {
  9334. // Can use an empty set, since event contains the info
  9335. jQuery().off( event );
  9336. return origFn.apply( this, arguments );
  9337. };
  9338. // Use same guid so caller can remove using origFn
  9339. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  9340. }
  9341. return elem.each( function() {
  9342. jQuery.event.add( this, types, fn, data, selector );
  9343. } );
  9344. }
  9345. /*
  9346. * Helper functions for managing events -- not part of the public interface.
  9347. * Props to Dean Edwards' addEvent library for many of the ideas.
  9348. */
  9349. jQuery.event = {
  9350. global: {},
  9351. add: function( elem, types, handler, data, selector ) {
  9352. var handleObjIn, eventHandle, tmp,
  9353. events, t, handleObj,
  9354. special, handlers, type, namespaces, origType,
  9355. elemData = dataPriv.get( elem );
  9356. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  9357. if ( !elemData ) {
  9358. return;
  9359. }
  9360. // Caller can pass in an object of custom data in lieu of the handler
  9361. if ( handler.handler ) {
  9362. handleObjIn = handler;
  9363. handler = handleObjIn.handler;
  9364. selector = handleObjIn.selector;
  9365. }
  9366. // Ensure that invalid selectors throw exceptions at attach time
  9367. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  9368. if ( selector ) {
  9369. jQuery.find.matchesSelector( documentElement, selector );
  9370. }
  9371. // Make sure that the handler has a unique ID, used to find/remove it later
  9372. if ( !handler.guid ) {
  9373. handler.guid = jQuery.guid++;
  9374. }
  9375. // Init the element's event structure and main handler, if this is the first
  9376. if ( !( events = elemData.events ) ) {
  9377. events = elemData.events = {};
  9378. }
  9379. if ( !( eventHandle = elemData.handle ) ) {
  9380. eventHandle = elemData.handle = function( e ) {
  9381. // Discard the second event of a jQuery.event.trigger() and
  9382. // when an event is called after a page has unloaded
  9383. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  9384. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  9385. };
  9386. }
  9387. // Handle multiple events separated by a space
  9388. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9389. t = types.length;
  9390. while ( t-- ) {
  9391. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9392. type = origType = tmp[ 1 ];
  9393. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9394. // There *must* be a type, no attaching namespace-only handlers
  9395. if ( !type ) {
  9396. continue;
  9397. }
  9398. // If event changes its type, use the special event handlers for the changed type
  9399. special = jQuery.event.special[ type ] || {};
  9400. // If selector defined, determine special event api type, otherwise given type
  9401. type = ( selector ? special.delegateType : special.bindType ) || type;
  9402. // Update special based on newly reset type
  9403. special = jQuery.event.special[ type ] || {};
  9404. // handleObj is passed to all event handlers
  9405. handleObj = jQuery.extend( {
  9406. type: type,
  9407. origType: origType,
  9408. data: data,
  9409. handler: handler,
  9410. guid: handler.guid,
  9411. selector: selector,
  9412. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  9413. namespace: namespaces.join( "." )
  9414. }, handleObjIn );
  9415. // Init the event handler queue if we're the first
  9416. if ( !( handlers = events[ type ] ) ) {
  9417. handlers = events[ type ] = [];
  9418. handlers.delegateCount = 0;
  9419. // Only use addEventListener if the special events handler returns false
  9420. if ( !special.setup ||
  9421. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  9422. if ( elem.addEventListener ) {
  9423. elem.addEventListener( type, eventHandle );
  9424. }
  9425. }
  9426. }
  9427. if ( special.add ) {
  9428. special.add.call( elem, handleObj );
  9429. if ( !handleObj.handler.guid ) {
  9430. handleObj.handler.guid = handler.guid;
  9431. }
  9432. }
  9433. // Add to the element's handler list, delegates in front
  9434. if ( selector ) {
  9435. handlers.splice( handlers.delegateCount++, 0, handleObj );
  9436. } else {
  9437. handlers.push( handleObj );
  9438. }
  9439. // Keep track of which events have ever been used, for event optimization
  9440. jQuery.event.global[ type ] = true;
  9441. }
  9442. },
  9443. // Detach an event or set of events from an element
  9444. remove: function( elem, types, handler, selector, mappedTypes ) {
  9445. var j, origCount, tmp,
  9446. events, t, handleObj,
  9447. special, handlers, type, namespaces, origType,
  9448. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  9449. if ( !elemData || !( events = elemData.events ) ) {
  9450. return;
  9451. }
  9452. // Once for each type.namespace in types; type may be omitted
  9453. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9454. t = types.length;
  9455. while ( t-- ) {
  9456. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9457. type = origType = tmp[ 1 ];
  9458. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9459. // Unbind all events (on this namespace, if provided) for the element
  9460. if ( !type ) {
  9461. for ( type in events ) {
  9462. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  9463. }
  9464. continue;
  9465. }
  9466. special = jQuery.event.special[ type ] || {};
  9467. type = ( selector ? special.delegateType : special.bindType ) || type;
  9468. handlers = events[ type ] || [];
  9469. tmp = tmp[ 2 ] &&
  9470. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  9471. // Remove matching events
  9472. origCount = j = handlers.length;
  9473. while ( j-- ) {
  9474. handleObj = handlers[ j ];
  9475. if ( ( mappedTypes || origType === handleObj.origType ) &&
  9476. ( !handler || handler.guid === handleObj.guid ) &&
  9477. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  9478. ( !selector || selector === handleObj.selector ||
  9479. selector === "**" && handleObj.selector ) ) {
  9480. handlers.splice( j, 1 );
  9481. if ( handleObj.selector ) {
  9482. handlers.delegateCount--;
  9483. }
  9484. if ( special.remove ) {
  9485. special.remove.call( elem, handleObj );
  9486. }
  9487. }
  9488. }
  9489. // Remove generic event handler if we removed something and no more handlers exist
  9490. // (avoids potential for endless recursion during removal of special event handlers)
  9491. if ( origCount && !handlers.length ) {
  9492. if ( !special.teardown ||
  9493. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  9494. jQuery.removeEvent( elem, type, elemData.handle );
  9495. }
  9496. delete events[ type ];
  9497. }
  9498. }
  9499. // Remove data and the expando if it's no longer used
  9500. if ( jQuery.isEmptyObject( events ) ) {
  9501. dataPriv.remove( elem, "handle events" );
  9502. }
  9503. },
  9504. dispatch: function( nativeEvent ) {
  9505. // Make a writable jQuery.Event from the native event object
  9506. var event = jQuery.event.fix( nativeEvent );
  9507. var i, j, ret, matched, handleObj, handlerQueue,
  9508. args = new Array( arguments.length ),
  9509. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  9510. special = jQuery.event.special[ event.type ] || {};
  9511. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  9512. args[ 0 ] = event;
  9513. for ( i = 1; i < arguments.length; i++ ) {
  9514. args[ i ] = arguments[ i ];
  9515. }
  9516. event.delegateTarget = this;
  9517. // Call the preDispatch hook for the mapped type, and let it bail if desired
  9518. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  9519. return;
  9520. }
  9521. // Determine handlers
  9522. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  9523. // Run delegates first; they may want to stop propagation beneath us
  9524. i = 0;
  9525. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  9526. event.currentTarget = matched.elem;
  9527. j = 0;
  9528. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  9529. !event.isImmediatePropagationStopped() ) {
  9530. // If the event is namespaced, then each handler is only invoked if it is
  9531. // specially universal or its namespaces are a superset of the event's.
  9532. if ( !event.rnamespace || handleObj.namespace === false ||
  9533. event.rnamespace.test( handleObj.namespace ) ) {
  9534. event.handleObj = handleObj;
  9535. event.data = handleObj.data;
  9536. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  9537. handleObj.handler ).apply( matched.elem, args );
  9538. if ( ret !== undefined ) {
  9539. if ( ( event.result = ret ) === false ) {
  9540. event.preventDefault();
  9541. event.stopPropagation();
  9542. }
  9543. }
  9544. }
  9545. }
  9546. }
  9547. // Call the postDispatch hook for the mapped type
  9548. if ( special.postDispatch ) {
  9549. special.postDispatch.call( this, event );
  9550. }
  9551. return event.result;
  9552. },
  9553. handlers: function( event, handlers ) {
  9554. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  9555. handlerQueue = [],
  9556. delegateCount = handlers.delegateCount,
  9557. cur = event.target;
  9558. // Find delegate handlers
  9559. if ( delegateCount &&
  9560. // Support: IE <=9
  9561. // Black-hole SVG <use> instance trees (trac-13180)
  9562. cur.nodeType &&
  9563. // Support: Firefox <=42
  9564. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  9565. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  9566. // Support: IE 11 only
  9567. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  9568. !( event.type === "click" && event.button >= 1 ) ) {
  9569. for ( ; cur !== this; cur = cur.parentNode || this ) {
  9570. // Don't check non-elements (#13208)
  9571. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  9572. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  9573. matchedHandlers = [];
  9574. matchedSelectors = {};
  9575. for ( i = 0; i < delegateCount; i++ ) {
  9576. handleObj = handlers[ i ];
  9577. // Don't conflict with Object.prototype properties (#13203)
  9578. sel = handleObj.selector + " ";
  9579. if ( matchedSelectors[ sel ] === undefined ) {
  9580. matchedSelectors[ sel ] = handleObj.needsContext ?
  9581. jQuery( sel, this ).index( cur ) > -1 :
  9582. jQuery.find( sel, this, null, [ cur ] ).length;
  9583. }
  9584. if ( matchedSelectors[ sel ] ) {
  9585. matchedHandlers.push( handleObj );
  9586. }
  9587. }
  9588. if ( matchedHandlers.length ) {
  9589. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  9590. }
  9591. }
  9592. }
  9593. }
  9594. // Add the remaining (directly-bound) handlers
  9595. cur = this;
  9596. if ( delegateCount < handlers.length ) {
  9597. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  9598. }
  9599. return handlerQueue;
  9600. },
  9601. addProp: function( name, hook ) {
  9602. Object.defineProperty( jQuery.Event.prototype, name, {
  9603. enumerable: true,
  9604. configurable: true,
  9605. get: isFunction( hook ) ?
  9606. function() {
  9607. if ( this.originalEvent ) {
  9608. return hook( this.originalEvent );
  9609. }
  9610. } :
  9611. function() {
  9612. if ( this.originalEvent ) {
  9613. return this.originalEvent[ name ];
  9614. }
  9615. },
  9616. set: function( value ) {
  9617. Object.defineProperty( this, name, {
  9618. enumerable: true,
  9619. configurable: true,
  9620. writable: true,
  9621. value: value
  9622. } );
  9623. }
  9624. } );
  9625. },
  9626. fix: function( originalEvent ) {
  9627. return originalEvent[ jQuery.expando ] ?
  9628. originalEvent :
  9629. new jQuery.Event( originalEvent );
  9630. },
  9631. special: {
  9632. load: {
  9633. // Prevent triggered image.load events from bubbling to window.load
  9634. noBubble: true
  9635. },
  9636. click: {
  9637. // Utilize native event to ensure correct state for checkable inputs
  9638. setup: function( data ) {
  9639. // For mutual compressibility with _default, replace `this` access with a local var.
  9640. // `|| data` is dead code meant only to preserve the variable through minification.
  9641. var el = this || data;
  9642. // Claim the first handler
  9643. if ( rcheckableType.test( el.type ) &&
  9644. el.click && nodeName( el, "input" ) ) {
  9645. // dataPriv.set( el, "click", ... )
  9646. leverageNative( el, "click", returnTrue );
  9647. }
  9648. // Return false to allow normal processing in the caller
  9649. return false;
  9650. },
  9651. trigger: function( data ) {
  9652. // For mutual compressibility with _default, replace `this` access with a local var.
  9653. // `|| data` is dead code meant only to preserve the variable through minification.
  9654. var el = this || data;
  9655. // Force setup before triggering a click
  9656. if ( rcheckableType.test( el.type ) &&
  9657. el.click && nodeName( el, "input" ) ) {
  9658. leverageNative( el, "click" );
  9659. }
  9660. // Return non-false to allow normal event-path propagation
  9661. return true;
  9662. },
  9663. // For cross-browser consistency, suppress native .click() on links
  9664. // Also prevent it if we're currently inside a leveraged native-event stack
  9665. _default: function( event ) {
  9666. var target = event.target;
  9667. return rcheckableType.test( target.type ) &&
  9668. target.click && nodeName( target, "input" ) &&
  9669. dataPriv.get( target, "click" ) ||
  9670. nodeName( target, "a" );
  9671. }
  9672. },
  9673. beforeunload: {
  9674. postDispatch: function( event ) {
  9675. // Support: Firefox 20+
  9676. // Firefox doesn't alert if the returnValue field is not set.
  9677. if ( event.result !== undefined && event.originalEvent ) {
  9678. event.originalEvent.returnValue = event.result;
  9679. }
  9680. }
  9681. }
  9682. }
  9683. };
  9684. // Ensure the presence of an event listener that handles manually-triggered
  9685. // synthetic events by interrupting progress until reinvoked in response to
  9686. // *native* events that it fires directly, ensuring that state changes have
  9687. // already occurred before other listeners are invoked.
  9688. function leverageNative( el, type, expectSync ) {
  9689. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  9690. if ( !expectSync ) {
  9691. if ( dataPriv.get( el, type ) === undefined ) {
  9692. jQuery.event.add( el, type, returnTrue );
  9693. }
  9694. return;
  9695. }
  9696. // Register the controller as a special universal handler for all event namespaces
  9697. dataPriv.set( el, type, false );
  9698. jQuery.event.add( el, type, {
  9699. namespace: false,
  9700. handler: function( event ) {
  9701. var notAsync, result,
  9702. saved = dataPriv.get( this, type );
  9703. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  9704. // Interrupt processing of the outer synthetic .trigger()ed event
  9705. // Saved data should be false in such cases, but might be a leftover capture object
  9706. // from an async native handler (gh-4350)
  9707. if ( !saved.length ) {
  9708. // Store arguments for use when handling the inner native event
  9709. // There will always be at least one argument (an event object), so this array
  9710. // will not be confused with a leftover capture object.
  9711. saved = slice.call( arguments );
  9712. dataPriv.set( this, type, saved );
  9713. // Trigger the native event and capture its result
  9714. // Support: IE <=9 - 11+
  9715. // focus() and blur() are asynchronous
  9716. notAsync = expectSync( this, type );
  9717. this[ type ]();
  9718. result = dataPriv.get( this, type );
  9719. if ( saved !== result || notAsync ) {
  9720. dataPriv.set( this, type, false );
  9721. } else {
  9722. result = {};
  9723. }
  9724. if ( saved !== result ) {
  9725. // Cancel the outer synthetic event
  9726. event.stopImmediatePropagation();
  9727. event.preventDefault();
  9728. return result.value;
  9729. }
  9730. // If this is an inner synthetic event for an event with a bubbling surrogate
  9731. // (focus or blur), assume that the surrogate already propagated from triggering the
  9732. // native event and prevent that from happening again here.
  9733. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  9734. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  9735. // less bad than duplication.
  9736. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  9737. event.stopPropagation();
  9738. }
  9739. // If this is a native event triggered above, everything is now in order
  9740. // Fire an inner synthetic event with the original arguments
  9741. } else if ( saved.length ) {
  9742. // ...and capture the result
  9743. dataPriv.set( this, type, {
  9744. value: jQuery.event.trigger(
  9745. // Support: IE <=9 - 11+
  9746. // Extend with the prototype to reset the above stopImmediatePropagation()
  9747. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  9748. saved.slice( 1 ),
  9749. this
  9750. )
  9751. } );
  9752. // Abort handling of the native event
  9753. event.stopImmediatePropagation();
  9754. }
  9755. }
  9756. } );
  9757. }
  9758. jQuery.removeEvent = function( elem, type, handle ) {
  9759. // This "if" is needed for plain objects
  9760. if ( elem.removeEventListener ) {
  9761. elem.removeEventListener( type, handle );
  9762. }
  9763. };
  9764. jQuery.Event = function( src, props ) {
  9765. // Allow instantiation without the 'new' keyword
  9766. if ( !( this instanceof jQuery.Event ) ) {
  9767. return new jQuery.Event( src, props );
  9768. }
  9769. // Event object
  9770. if ( src && src.type ) {
  9771. this.originalEvent = src;
  9772. this.type = src.type;
  9773. // Events bubbling up the document may have been marked as prevented
  9774. // by a handler lower down the tree; reflect the correct value.
  9775. this.isDefaultPrevented = src.defaultPrevented ||
  9776. src.defaultPrevented === undefined &&
  9777. // Support: Android <=2.3 only
  9778. src.returnValue === false ?
  9779. returnTrue :
  9780. returnFalse;
  9781. // Create target properties
  9782. // Support: Safari <=6 - 7 only
  9783. // Target should not be a text node (#504, #13143)
  9784. this.target = ( src.target && src.target.nodeType === 3 ) ?
  9785. src.target.parentNode :
  9786. src.target;
  9787. this.currentTarget = src.currentTarget;
  9788. this.relatedTarget = src.relatedTarget;
  9789. // Event type
  9790. } else {
  9791. this.type = src;
  9792. }
  9793. // Put explicitly provided properties onto the event object
  9794. if ( props ) {
  9795. jQuery.extend( this, props );
  9796. }
  9797. // Create a timestamp if incoming event doesn't have one
  9798. this.timeStamp = src && src.timeStamp || Date.now();
  9799. // Mark it as fixed
  9800. this[ jQuery.expando ] = true;
  9801. };
  9802. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  9803. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  9804. jQuery.Event.prototype = {
  9805. constructor: jQuery.Event,
  9806. isDefaultPrevented: returnFalse,
  9807. isPropagationStopped: returnFalse,
  9808. isImmediatePropagationStopped: returnFalse,
  9809. isSimulated: false,
  9810. preventDefault: function() {
  9811. var e = this.originalEvent;
  9812. this.isDefaultPrevented = returnTrue;
  9813. if ( e && !this.isSimulated ) {
  9814. e.preventDefault();
  9815. }
  9816. },
  9817. stopPropagation: function() {
  9818. var e = this.originalEvent;
  9819. this.isPropagationStopped = returnTrue;
  9820. if ( e && !this.isSimulated ) {
  9821. e.stopPropagation();
  9822. }
  9823. },
  9824. stopImmediatePropagation: function() {
  9825. var e = this.originalEvent;
  9826. this.isImmediatePropagationStopped = returnTrue;
  9827. if ( e && !this.isSimulated ) {
  9828. e.stopImmediatePropagation();
  9829. }
  9830. this.stopPropagation();
  9831. }
  9832. };
  9833. // Includes all common event props including KeyEvent and MouseEvent specific props
  9834. jQuery.each( {
  9835. altKey: true,
  9836. bubbles: true,
  9837. cancelable: true,
  9838. changedTouches: true,
  9839. ctrlKey: true,
  9840. detail: true,
  9841. eventPhase: true,
  9842. metaKey: true,
  9843. pageX: true,
  9844. pageY: true,
  9845. shiftKey: true,
  9846. view: true,
  9847. "char": true,
  9848. code: true,
  9849. charCode: true,
  9850. key: true,
  9851. keyCode: true,
  9852. button: true,
  9853. buttons: true,
  9854. clientX: true,
  9855. clientY: true,
  9856. offsetX: true,
  9857. offsetY: true,
  9858. pointerId: true,
  9859. pointerType: true,
  9860. screenX: true,
  9861. screenY: true,
  9862. targetTouches: true,
  9863. toElement: true,
  9864. touches: true,
  9865. which: function( event ) {
  9866. var button = event.button;
  9867. // Add which for key events
  9868. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  9869. return event.charCode != null ? event.charCode : event.keyCode;
  9870. }
  9871. // Add which for click: 1 === left; 2 === middle; 3 === right
  9872. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  9873. if ( button & 1 ) {
  9874. return 1;
  9875. }
  9876. if ( button & 2 ) {
  9877. return 3;
  9878. }
  9879. if ( button & 4 ) {
  9880. return 2;
  9881. }
  9882. return 0;
  9883. }
  9884. return event.which;
  9885. }
  9886. }, jQuery.event.addProp );
  9887. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  9888. jQuery.event.special[ type ] = {
  9889. // Utilize native event if possible so blur/focus sequence is correct
  9890. setup: function() {
  9891. // Claim the first handler
  9892. // dataPriv.set( this, "focus", ... )
  9893. // dataPriv.set( this, "blur", ... )
  9894. leverageNative( this, type, expectSync );
  9895. // Return false to allow normal processing in the caller
  9896. return false;
  9897. },
  9898. trigger: function() {
  9899. // Force setup before trigger
  9900. leverageNative( this, type );
  9901. // Return non-false to allow normal event-path propagation
  9902. return true;
  9903. },
  9904. delegateType: delegateType
  9905. };
  9906. } );
  9907. // Create mouseenter/leave events using mouseover/out and event-time checks
  9908. // so that event delegation works in jQuery.
  9909. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  9910. //
  9911. // Support: Safari 7 only
  9912. // Safari sends mouseenter too often; see:
  9913. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  9914. // for the description of the bug (it existed in older Chrome versions as well).
  9915. jQuery.each( {
  9916. mouseenter: "mouseover",
  9917. mouseleave: "mouseout",
  9918. pointerenter: "pointerover",
  9919. pointerleave: "pointerout"
  9920. }, function( orig, fix ) {
  9921. jQuery.event.special[ orig ] = {
  9922. delegateType: fix,
  9923. bindType: fix,
  9924. handle: function( event ) {
  9925. var ret,
  9926. target = this,
  9927. related = event.relatedTarget,
  9928. handleObj = event.handleObj;
  9929. // For mouseenter/leave call the handler if related is outside the target.
  9930. // NB: No relatedTarget if the mouse left/entered the browser window
  9931. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  9932. event.type = handleObj.origType;
  9933. ret = handleObj.handler.apply( this, arguments );
  9934. event.type = fix;
  9935. }
  9936. return ret;
  9937. }
  9938. };
  9939. } );
  9940. jQuery.fn.extend( {
  9941. on: function( types, selector, data, fn ) {
  9942. return on( this, types, selector, data, fn );
  9943. },
  9944. one: function( types, selector, data, fn ) {
  9945. return on( this, types, selector, data, fn, 1 );
  9946. },
  9947. off: function( types, selector, fn ) {
  9948. var handleObj, type;
  9949. if ( types && types.preventDefault && types.handleObj ) {
  9950. // ( event ) dispatched jQuery.Event
  9951. handleObj = types.handleObj;
  9952. jQuery( types.delegateTarget ).off(
  9953. handleObj.namespace ?
  9954. handleObj.origType + "." + handleObj.namespace :
  9955. handleObj.origType,
  9956. handleObj.selector,
  9957. handleObj.handler
  9958. );
  9959. return this;
  9960. }
  9961. if ( typeof types === "object" ) {
  9962. // ( types-object [, selector] )
  9963. for ( type in types ) {
  9964. this.off( type, selector, types[ type ] );
  9965. }
  9966. return this;
  9967. }
  9968. if ( selector === false || typeof selector === "function" ) {
  9969. // ( types [, fn] )
  9970. fn = selector;
  9971. selector = undefined;
  9972. }
  9973. if ( fn === false ) {
  9974. fn = returnFalse;
  9975. }
  9976. return this.each( function() {
  9977. jQuery.event.remove( this, types, fn, selector );
  9978. } );
  9979. }
  9980. } );
  9981. var
  9982. /* eslint-disable max-len */
  9983. // See https://github.com/eslint/eslint/issues/3229
  9984. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  9985. /* eslint-enable */
  9986. // Support: IE <=10 - 11, Edge 12 - 13 only
  9987. // In IE/Edge using regex groups here causes severe slowdowns.
  9988. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  9989. rnoInnerhtml = /<script|<style|<link/i,
  9990. // checked="checked" or checked
  9991. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  9992. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  9993. // Prefer a tbody over its parent table for containing new rows
  9994. function manipulationTarget( elem, content ) {
  9995. if ( nodeName( elem, "table" ) &&
  9996. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  9997. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  9998. }
  9999. return elem;
  10000. }
  10001. // Replace/restore the type attribute of script elements for safe DOM manipulation
  10002. function disableScript( elem ) {
  10003. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  10004. return elem;
  10005. }
  10006. function restoreScript( elem ) {
  10007. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  10008. elem.type = elem.type.slice( 5 );
  10009. } else {
  10010. elem.removeAttribute( "type" );
  10011. }
  10012. return elem;
  10013. }
  10014. function cloneCopyEvent( src, dest ) {
  10015. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  10016. if ( dest.nodeType !== 1 ) {
  10017. return;
  10018. }
  10019. // 1. Copy private data: events, handlers, etc.
  10020. if ( dataPriv.hasData( src ) ) {
  10021. pdataOld = dataPriv.access( src );
  10022. pdataCur = dataPriv.set( dest, pdataOld );
  10023. events = pdataOld.events;
  10024. if ( events ) {
  10025. delete pdataCur.handle;
  10026. pdataCur.events = {};
  10027. for ( type in events ) {
  10028. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  10029. jQuery.event.add( dest, type, events[ type ][ i ] );
  10030. }
  10031. }
  10032. }
  10033. }
  10034. // 2. Copy user data
  10035. if ( dataUser.hasData( src ) ) {
  10036. udataOld = dataUser.access( src );
  10037. udataCur = jQuery.extend( {}, udataOld );
  10038. dataUser.set( dest, udataCur );
  10039. }
  10040. }
  10041. // Fix IE bugs, see support tests
  10042. function fixInput( src, dest ) {
  10043. var nodeName = dest.nodeName.toLowerCase();
  10044. // Fails to persist the checked state of a cloned checkbox or radio button.
  10045. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  10046. dest.checked = src.checked;
  10047. // Fails to return the selected option to the default selected state when cloning options
  10048. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  10049. dest.defaultValue = src.defaultValue;
  10050. }
  10051. }
  10052. function domManip( collection, args, callback, ignored ) {
  10053. // Flatten any nested arrays
  10054. args = concat.apply( [], args );
  10055. var fragment, first, scripts, hasScripts, node, doc,
  10056. i = 0,
  10057. l = collection.length,
  10058. iNoClone = l - 1,
  10059. value = args[ 0 ],
  10060. valueIsFunction = isFunction( value );
  10061. // We can't cloneNode fragments that contain checked, in WebKit
  10062. if ( valueIsFunction ||
  10063. ( l > 1 && typeof value === "string" &&
  10064. !support.checkClone && rchecked.test( value ) ) ) {
  10065. return collection.each( function( index ) {
  10066. var self = collection.eq( index );
  10067. if ( valueIsFunction ) {
  10068. args[ 0 ] = value.call( this, index, self.html() );
  10069. }
  10070. domManip( self, args, callback, ignored );
  10071. } );
  10072. }
  10073. if ( l ) {
  10074. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  10075. first = fragment.firstChild;
  10076. if ( fragment.childNodes.length === 1 ) {
  10077. fragment = first;
  10078. }
  10079. // Require either new content or an interest in ignored elements to invoke the callback
  10080. if ( first || ignored ) {
  10081. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  10082. hasScripts = scripts.length;
  10083. // Use the original fragment for the last item
  10084. // instead of the first because it can end up
  10085. // being emptied incorrectly in certain situations (#8070).
  10086. for ( ; i < l; i++ ) {
  10087. node = fragment;
  10088. if ( i !== iNoClone ) {
  10089. node = jQuery.clone( node, true, true );
  10090. // Keep references to cloned scripts for later restoration
  10091. if ( hasScripts ) {
  10092. // Support: Android <=4.0 only, PhantomJS 1 only
  10093. // push.apply(_, arraylike) throws on ancient WebKit
  10094. jQuery.merge( scripts, getAll( node, "script" ) );
  10095. }
  10096. }
  10097. callback.call( collection[ i ], node, i );
  10098. }
  10099. if ( hasScripts ) {
  10100. doc = scripts[ scripts.length - 1 ].ownerDocument;
  10101. // Reenable scripts
  10102. jQuery.map( scripts, restoreScript );
  10103. // Evaluate executable scripts on first document insertion
  10104. for ( i = 0; i < hasScripts; i++ ) {
  10105. node = scripts[ i ];
  10106. if ( rscriptType.test( node.type || "" ) &&
  10107. !dataPriv.access( node, "globalEval" ) &&
  10108. jQuery.contains( doc, node ) ) {
  10109. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  10110. // Optional AJAX dependency, but won't run scripts if not present
  10111. if ( jQuery._evalUrl && !node.noModule ) {
  10112. jQuery._evalUrl( node.src, {
  10113. nonce: node.nonce || node.getAttribute( "nonce" )
  10114. } );
  10115. }
  10116. } else {
  10117. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  10118. }
  10119. }
  10120. }
  10121. }
  10122. }
  10123. }
  10124. return collection;
  10125. }
  10126. function remove( elem, selector, keepData ) {
  10127. var node,
  10128. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  10129. i = 0;
  10130. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  10131. if ( !keepData && node.nodeType === 1 ) {
  10132. jQuery.cleanData( getAll( node ) );
  10133. }
  10134. if ( node.parentNode ) {
  10135. if ( keepData && isAttached( node ) ) {
  10136. setGlobalEval( getAll( node, "script" ) );
  10137. }
  10138. node.parentNode.removeChild( node );
  10139. }
  10140. }
  10141. return elem;
  10142. }
  10143. jQuery.extend( {
  10144. htmlPrefilter: function( html ) {
  10145. return html.replace( rxhtmlTag, "<$1></$2>" );
  10146. },
  10147. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  10148. var i, l, srcElements, destElements,
  10149. clone = elem.cloneNode( true ),
  10150. inPage = isAttached( elem );
  10151. // Fix IE cloning issues
  10152. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  10153. !jQuery.isXMLDoc( elem ) ) {
  10154. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  10155. destElements = getAll( clone );
  10156. srcElements = getAll( elem );
  10157. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10158. fixInput( srcElements[ i ], destElements[ i ] );
  10159. }
  10160. }
  10161. // Copy the events from the original to the clone
  10162. if ( dataAndEvents ) {
  10163. if ( deepDataAndEvents ) {
  10164. srcElements = srcElements || getAll( elem );
  10165. destElements = destElements || getAll( clone );
  10166. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10167. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  10168. }
  10169. } else {
  10170. cloneCopyEvent( elem, clone );
  10171. }
  10172. }
  10173. // Preserve script evaluation history
  10174. destElements = getAll( clone, "script" );
  10175. if ( destElements.length > 0 ) {
  10176. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  10177. }
  10178. // Return the cloned set
  10179. return clone;
  10180. },
  10181. cleanData: function( elems ) {
  10182. var data, elem, type,
  10183. special = jQuery.event.special,
  10184. i = 0;
  10185. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  10186. if ( acceptData( elem ) ) {
  10187. if ( ( data = elem[ dataPriv.expando ] ) ) {
  10188. if ( data.events ) {
  10189. for ( type in data.events ) {
  10190. if ( special[ type ] ) {
  10191. jQuery.event.remove( elem, type );
  10192. // This is a shortcut to avoid jQuery.event.remove's overhead
  10193. } else {
  10194. jQuery.removeEvent( elem, type, data.handle );
  10195. }
  10196. }
  10197. }
  10198. // Support: Chrome <=35 - 45+
  10199. // Assign undefined instead of using delete, see Data#remove
  10200. elem[ dataPriv.expando ] = undefined;
  10201. }
  10202. if ( elem[ dataUser.expando ] ) {
  10203. // Support: Chrome <=35 - 45+
  10204. // Assign undefined instead of using delete, see Data#remove
  10205. elem[ dataUser.expando ] = undefined;
  10206. }
  10207. }
  10208. }
  10209. }
  10210. } );
  10211. jQuery.fn.extend( {
  10212. detach: function( selector ) {
  10213. return remove( this, selector, true );
  10214. },
  10215. remove: function( selector ) {
  10216. return remove( this, selector );
  10217. },
  10218. text: function( value ) {
  10219. return access( this, function( value ) {
  10220. return value === undefined ?
  10221. jQuery.text( this ) :
  10222. this.empty().each( function() {
  10223. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10224. this.textContent = value;
  10225. }
  10226. } );
  10227. }, null, value, arguments.length );
  10228. },
  10229. append: function() {
  10230. return domManip( this, arguments, function( elem ) {
  10231. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10232. var target = manipulationTarget( this, elem );
  10233. target.appendChild( elem );
  10234. }
  10235. } );
  10236. },
  10237. prepend: function() {
  10238. return domManip( this, arguments, function( elem ) {
  10239. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10240. var target = manipulationTarget( this, elem );
  10241. target.insertBefore( elem, target.firstChild );
  10242. }
  10243. } );
  10244. },
  10245. before: function() {
  10246. return domManip( this, arguments, function( elem ) {
  10247. if ( this.parentNode ) {
  10248. this.parentNode.insertBefore( elem, this );
  10249. }
  10250. } );
  10251. },
  10252. after: function() {
  10253. return domManip( this, arguments, function( elem ) {
  10254. if ( this.parentNode ) {
  10255. this.parentNode.insertBefore( elem, this.nextSibling );
  10256. }
  10257. } );
  10258. },
  10259. empty: function() {
  10260. var elem,
  10261. i = 0;
  10262. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  10263. if ( elem.nodeType === 1 ) {
  10264. // Prevent memory leaks
  10265. jQuery.cleanData( getAll( elem, false ) );
  10266. // Remove any remaining nodes
  10267. elem.textContent = "";
  10268. }
  10269. }
  10270. return this;
  10271. },
  10272. clone: function( dataAndEvents, deepDataAndEvents ) {
  10273. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  10274. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  10275. return this.map( function() {
  10276. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  10277. } );
  10278. },
  10279. html: function( value ) {
  10280. return access( this, function( value ) {
  10281. var elem = this[ 0 ] || {},
  10282. i = 0,
  10283. l = this.length;
  10284. if ( value === undefined && elem.nodeType === 1 ) {
  10285. return elem.innerHTML;
  10286. }
  10287. // See if we can take a shortcut and just use innerHTML
  10288. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  10289. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  10290. value = jQuery.htmlPrefilter( value );
  10291. try {
  10292. for ( ; i < l; i++ ) {
  10293. elem = this[ i ] || {};
  10294. // Remove element nodes and prevent memory leaks
  10295. if ( elem.nodeType === 1 ) {
  10296. jQuery.cleanData( getAll( elem, false ) );
  10297. elem.innerHTML = value;
  10298. }
  10299. }
  10300. elem = 0;
  10301. // If using innerHTML throws an exception, use the fallback method
  10302. } catch ( e ) {}
  10303. }
  10304. if ( elem ) {
  10305. this.empty().append( value );
  10306. }
  10307. }, null, value, arguments.length );
  10308. },
  10309. replaceWith: function() {
  10310. var ignored = [];
  10311. // Make the changes, replacing each non-ignored context element with the new content
  10312. return domManip( this, arguments, function( elem ) {
  10313. var parent = this.parentNode;
  10314. if ( jQuery.inArray( this, ignored ) < 0 ) {
  10315. jQuery.cleanData( getAll( this ) );
  10316. if ( parent ) {
  10317. parent.replaceChild( elem, this );
  10318. }
  10319. }
  10320. // Force callback invocation
  10321. }, ignored );
  10322. }
  10323. } );
  10324. jQuery.each( {
  10325. appendTo: "append",
  10326. prependTo: "prepend",
  10327. insertBefore: "before",
  10328. insertAfter: "after",
  10329. replaceAll: "replaceWith"
  10330. }, function( name, original ) {
  10331. jQuery.fn[ name ] = function( selector ) {
  10332. var elems,
  10333. ret = [],
  10334. insert = jQuery( selector ),
  10335. last = insert.length - 1,
  10336. i = 0;
  10337. for ( ; i <= last; i++ ) {
  10338. elems = i === last ? this : this.clone( true );
  10339. jQuery( insert[ i ] )[ original ]( elems );
  10340. // Support: Android <=4.0 only, PhantomJS 1 only
  10341. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  10342. push.apply( ret, elems.get() );
  10343. }
  10344. return this.pushStack( ret );
  10345. };
  10346. } );
  10347. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  10348. var getStyles = function( elem ) {
  10349. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  10350. // IE throws on elements created in popups
  10351. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  10352. var view = elem.ownerDocument.defaultView;
  10353. if ( !view || !view.opener ) {
  10354. view = window;
  10355. }
  10356. return view.getComputedStyle( elem );
  10357. };
  10358. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  10359. ( function() {
  10360. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  10361. // so they're executed at the same time to save the second computation.
  10362. function computeStyleTests() {
  10363. // This is a singleton, we need to execute it only once
  10364. if ( !div ) {
  10365. return;
  10366. }
  10367. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  10368. "margin-top:1px;padding:0;border:0";
  10369. div.style.cssText =
  10370. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  10371. "margin:auto;border:1px;padding:1px;" +
  10372. "width:60%;top:1%";
  10373. documentElement.appendChild( container ).appendChild( div );
  10374. var divStyle = window.getComputedStyle( div );
  10375. pixelPositionVal = divStyle.top !== "1%";
  10376. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  10377. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  10378. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  10379. // Some styles come back with percentage values, even though they shouldn't
  10380. div.style.right = "60%";
  10381. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  10382. // Support: IE 9 - 11 only
  10383. // Detect misreporting of content dimensions for box-sizing:border-box elements
  10384. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  10385. // Support: IE 9 only
  10386. // Detect overflow:scroll screwiness (gh-3699)
  10387. // Support: Chrome <=64
  10388. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  10389. div.style.position = "absolute";
  10390. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  10391. documentElement.removeChild( container );
  10392. // Nullify the div so it wouldn't be stored in the memory and
  10393. // it will also be a sign that checks already performed
  10394. div = null;
  10395. }
  10396. function roundPixelMeasures( measure ) {
  10397. return Math.round( parseFloat( measure ) );
  10398. }
  10399. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  10400. reliableMarginLeftVal,
  10401. container = document.createElement( "div" ),
  10402. div = document.createElement( "div" );
  10403. // Finish early in limited (non-browser) environments
  10404. if ( !div.style ) {
  10405. return;
  10406. }
  10407. // Support: IE <=9 - 11 only
  10408. // Style of cloned element affects source element cloned (#8908)
  10409. div.style.backgroundClip = "content-box";
  10410. div.cloneNode( true ).style.backgroundClip = "";
  10411. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  10412. jQuery.extend( support, {
  10413. boxSizingReliable: function() {
  10414. computeStyleTests();
  10415. return boxSizingReliableVal;
  10416. },
  10417. pixelBoxStyles: function() {
  10418. computeStyleTests();
  10419. return pixelBoxStylesVal;
  10420. },
  10421. pixelPosition: function() {
  10422. computeStyleTests();
  10423. return pixelPositionVal;
  10424. },
  10425. reliableMarginLeft: function() {
  10426. computeStyleTests();
  10427. return reliableMarginLeftVal;
  10428. },
  10429. scrollboxSize: function() {
  10430. computeStyleTests();
  10431. return scrollboxSizeVal;
  10432. }
  10433. } );
  10434. } )();
  10435. function curCSS( elem, name, computed ) {
  10436. var width, minWidth, maxWidth, ret,
  10437. // Support: Firefox 51+
  10438. // Retrieving style before computed somehow
  10439. // fixes an issue with getting wrong values
  10440. // on detached elements
  10441. style = elem.style;
  10442. computed = computed || getStyles( elem );
  10443. // getPropertyValue is needed for:
  10444. // .css('filter') (IE 9 only, #12537)
  10445. // .css('--customProperty) (#3144)
  10446. if ( computed ) {
  10447. ret = computed.getPropertyValue( name ) || computed[ name ];
  10448. if ( ret === "" && !isAttached( elem ) ) {
  10449. ret = jQuery.style( elem, name );
  10450. }
  10451. // A tribute to the "awesome hack by Dean Edwards"
  10452. // Android Browser returns percentage for some values,
  10453. // but width seems to be reliably pixels.
  10454. // This is against the CSSOM draft spec:
  10455. // https://drafts.csswg.org/cssom/#resolved-values
  10456. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  10457. // Remember the original values
  10458. width = style.width;
  10459. minWidth = style.minWidth;
  10460. maxWidth = style.maxWidth;
  10461. // Put in the new values to get a computed value out
  10462. style.minWidth = style.maxWidth = style.width = ret;
  10463. ret = computed.width;
  10464. // Revert the changed values
  10465. style.width = width;
  10466. style.minWidth = minWidth;
  10467. style.maxWidth = maxWidth;
  10468. }
  10469. }
  10470. return ret !== undefined ?
  10471. // Support: IE <=9 - 11 only
  10472. // IE returns zIndex value as an integer.
  10473. ret + "" :
  10474. ret;
  10475. }
  10476. function addGetHookIf( conditionFn, hookFn ) {
  10477. // Define the hook, we'll check on the first run if it's really needed.
  10478. return {
  10479. get: function() {
  10480. if ( conditionFn() ) {
  10481. // Hook not needed (or it's not possible to use it due
  10482. // to missing dependency), remove it.
  10483. delete this.get;
  10484. return;
  10485. }
  10486. // Hook needed; redefine it so that the support test is not executed again.
  10487. return ( this.get = hookFn ).apply( this, arguments );
  10488. }
  10489. };
  10490. }
  10491. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  10492. emptyStyle = document.createElement( "div" ).style,
  10493. vendorProps = {};
  10494. // Return a vendor-prefixed property or undefined
  10495. function vendorPropName( name ) {
  10496. // Check for vendor prefixed names
  10497. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  10498. i = cssPrefixes.length;
  10499. while ( i-- ) {
  10500. name = cssPrefixes[ i ] + capName;
  10501. if ( name in emptyStyle ) {
  10502. return name;
  10503. }
  10504. }
  10505. }
  10506. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  10507. function finalPropName( name ) {
  10508. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  10509. if ( final ) {
  10510. return final;
  10511. }
  10512. if ( name in emptyStyle ) {
  10513. return name;
  10514. }
  10515. return vendorProps[ name ] = vendorPropName( name ) || name;
  10516. }
  10517. var
  10518. // Swappable if display is none or starts with table
  10519. // except "table", "table-cell", or "table-caption"
  10520. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  10521. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  10522. rcustomProp = /^--/,
  10523. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  10524. cssNormalTransform = {
  10525. letterSpacing: "0",
  10526. fontWeight: "400"
  10527. };
  10528. function setPositiveNumber( elem, value, subtract ) {
  10529. // Any relative (+/-) values have already been
  10530. // normalized at this point
  10531. var matches = rcssNum.exec( value );
  10532. return matches ?
  10533. // Guard against undefined "subtract", e.g., when used as in cssHooks
  10534. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  10535. value;
  10536. }
  10537. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  10538. var i = dimension === "width" ? 1 : 0,
  10539. extra = 0,
  10540. delta = 0;
  10541. // Adjustment may not be necessary
  10542. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  10543. return 0;
  10544. }
  10545. for ( ; i < 4; i += 2 ) {
  10546. // Both box models exclude margin
  10547. if ( box === "margin" ) {
  10548. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  10549. }
  10550. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  10551. if ( !isBorderBox ) {
  10552. // Add padding
  10553. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10554. // For "border" or "margin", add border
  10555. if ( box !== "padding" ) {
  10556. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10557. // But still keep track of it otherwise
  10558. } else {
  10559. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10560. }
  10561. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  10562. // "padding" or "margin"
  10563. } else {
  10564. // For "content", subtract padding
  10565. if ( box === "content" ) {
  10566. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10567. }
  10568. // For "content" or "padding", subtract border
  10569. if ( box !== "margin" ) {
  10570. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10571. }
  10572. }
  10573. }
  10574. // Account for positive content-box scroll gutter when requested by providing computedVal
  10575. if ( !isBorderBox && computedVal >= 0 ) {
  10576. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  10577. // Assuming integer scroll gutter, subtract the rest and round down
  10578. delta += Math.max( 0, Math.ceil(
  10579. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10580. computedVal -
  10581. delta -
  10582. extra -
  10583. 0.5
  10584. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  10585. // Use an explicit zero to avoid NaN (gh-3964)
  10586. ) ) || 0;
  10587. }
  10588. return delta;
  10589. }
  10590. function getWidthOrHeight( elem, dimension, extra ) {
  10591. // Start with computed style
  10592. var styles = getStyles( elem ),
  10593. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  10594. // Fake content-box until we know it's needed to know the true value.
  10595. boxSizingNeeded = !support.boxSizingReliable() || extra,
  10596. isBorderBox = boxSizingNeeded &&
  10597. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10598. valueIsBorderBox = isBorderBox,
  10599. val = curCSS( elem, dimension, styles ),
  10600. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  10601. // Support: Firefox <=54
  10602. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  10603. if ( rnumnonpx.test( val ) ) {
  10604. if ( !extra ) {
  10605. return val;
  10606. }
  10607. val = "auto";
  10608. }
  10609. // Fall back to offsetWidth/offsetHeight when value is "auto"
  10610. // This happens for inline elements with no explicit setting (gh-3571)
  10611. // Support: Android <=4.1 - 4.3 only
  10612. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  10613. // Support: IE 9-11 only
  10614. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  10615. // We use getClientRects() to check for hidden/disconnected.
  10616. // In those cases, the computed value can be trusted to be border-box
  10617. if ( ( !support.boxSizingReliable() && isBorderBox ||
  10618. val === "auto" ||
  10619. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  10620. elem.getClientRects().length ) {
  10621. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  10622. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  10623. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  10624. // retrieved value as a content box dimension.
  10625. valueIsBorderBox = offsetProp in elem;
  10626. if ( valueIsBorderBox ) {
  10627. val = elem[ offsetProp ];
  10628. }
  10629. }
  10630. // Normalize "" and auto
  10631. val = parseFloat( val ) || 0;
  10632. // Adjust for the element's box model
  10633. return ( val +
  10634. boxModelAdjustment(
  10635. elem,
  10636. dimension,
  10637. extra || ( isBorderBox ? "border" : "content" ),
  10638. valueIsBorderBox,
  10639. styles,
  10640. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  10641. val
  10642. )
  10643. ) + "px";
  10644. }
  10645. jQuery.extend( {
  10646. // Add in style property hooks for overriding the default
  10647. // behavior of getting and setting a style property
  10648. cssHooks: {
  10649. opacity: {
  10650. get: function( elem, computed ) {
  10651. if ( computed ) {
  10652. // We should always get a number back from opacity
  10653. var ret = curCSS( elem, "opacity" );
  10654. return ret === "" ? "1" : ret;
  10655. }
  10656. }
  10657. }
  10658. },
  10659. // Don't automatically add "px" to these possibly-unitless properties
  10660. cssNumber: {
  10661. "animationIterationCount": true,
  10662. "columnCount": true,
  10663. "fillOpacity": true,
  10664. "flexGrow": true,
  10665. "flexShrink": true,
  10666. "fontWeight": true,
  10667. "gridArea": true,
  10668. "gridColumn": true,
  10669. "gridColumnEnd": true,
  10670. "gridColumnStart": true,
  10671. "gridRow": true,
  10672. "gridRowEnd": true,
  10673. "gridRowStart": true,
  10674. "lineHeight": true,
  10675. "opacity": true,
  10676. "order": true,
  10677. "orphans": true,
  10678. "widows": true,
  10679. "zIndex": true,
  10680. "zoom": true
  10681. },
  10682. // Add in properties whose names you wish to fix before
  10683. // setting or getting the value
  10684. cssProps: {},
  10685. // Get and set the style property on a DOM Node
  10686. style: function( elem, name, value, extra ) {
  10687. // Don't set styles on text and comment nodes
  10688. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  10689. return;
  10690. }
  10691. // Make sure that we're working with the right name
  10692. var ret, type, hooks,
  10693. origName = camelCase( name ),
  10694. isCustomProp = rcustomProp.test( name ),
  10695. style = elem.style;
  10696. // Make sure that we're working with the right name. We don't
  10697. // want to query the value if it is a CSS custom property
  10698. // since they are user-defined.
  10699. if ( !isCustomProp ) {
  10700. name = finalPropName( origName );
  10701. }
  10702. // Gets hook for the prefixed version, then unprefixed version
  10703. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10704. // Check if we're setting a value
  10705. if ( value !== undefined ) {
  10706. type = typeof value;
  10707. // Convert "+=" or "-=" to relative numbers (#7345)
  10708. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  10709. value = adjustCSS( elem, name, ret );
  10710. // Fixes bug #9237
  10711. type = "number";
  10712. }
  10713. // Make sure that null and NaN values aren't set (#7116)
  10714. if ( value == null || value !== value ) {
  10715. return;
  10716. }
  10717. // If a number was passed in, add the unit (except for certain CSS properties)
  10718. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  10719. // "px" to a few hardcoded values.
  10720. if ( type === "number" && !isCustomProp ) {
  10721. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  10722. }
  10723. // background-* props affect original clone's values
  10724. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  10725. style[ name ] = "inherit";
  10726. }
  10727. // If a hook was provided, use that value, otherwise just set the specified value
  10728. if ( !hooks || !( "set" in hooks ) ||
  10729. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  10730. if ( isCustomProp ) {
  10731. style.setProperty( name, value );
  10732. } else {
  10733. style[ name ] = value;
  10734. }
  10735. }
  10736. } else {
  10737. // If a hook was provided get the non-computed value from there
  10738. if ( hooks && "get" in hooks &&
  10739. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  10740. return ret;
  10741. }
  10742. // Otherwise just get the value from the style object
  10743. return style[ name ];
  10744. }
  10745. },
  10746. css: function( elem, name, extra, styles ) {
  10747. var val, num, hooks,
  10748. origName = camelCase( name ),
  10749. isCustomProp = rcustomProp.test( name );
  10750. // Make sure that we're working with the right name. We don't
  10751. // want to modify the value if it is a CSS custom property
  10752. // since they are user-defined.
  10753. if ( !isCustomProp ) {
  10754. name = finalPropName( origName );
  10755. }
  10756. // Try prefixed name followed by the unprefixed name
  10757. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10758. // If a hook was provided get the computed value from there
  10759. if ( hooks && "get" in hooks ) {
  10760. val = hooks.get( elem, true, extra );
  10761. }
  10762. // Otherwise, if a way to get the computed value exists, use that
  10763. if ( val === undefined ) {
  10764. val = curCSS( elem, name, styles );
  10765. }
  10766. // Convert "normal" to computed value
  10767. if ( val === "normal" && name in cssNormalTransform ) {
  10768. val = cssNormalTransform[ name ];
  10769. }
  10770. // Make numeric if forced or a qualifier was provided and val looks numeric
  10771. if ( extra === "" || extra ) {
  10772. num = parseFloat( val );
  10773. return extra === true || isFinite( num ) ? num || 0 : val;
  10774. }
  10775. return val;
  10776. }
  10777. } );
  10778. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  10779. jQuery.cssHooks[ dimension ] = {
  10780. get: function( elem, computed, extra ) {
  10781. if ( computed ) {
  10782. // Certain elements can have dimension info if we invisibly show them
  10783. // but it must have a current display style that would benefit
  10784. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  10785. // Support: Safari 8+
  10786. // Table columns in Safari have non-zero offsetWidth & zero
  10787. // getBoundingClientRect().width unless display is changed.
  10788. // Support: IE <=11 only
  10789. // Running getBoundingClientRect on a disconnected node
  10790. // in IE throws an error.
  10791. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  10792. swap( elem, cssShow, function() {
  10793. return getWidthOrHeight( elem, dimension, extra );
  10794. } ) :
  10795. getWidthOrHeight( elem, dimension, extra );
  10796. }
  10797. },
  10798. set: function( elem, value, extra ) {
  10799. var matches,
  10800. styles = getStyles( elem ),
  10801. // Only read styles.position if the test has a chance to fail
  10802. // to avoid forcing a reflow.
  10803. scrollboxSizeBuggy = !support.scrollboxSize() &&
  10804. styles.position === "absolute",
  10805. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  10806. boxSizingNeeded = scrollboxSizeBuggy || extra,
  10807. isBorderBox = boxSizingNeeded &&
  10808. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10809. subtract = extra ?
  10810. boxModelAdjustment(
  10811. elem,
  10812. dimension,
  10813. extra,
  10814. isBorderBox,
  10815. styles
  10816. ) :
  10817. 0;
  10818. // Account for unreliable border-box dimensions by comparing offset* to computed and
  10819. // faking a content-box to get border and padding (gh-3699)
  10820. if ( isBorderBox && scrollboxSizeBuggy ) {
  10821. subtract -= Math.ceil(
  10822. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10823. parseFloat( styles[ dimension ] ) -
  10824. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  10825. 0.5
  10826. );
  10827. }
  10828. // Convert to pixels if value adjustment is needed
  10829. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  10830. ( matches[ 3 ] || "px" ) !== "px" ) {
  10831. elem.style[ dimension ] = value;
  10832. value = jQuery.css( elem, dimension );
  10833. }
  10834. return setPositiveNumber( elem, value, subtract );
  10835. }
  10836. };
  10837. } );
  10838. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  10839. function( elem, computed ) {
  10840. if ( computed ) {
  10841. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  10842. elem.getBoundingClientRect().left -
  10843. swap( elem, { marginLeft: 0 }, function() {
  10844. return elem.getBoundingClientRect().left;
  10845. } )
  10846. ) + "px";
  10847. }
  10848. }
  10849. );
  10850. // These hooks are used by animate to expand properties
  10851. jQuery.each( {
  10852. margin: "",
  10853. padding: "",
  10854. border: "Width"
  10855. }, function( prefix, suffix ) {
  10856. jQuery.cssHooks[ prefix + suffix ] = {
  10857. expand: function( value ) {
  10858. var i = 0,
  10859. expanded = {},
  10860. // Assumes a single number if not a string
  10861. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  10862. for ( ; i < 4; i++ ) {
  10863. expanded[ prefix + cssExpand[ i ] + suffix ] =
  10864. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  10865. }
  10866. return expanded;
  10867. }
  10868. };
  10869. if ( prefix !== "margin" ) {
  10870. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  10871. }
  10872. } );
  10873. jQuery.fn.extend( {
  10874. css: function( name, value ) {
  10875. return access( this, function( elem, name, value ) {
  10876. var styles, len,
  10877. map = {},
  10878. i = 0;
  10879. if ( Array.isArray( name ) ) {
  10880. styles = getStyles( elem );
  10881. len = name.length;
  10882. for ( ; i < len; i++ ) {
  10883. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  10884. }
  10885. return map;
  10886. }
  10887. return value !== undefined ?
  10888. jQuery.style( elem, name, value ) :
  10889. jQuery.css( elem, name );
  10890. }, name, value, arguments.length > 1 );
  10891. }
  10892. } );
  10893. function Tween( elem, options, prop, end, easing ) {
  10894. return new Tween.prototype.init( elem, options, prop, end, easing );
  10895. }
  10896. jQuery.Tween = Tween;
  10897. Tween.prototype = {
  10898. constructor: Tween,
  10899. init: function( elem, options, prop, end, easing, unit ) {
  10900. this.elem = elem;
  10901. this.prop = prop;
  10902. this.easing = easing || jQuery.easing._default;
  10903. this.options = options;
  10904. this.start = this.now = this.cur();
  10905. this.end = end;
  10906. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  10907. },
  10908. cur: function() {
  10909. var hooks = Tween.propHooks[ this.prop ];
  10910. return hooks && hooks.get ?
  10911. hooks.get( this ) :
  10912. Tween.propHooks._default.get( this );
  10913. },
  10914. run: function( percent ) {
  10915. var eased,
  10916. hooks = Tween.propHooks[ this.prop ];
  10917. if ( this.options.duration ) {
  10918. this.pos = eased = jQuery.easing[ this.easing ](
  10919. percent, this.options.duration * percent, 0, 1, this.options.duration
  10920. );
  10921. } else {
  10922. this.pos = eased = percent;
  10923. }
  10924. this.now = ( this.end - this.start ) * eased + this.start;
  10925. if ( this.options.step ) {
  10926. this.options.step.call( this.elem, this.now, this );
  10927. }
  10928. if ( hooks && hooks.set ) {
  10929. hooks.set( this );
  10930. } else {
  10931. Tween.propHooks._default.set( this );
  10932. }
  10933. return this;
  10934. }
  10935. };
  10936. Tween.prototype.init.prototype = Tween.prototype;
  10937. Tween.propHooks = {
  10938. _default: {
  10939. get: function( tween ) {
  10940. var result;
  10941. // Use a property on the element directly when it is not a DOM element,
  10942. // or when there is no matching style property that exists.
  10943. if ( tween.elem.nodeType !== 1 ||
  10944. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  10945. return tween.elem[ tween.prop ];
  10946. }
  10947. // Passing an empty string as a 3rd parameter to .css will automatically
  10948. // attempt a parseFloat and fallback to a string if the parse fails.
  10949. // Simple values such as "10px" are parsed to Float;
  10950. // complex values such as "rotate(1rad)" are returned as-is.
  10951. result = jQuery.css( tween.elem, tween.prop, "" );
  10952. // Empty strings, null, undefined and "auto" are converted to 0.
  10953. return !result || result === "auto" ? 0 : result;
  10954. },
  10955. set: function( tween ) {
  10956. // Use step hook for back compat.
  10957. // Use cssHook if its there.
  10958. // Use .style if available and use plain properties where available.
  10959. if ( jQuery.fx.step[ tween.prop ] ) {
  10960. jQuery.fx.step[ tween.prop ]( tween );
  10961. } else if ( tween.elem.nodeType === 1 && (
  10962. jQuery.cssHooks[ tween.prop ] ||
  10963. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  10964. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  10965. } else {
  10966. tween.elem[ tween.prop ] = tween.now;
  10967. }
  10968. }
  10969. }
  10970. };
  10971. // Support: IE <=9 only
  10972. // Panic based approach to setting things on disconnected nodes
  10973. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  10974. set: function( tween ) {
  10975. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  10976. tween.elem[ tween.prop ] = tween.now;
  10977. }
  10978. }
  10979. };
  10980. jQuery.easing = {
  10981. linear: function( p ) {
  10982. return p;
  10983. },
  10984. swing: function( p ) {
  10985. return 0.5 - Math.cos( p * Math.PI ) / 2;
  10986. },
  10987. _default: "swing"
  10988. };
  10989. jQuery.fx = Tween.prototype.init;
  10990. // Back compat <1.8 extension point
  10991. jQuery.fx.step = {};
  10992. var
  10993. fxNow, inProgress,
  10994. rfxtypes = /^(?:toggle|show|hide)$/,
  10995. rrun = /queueHooks$/;
  10996. function schedule() {
  10997. if ( inProgress ) {
  10998. if ( document.hidden === false && window.requestAnimationFrame ) {
  10999. window.requestAnimationFrame( schedule );
  11000. } else {
  11001. window.setTimeout( schedule, jQuery.fx.interval );
  11002. }
  11003. jQuery.fx.tick();
  11004. }
  11005. }
  11006. // Animations created synchronously will run synchronously
  11007. function createFxNow() {
  11008. window.setTimeout( function() {
  11009. fxNow = undefined;
  11010. } );
  11011. return ( fxNow = Date.now() );
  11012. }
  11013. // Generate parameters to create a standard animation
  11014. function genFx( type, includeWidth ) {
  11015. var which,
  11016. i = 0,
  11017. attrs = { height: type };
  11018. // If we include width, step value is 1 to do all cssExpand values,
  11019. // otherwise step value is 2 to skip over Left and Right
  11020. includeWidth = includeWidth ? 1 : 0;
  11021. for ( ; i < 4; i += 2 - includeWidth ) {
  11022. which = cssExpand[ i ];
  11023. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  11024. }
  11025. if ( includeWidth ) {
  11026. attrs.opacity = attrs.width = type;
  11027. }
  11028. return attrs;
  11029. }
  11030. function createTween( value, prop, animation ) {
  11031. var tween,
  11032. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  11033. index = 0,
  11034. length = collection.length;
  11035. for ( ; index < length; index++ ) {
  11036. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  11037. // We're done with this property
  11038. return tween;
  11039. }
  11040. }
  11041. }
  11042. function defaultPrefilter( elem, props, opts ) {
  11043. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  11044. isBox = "width" in props || "height" in props,
  11045. anim = this,
  11046. orig = {},
  11047. style = elem.style,
  11048. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  11049. dataShow = dataPriv.get( elem, "fxshow" );
  11050. // Queue-skipping animations hijack the fx hooks
  11051. if ( !opts.queue ) {
  11052. hooks = jQuery._queueHooks( elem, "fx" );
  11053. if ( hooks.unqueued == null ) {
  11054. hooks.unqueued = 0;
  11055. oldfire = hooks.empty.fire;
  11056. hooks.empty.fire = function() {
  11057. if ( !hooks.unqueued ) {
  11058. oldfire();
  11059. }
  11060. };
  11061. }
  11062. hooks.unqueued++;
  11063. anim.always( function() {
  11064. // Ensure the complete handler is called before this completes
  11065. anim.always( function() {
  11066. hooks.unqueued--;
  11067. if ( !jQuery.queue( elem, "fx" ).length ) {
  11068. hooks.empty.fire();
  11069. }
  11070. } );
  11071. } );
  11072. }
  11073. // Detect show/hide animations
  11074. for ( prop in props ) {
  11075. value = props[ prop ];
  11076. if ( rfxtypes.test( value ) ) {
  11077. delete props[ prop ];
  11078. toggle = toggle || value === "toggle";
  11079. if ( value === ( hidden ? "hide" : "show" ) ) {
  11080. // Pretend to be hidden if this is a "show" and
  11081. // there is still data from a stopped show/hide
  11082. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  11083. hidden = true;
  11084. // Ignore all other no-op show/hide data
  11085. } else {
  11086. continue;
  11087. }
  11088. }
  11089. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  11090. }
  11091. }
  11092. // Bail out if this is a no-op like .hide().hide()
  11093. propTween = !jQuery.isEmptyObject( props );
  11094. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  11095. return;
  11096. }
  11097. // Restrict "overflow" and "display" styles during box animations
  11098. if ( isBox && elem.nodeType === 1 ) {
  11099. // Support: IE <=9 - 11, Edge 12 - 15
  11100. // Record all 3 overflow attributes because IE does not infer the shorthand
  11101. // from identically-valued overflowX and overflowY and Edge just mirrors
  11102. // the overflowX value there.
  11103. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  11104. // Identify a display type, preferring old show/hide data over the CSS cascade
  11105. restoreDisplay = dataShow && dataShow.display;
  11106. if ( restoreDisplay == null ) {
  11107. restoreDisplay = dataPriv.get( elem, "display" );
  11108. }
  11109. display = jQuery.css( elem, "display" );
  11110. if ( display === "none" ) {
  11111. if ( restoreDisplay ) {
  11112. display = restoreDisplay;
  11113. } else {
  11114. // Get nonempty value(s) by temporarily forcing visibility
  11115. showHide( [ elem ], true );
  11116. restoreDisplay = elem.style.display || restoreDisplay;
  11117. display = jQuery.css( elem, "display" );
  11118. showHide( [ elem ] );
  11119. }
  11120. }
  11121. // Animate inline elements as inline-block
  11122. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  11123. if ( jQuery.css( elem, "float" ) === "none" ) {
  11124. // Restore the original display value at the end of pure show/hide animations
  11125. if ( !propTween ) {
  11126. anim.done( function() {
  11127. style.display = restoreDisplay;
  11128. } );
  11129. if ( restoreDisplay == null ) {
  11130. display = style.display;
  11131. restoreDisplay = display === "none" ? "" : display;
  11132. }
  11133. }
  11134. style.display = "inline-block";
  11135. }
  11136. }
  11137. }
  11138. if ( opts.overflow ) {
  11139. style.overflow = "hidden";
  11140. anim.always( function() {
  11141. style.overflow = opts.overflow[ 0 ];
  11142. style.overflowX = opts.overflow[ 1 ];
  11143. style.overflowY = opts.overflow[ 2 ];
  11144. } );
  11145. }
  11146. // Implement show/hide animations
  11147. propTween = false;
  11148. for ( prop in orig ) {
  11149. // General show/hide setup for this element animation
  11150. if ( !propTween ) {
  11151. if ( dataShow ) {
  11152. if ( "hidden" in dataShow ) {
  11153. hidden = dataShow.hidden;
  11154. }
  11155. } else {
  11156. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  11157. }
  11158. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  11159. if ( toggle ) {
  11160. dataShow.hidden = !hidden;
  11161. }
  11162. // Show elements before animating them
  11163. if ( hidden ) {
  11164. showHide( [ elem ], true );
  11165. }
  11166. /* eslint-disable no-loop-func */
  11167. anim.done( function() {
  11168. /* eslint-enable no-loop-func */
  11169. // The final step of a "hide" animation is actually hiding the element
  11170. if ( !hidden ) {
  11171. showHide( [ elem ] );
  11172. }
  11173. dataPriv.remove( elem, "fxshow" );
  11174. for ( prop in orig ) {
  11175. jQuery.style( elem, prop, orig[ prop ] );
  11176. }
  11177. } );
  11178. }
  11179. // Per-property setup
  11180. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  11181. if ( !( prop in dataShow ) ) {
  11182. dataShow[ prop ] = propTween.start;
  11183. if ( hidden ) {
  11184. propTween.end = propTween.start;
  11185. propTween.start = 0;
  11186. }
  11187. }
  11188. }
  11189. }
  11190. function propFilter( props, specialEasing ) {
  11191. var index, name, easing, value, hooks;
  11192. // camelCase, specialEasing and expand cssHook pass
  11193. for ( index in props ) {
  11194. name = camelCase( index );
  11195. easing = specialEasing[ name ];
  11196. value = props[ index ];
  11197. if ( Array.isArray( value ) ) {
  11198. easing = value[ 1 ];
  11199. value = props[ index ] = value[ 0 ];
  11200. }
  11201. if ( index !== name ) {
  11202. props[ name ] = value;
  11203. delete props[ index ];
  11204. }
  11205. hooks = jQuery.cssHooks[ name ];
  11206. if ( hooks && "expand" in hooks ) {
  11207. value = hooks.expand( value );
  11208. delete props[ name ];
  11209. // Not quite $.extend, this won't overwrite existing keys.
  11210. // Reusing 'index' because we have the correct "name"
  11211. for ( index in value ) {
  11212. if ( !( index in props ) ) {
  11213. props[ index ] = value[ index ];
  11214. specialEasing[ index ] = easing;
  11215. }
  11216. }
  11217. } else {
  11218. specialEasing[ name ] = easing;
  11219. }
  11220. }
  11221. }
  11222. function Animation( elem, properties, options ) {
  11223. var result,
  11224. stopped,
  11225. index = 0,
  11226. length = Animation.prefilters.length,
  11227. deferred = jQuery.Deferred().always( function() {
  11228. // Don't match elem in the :animated selector
  11229. delete tick.elem;
  11230. } ),
  11231. tick = function() {
  11232. if ( stopped ) {
  11233. return false;
  11234. }
  11235. var currentTime = fxNow || createFxNow(),
  11236. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  11237. // Support: Android 2.3 only
  11238. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  11239. temp = remaining / animation.duration || 0,
  11240. percent = 1 - temp,
  11241. index = 0,
  11242. length = animation.tweens.length;
  11243. for ( ; index < length; index++ ) {
  11244. animation.tweens[ index ].run( percent );
  11245. }
  11246. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  11247. // If there's more to do, yield
  11248. if ( percent < 1 && length ) {
  11249. return remaining;
  11250. }
  11251. // If this was an empty animation, synthesize a final progress notification
  11252. if ( !length ) {
  11253. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11254. }
  11255. // Resolve the animation and report its conclusion
  11256. deferred.resolveWith( elem, [ animation ] );
  11257. return false;
  11258. },
  11259. animation = deferred.promise( {
  11260. elem: elem,
  11261. props: jQuery.extend( {}, properties ),
  11262. opts: jQuery.extend( true, {
  11263. specialEasing: {},
  11264. easing: jQuery.easing._default
  11265. }, options ),
  11266. originalProperties: properties,
  11267. originalOptions: options,
  11268. startTime: fxNow || createFxNow(),
  11269. duration: options.duration,
  11270. tweens: [],
  11271. createTween: function( prop, end ) {
  11272. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  11273. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  11274. animation.tweens.push( tween );
  11275. return tween;
  11276. },
  11277. stop: function( gotoEnd ) {
  11278. var index = 0,
  11279. // If we are going to the end, we want to run all the tweens
  11280. // otherwise we skip this part
  11281. length = gotoEnd ? animation.tweens.length : 0;
  11282. if ( stopped ) {
  11283. return this;
  11284. }
  11285. stopped = true;
  11286. for ( ; index < length; index++ ) {
  11287. animation.tweens[ index ].run( 1 );
  11288. }
  11289. // Resolve when we played the last frame; otherwise, reject
  11290. if ( gotoEnd ) {
  11291. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11292. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  11293. } else {
  11294. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  11295. }
  11296. return this;
  11297. }
  11298. } ),
  11299. props = animation.props;
  11300. propFilter( props, animation.opts.specialEasing );
  11301. for ( ; index < length; index++ ) {
  11302. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  11303. if ( result ) {
  11304. if ( isFunction( result.stop ) ) {
  11305. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  11306. result.stop.bind( result );
  11307. }
  11308. return result;
  11309. }
  11310. }
  11311. jQuery.map( props, createTween, animation );
  11312. if ( isFunction( animation.opts.start ) ) {
  11313. animation.opts.start.call( elem, animation );
  11314. }
  11315. // Attach callbacks from options
  11316. animation
  11317. .progress( animation.opts.progress )
  11318. .done( animation.opts.done, animation.opts.complete )
  11319. .fail( animation.opts.fail )
  11320. .always( animation.opts.always );
  11321. jQuery.fx.timer(
  11322. jQuery.extend( tick, {
  11323. elem: elem,
  11324. anim: animation,
  11325. queue: animation.opts.queue
  11326. } )
  11327. );
  11328. return animation;
  11329. }
  11330. jQuery.Animation = jQuery.extend( Animation, {
  11331. tweeners: {
  11332. "*": [ function( prop, value ) {
  11333. var tween = this.createTween( prop, value );
  11334. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  11335. return tween;
  11336. } ]
  11337. },
  11338. tweener: function( props, callback ) {
  11339. if ( isFunction( props ) ) {
  11340. callback = props;
  11341. props = [ "*" ];
  11342. } else {
  11343. props = props.match( rnothtmlwhite );
  11344. }
  11345. var prop,
  11346. index = 0,
  11347. length = props.length;
  11348. for ( ; index < length; index++ ) {
  11349. prop = props[ index ];
  11350. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  11351. Animation.tweeners[ prop ].unshift( callback );
  11352. }
  11353. },
  11354. prefilters: [ defaultPrefilter ],
  11355. prefilter: function( callback, prepend ) {
  11356. if ( prepend ) {
  11357. Animation.prefilters.unshift( callback );
  11358. } else {
  11359. Animation.prefilters.push( callback );
  11360. }
  11361. }
  11362. } );
  11363. jQuery.speed = function( speed, easing, fn ) {
  11364. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  11365. complete: fn || !fn && easing ||
  11366. isFunction( speed ) && speed,
  11367. duration: speed,
  11368. easing: fn && easing || easing && !isFunction( easing ) && easing
  11369. };
  11370. // Go to the end state if fx are off
  11371. if ( jQuery.fx.off ) {
  11372. opt.duration = 0;
  11373. } else {
  11374. if ( typeof opt.duration !== "number" ) {
  11375. if ( opt.duration in jQuery.fx.speeds ) {
  11376. opt.duration = jQuery.fx.speeds[ opt.duration ];
  11377. } else {
  11378. opt.duration = jQuery.fx.speeds._default;
  11379. }
  11380. }
  11381. }
  11382. // Normalize opt.queue - true/undefined/null -> "fx"
  11383. if ( opt.queue == null || opt.queue === true ) {
  11384. opt.queue = "fx";
  11385. }
  11386. // Queueing
  11387. opt.old = opt.complete;
  11388. opt.complete = function() {
  11389. if ( isFunction( opt.old ) ) {
  11390. opt.old.call( this );
  11391. }
  11392. if ( opt.queue ) {
  11393. jQuery.dequeue( this, opt.queue );
  11394. }
  11395. };
  11396. return opt;
  11397. };
  11398. jQuery.fn.extend( {
  11399. fadeTo: function( speed, to, easing, callback ) {
  11400. // Show any hidden elements after setting opacity to 0
  11401. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  11402. // Animate to the value specified
  11403. .end().animate( { opacity: to }, speed, easing, callback );
  11404. },
  11405. animate: function( prop, speed, easing, callback ) {
  11406. var empty = jQuery.isEmptyObject( prop ),
  11407. optall = jQuery.speed( speed, easing, callback ),
  11408. doAnimation = function() {
  11409. // Operate on a copy of prop so per-property easing won't be lost
  11410. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  11411. // Empty animations, or finishing resolves immediately
  11412. if ( empty || dataPriv.get( this, "finish" ) ) {
  11413. anim.stop( true );
  11414. }
  11415. };
  11416. doAnimation.finish = doAnimation;
  11417. return empty || optall.queue === false ?
  11418. this.each( doAnimation ) :
  11419. this.queue( optall.queue, doAnimation );
  11420. },
  11421. stop: function( type, clearQueue, gotoEnd ) {
  11422. var stopQueue = function( hooks ) {
  11423. var stop = hooks.stop;
  11424. delete hooks.stop;
  11425. stop( gotoEnd );
  11426. };
  11427. if ( typeof type !== "string" ) {
  11428. gotoEnd = clearQueue;
  11429. clearQueue = type;
  11430. type = undefined;
  11431. }
  11432. if ( clearQueue && type !== false ) {
  11433. this.queue( type || "fx", [] );
  11434. }
  11435. return this.each( function() {
  11436. var dequeue = true,
  11437. index = type != null && type + "queueHooks",
  11438. timers = jQuery.timers,
  11439. data = dataPriv.get( this );
  11440. if ( index ) {
  11441. if ( data[ index ] && data[ index ].stop ) {
  11442. stopQueue( data[ index ] );
  11443. }
  11444. } else {
  11445. for ( index in data ) {
  11446. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  11447. stopQueue( data[ index ] );
  11448. }
  11449. }
  11450. }
  11451. for ( index = timers.length; index--; ) {
  11452. if ( timers[ index ].elem === this &&
  11453. ( type == null || timers[ index ].queue === type ) ) {
  11454. timers[ index ].anim.stop( gotoEnd );
  11455. dequeue = false;
  11456. timers.splice( index, 1 );
  11457. }
  11458. }
  11459. // Start the next in the queue if the last step wasn't forced.
  11460. // Timers currently will call their complete callbacks, which
  11461. // will dequeue but only if they were gotoEnd.
  11462. if ( dequeue || !gotoEnd ) {
  11463. jQuery.dequeue( this, type );
  11464. }
  11465. } );
  11466. },
  11467. finish: function( type ) {
  11468. if ( type !== false ) {
  11469. type = type || "fx";
  11470. }
  11471. return this.each( function() {
  11472. var index,
  11473. data = dataPriv.get( this ),
  11474. queue = data[ type + "queue" ],
  11475. hooks = data[ type + "queueHooks" ],
  11476. timers = jQuery.timers,
  11477. length = queue ? queue.length : 0;
  11478. // Enable finishing flag on private data
  11479. data.finish = true;
  11480. // Empty the queue first
  11481. jQuery.queue( this, type, [] );
  11482. if ( hooks && hooks.stop ) {
  11483. hooks.stop.call( this, true );
  11484. }
  11485. // Look for any active animations, and finish them
  11486. for ( index = timers.length; index--; ) {
  11487. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  11488. timers[ index ].anim.stop( true );
  11489. timers.splice( index, 1 );
  11490. }
  11491. }
  11492. // Look for any animations in the old queue and finish them
  11493. for ( index = 0; index < length; index++ ) {
  11494. if ( queue[ index ] && queue[ index ].finish ) {
  11495. queue[ index ].finish.call( this );
  11496. }
  11497. }
  11498. // Turn off finishing flag
  11499. delete data.finish;
  11500. } );
  11501. }
  11502. } );
  11503. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  11504. var cssFn = jQuery.fn[ name ];
  11505. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11506. return speed == null || typeof speed === "boolean" ?
  11507. cssFn.apply( this, arguments ) :
  11508. this.animate( genFx( name, true ), speed, easing, callback );
  11509. };
  11510. } );
  11511. // Generate shortcuts for custom animations
  11512. jQuery.each( {
  11513. slideDown: genFx( "show" ),
  11514. slideUp: genFx( "hide" ),
  11515. slideToggle: genFx( "toggle" ),
  11516. fadeIn: { opacity: "show" },
  11517. fadeOut: { opacity: "hide" },
  11518. fadeToggle: { opacity: "toggle" }
  11519. }, function( name, props ) {
  11520. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11521. return this.animate( props, speed, easing, callback );
  11522. };
  11523. } );
  11524. jQuery.timers = [];
  11525. jQuery.fx.tick = function() {
  11526. var timer,
  11527. i = 0,
  11528. timers = jQuery.timers;
  11529. fxNow = Date.now();
  11530. for ( ; i < timers.length; i++ ) {
  11531. timer = timers[ i ];
  11532. // Run the timer and safely remove it when done (allowing for external removal)
  11533. if ( !timer() && timers[ i ] === timer ) {
  11534. timers.splice( i--, 1 );
  11535. }
  11536. }
  11537. if ( !timers.length ) {
  11538. jQuery.fx.stop();
  11539. }
  11540. fxNow = undefined;
  11541. };
  11542. jQuery.fx.timer = function( timer ) {
  11543. jQuery.timers.push( timer );
  11544. jQuery.fx.start();
  11545. };
  11546. jQuery.fx.interval = 13;
  11547. jQuery.fx.start = function() {
  11548. if ( inProgress ) {
  11549. return;
  11550. }
  11551. inProgress = true;
  11552. schedule();
  11553. };
  11554. jQuery.fx.stop = function() {
  11555. inProgress = null;
  11556. };
  11557. jQuery.fx.speeds = {
  11558. slow: 600,
  11559. fast: 200,
  11560. // Default speed
  11561. _default: 400
  11562. };
  11563. // Based off of the plugin by Clint Helfers, with permission.
  11564. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  11565. jQuery.fn.delay = function( time, type ) {
  11566. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  11567. type = type || "fx";
  11568. return this.queue( type, function( next, hooks ) {
  11569. var timeout = window.setTimeout( next, time );
  11570. hooks.stop = function() {
  11571. window.clearTimeout( timeout );
  11572. };
  11573. } );
  11574. };
  11575. ( function() {
  11576. var input = document.createElement( "input" ),
  11577. select = document.createElement( "select" ),
  11578. opt = select.appendChild( document.createElement( "option" ) );
  11579. input.type = "checkbox";
  11580. // Support: Android <=4.3 only
  11581. // Default value for a checkbox should be "on"
  11582. support.checkOn = input.value !== "";
  11583. // Support: IE <=11 only
  11584. // Must access selectedIndex to make default options select
  11585. support.optSelected = opt.selected;
  11586. // Support: IE <=11 only
  11587. // An input loses its value after becoming a radio
  11588. input = document.createElement( "input" );
  11589. input.value = "t";
  11590. input.type = "radio";
  11591. support.radioValue = input.value === "t";
  11592. } )();
  11593. var boolHook,
  11594. attrHandle = jQuery.expr.attrHandle;
  11595. jQuery.fn.extend( {
  11596. attr: function( name, value ) {
  11597. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  11598. },
  11599. removeAttr: function( name ) {
  11600. return this.each( function() {
  11601. jQuery.removeAttr( this, name );
  11602. } );
  11603. }
  11604. } );
  11605. jQuery.extend( {
  11606. attr: function( elem, name, value ) {
  11607. var ret, hooks,
  11608. nType = elem.nodeType;
  11609. // Don't get/set attributes on text, comment and attribute nodes
  11610. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11611. return;
  11612. }
  11613. // Fallback to prop when attributes are not supported
  11614. if ( typeof elem.getAttribute === "undefined" ) {
  11615. return jQuery.prop( elem, name, value );
  11616. }
  11617. // Attribute hooks are determined by the lowercase version
  11618. // Grab necessary hook if one is defined
  11619. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11620. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  11621. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  11622. }
  11623. if ( value !== undefined ) {
  11624. if ( value === null ) {
  11625. jQuery.removeAttr( elem, name );
  11626. return;
  11627. }
  11628. if ( hooks && "set" in hooks &&
  11629. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11630. return ret;
  11631. }
  11632. elem.setAttribute( name, value + "" );
  11633. return value;
  11634. }
  11635. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11636. return ret;
  11637. }
  11638. ret = jQuery.find.attr( elem, name );
  11639. // Non-existent attributes return null, we normalize to undefined
  11640. return ret == null ? undefined : ret;
  11641. },
  11642. attrHooks: {
  11643. type: {
  11644. set: function( elem, value ) {
  11645. if ( !support.radioValue && value === "radio" &&
  11646. nodeName( elem, "input" ) ) {
  11647. var val = elem.value;
  11648. elem.setAttribute( "type", value );
  11649. if ( val ) {
  11650. elem.value = val;
  11651. }
  11652. return value;
  11653. }
  11654. }
  11655. }
  11656. },
  11657. removeAttr: function( elem, value ) {
  11658. var name,
  11659. i = 0,
  11660. // Attribute names can contain non-HTML whitespace characters
  11661. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  11662. attrNames = value && value.match( rnothtmlwhite );
  11663. if ( attrNames && elem.nodeType === 1 ) {
  11664. while ( ( name = attrNames[ i++ ] ) ) {
  11665. elem.removeAttribute( name );
  11666. }
  11667. }
  11668. }
  11669. } );
  11670. // Hooks for boolean attributes
  11671. boolHook = {
  11672. set: function( elem, value, name ) {
  11673. if ( value === false ) {
  11674. // Remove boolean attributes when set to false
  11675. jQuery.removeAttr( elem, name );
  11676. } else {
  11677. elem.setAttribute( name, name );
  11678. }
  11679. return name;
  11680. }
  11681. };
  11682. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  11683. var getter = attrHandle[ name ] || jQuery.find.attr;
  11684. attrHandle[ name ] = function( elem, name, isXML ) {
  11685. var ret, handle,
  11686. lowercaseName = name.toLowerCase();
  11687. if ( !isXML ) {
  11688. // Avoid an infinite loop by temporarily removing this function from the getter
  11689. handle = attrHandle[ lowercaseName ];
  11690. attrHandle[ lowercaseName ] = ret;
  11691. ret = getter( elem, name, isXML ) != null ?
  11692. lowercaseName :
  11693. null;
  11694. attrHandle[ lowercaseName ] = handle;
  11695. }
  11696. return ret;
  11697. };
  11698. } );
  11699. var rfocusable = /^(?:input|select|textarea|button)$/i,
  11700. rclickable = /^(?:a|area)$/i;
  11701. jQuery.fn.extend( {
  11702. prop: function( name, value ) {
  11703. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  11704. },
  11705. removeProp: function( name ) {
  11706. return this.each( function() {
  11707. delete this[ jQuery.propFix[ name ] || name ];
  11708. } );
  11709. }
  11710. } );
  11711. jQuery.extend( {
  11712. prop: function( elem, name, value ) {
  11713. var ret, hooks,
  11714. nType = elem.nodeType;
  11715. // Don't get/set properties on text, comment and attribute nodes
  11716. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11717. return;
  11718. }
  11719. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11720. // Fix name and attach hooks
  11721. name = jQuery.propFix[ name ] || name;
  11722. hooks = jQuery.propHooks[ name ];
  11723. }
  11724. if ( value !== undefined ) {
  11725. if ( hooks && "set" in hooks &&
  11726. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11727. return ret;
  11728. }
  11729. return ( elem[ name ] = value );
  11730. }
  11731. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11732. return ret;
  11733. }
  11734. return elem[ name ];
  11735. },
  11736. propHooks: {
  11737. tabIndex: {
  11738. get: function( elem ) {
  11739. // Support: IE <=9 - 11 only
  11740. // elem.tabIndex doesn't always return the
  11741. // correct value when it hasn't been explicitly set
  11742. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  11743. // Use proper attribute retrieval(#12072)
  11744. var tabindex = jQuery.find.attr( elem, "tabindex" );
  11745. if ( tabindex ) {
  11746. return parseInt( tabindex, 10 );
  11747. }
  11748. if (
  11749. rfocusable.test( elem.nodeName ) ||
  11750. rclickable.test( elem.nodeName ) &&
  11751. elem.href
  11752. ) {
  11753. return 0;
  11754. }
  11755. return -1;
  11756. }
  11757. }
  11758. },
  11759. propFix: {
  11760. "for": "htmlFor",
  11761. "class": "className"
  11762. }
  11763. } );
  11764. // Support: IE <=11 only
  11765. // Accessing the selectedIndex property
  11766. // forces the browser to respect setting selected
  11767. // on the option
  11768. // The getter ensures a default option is selected
  11769. // when in an optgroup
  11770. // eslint rule "no-unused-expressions" is disabled for this code
  11771. // since it considers such accessions noop
  11772. if ( !support.optSelected ) {
  11773. jQuery.propHooks.selected = {
  11774. get: function( elem ) {
  11775. /* eslint no-unused-expressions: "off" */
  11776. var parent = elem.parentNode;
  11777. if ( parent && parent.parentNode ) {
  11778. parent.parentNode.selectedIndex;
  11779. }
  11780. return null;
  11781. },
  11782. set: function( elem ) {
  11783. /* eslint no-unused-expressions: "off" */
  11784. var parent = elem.parentNode;
  11785. if ( parent ) {
  11786. parent.selectedIndex;
  11787. if ( parent.parentNode ) {
  11788. parent.parentNode.selectedIndex;
  11789. }
  11790. }
  11791. }
  11792. };
  11793. }
  11794. jQuery.each( [
  11795. "tabIndex",
  11796. "readOnly",
  11797. "maxLength",
  11798. "cellSpacing",
  11799. "cellPadding",
  11800. "rowSpan",
  11801. "colSpan",
  11802. "useMap",
  11803. "frameBorder",
  11804. "contentEditable"
  11805. ], function() {
  11806. jQuery.propFix[ this.toLowerCase() ] = this;
  11807. } );
  11808. // Strip and collapse whitespace according to HTML spec
  11809. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  11810. function stripAndCollapse( value ) {
  11811. var tokens = value.match( rnothtmlwhite ) || [];
  11812. return tokens.join( " " );
  11813. }
  11814. function getClass( elem ) {
  11815. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  11816. }
  11817. function classesToArray( value ) {
  11818. if ( Array.isArray( value ) ) {
  11819. return value;
  11820. }
  11821. if ( typeof value === "string" ) {
  11822. return value.match( rnothtmlwhite ) || [];
  11823. }
  11824. return [];
  11825. }
  11826. jQuery.fn.extend( {
  11827. addClass: function( value ) {
  11828. var classes, elem, cur, curValue, clazz, j, finalValue,
  11829. i = 0;
  11830. if ( isFunction( value ) ) {
  11831. return this.each( function( j ) {
  11832. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  11833. } );
  11834. }
  11835. classes = classesToArray( value );
  11836. if ( classes.length ) {
  11837. while ( ( elem = this[ i++ ] ) ) {
  11838. curValue = getClass( elem );
  11839. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11840. if ( cur ) {
  11841. j = 0;
  11842. while ( ( clazz = classes[ j++ ] ) ) {
  11843. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  11844. cur += clazz + " ";
  11845. }
  11846. }
  11847. // Only assign if different to avoid unneeded rendering.
  11848. finalValue = stripAndCollapse( cur );
  11849. if ( curValue !== finalValue ) {
  11850. elem.setAttribute( "class", finalValue );
  11851. }
  11852. }
  11853. }
  11854. }
  11855. return this;
  11856. },
  11857. removeClass: function( value ) {
  11858. var classes, elem, cur, curValue, clazz, j, finalValue,
  11859. i = 0;
  11860. if ( isFunction( value ) ) {
  11861. return this.each( function( j ) {
  11862. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  11863. } );
  11864. }
  11865. if ( !arguments.length ) {
  11866. return this.attr( "class", "" );
  11867. }
  11868. classes = classesToArray( value );
  11869. if ( classes.length ) {
  11870. while ( ( elem = this[ i++ ] ) ) {
  11871. curValue = getClass( elem );
  11872. // This expression is here for better compressibility (see addClass)
  11873. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11874. if ( cur ) {
  11875. j = 0;
  11876. while ( ( clazz = classes[ j++ ] ) ) {
  11877. // Remove *all* instances
  11878. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  11879. cur = cur.replace( " " + clazz + " ", " " );
  11880. }
  11881. }
  11882. // Only assign if different to avoid unneeded rendering.
  11883. finalValue = stripAndCollapse( cur );
  11884. if ( curValue !== finalValue ) {
  11885. elem.setAttribute( "class", finalValue );
  11886. }
  11887. }
  11888. }
  11889. }
  11890. return this;
  11891. },
  11892. toggleClass: function( value, stateVal ) {
  11893. var type = typeof value,
  11894. isValidValue = type === "string" || Array.isArray( value );
  11895. if ( typeof stateVal === "boolean" && isValidValue ) {
  11896. return stateVal ? this.addClass( value ) : this.removeClass( value );
  11897. }
  11898. if ( isFunction( value ) ) {
  11899. return this.each( function( i ) {
  11900. jQuery( this ).toggleClass(
  11901. value.call( this, i, getClass( this ), stateVal ),
  11902. stateVal
  11903. );
  11904. } );
  11905. }
  11906. return this.each( function() {
  11907. var className, i, self, classNames;
  11908. if ( isValidValue ) {
  11909. // Toggle individual class names
  11910. i = 0;
  11911. self = jQuery( this );
  11912. classNames = classesToArray( value );
  11913. while ( ( className = classNames[ i++ ] ) ) {
  11914. // Check each className given, space separated list
  11915. if ( self.hasClass( className ) ) {
  11916. self.removeClass( className );
  11917. } else {
  11918. self.addClass( className );
  11919. }
  11920. }
  11921. // Toggle whole class name
  11922. } else if ( value === undefined || type === "boolean" ) {
  11923. className = getClass( this );
  11924. if ( className ) {
  11925. // Store className if set
  11926. dataPriv.set( this, "__className__", className );
  11927. }
  11928. // If the element has a class name or if we're passed `false`,
  11929. // then remove the whole classname (if there was one, the above saved it).
  11930. // Otherwise bring back whatever was previously saved (if anything),
  11931. // falling back to the empty string if nothing was stored.
  11932. if ( this.setAttribute ) {
  11933. this.setAttribute( "class",
  11934. className || value === false ?
  11935. "" :
  11936. dataPriv.get( this, "__className__" ) || ""
  11937. );
  11938. }
  11939. }
  11940. } );
  11941. },
  11942. hasClass: function( selector ) {
  11943. var className, elem,
  11944. i = 0;
  11945. className = " " + selector + " ";
  11946. while ( ( elem = this[ i++ ] ) ) {
  11947. if ( elem.nodeType === 1 &&
  11948. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  11949. return true;
  11950. }
  11951. }
  11952. return false;
  11953. }
  11954. } );
  11955. var rreturn = /\r/g;
  11956. jQuery.fn.extend( {
  11957. val: function( value ) {
  11958. var hooks, ret, valueIsFunction,
  11959. elem = this[ 0 ];
  11960. if ( !arguments.length ) {
  11961. if ( elem ) {
  11962. hooks = jQuery.valHooks[ elem.type ] ||
  11963. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  11964. if ( hooks &&
  11965. "get" in hooks &&
  11966. ( ret = hooks.get( elem, "value" ) ) !== undefined
  11967. ) {
  11968. return ret;
  11969. }
  11970. ret = elem.value;
  11971. // Handle most common string cases
  11972. if ( typeof ret === "string" ) {
  11973. return ret.replace( rreturn, "" );
  11974. }
  11975. // Handle cases where value is null/undef or number
  11976. return ret == null ? "" : ret;
  11977. }
  11978. return;
  11979. }
  11980. valueIsFunction = isFunction( value );
  11981. return this.each( function( i ) {
  11982. var val;
  11983. if ( this.nodeType !== 1 ) {
  11984. return;
  11985. }
  11986. if ( valueIsFunction ) {
  11987. val = value.call( this, i, jQuery( this ).val() );
  11988. } else {
  11989. val = value;
  11990. }
  11991. // Treat null/undefined as ""; convert numbers to string
  11992. if ( val == null ) {
  11993. val = "";
  11994. } else if ( typeof val === "number" ) {
  11995. val += "";
  11996. } else if ( Array.isArray( val ) ) {
  11997. val = jQuery.map( val, function( value ) {
  11998. return value == null ? "" : value + "";
  11999. } );
  12000. }
  12001. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  12002. // If set returns undefined, fall back to normal setting
  12003. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  12004. this.value = val;
  12005. }
  12006. } );
  12007. }
  12008. } );
  12009. jQuery.extend( {
  12010. valHooks: {
  12011. option: {
  12012. get: function( elem ) {
  12013. var val = jQuery.find.attr( elem, "value" );
  12014. return val != null ?
  12015. val :
  12016. // Support: IE <=10 - 11 only
  12017. // option.text throws exceptions (#14686, #14858)
  12018. // Strip and collapse whitespace
  12019. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  12020. stripAndCollapse( jQuery.text( elem ) );
  12021. }
  12022. },
  12023. select: {
  12024. get: function( elem ) {
  12025. var value, option, i,
  12026. options = elem.options,
  12027. index = elem.selectedIndex,
  12028. one = elem.type === "select-one",
  12029. values = one ? null : [],
  12030. max = one ? index + 1 : options.length;
  12031. if ( index < 0 ) {
  12032. i = max;
  12033. } else {
  12034. i = one ? index : 0;
  12035. }
  12036. // Loop through all the selected options
  12037. for ( ; i < max; i++ ) {
  12038. option = options[ i ];
  12039. // Support: IE <=9 only
  12040. // IE8-9 doesn't update selected after form reset (#2551)
  12041. if ( ( option.selected || i === index ) &&
  12042. // Don't return options that are disabled or in a disabled optgroup
  12043. !option.disabled &&
  12044. ( !option.parentNode.disabled ||
  12045. !nodeName( option.parentNode, "optgroup" ) ) ) {
  12046. // Get the specific value for the option
  12047. value = jQuery( option ).val();
  12048. // We don't need an array for one selects
  12049. if ( one ) {
  12050. return value;
  12051. }
  12052. // Multi-Selects return an array
  12053. values.push( value );
  12054. }
  12055. }
  12056. return values;
  12057. },
  12058. set: function( elem, value ) {
  12059. var optionSet, option,
  12060. options = elem.options,
  12061. values = jQuery.makeArray( value ),
  12062. i = options.length;
  12063. while ( i-- ) {
  12064. option = options[ i ];
  12065. /* eslint-disable no-cond-assign */
  12066. if ( option.selected =
  12067. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  12068. ) {
  12069. optionSet = true;
  12070. }
  12071. /* eslint-enable no-cond-assign */
  12072. }
  12073. // Force browsers to behave consistently when non-matching value is set
  12074. if ( !optionSet ) {
  12075. elem.selectedIndex = -1;
  12076. }
  12077. return values;
  12078. }
  12079. }
  12080. }
  12081. } );
  12082. // Radios and checkboxes getter/setter
  12083. jQuery.each( [ "radio", "checkbox" ], function() {
  12084. jQuery.valHooks[ this ] = {
  12085. set: function( elem, value ) {
  12086. if ( Array.isArray( value ) ) {
  12087. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  12088. }
  12089. }
  12090. };
  12091. if ( !support.checkOn ) {
  12092. jQuery.valHooks[ this ].get = function( elem ) {
  12093. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  12094. };
  12095. }
  12096. } );
  12097. // Return jQuery for attributes-only inclusion
  12098. support.focusin = "onfocusin" in window;
  12099. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  12100. stopPropagationCallback = function( e ) {
  12101. e.stopPropagation();
  12102. };
  12103. jQuery.extend( jQuery.event, {
  12104. trigger: function( event, data, elem, onlyHandlers ) {
  12105. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  12106. eventPath = [ elem || document ],
  12107. type = hasOwn.call( event, "type" ) ? event.type : event,
  12108. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  12109. cur = lastElement = tmp = elem = elem || document;
  12110. // Don't do events on text and comment nodes
  12111. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  12112. return;
  12113. }
  12114. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  12115. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  12116. return;
  12117. }
  12118. if ( type.indexOf( "." ) > -1 ) {
  12119. // Namespaced trigger; create a regexp to match event type in handle()
  12120. namespaces = type.split( "." );
  12121. type = namespaces.shift();
  12122. namespaces.sort();
  12123. }
  12124. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  12125. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  12126. event = event[ jQuery.expando ] ?
  12127. event :
  12128. new jQuery.Event( type, typeof event === "object" && event );
  12129. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  12130. event.isTrigger = onlyHandlers ? 2 : 3;
  12131. event.namespace = namespaces.join( "." );
  12132. event.rnamespace = event.namespace ?
  12133. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  12134. null;
  12135. // Clean up the event in case it is being reused
  12136. event.result = undefined;
  12137. if ( !event.target ) {
  12138. event.target = elem;
  12139. }
  12140. // Clone any incoming data and prepend the event, creating the handler arg list
  12141. data = data == null ?
  12142. [ event ] :
  12143. jQuery.makeArray( data, [ event ] );
  12144. // Allow special events to draw outside the lines
  12145. special = jQuery.event.special[ type ] || {};
  12146. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  12147. return;
  12148. }
  12149. // Determine event propagation path in advance, per W3C events spec (#9951)
  12150. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  12151. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  12152. bubbleType = special.delegateType || type;
  12153. if ( !rfocusMorph.test( bubbleType + type ) ) {
  12154. cur = cur.parentNode;
  12155. }
  12156. for ( ; cur; cur = cur.parentNode ) {
  12157. eventPath.push( cur );
  12158. tmp = cur;
  12159. }
  12160. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  12161. if ( tmp === ( elem.ownerDocument || document ) ) {
  12162. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  12163. }
  12164. }
  12165. // Fire handlers on the event path
  12166. i = 0;
  12167. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  12168. lastElement = cur;
  12169. event.type = i > 1 ?
  12170. bubbleType :
  12171. special.bindType || type;
  12172. // jQuery handler
  12173. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  12174. dataPriv.get( cur, "handle" );
  12175. if ( handle ) {
  12176. handle.apply( cur, data );
  12177. }
  12178. // Native handler
  12179. handle = ontype && cur[ ontype ];
  12180. if ( handle && handle.apply && acceptData( cur ) ) {
  12181. event.result = handle.apply( cur, data );
  12182. if ( event.result === false ) {
  12183. event.preventDefault();
  12184. }
  12185. }
  12186. }
  12187. event.type = type;
  12188. // If nobody prevented the default action, do it now
  12189. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  12190. if ( ( !special._default ||
  12191. special._default.apply( eventPath.pop(), data ) === false ) &&
  12192. acceptData( elem ) ) {
  12193. // Call a native DOM method on the target with the same name as the event.
  12194. // Don't do default actions on window, that's where global variables be (#6170)
  12195. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  12196. // Don't re-trigger an onFOO event when we call its FOO() method
  12197. tmp = elem[ ontype ];
  12198. if ( tmp ) {
  12199. elem[ ontype ] = null;
  12200. }
  12201. // Prevent re-triggering of the same event, since we already bubbled it above
  12202. jQuery.event.triggered = type;
  12203. if ( event.isPropagationStopped() ) {
  12204. lastElement.addEventListener( type, stopPropagationCallback );
  12205. }
  12206. elem[ type ]();
  12207. if ( event.isPropagationStopped() ) {
  12208. lastElement.removeEventListener( type, stopPropagationCallback );
  12209. }
  12210. jQuery.event.triggered = undefined;
  12211. if ( tmp ) {
  12212. elem[ ontype ] = tmp;
  12213. }
  12214. }
  12215. }
  12216. }
  12217. return event.result;
  12218. },
  12219. // Piggyback on a donor event to simulate a different one
  12220. // Used only for `focus(in | out)` events
  12221. simulate: function( type, elem, event ) {
  12222. var e = jQuery.extend(
  12223. new jQuery.Event(),
  12224. event,
  12225. {
  12226. type: type,
  12227. isSimulated: true
  12228. }
  12229. );
  12230. jQuery.event.trigger( e, null, elem );
  12231. }
  12232. } );
  12233. jQuery.fn.extend( {
  12234. trigger: function( type, data ) {
  12235. return this.each( function() {
  12236. jQuery.event.trigger( type, data, this );
  12237. } );
  12238. },
  12239. triggerHandler: function( type, data ) {
  12240. var elem = this[ 0 ];
  12241. if ( elem ) {
  12242. return jQuery.event.trigger( type, data, elem, true );
  12243. }
  12244. }
  12245. } );
  12246. // Support: Firefox <=44
  12247. // Firefox doesn't have focus(in | out) events
  12248. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  12249. //
  12250. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  12251. // focus(in | out) events fire after focus & blur events,
  12252. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  12253. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  12254. if ( !support.focusin ) {
  12255. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  12256. // Attach a single capturing handler on the document while someone wants focusin/focusout
  12257. var handler = function( event ) {
  12258. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  12259. };
  12260. jQuery.event.special[ fix ] = {
  12261. setup: function() {
  12262. var doc = this.ownerDocument || this,
  12263. attaches = dataPriv.access( doc, fix );
  12264. if ( !attaches ) {
  12265. doc.addEventListener( orig, handler, true );
  12266. }
  12267. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  12268. },
  12269. teardown: function() {
  12270. var doc = this.ownerDocument || this,
  12271. attaches = dataPriv.access( doc, fix ) - 1;
  12272. if ( !attaches ) {
  12273. doc.removeEventListener( orig, handler, true );
  12274. dataPriv.remove( doc, fix );
  12275. } else {
  12276. dataPriv.access( doc, fix, attaches );
  12277. }
  12278. }
  12279. };
  12280. } );
  12281. }
  12282. var location = window.location;
  12283. var nonce = Date.now();
  12284. var rquery = ( /\?/ );
  12285. // Cross-browser xml parsing
  12286. jQuery.parseXML = function( data ) {
  12287. var xml;
  12288. if ( !data || typeof data !== "string" ) {
  12289. return null;
  12290. }
  12291. // Support: IE 9 - 11 only
  12292. // IE throws on parseFromString with invalid input.
  12293. try {
  12294. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  12295. } catch ( e ) {
  12296. xml = undefined;
  12297. }
  12298. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  12299. jQuery.error( "Invalid XML: " + data );
  12300. }
  12301. return xml;
  12302. };
  12303. var
  12304. rbracket = /\[\]$/,
  12305. rCRLF = /\r?\n/g,
  12306. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  12307. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  12308. function buildParams( prefix, obj, traditional, add ) {
  12309. var name;
  12310. if ( Array.isArray( obj ) ) {
  12311. // Serialize array item.
  12312. jQuery.each( obj, function( i, v ) {
  12313. if ( traditional || rbracket.test( prefix ) ) {
  12314. // Treat each array item as a scalar.
  12315. add( prefix, v );
  12316. } else {
  12317. // Item is non-scalar (array or object), encode its numeric index.
  12318. buildParams(
  12319. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  12320. v,
  12321. traditional,
  12322. add
  12323. );
  12324. }
  12325. } );
  12326. } else if ( !traditional && toType( obj ) === "object" ) {
  12327. // Serialize object item.
  12328. for ( name in obj ) {
  12329. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  12330. }
  12331. } else {
  12332. // Serialize scalar item.
  12333. add( prefix, obj );
  12334. }
  12335. }
  12336. // Serialize an array of form elements or a set of
  12337. // key/values into a query string
  12338. jQuery.param = function( a, traditional ) {
  12339. var prefix,
  12340. s = [],
  12341. add = function( key, valueOrFunction ) {
  12342. // If value is a function, invoke it and use its return value
  12343. var value = isFunction( valueOrFunction ) ?
  12344. valueOrFunction() :
  12345. valueOrFunction;
  12346. s[ s.length ] = encodeURIComponent( key ) + "=" +
  12347. encodeURIComponent( value == null ? "" : value );
  12348. };
  12349. if ( a == null ) {
  12350. return "";
  12351. }
  12352. // If an array was passed in, assume that it is an array of form elements.
  12353. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  12354. // Serialize the form elements
  12355. jQuery.each( a, function() {
  12356. add( this.name, this.value );
  12357. } );
  12358. } else {
  12359. // If traditional, encode the "old" way (the way 1.3.2 or older
  12360. // did it), otherwise encode params recursively.
  12361. for ( prefix in a ) {
  12362. buildParams( prefix, a[ prefix ], traditional, add );
  12363. }
  12364. }
  12365. // Return the resulting serialization
  12366. return s.join( "&" );
  12367. };
  12368. jQuery.fn.extend( {
  12369. serialize: function() {
  12370. return jQuery.param( this.serializeArray() );
  12371. },
  12372. serializeArray: function() {
  12373. return this.map( function() {
  12374. // Can add propHook for "elements" to filter or add form elements
  12375. var elements = jQuery.prop( this, "elements" );
  12376. return elements ? jQuery.makeArray( elements ) : this;
  12377. } )
  12378. .filter( function() {
  12379. var type = this.type;
  12380. // Use .is( ":disabled" ) so that fieldset[disabled] works
  12381. return this.name && !jQuery( this ).is( ":disabled" ) &&
  12382. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  12383. ( this.checked || !rcheckableType.test( type ) );
  12384. } )
  12385. .map( function( i, elem ) {
  12386. var val = jQuery( this ).val();
  12387. if ( val == null ) {
  12388. return null;
  12389. }
  12390. if ( Array.isArray( val ) ) {
  12391. return jQuery.map( val, function( val ) {
  12392. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12393. } );
  12394. }
  12395. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12396. } ).get();
  12397. }
  12398. } );
  12399. var
  12400. r20 = /%20/g,
  12401. rhash = /#.*$/,
  12402. rantiCache = /([?&])_=[^&]*/,
  12403. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  12404. // #7653, #8125, #8152: local protocol detection
  12405. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  12406. rnoContent = /^(?:GET|HEAD)$/,
  12407. rprotocol = /^\/\//,
  12408. /* Prefilters
  12409. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  12410. * 2) These are called:
  12411. * - BEFORE asking for a transport
  12412. * - AFTER param serialization (s.data is a string if s.processData is true)
  12413. * 3) key is the dataType
  12414. * 4) the catchall symbol "*" can be used
  12415. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  12416. */
  12417. prefilters = {},
  12418. /* Transports bindings
  12419. * 1) key is the dataType
  12420. * 2) the catchall symbol "*" can be used
  12421. * 3) selection will start with transport dataType and THEN go to "*" if needed
  12422. */
  12423. transports = {},
  12424. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  12425. allTypes = "*/".concat( "*" ),
  12426. // Anchor tag for parsing the document origin
  12427. originAnchor = document.createElement( "a" );
  12428. originAnchor.href = location.href;
  12429. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  12430. function addToPrefiltersOrTransports( structure ) {
  12431. // dataTypeExpression is optional and defaults to "*"
  12432. return function( dataTypeExpression, func ) {
  12433. if ( typeof dataTypeExpression !== "string" ) {
  12434. func = dataTypeExpression;
  12435. dataTypeExpression = "*";
  12436. }
  12437. var dataType,
  12438. i = 0,
  12439. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  12440. if ( isFunction( func ) ) {
  12441. // For each dataType in the dataTypeExpression
  12442. while ( ( dataType = dataTypes[ i++ ] ) ) {
  12443. // Prepend if requested
  12444. if ( dataType[ 0 ] === "+" ) {
  12445. dataType = dataType.slice( 1 ) || "*";
  12446. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  12447. // Otherwise append
  12448. } else {
  12449. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  12450. }
  12451. }
  12452. }
  12453. };
  12454. }
  12455. // Base inspection function for prefilters and transports
  12456. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  12457. var inspected = {},
  12458. seekingTransport = ( structure === transports );
  12459. function inspect( dataType ) {
  12460. var selected;
  12461. inspected[ dataType ] = true;
  12462. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  12463. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  12464. if ( typeof dataTypeOrTransport === "string" &&
  12465. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  12466. options.dataTypes.unshift( dataTypeOrTransport );
  12467. inspect( dataTypeOrTransport );
  12468. return false;
  12469. } else if ( seekingTransport ) {
  12470. return !( selected = dataTypeOrTransport );
  12471. }
  12472. } );
  12473. return selected;
  12474. }
  12475. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  12476. }
  12477. // A special extend for ajax options
  12478. // that takes "flat" options (not to be deep extended)
  12479. // Fixes #9887
  12480. function ajaxExtend( target, src ) {
  12481. var key, deep,
  12482. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  12483. for ( key in src ) {
  12484. if ( src[ key ] !== undefined ) {
  12485. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  12486. }
  12487. }
  12488. if ( deep ) {
  12489. jQuery.extend( true, target, deep );
  12490. }
  12491. return target;
  12492. }
  12493. /* Handles responses to an ajax request:
  12494. * - finds the right dataType (mediates between content-type and expected dataType)
  12495. * - returns the corresponding response
  12496. */
  12497. function ajaxHandleResponses( s, jqXHR, responses ) {
  12498. var ct, type, finalDataType, firstDataType,
  12499. contents = s.contents,
  12500. dataTypes = s.dataTypes;
  12501. // Remove auto dataType and get content-type in the process
  12502. while ( dataTypes[ 0 ] === "*" ) {
  12503. dataTypes.shift();
  12504. if ( ct === undefined ) {
  12505. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  12506. }
  12507. }
  12508. // Check if we're dealing with a known content-type
  12509. if ( ct ) {
  12510. for ( type in contents ) {
  12511. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  12512. dataTypes.unshift( type );
  12513. break;
  12514. }
  12515. }
  12516. }
  12517. // Check to see if we have a response for the expected dataType
  12518. if ( dataTypes[ 0 ] in responses ) {
  12519. finalDataType = dataTypes[ 0 ];
  12520. } else {
  12521. // Try convertible dataTypes
  12522. for ( type in responses ) {
  12523. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  12524. finalDataType = type;
  12525. break;
  12526. }
  12527. if ( !firstDataType ) {
  12528. firstDataType = type;
  12529. }
  12530. }
  12531. // Or just use first one
  12532. finalDataType = finalDataType || firstDataType;
  12533. }
  12534. // If we found a dataType
  12535. // We add the dataType to the list if needed
  12536. // and return the corresponding response
  12537. if ( finalDataType ) {
  12538. if ( finalDataType !== dataTypes[ 0 ] ) {
  12539. dataTypes.unshift( finalDataType );
  12540. }
  12541. return responses[ finalDataType ];
  12542. }
  12543. }
  12544. /* Chain conversions given the request and the original response
  12545. * Also sets the responseXXX fields on the jqXHR instance
  12546. */
  12547. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  12548. var conv2, current, conv, tmp, prev,
  12549. converters = {},
  12550. // Work with a copy of dataTypes in case we need to modify it for conversion
  12551. dataTypes = s.dataTypes.slice();
  12552. // Create converters map with lowercased keys
  12553. if ( dataTypes[ 1 ] ) {
  12554. for ( conv in s.converters ) {
  12555. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  12556. }
  12557. }
  12558. current = dataTypes.shift();
  12559. // Convert to each sequential dataType
  12560. while ( current ) {
  12561. if ( s.responseFields[ current ] ) {
  12562. jqXHR[ s.responseFields[ current ] ] = response;
  12563. }
  12564. // Apply the dataFilter if provided
  12565. if ( !prev && isSuccess && s.dataFilter ) {
  12566. response = s.dataFilter( response, s.dataType );
  12567. }
  12568. prev = current;
  12569. current = dataTypes.shift();
  12570. if ( current ) {
  12571. // There's only work to do if current dataType is non-auto
  12572. if ( current === "*" ) {
  12573. current = prev;
  12574. // Convert response if prev dataType is non-auto and differs from current
  12575. } else if ( prev !== "*" && prev !== current ) {
  12576. // Seek a direct converter
  12577. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  12578. // If none found, seek a pair
  12579. if ( !conv ) {
  12580. for ( conv2 in converters ) {
  12581. // If conv2 outputs current
  12582. tmp = conv2.split( " " );
  12583. if ( tmp[ 1 ] === current ) {
  12584. // If prev can be converted to accepted input
  12585. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  12586. converters[ "* " + tmp[ 0 ] ];
  12587. if ( conv ) {
  12588. // Condense equivalence converters
  12589. if ( conv === true ) {
  12590. conv = converters[ conv2 ];
  12591. // Otherwise, insert the intermediate dataType
  12592. } else if ( converters[ conv2 ] !== true ) {
  12593. current = tmp[ 0 ];
  12594. dataTypes.unshift( tmp[ 1 ] );
  12595. }
  12596. break;
  12597. }
  12598. }
  12599. }
  12600. }
  12601. // Apply converter (if not an equivalence)
  12602. if ( conv !== true ) {
  12603. // Unless errors are allowed to bubble, catch and return them
  12604. if ( conv && s.throws ) {
  12605. response = conv( response );
  12606. } else {
  12607. try {
  12608. response = conv( response );
  12609. } catch ( e ) {
  12610. return {
  12611. state: "parsererror",
  12612. error: conv ? e : "No conversion from " + prev + " to " + current
  12613. };
  12614. }
  12615. }
  12616. }
  12617. }
  12618. }
  12619. }
  12620. return { state: "success", data: response };
  12621. }
  12622. jQuery.extend( {
  12623. // Counter for holding the number of active queries
  12624. active: 0,
  12625. // Last-Modified header cache for next request
  12626. lastModified: {},
  12627. etag: {},
  12628. ajaxSettings: {
  12629. url: location.href,
  12630. type: "GET",
  12631. isLocal: rlocalProtocol.test( location.protocol ),
  12632. global: true,
  12633. processData: true,
  12634. async: true,
  12635. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  12636. /*
  12637. timeout: 0,
  12638. data: null,
  12639. dataType: null,
  12640. username: null,
  12641. password: null,
  12642. cache: null,
  12643. throws: false,
  12644. traditional: false,
  12645. headers: {},
  12646. */
  12647. accepts: {
  12648. "*": allTypes,
  12649. text: "text/plain",
  12650. html: "text/html",
  12651. xml: "application/xml, text/xml",
  12652. json: "application/json, text/javascript"
  12653. },
  12654. contents: {
  12655. xml: /\bxml\b/,
  12656. html: /\bhtml/,
  12657. json: /\bjson\b/
  12658. },
  12659. responseFields: {
  12660. xml: "responseXML",
  12661. text: "responseText",
  12662. json: "responseJSON"
  12663. },
  12664. // Data converters
  12665. // Keys separate source (or catchall "*") and destination types with a single space
  12666. converters: {
  12667. // Convert anything to text
  12668. "* text": String,
  12669. // Text to html (true = no transformation)
  12670. "text html": true,
  12671. // Evaluate text as a json expression
  12672. "text json": JSON.parse,
  12673. // Parse text as xml
  12674. "text xml": jQuery.parseXML
  12675. },
  12676. // For options that shouldn't be deep extended:
  12677. // you can add your own custom options here if
  12678. // and when you create one that shouldn't be
  12679. // deep extended (see ajaxExtend)
  12680. flatOptions: {
  12681. url: true,
  12682. context: true
  12683. }
  12684. },
  12685. // Creates a full fledged settings object into target
  12686. // with both ajaxSettings and settings fields.
  12687. // If target is omitted, writes into ajaxSettings.
  12688. ajaxSetup: function( target, settings ) {
  12689. return settings ?
  12690. // Building a settings object
  12691. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  12692. // Extending ajaxSettings
  12693. ajaxExtend( jQuery.ajaxSettings, target );
  12694. },
  12695. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  12696. ajaxTransport: addToPrefiltersOrTransports( transports ),
  12697. // Main method
  12698. ajax: function( url, options ) {
  12699. // If url is an object, simulate pre-1.5 signature
  12700. if ( typeof url === "object" ) {
  12701. options = url;
  12702. url = undefined;
  12703. }
  12704. // Force options to be an object
  12705. options = options || {};
  12706. var transport,
  12707. // URL without anti-cache param
  12708. cacheURL,
  12709. // Response headers
  12710. responseHeadersString,
  12711. responseHeaders,
  12712. // timeout handle
  12713. timeoutTimer,
  12714. // Url cleanup var
  12715. urlAnchor,
  12716. // Request state (becomes false upon send and true upon completion)
  12717. completed,
  12718. // To know if global events are to be dispatched
  12719. fireGlobals,
  12720. // Loop variable
  12721. i,
  12722. // uncached part of the url
  12723. uncached,
  12724. // Create the final options object
  12725. s = jQuery.ajaxSetup( {}, options ),
  12726. // Callbacks context
  12727. callbackContext = s.context || s,
  12728. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  12729. globalEventContext = s.context &&
  12730. ( callbackContext.nodeType || callbackContext.jquery ) ?
  12731. jQuery( callbackContext ) :
  12732. jQuery.event,
  12733. // Deferreds
  12734. deferred = jQuery.Deferred(),
  12735. completeDeferred = jQuery.Callbacks( "once memory" ),
  12736. // Status-dependent callbacks
  12737. statusCode = s.statusCode || {},
  12738. // Headers (they are sent all at once)
  12739. requestHeaders = {},
  12740. requestHeadersNames = {},
  12741. // Default abort message
  12742. strAbort = "canceled",
  12743. // Fake xhr
  12744. jqXHR = {
  12745. readyState: 0,
  12746. // Builds headers hashtable if needed
  12747. getResponseHeader: function( key ) {
  12748. var match;
  12749. if ( completed ) {
  12750. if ( !responseHeaders ) {
  12751. responseHeaders = {};
  12752. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  12753. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  12754. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  12755. .concat( match[ 2 ] );
  12756. }
  12757. }
  12758. match = responseHeaders[ key.toLowerCase() + " " ];
  12759. }
  12760. return match == null ? null : match.join( ", " );
  12761. },
  12762. // Raw string
  12763. getAllResponseHeaders: function() {
  12764. return completed ? responseHeadersString : null;
  12765. },
  12766. // Caches the header
  12767. setRequestHeader: function( name, value ) {
  12768. if ( completed == null ) {
  12769. name = requestHeadersNames[ name.toLowerCase() ] =
  12770. requestHeadersNames[ name.toLowerCase() ] || name;
  12771. requestHeaders[ name ] = value;
  12772. }
  12773. return this;
  12774. },
  12775. // Overrides response content-type header
  12776. overrideMimeType: function( type ) {
  12777. if ( completed == null ) {
  12778. s.mimeType = type;
  12779. }
  12780. return this;
  12781. },
  12782. // Status-dependent callbacks
  12783. statusCode: function( map ) {
  12784. var code;
  12785. if ( map ) {
  12786. if ( completed ) {
  12787. // Execute the appropriate callbacks
  12788. jqXHR.always( map[ jqXHR.status ] );
  12789. } else {
  12790. // Lazy-add the new callbacks in a way that preserves old ones
  12791. for ( code in map ) {
  12792. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  12793. }
  12794. }
  12795. }
  12796. return this;
  12797. },
  12798. // Cancel the request
  12799. abort: function( statusText ) {
  12800. var finalText = statusText || strAbort;
  12801. if ( transport ) {
  12802. transport.abort( finalText );
  12803. }
  12804. done( 0, finalText );
  12805. return this;
  12806. }
  12807. };
  12808. // Attach deferreds
  12809. deferred.promise( jqXHR );
  12810. // Add protocol if not provided (prefilters might expect it)
  12811. // Handle falsy url in the settings object (#10093: consistency with old signature)
  12812. // We also use the url parameter if available
  12813. s.url = ( ( url || s.url || location.href ) + "" )
  12814. .replace( rprotocol, location.protocol + "//" );
  12815. // Alias method option to type as per ticket #12004
  12816. s.type = options.method || options.type || s.method || s.type;
  12817. // Extract dataTypes list
  12818. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  12819. // A cross-domain request is in order when the origin doesn't match the current origin.
  12820. if ( s.crossDomain == null ) {
  12821. urlAnchor = document.createElement( "a" );
  12822. // Support: IE <=8 - 11, Edge 12 - 15
  12823. // IE throws exception on accessing the href property if url is malformed,
  12824. // e.g. http://example.com:80x/
  12825. try {
  12826. urlAnchor.href = s.url;
  12827. // Support: IE <=8 - 11 only
  12828. // Anchor's host property isn't correctly set when s.url is relative
  12829. urlAnchor.href = urlAnchor.href;
  12830. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  12831. urlAnchor.protocol + "//" + urlAnchor.host;
  12832. } catch ( e ) {
  12833. // If there is an error parsing the URL, assume it is crossDomain,
  12834. // it can be rejected by the transport if it is invalid
  12835. s.crossDomain = true;
  12836. }
  12837. }
  12838. // Convert data if not already a string
  12839. if ( s.data && s.processData && typeof s.data !== "string" ) {
  12840. s.data = jQuery.param( s.data, s.traditional );
  12841. }
  12842. // Apply prefilters
  12843. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  12844. // If request was aborted inside a prefilter, stop there
  12845. if ( completed ) {
  12846. return jqXHR;
  12847. }
  12848. // We can fire global events as of now if asked to
  12849. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  12850. fireGlobals = jQuery.event && s.global;
  12851. // Watch for a new set of requests
  12852. if ( fireGlobals && jQuery.active++ === 0 ) {
  12853. jQuery.event.trigger( "ajaxStart" );
  12854. }
  12855. // Uppercase the type
  12856. s.type = s.type.toUpperCase();
  12857. // Determine if request has content
  12858. s.hasContent = !rnoContent.test( s.type );
  12859. // Save the URL in case we're toying with the If-Modified-Since
  12860. // and/or If-None-Match header later on
  12861. // Remove hash to simplify url manipulation
  12862. cacheURL = s.url.replace( rhash, "" );
  12863. // More options handling for requests with no content
  12864. if ( !s.hasContent ) {
  12865. // Remember the hash so we can put it back
  12866. uncached = s.url.slice( cacheURL.length );
  12867. // If data is available and should be processed, append data to url
  12868. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  12869. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  12870. // #9682: remove data so that it's not used in an eventual retry
  12871. delete s.data;
  12872. }
  12873. // Add or update anti-cache param if needed
  12874. if ( s.cache === false ) {
  12875. cacheURL = cacheURL.replace( rantiCache, "$1" );
  12876. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  12877. }
  12878. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  12879. s.url = cacheURL + uncached;
  12880. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  12881. } else if ( s.data && s.processData &&
  12882. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  12883. s.data = s.data.replace( r20, "+" );
  12884. }
  12885. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  12886. if ( s.ifModified ) {
  12887. if ( jQuery.lastModified[ cacheURL ] ) {
  12888. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  12889. }
  12890. if ( jQuery.etag[ cacheURL ] ) {
  12891. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  12892. }
  12893. }
  12894. // Set the correct header, if data is being sent
  12895. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  12896. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  12897. }
  12898. // Set the Accepts header for the server, depending on the dataType
  12899. jqXHR.setRequestHeader(
  12900. "Accept",
  12901. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  12902. s.accepts[ s.dataTypes[ 0 ] ] +
  12903. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  12904. s.accepts[ "*" ]
  12905. );
  12906. // Check for headers option
  12907. for ( i in s.headers ) {
  12908. jqXHR.setRequestHeader( i, s.headers[ i ] );
  12909. }
  12910. // Allow custom headers/mimetypes and early abort
  12911. if ( s.beforeSend &&
  12912. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  12913. // Abort if not done already and return
  12914. return jqXHR.abort();
  12915. }
  12916. // Aborting is no longer a cancellation
  12917. strAbort = "abort";
  12918. // Install callbacks on deferreds
  12919. completeDeferred.add( s.complete );
  12920. jqXHR.done( s.success );
  12921. jqXHR.fail( s.error );
  12922. // Get transport
  12923. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  12924. // If no transport, we auto-abort
  12925. if ( !transport ) {
  12926. done( -1, "No Transport" );
  12927. } else {
  12928. jqXHR.readyState = 1;
  12929. // Send global event
  12930. if ( fireGlobals ) {
  12931. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  12932. }
  12933. // If request was aborted inside ajaxSend, stop there
  12934. if ( completed ) {
  12935. return jqXHR;
  12936. }
  12937. // Timeout
  12938. if ( s.async && s.timeout > 0 ) {
  12939. timeoutTimer = window.setTimeout( function() {
  12940. jqXHR.abort( "timeout" );
  12941. }, s.timeout );
  12942. }
  12943. try {
  12944. completed = false;
  12945. transport.send( requestHeaders, done );
  12946. } catch ( e ) {
  12947. // Rethrow post-completion exceptions
  12948. if ( completed ) {
  12949. throw e;
  12950. }
  12951. // Propagate others as results
  12952. done( -1, e );
  12953. }
  12954. }
  12955. // Callback for when everything is done
  12956. function done( status, nativeStatusText, responses, headers ) {
  12957. var isSuccess, success, error, response, modified,
  12958. statusText = nativeStatusText;
  12959. // Ignore repeat invocations
  12960. if ( completed ) {
  12961. return;
  12962. }
  12963. completed = true;
  12964. // Clear timeout if it exists
  12965. if ( timeoutTimer ) {
  12966. window.clearTimeout( timeoutTimer );
  12967. }
  12968. // Dereference transport for early garbage collection
  12969. // (no matter how long the jqXHR object will be used)
  12970. transport = undefined;
  12971. // Cache response headers
  12972. responseHeadersString = headers || "";
  12973. // Set readyState
  12974. jqXHR.readyState = status > 0 ? 4 : 0;
  12975. // Determine if successful
  12976. isSuccess = status >= 200 && status < 300 || status === 304;
  12977. // Get response data
  12978. if ( responses ) {
  12979. response = ajaxHandleResponses( s, jqXHR, responses );
  12980. }
  12981. // Convert no matter what (that way responseXXX fields are always set)
  12982. response = ajaxConvert( s, response, jqXHR, isSuccess );
  12983. // If successful, handle type chaining
  12984. if ( isSuccess ) {
  12985. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  12986. if ( s.ifModified ) {
  12987. modified = jqXHR.getResponseHeader( "Last-Modified" );
  12988. if ( modified ) {
  12989. jQuery.lastModified[ cacheURL ] = modified;
  12990. }
  12991. modified = jqXHR.getResponseHeader( "etag" );
  12992. if ( modified ) {
  12993. jQuery.etag[ cacheURL ] = modified;
  12994. }
  12995. }
  12996. // if no content
  12997. if ( status === 204 || s.type === "HEAD" ) {
  12998. statusText = "nocontent";
  12999. // if not modified
  13000. } else if ( status === 304 ) {
  13001. statusText = "notmodified";
  13002. // If we have data, let's convert it
  13003. } else {
  13004. statusText = response.state;
  13005. success = response.data;
  13006. error = response.error;
  13007. isSuccess = !error;
  13008. }
  13009. } else {
  13010. // Extract error from statusText and normalize for non-aborts
  13011. error = statusText;
  13012. if ( status || !statusText ) {
  13013. statusText = "error";
  13014. if ( status < 0 ) {
  13015. status = 0;
  13016. }
  13017. }
  13018. }
  13019. // Set data for the fake xhr object
  13020. jqXHR.status = status;
  13021. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  13022. // Success/Error
  13023. if ( isSuccess ) {
  13024. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  13025. } else {
  13026. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  13027. }
  13028. // Status-dependent callbacks
  13029. jqXHR.statusCode( statusCode );
  13030. statusCode = undefined;
  13031. if ( fireGlobals ) {
  13032. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  13033. [ jqXHR, s, isSuccess ? success : error ] );
  13034. }
  13035. // Complete
  13036. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  13037. if ( fireGlobals ) {
  13038. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  13039. // Handle the global AJAX counter
  13040. if ( !( --jQuery.active ) ) {
  13041. jQuery.event.trigger( "ajaxStop" );
  13042. }
  13043. }
  13044. }
  13045. return jqXHR;
  13046. },
  13047. getJSON: function( url, data, callback ) {
  13048. return jQuery.get( url, data, callback, "json" );
  13049. },
  13050. getScript: function( url, callback ) {
  13051. return jQuery.get( url, undefined, callback, "script" );
  13052. }
  13053. } );
  13054. jQuery.each( [ "get", "post" ], function( i, method ) {
  13055. jQuery[ method ] = function( url, data, callback, type ) {
  13056. // Shift arguments if data argument was omitted
  13057. if ( isFunction( data ) ) {
  13058. type = type || callback;
  13059. callback = data;
  13060. data = undefined;
  13061. }
  13062. // The url can be an options object (which then must have .url)
  13063. return jQuery.ajax( jQuery.extend( {
  13064. url: url,
  13065. type: method,
  13066. dataType: type,
  13067. data: data,
  13068. success: callback
  13069. }, jQuery.isPlainObject( url ) && url ) );
  13070. };
  13071. } );
  13072. jQuery._evalUrl = function( url, options ) {
  13073. return jQuery.ajax( {
  13074. url: url,
  13075. // Make this explicit, since user can override this through ajaxSetup (#11264)
  13076. type: "GET",
  13077. dataType: "script",
  13078. cache: true,
  13079. async: false,
  13080. global: false,
  13081. // Only evaluate the response if it is successful (gh-4126)
  13082. // dataFilter is not invoked for failure responses, so using it instead
  13083. // of the default converter is kludgy but it works.
  13084. converters: {
  13085. "text script": function() {}
  13086. },
  13087. dataFilter: function( response ) {
  13088. jQuery.globalEval( response, options );
  13089. }
  13090. } );
  13091. };
  13092. jQuery.fn.extend( {
  13093. wrapAll: function( html ) {
  13094. var wrap;
  13095. if ( this[ 0 ] ) {
  13096. if ( isFunction( html ) ) {
  13097. html = html.call( this[ 0 ] );
  13098. }
  13099. // The elements to wrap the target around
  13100. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  13101. if ( this[ 0 ].parentNode ) {
  13102. wrap.insertBefore( this[ 0 ] );
  13103. }
  13104. wrap.map( function() {
  13105. var elem = this;
  13106. while ( elem.firstElementChild ) {
  13107. elem = elem.firstElementChild;
  13108. }
  13109. return elem;
  13110. } ).append( this );
  13111. }
  13112. return this;
  13113. },
  13114. wrapInner: function( html ) {
  13115. if ( isFunction( html ) ) {
  13116. return this.each( function( i ) {
  13117. jQuery( this ).wrapInner( html.call( this, i ) );
  13118. } );
  13119. }
  13120. return this.each( function() {
  13121. var self = jQuery( this ),
  13122. contents = self.contents();
  13123. if ( contents.length ) {
  13124. contents.wrapAll( html );
  13125. } else {
  13126. self.append( html );
  13127. }
  13128. } );
  13129. },
  13130. wrap: function( html ) {
  13131. var htmlIsFunction = isFunction( html );
  13132. return this.each( function( i ) {
  13133. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  13134. } );
  13135. },
  13136. unwrap: function( selector ) {
  13137. this.parent( selector ).not( "body" ).each( function() {
  13138. jQuery( this ).replaceWith( this.childNodes );
  13139. } );
  13140. return this;
  13141. }
  13142. } );
  13143. jQuery.expr.pseudos.hidden = function( elem ) {
  13144. return !jQuery.expr.pseudos.visible( elem );
  13145. };
  13146. jQuery.expr.pseudos.visible = function( elem ) {
  13147. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  13148. };
  13149. jQuery.ajaxSettings.xhr = function() {
  13150. try {
  13151. return new window.XMLHttpRequest();
  13152. } catch ( e ) {}
  13153. };
  13154. var xhrSuccessStatus = {
  13155. // File protocol always yields status code 0, assume 200
  13156. 0: 200,
  13157. // Support: IE <=9 only
  13158. // #1450: sometimes IE returns 1223 when it should be 204
  13159. 1223: 204
  13160. },
  13161. xhrSupported = jQuery.ajaxSettings.xhr();
  13162. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  13163. support.ajax = xhrSupported = !!xhrSupported;
  13164. jQuery.ajaxTransport( function( options ) {
  13165. var callback, errorCallback;
  13166. // Cross domain only allowed if supported through XMLHttpRequest
  13167. if ( support.cors || xhrSupported && !options.crossDomain ) {
  13168. return {
  13169. send: function( headers, complete ) {
  13170. var i,
  13171. xhr = options.xhr();
  13172. xhr.open(
  13173. options.type,
  13174. options.url,
  13175. options.async,
  13176. options.username,
  13177. options.password
  13178. );
  13179. // Apply custom fields if provided
  13180. if ( options.xhrFields ) {
  13181. for ( i in options.xhrFields ) {
  13182. xhr[ i ] = options.xhrFields[ i ];
  13183. }
  13184. }
  13185. // Override mime type if needed
  13186. if ( options.mimeType && xhr.overrideMimeType ) {
  13187. xhr.overrideMimeType( options.mimeType );
  13188. }
  13189. // X-Requested-With header
  13190. // For cross-domain requests, seeing as conditions for a preflight are
  13191. // akin to a jigsaw puzzle, we simply never set it to be sure.
  13192. // (it can always be set on a per-request basis or even using ajaxSetup)
  13193. // For same-domain requests, won't change header if already provided.
  13194. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  13195. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  13196. }
  13197. // Set headers
  13198. for ( i in headers ) {
  13199. xhr.setRequestHeader( i, headers[ i ] );
  13200. }
  13201. // Callback
  13202. callback = function( type ) {
  13203. return function() {
  13204. if ( callback ) {
  13205. callback = errorCallback = xhr.onload =
  13206. xhr.onerror = xhr.onabort = xhr.ontimeout =
  13207. xhr.onreadystatechange = null;
  13208. if ( type === "abort" ) {
  13209. xhr.abort();
  13210. } else if ( type === "error" ) {
  13211. // Support: IE <=9 only
  13212. // On a manual native abort, IE9 throws
  13213. // errors on any property access that is not readyState
  13214. if ( typeof xhr.status !== "number" ) {
  13215. complete( 0, "error" );
  13216. } else {
  13217. complete(
  13218. // File: protocol always yields status 0; see #8605, #14207
  13219. xhr.status,
  13220. xhr.statusText
  13221. );
  13222. }
  13223. } else {
  13224. complete(
  13225. xhrSuccessStatus[ xhr.status ] || xhr.status,
  13226. xhr.statusText,
  13227. // Support: IE <=9 only
  13228. // IE9 has no XHR2 but throws on binary (trac-11426)
  13229. // For XHR2 non-text, let the caller handle it (gh-2498)
  13230. ( xhr.responseType || "text" ) !== "text" ||
  13231. typeof xhr.responseText !== "string" ?
  13232. { binary: xhr.response } :
  13233. { text: xhr.responseText },
  13234. xhr.getAllResponseHeaders()
  13235. );
  13236. }
  13237. }
  13238. };
  13239. };
  13240. // Listen to events
  13241. xhr.onload = callback();
  13242. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  13243. // Support: IE 9 only
  13244. // Use onreadystatechange to replace onabort
  13245. // to handle uncaught aborts
  13246. if ( xhr.onabort !== undefined ) {
  13247. xhr.onabort = errorCallback;
  13248. } else {
  13249. xhr.onreadystatechange = function() {
  13250. // Check readyState before timeout as it changes
  13251. if ( xhr.readyState === 4 ) {
  13252. // Allow onerror to be called first,
  13253. // but that will not handle a native abort
  13254. // Also, save errorCallback to a variable
  13255. // as xhr.onerror cannot be accessed
  13256. window.setTimeout( function() {
  13257. if ( callback ) {
  13258. errorCallback();
  13259. }
  13260. } );
  13261. }
  13262. };
  13263. }
  13264. // Create the abort callback
  13265. callback = callback( "abort" );
  13266. try {
  13267. // Do send the request (this may raise an exception)
  13268. xhr.send( options.hasContent && options.data || null );
  13269. } catch ( e ) {
  13270. // #14683: Only rethrow if this hasn't been notified as an error yet
  13271. if ( callback ) {
  13272. throw e;
  13273. }
  13274. }
  13275. },
  13276. abort: function() {
  13277. if ( callback ) {
  13278. callback();
  13279. }
  13280. }
  13281. };
  13282. }
  13283. } );
  13284. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  13285. jQuery.ajaxPrefilter( function( s ) {
  13286. if ( s.crossDomain ) {
  13287. s.contents.script = false;
  13288. }
  13289. } );
  13290. // Install script dataType
  13291. jQuery.ajaxSetup( {
  13292. accepts: {
  13293. script: "text/javascript, application/javascript, " +
  13294. "application/ecmascript, application/x-ecmascript"
  13295. },
  13296. contents: {
  13297. script: /\b(?:java|ecma)script\b/
  13298. },
  13299. converters: {
  13300. "text script": function( text ) {
  13301. jQuery.globalEval( text );
  13302. return text;
  13303. }
  13304. }
  13305. } );
  13306. // Handle cache's special case and crossDomain
  13307. jQuery.ajaxPrefilter( "script", function( s ) {
  13308. if ( s.cache === undefined ) {
  13309. s.cache = false;
  13310. }
  13311. if ( s.crossDomain ) {
  13312. s.type = "GET";
  13313. }
  13314. } );
  13315. // Bind script tag hack transport
  13316. jQuery.ajaxTransport( "script", function( s ) {
  13317. // This transport only deals with cross domain or forced-by-attrs requests
  13318. if ( s.crossDomain || s.scriptAttrs ) {
  13319. var script, callback;
  13320. return {
  13321. send: function( _, complete ) {
  13322. script = jQuery( "<script>" )
  13323. .attr( s.scriptAttrs || {} )
  13324. .prop( { charset: s.scriptCharset, src: s.url } )
  13325. .on( "load error", callback = function( evt ) {
  13326. script.remove();
  13327. callback = null;
  13328. if ( evt ) {
  13329. complete( evt.type === "error" ? 404 : 200, evt.type );
  13330. }
  13331. } );
  13332. // Use native DOM manipulation to avoid our domManip AJAX trickery
  13333. document.head.appendChild( script[ 0 ] );
  13334. },
  13335. abort: function() {
  13336. if ( callback ) {
  13337. callback();
  13338. }
  13339. }
  13340. };
  13341. }
  13342. } );
  13343. var oldCallbacks = [],
  13344. rjsonp = /(=)\?(?=&|$)|\?\?/;
  13345. // Default jsonp settings
  13346. jQuery.ajaxSetup( {
  13347. jsonp: "callback",
  13348. jsonpCallback: function() {
  13349. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  13350. this[ callback ] = true;
  13351. return callback;
  13352. }
  13353. } );
  13354. // Detect, normalize options and install callbacks for jsonp requests
  13355. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  13356. var callbackName, overwritten, responseContainer,
  13357. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  13358. "url" :
  13359. typeof s.data === "string" &&
  13360. ( s.contentType || "" )
  13361. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  13362. rjsonp.test( s.data ) && "data"
  13363. );
  13364. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  13365. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  13366. // Get callback name, remembering preexisting value associated with it
  13367. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  13368. s.jsonpCallback() :
  13369. s.jsonpCallback;
  13370. // Insert callback into url or form data
  13371. if ( jsonProp ) {
  13372. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  13373. } else if ( s.jsonp !== false ) {
  13374. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  13375. }
  13376. // Use data converter to retrieve json after script execution
  13377. s.converters[ "script json" ] = function() {
  13378. if ( !responseContainer ) {
  13379. jQuery.error( callbackName + " was not called" );
  13380. }
  13381. return responseContainer[ 0 ];
  13382. };
  13383. // Force json dataType
  13384. s.dataTypes[ 0 ] = "json";
  13385. // Install callback
  13386. overwritten = window[ callbackName ];
  13387. window[ callbackName ] = function() {
  13388. responseContainer = arguments;
  13389. };
  13390. // Clean-up function (fires after converters)
  13391. jqXHR.always( function() {
  13392. // If previous value didn't exist - remove it
  13393. if ( overwritten === undefined ) {
  13394. jQuery( window ).removeProp( callbackName );
  13395. // Otherwise restore preexisting value
  13396. } else {
  13397. window[ callbackName ] = overwritten;
  13398. }
  13399. // Save back as free
  13400. if ( s[ callbackName ] ) {
  13401. // Make sure that re-using the options doesn't screw things around
  13402. s.jsonpCallback = originalSettings.jsonpCallback;
  13403. // Save the callback name for future use
  13404. oldCallbacks.push( callbackName );
  13405. }
  13406. // Call if it was a function and we have a response
  13407. if ( responseContainer && isFunction( overwritten ) ) {
  13408. overwritten( responseContainer[ 0 ] );
  13409. }
  13410. responseContainer = overwritten = undefined;
  13411. } );
  13412. // Delegate to script
  13413. return "script";
  13414. }
  13415. } );
  13416. // Support: Safari 8 only
  13417. // In Safari 8 documents created via document.implementation.createHTMLDocument
  13418. // collapse sibling forms: the second one becomes a child of the first one.
  13419. // Because of that, this security measure has to be disabled in Safari 8.
  13420. // https://bugs.webkit.org/show_bug.cgi?id=137337
  13421. support.createHTMLDocument = ( function() {
  13422. var body = document.implementation.createHTMLDocument( "" ).body;
  13423. body.innerHTML = "<form></form><form></form>";
  13424. return body.childNodes.length === 2;
  13425. } )();
  13426. // Argument "data" should be string of html
  13427. // context (optional): If specified, the fragment will be created in this context,
  13428. // defaults to document
  13429. // keepScripts (optional): If true, will include scripts passed in the html string
  13430. jQuery.parseHTML = function( data, context, keepScripts ) {
  13431. if ( typeof data !== "string" ) {
  13432. return [];
  13433. }
  13434. if ( typeof context === "boolean" ) {
  13435. keepScripts = context;
  13436. context = false;
  13437. }
  13438. var base, parsed, scripts;
  13439. if ( !context ) {
  13440. // Stop scripts or inline event handlers from being executed immediately
  13441. // by using document.implementation
  13442. if ( support.createHTMLDocument ) {
  13443. context = document.implementation.createHTMLDocument( "" );
  13444. // Set the base href for the created document
  13445. // so any parsed elements with URLs
  13446. // are based on the document's URL (gh-2965)
  13447. base = context.createElement( "base" );
  13448. base.href = document.location.href;
  13449. context.head.appendChild( base );
  13450. } else {
  13451. context = document;
  13452. }
  13453. }
  13454. parsed = rsingleTag.exec( data );
  13455. scripts = !keepScripts && [];
  13456. // Single tag
  13457. if ( parsed ) {
  13458. return [ context.createElement( parsed[ 1 ] ) ];
  13459. }
  13460. parsed = buildFragment( [ data ], context, scripts );
  13461. if ( scripts && scripts.length ) {
  13462. jQuery( scripts ).remove();
  13463. }
  13464. return jQuery.merge( [], parsed.childNodes );
  13465. };
  13466. /**
  13467. * Load a url into a page
  13468. */
  13469. jQuery.fn.load = function( url, params, callback ) {
  13470. var selector, type, response,
  13471. self = this,
  13472. off = url.indexOf( " " );
  13473. if ( off > -1 ) {
  13474. selector = stripAndCollapse( url.slice( off ) );
  13475. url = url.slice( 0, off );
  13476. }
  13477. // If it's a function
  13478. if ( isFunction( params ) ) {
  13479. // We assume that it's the callback
  13480. callback = params;
  13481. params = undefined;
  13482. // Otherwise, build a param string
  13483. } else if ( params && typeof params === "object" ) {
  13484. type = "POST";
  13485. }
  13486. // If we have elements to modify, make the request
  13487. if ( self.length > 0 ) {
  13488. jQuery.ajax( {
  13489. url: url,
  13490. // If "type" variable is undefined, then "GET" method will be used.
  13491. // Make value of this field explicit since
  13492. // user can override it through ajaxSetup method
  13493. type: type || "GET",
  13494. dataType: "html",
  13495. data: params
  13496. } ).done( function( responseText ) {
  13497. // Save response for use in complete callback
  13498. response = arguments;
  13499. self.html( selector ?
  13500. // If a selector was specified, locate the right elements in a dummy div
  13501. // Exclude scripts to avoid IE 'Permission Denied' errors
  13502. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  13503. // Otherwise use the full result
  13504. responseText );
  13505. // If the request succeeds, this function gets "data", "status", "jqXHR"
  13506. // but they are ignored because response was set above.
  13507. // If it fails, this function gets "jqXHR", "status", "error"
  13508. } ).always( callback && function( jqXHR, status ) {
  13509. self.each( function() {
  13510. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  13511. } );
  13512. } );
  13513. }
  13514. return this;
  13515. };
  13516. // Attach a bunch of functions for handling common AJAX events
  13517. jQuery.each( [
  13518. "ajaxStart",
  13519. "ajaxStop",
  13520. "ajaxComplete",
  13521. "ajaxError",
  13522. "ajaxSuccess",
  13523. "ajaxSend"
  13524. ], function( i, type ) {
  13525. jQuery.fn[ type ] = function( fn ) {
  13526. return this.on( type, fn );
  13527. };
  13528. } );
  13529. jQuery.expr.pseudos.animated = function( elem ) {
  13530. return jQuery.grep( jQuery.timers, function( fn ) {
  13531. return elem === fn.elem;
  13532. } ).length;
  13533. };
  13534. jQuery.offset = {
  13535. setOffset: function( elem, options, i ) {
  13536. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  13537. position = jQuery.css( elem, "position" ),
  13538. curElem = jQuery( elem ),
  13539. props = {};
  13540. // Set position first, in-case top/left are set even on static elem
  13541. if ( position === "static" ) {
  13542. elem.style.position = "relative";
  13543. }
  13544. curOffset = curElem.offset();
  13545. curCSSTop = jQuery.css( elem, "top" );
  13546. curCSSLeft = jQuery.css( elem, "left" );
  13547. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  13548. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  13549. // Need to be able to calculate position if either
  13550. // top or left is auto and position is either absolute or fixed
  13551. if ( calculatePosition ) {
  13552. curPosition = curElem.position();
  13553. curTop = curPosition.top;
  13554. curLeft = curPosition.left;
  13555. } else {
  13556. curTop = parseFloat( curCSSTop ) || 0;
  13557. curLeft = parseFloat( curCSSLeft ) || 0;
  13558. }
  13559. if ( isFunction( options ) ) {
  13560. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  13561. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  13562. }
  13563. if ( options.top != null ) {
  13564. props.top = ( options.top - curOffset.top ) + curTop;
  13565. }
  13566. if ( options.left != null ) {
  13567. props.left = ( options.left - curOffset.left ) + curLeft;
  13568. }
  13569. if ( "using" in options ) {
  13570. options.using.call( elem, props );
  13571. } else {
  13572. curElem.css( props );
  13573. }
  13574. }
  13575. };
  13576. jQuery.fn.extend( {
  13577. // offset() relates an element's border box to the document origin
  13578. offset: function( options ) {
  13579. // Preserve chaining for setter
  13580. if ( arguments.length ) {
  13581. return options === undefined ?
  13582. this :
  13583. this.each( function( i ) {
  13584. jQuery.offset.setOffset( this, options, i );
  13585. } );
  13586. }
  13587. var rect, win,
  13588. elem = this[ 0 ];
  13589. if ( !elem ) {
  13590. return;
  13591. }
  13592. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  13593. // Support: IE <=11 only
  13594. // Running getBoundingClientRect on a
  13595. // disconnected node in IE throws an error
  13596. if ( !elem.getClientRects().length ) {
  13597. return { top: 0, left: 0 };
  13598. }
  13599. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  13600. rect = elem.getBoundingClientRect();
  13601. win = elem.ownerDocument.defaultView;
  13602. return {
  13603. top: rect.top + win.pageYOffset,
  13604. left: rect.left + win.pageXOffset
  13605. };
  13606. },
  13607. // position() relates an element's margin box to its offset parent's padding box
  13608. // This corresponds to the behavior of CSS absolute positioning
  13609. position: function() {
  13610. if ( !this[ 0 ] ) {
  13611. return;
  13612. }
  13613. var offsetParent, offset, doc,
  13614. elem = this[ 0 ],
  13615. parentOffset = { top: 0, left: 0 };
  13616. // position:fixed elements are offset from the viewport, which itself always has zero offset
  13617. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  13618. // Assume position:fixed implies availability of getBoundingClientRect
  13619. offset = elem.getBoundingClientRect();
  13620. } else {
  13621. offset = this.offset();
  13622. // Account for the *real* offset parent, which can be the document or its root element
  13623. // when a statically positioned element is identified
  13624. doc = elem.ownerDocument;
  13625. offsetParent = elem.offsetParent || doc.documentElement;
  13626. while ( offsetParent &&
  13627. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  13628. jQuery.css( offsetParent, "position" ) === "static" ) {
  13629. offsetParent = offsetParent.parentNode;
  13630. }
  13631. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  13632. // Incorporate borders into its offset, since they are outside its content origin
  13633. parentOffset = jQuery( offsetParent ).offset();
  13634. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  13635. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  13636. }
  13637. }
  13638. // Subtract parent offsets and element margins
  13639. return {
  13640. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  13641. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  13642. };
  13643. },
  13644. // This method will return documentElement in the following cases:
  13645. // 1) For the element inside the iframe without offsetParent, this method will return
  13646. // documentElement of the parent window
  13647. // 2) For the hidden or detached element
  13648. // 3) For body or html element, i.e. in case of the html node - it will return itself
  13649. //
  13650. // but those exceptions were never presented as a real life use-cases
  13651. // and might be considered as more preferable results.
  13652. //
  13653. // This logic, however, is not guaranteed and can change at any point in the future
  13654. offsetParent: function() {
  13655. return this.map( function() {
  13656. var offsetParent = this.offsetParent;
  13657. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  13658. offsetParent = offsetParent.offsetParent;
  13659. }
  13660. return offsetParent || documentElement;
  13661. } );
  13662. }
  13663. } );
  13664. // Create scrollLeft and scrollTop methods
  13665. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  13666. var top = "pageYOffset" === prop;
  13667. jQuery.fn[ method ] = function( val ) {
  13668. return access( this, function( elem, method, val ) {
  13669. // Coalesce documents and windows
  13670. var win;
  13671. if ( isWindow( elem ) ) {
  13672. win = elem;
  13673. } else if ( elem.nodeType === 9 ) {
  13674. win = elem.defaultView;
  13675. }
  13676. if ( val === undefined ) {
  13677. return win ? win[ prop ] : elem[ method ];
  13678. }
  13679. if ( win ) {
  13680. win.scrollTo(
  13681. !top ? val : win.pageXOffset,
  13682. top ? val : win.pageYOffset
  13683. );
  13684. } else {
  13685. elem[ method ] = val;
  13686. }
  13687. }, method, val, arguments.length );
  13688. };
  13689. } );
  13690. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  13691. // Add the top/left cssHooks using jQuery.fn.position
  13692. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  13693. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  13694. // getComputedStyle returns percent when specified for top/left/bottom/right;
  13695. // rather than make the css module depend on the offset module, just check for it here
  13696. jQuery.each( [ "top", "left" ], function( i, prop ) {
  13697. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  13698. function( elem, computed ) {
  13699. if ( computed ) {
  13700. computed = curCSS( elem, prop );
  13701. // If curCSS returns percentage, fallback to offset
  13702. return rnumnonpx.test( computed ) ?
  13703. jQuery( elem ).position()[ prop ] + "px" :
  13704. computed;
  13705. }
  13706. }
  13707. );
  13708. } );
  13709. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  13710. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  13711. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  13712. function( defaultExtra, funcName ) {
  13713. // Margin is only for outerHeight, outerWidth
  13714. jQuery.fn[ funcName ] = function( margin, value ) {
  13715. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  13716. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  13717. return access( this, function( elem, type, value ) {
  13718. var doc;
  13719. if ( isWindow( elem ) ) {
  13720. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  13721. return funcName.indexOf( "outer" ) === 0 ?
  13722. elem[ "inner" + name ] :
  13723. elem.document.documentElement[ "client" + name ];
  13724. }
  13725. // Get document width or height
  13726. if ( elem.nodeType === 9 ) {
  13727. doc = elem.documentElement;
  13728. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  13729. // whichever is greatest
  13730. return Math.max(
  13731. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  13732. elem.body[ "offset" + name ], doc[ "offset" + name ],
  13733. doc[ "client" + name ]
  13734. );
  13735. }
  13736. return value === undefined ?
  13737. // Get width or height on the element, requesting but not forcing parseFloat
  13738. jQuery.css( elem, type, extra ) :
  13739. // Set width or height on the element
  13740. jQuery.style( elem, type, value, extra );
  13741. }, type, chainable ? margin : undefined, chainable );
  13742. };
  13743. } );
  13744. } );
  13745. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  13746. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  13747. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  13748. function( i, name ) {
  13749. // Handle event binding
  13750. jQuery.fn[ name ] = function( data, fn ) {
  13751. return arguments.length > 0 ?
  13752. this.on( name, null, data, fn ) :
  13753. this.trigger( name );
  13754. };
  13755. } );
  13756. jQuery.fn.extend( {
  13757. hover: function( fnOver, fnOut ) {
  13758. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  13759. }
  13760. } );
  13761. jQuery.fn.extend( {
  13762. bind: function( types, data, fn ) {
  13763. return this.on( types, null, data, fn );
  13764. },
  13765. unbind: function( types, fn ) {
  13766. return this.off( types, null, fn );
  13767. },
  13768. delegate: function( selector, types, data, fn ) {
  13769. return this.on( types, selector, data, fn );
  13770. },
  13771. undelegate: function( selector, types, fn ) {
  13772. // ( namespace ) or ( selector, types [, fn] )
  13773. return arguments.length === 1 ?
  13774. this.off( selector, "**" ) :
  13775. this.off( types, selector || "**", fn );
  13776. }
  13777. } );
  13778. // Bind a function to a context, optionally partially applying any
  13779. // arguments.
  13780. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  13781. // However, it is not slated for removal any time soon
  13782. jQuery.proxy = function( fn, context ) {
  13783. var tmp, args, proxy;
  13784. if ( typeof context === "string" ) {
  13785. tmp = fn[ context ];
  13786. context = fn;
  13787. fn = tmp;
  13788. }
  13789. // Quick check to determine if target is callable, in the spec
  13790. // this throws a TypeError, but we will just return undefined.
  13791. if ( !isFunction( fn ) ) {
  13792. return undefined;
  13793. }
  13794. // Simulated bind
  13795. args = slice.call( arguments, 2 );
  13796. proxy = function() {
  13797. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  13798. };
  13799. // Set the guid of unique handler to the same of original handler, so it can be removed
  13800. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  13801. return proxy;
  13802. };
  13803. jQuery.holdReady = function( hold ) {
  13804. if ( hold ) {
  13805. jQuery.readyWait++;
  13806. } else {
  13807. jQuery.ready( true );
  13808. }
  13809. };
  13810. jQuery.isArray = Array.isArray;
  13811. jQuery.parseJSON = JSON.parse;
  13812. jQuery.nodeName = nodeName;
  13813. jQuery.isFunction = isFunction;
  13814. jQuery.isWindow = isWindow;
  13815. jQuery.camelCase = camelCase;
  13816. jQuery.type = toType;
  13817. jQuery.now = Date.now;
  13818. jQuery.isNumeric = function( obj ) {
  13819. // As of jQuery 3.0, isNumeric is limited to
  13820. // strings and numbers (primitives or objects)
  13821. // that can be coerced to finite numbers (gh-2662)
  13822. var type = jQuery.type( obj );
  13823. return ( type === "number" || type === "string" ) &&
  13824. // parseFloat NaNs numeric-cast false positives ("")
  13825. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  13826. // subtraction forces infinities to NaN
  13827. !isNaN( obj - parseFloat( obj ) );
  13828. };
  13829. // Register as a named AMD module, since jQuery can be concatenated with other
  13830. // files that may use define, but not via a proper concatenation script that
  13831. // understands anonymous AMD modules. A named AMD is safest and most robust
  13832. // way to register. Lowercase jquery is used because AMD module names are
  13833. // derived from file names, and jQuery is normally delivered in a lowercase
  13834. // file name. Do this after creating the global so that if an AMD module wants
  13835. // to call noConflict to hide this version of jQuery, it will work.
  13836. // Note that for maximum portability, libraries that are not jQuery should
  13837. // declare themselves as anonymous modules, and avoid setting a global if an
  13838. // AMD loader is present. jQuery is a special case. For more information, see
  13839. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  13840. if ( true ) {
  13841. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  13842. return jQuery;
  13843. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  13844. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  13845. }
  13846. var
  13847. // Map over jQuery in case of overwrite
  13848. _jQuery = window.jQuery,
  13849. // Map over the $ in case of overwrite
  13850. _$ = window.$;
  13851. jQuery.noConflict = function( deep ) {
  13852. if ( window.$ === jQuery ) {
  13853. window.$ = _$;
  13854. }
  13855. if ( deep && window.jQuery === jQuery ) {
  13856. window.jQuery = _jQuery;
  13857. }
  13858. return jQuery;
  13859. };
  13860. // Expose jQuery and $ identifiers, even in AMD
  13861. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  13862. // and CommonJS for browser emulators (#13566)
  13863. if ( !noGlobal ) {
  13864. window.jQuery = window.$ = jQuery;
  13865. }
  13866. return jQuery;
  13867. } );
  13868. /***/ }),
  13869. /***/ "./node_modules/lodash/lodash.js":
  13870. /*!***************************************!*\
  13871. !*** ./node_modules/lodash/lodash.js ***!
  13872. \***************************************/
  13873. /*! no static exports found */
  13874. /***/ (function(module, exports, __webpack_require__) {
  13875. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  13876. * @license
  13877. * Lodash <https://lodash.com/>
  13878. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  13879. * Released under MIT license <https://lodash.com/license>
  13880. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  13881. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  13882. */
  13883. ;(function() {
  13884. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  13885. var undefined;
  13886. /** Used as the semantic version number. */
  13887. var VERSION = '4.17.15';
  13888. /** Used as the size to enable large array optimizations. */
  13889. var LARGE_ARRAY_SIZE = 200;
  13890. /** Error message constants. */
  13891. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  13892. FUNC_ERROR_TEXT = 'Expected a function';
  13893. /** Used to stand-in for `undefined` hash values. */
  13894. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  13895. /** Used as the maximum memoize cache size. */
  13896. var MAX_MEMOIZE_SIZE = 500;
  13897. /** Used as the internal argument placeholder. */
  13898. var PLACEHOLDER = '__lodash_placeholder__';
  13899. /** Used to compose bitmasks for cloning. */
  13900. var CLONE_DEEP_FLAG = 1,
  13901. CLONE_FLAT_FLAG = 2,
  13902. CLONE_SYMBOLS_FLAG = 4;
  13903. /** Used to compose bitmasks for value comparisons. */
  13904. var COMPARE_PARTIAL_FLAG = 1,
  13905. COMPARE_UNORDERED_FLAG = 2;
  13906. /** Used to compose bitmasks for function metadata. */
  13907. var WRAP_BIND_FLAG = 1,
  13908. WRAP_BIND_KEY_FLAG = 2,
  13909. WRAP_CURRY_BOUND_FLAG = 4,
  13910. WRAP_CURRY_FLAG = 8,
  13911. WRAP_CURRY_RIGHT_FLAG = 16,
  13912. WRAP_PARTIAL_FLAG = 32,
  13913. WRAP_PARTIAL_RIGHT_FLAG = 64,
  13914. WRAP_ARY_FLAG = 128,
  13915. WRAP_REARG_FLAG = 256,
  13916. WRAP_FLIP_FLAG = 512;
  13917. /** Used as default options for `_.truncate`. */
  13918. var DEFAULT_TRUNC_LENGTH = 30,
  13919. DEFAULT_TRUNC_OMISSION = '...';
  13920. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  13921. var HOT_COUNT = 800,
  13922. HOT_SPAN = 16;
  13923. /** Used to indicate the type of lazy iteratees. */
  13924. var LAZY_FILTER_FLAG = 1,
  13925. LAZY_MAP_FLAG = 2,
  13926. LAZY_WHILE_FLAG = 3;
  13927. /** Used as references for various `Number` constants. */
  13928. var INFINITY = 1 / 0,
  13929. MAX_SAFE_INTEGER = 9007199254740991,
  13930. MAX_INTEGER = 1.7976931348623157e+308,
  13931. NAN = 0 / 0;
  13932. /** Used as references for the maximum length and index of an array. */
  13933. var MAX_ARRAY_LENGTH = 4294967295,
  13934. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  13935. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  13936. /** Used to associate wrap methods with their bit flags. */
  13937. var wrapFlags = [
  13938. ['ary', WRAP_ARY_FLAG],
  13939. ['bind', WRAP_BIND_FLAG],
  13940. ['bindKey', WRAP_BIND_KEY_FLAG],
  13941. ['curry', WRAP_CURRY_FLAG],
  13942. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  13943. ['flip', WRAP_FLIP_FLAG],
  13944. ['partial', WRAP_PARTIAL_FLAG],
  13945. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  13946. ['rearg', WRAP_REARG_FLAG]
  13947. ];
  13948. /** `Object#toString` result references. */
  13949. var argsTag = '[object Arguments]',
  13950. arrayTag = '[object Array]',
  13951. asyncTag = '[object AsyncFunction]',
  13952. boolTag = '[object Boolean]',
  13953. dateTag = '[object Date]',
  13954. domExcTag = '[object DOMException]',
  13955. errorTag = '[object Error]',
  13956. funcTag = '[object Function]',
  13957. genTag = '[object GeneratorFunction]',
  13958. mapTag = '[object Map]',
  13959. numberTag = '[object Number]',
  13960. nullTag = '[object Null]',
  13961. objectTag = '[object Object]',
  13962. promiseTag = '[object Promise]',
  13963. proxyTag = '[object Proxy]',
  13964. regexpTag = '[object RegExp]',
  13965. setTag = '[object Set]',
  13966. stringTag = '[object String]',
  13967. symbolTag = '[object Symbol]',
  13968. undefinedTag = '[object Undefined]',
  13969. weakMapTag = '[object WeakMap]',
  13970. weakSetTag = '[object WeakSet]';
  13971. var arrayBufferTag = '[object ArrayBuffer]',
  13972. dataViewTag = '[object DataView]',
  13973. float32Tag = '[object Float32Array]',
  13974. float64Tag = '[object Float64Array]',
  13975. int8Tag = '[object Int8Array]',
  13976. int16Tag = '[object Int16Array]',
  13977. int32Tag = '[object Int32Array]',
  13978. uint8Tag = '[object Uint8Array]',
  13979. uint8ClampedTag = '[object Uint8ClampedArray]',
  13980. uint16Tag = '[object Uint16Array]',
  13981. uint32Tag = '[object Uint32Array]';
  13982. /** Used to match empty string literals in compiled template source. */
  13983. var reEmptyStringLeading = /\b__p \+= '';/g,
  13984. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  13985. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  13986. /** Used to match HTML entities and HTML characters. */
  13987. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  13988. reUnescapedHtml = /[&<>"']/g,
  13989. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  13990. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  13991. /** Used to match template delimiters. */
  13992. var reEscape = /<%-([\s\S]+?)%>/g,
  13993. reEvaluate = /<%([\s\S]+?)%>/g,
  13994. reInterpolate = /<%=([\s\S]+?)%>/g;
  13995. /** Used to match property names within property paths. */
  13996. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  13997. reIsPlainProp = /^\w*$/,
  13998. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  13999. /**
  14000. * Used to match `RegExp`
  14001. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  14002. */
  14003. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  14004. reHasRegExpChar = RegExp(reRegExpChar.source);
  14005. /** Used to match leading and trailing whitespace. */
  14006. var reTrim = /^\s+|\s+$/g,
  14007. reTrimStart = /^\s+/,
  14008. reTrimEnd = /\s+$/;
  14009. /** Used to match wrap detail comments. */
  14010. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  14011. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  14012. reSplitDetails = /,? & /;
  14013. /** Used to match words composed of alphanumeric characters. */
  14014. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  14015. /** Used to match backslashes in property paths. */
  14016. var reEscapeChar = /\\(\\)?/g;
  14017. /**
  14018. * Used to match
  14019. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  14020. */
  14021. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  14022. /** Used to match `RegExp` flags from their coerced string values. */
  14023. var reFlags = /\w*$/;
  14024. /** Used to detect bad signed hexadecimal string values. */
  14025. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  14026. /** Used to detect binary string values. */
  14027. var reIsBinary = /^0b[01]+$/i;
  14028. /** Used to detect host constructors (Safari). */
  14029. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  14030. /** Used to detect octal string values. */
  14031. var reIsOctal = /^0o[0-7]+$/i;
  14032. /** Used to detect unsigned integer values. */
  14033. var reIsUint = /^(?:0|[1-9]\d*)$/;
  14034. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  14035. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  14036. /** Used to ensure capturing order of template delimiters. */
  14037. var reNoMatch = /($^)/;
  14038. /** Used to match unescaped characters in compiled string literals. */
  14039. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  14040. /** Used to compose unicode character classes. */
  14041. var rsAstralRange = '\\ud800-\\udfff',
  14042. rsComboMarksRange = '\\u0300-\\u036f',
  14043. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  14044. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  14045. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  14046. rsDingbatRange = '\\u2700-\\u27bf',
  14047. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  14048. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  14049. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  14050. rsPunctuationRange = '\\u2000-\\u206f',
  14051. 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',
  14052. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  14053. rsVarRange = '\\ufe0e\\ufe0f',
  14054. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  14055. /** Used to compose unicode capture groups. */
  14056. var rsApos = "['\u2019]",
  14057. rsAstral = '[' + rsAstralRange + ']',
  14058. rsBreak = '[' + rsBreakRange + ']',
  14059. rsCombo = '[' + rsComboRange + ']',
  14060. rsDigits = '\\d+',
  14061. rsDingbat = '[' + rsDingbatRange + ']',
  14062. rsLower = '[' + rsLowerRange + ']',
  14063. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  14064. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  14065. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  14066. rsNonAstral = '[^' + rsAstralRange + ']',
  14067. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  14068. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  14069. rsUpper = '[' + rsUpperRange + ']',
  14070. rsZWJ = '\\u200d';
  14071. /** Used to compose unicode regexes. */
  14072. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  14073. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  14074. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  14075. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  14076. reOptMod = rsModifier + '?',
  14077. rsOptVar = '[' + rsVarRange + ']?',
  14078. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  14079. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  14080. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  14081. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  14082. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  14083. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  14084. /** Used to match apostrophes. */
  14085. var reApos = RegExp(rsApos, 'g');
  14086. /**
  14087. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  14088. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  14089. */
  14090. var reComboMark = RegExp(rsCombo, 'g');
  14091. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  14092. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  14093. /** Used to match complex or compound words. */
  14094. var reUnicodeWord = RegExp([
  14095. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  14096. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  14097. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  14098. rsUpper + '+' + rsOptContrUpper,
  14099. rsOrdUpper,
  14100. rsOrdLower,
  14101. rsDigits,
  14102. rsEmoji
  14103. ].join('|'), 'g');
  14104. /** 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/). */
  14105. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  14106. /** Used to detect strings that need a more robust regexp to match words. */
  14107. 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 ]/;
  14108. /** Used to assign default `context` object properties. */
  14109. var contextProps = [
  14110. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  14111. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  14112. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  14113. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  14114. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  14115. ];
  14116. /** Used to make template sourceURLs easier to identify. */
  14117. var templateCounter = -1;
  14118. /** Used to identify `toStringTag` values of typed arrays. */
  14119. var typedArrayTags = {};
  14120. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  14121. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  14122. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  14123. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  14124. typedArrayTags[uint32Tag] = true;
  14125. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  14126. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  14127. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  14128. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  14129. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  14130. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  14131. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  14132. typedArrayTags[weakMapTag] = false;
  14133. /** Used to identify `toStringTag` values supported by `_.clone`. */
  14134. var cloneableTags = {};
  14135. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  14136. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  14137. cloneableTags[boolTag] = cloneableTags[dateTag] =
  14138. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  14139. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  14140. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  14141. cloneableTags[numberTag] = cloneableTags[objectTag] =
  14142. cloneableTags[regexpTag] = cloneableTags[setTag] =
  14143. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  14144. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  14145. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  14146. cloneableTags[errorTag] = cloneableTags[funcTag] =
  14147. cloneableTags[weakMapTag] = false;
  14148. /** Used to map Latin Unicode letters to basic Latin letters. */
  14149. var deburredLetters = {
  14150. // Latin-1 Supplement block.
  14151. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  14152. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  14153. '\xc7': 'C', '\xe7': 'c',
  14154. '\xd0': 'D', '\xf0': 'd',
  14155. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  14156. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  14157. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  14158. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  14159. '\xd1': 'N', '\xf1': 'n',
  14160. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  14161. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  14162. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  14163. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  14164. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  14165. '\xc6': 'Ae', '\xe6': 'ae',
  14166. '\xde': 'Th', '\xfe': 'th',
  14167. '\xdf': 'ss',
  14168. // Latin Extended-A block.
  14169. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  14170. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  14171. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  14172. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  14173. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  14174. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  14175. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  14176. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  14177. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  14178. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  14179. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  14180. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  14181. '\u0134': 'J', '\u0135': 'j',
  14182. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  14183. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  14184. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  14185. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  14186. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  14187. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  14188. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  14189. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  14190. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  14191. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  14192. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  14193. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  14194. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  14195. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  14196. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  14197. '\u0174': 'W', '\u0175': 'w',
  14198. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  14199. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  14200. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  14201. '\u0132': 'IJ', '\u0133': 'ij',
  14202. '\u0152': 'Oe', '\u0153': 'oe',
  14203. '\u0149': "'n", '\u017f': 's'
  14204. };
  14205. /** Used to map characters to HTML entities. */
  14206. var htmlEscapes = {
  14207. '&': '&amp;',
  14208. '<': '&lt;',
  14209. '>': '&gt;',
  14210. '"': '&quot;',
  14211. "'": '&#39;'
  14212. };
  14213. /** Used to map HTML entities to characters. */
  14214. var htmlUnescapes = {
  14215. '&amp;': '&',
  14216. '&lt;': '<',
  14217. '&gt;': '>',
  14218. '&quot;': '"',
  14219. '&#39;': "'"
  14220. };
  14221. /** Used to escape characters for inclusion in compiled string literals. */
  14222. var stringEscapes = {
  14223. '\\': '\\',
  14224. "'": "'",
  14225. '\n': 'n',
  14226. '\r': 'r',
  14227. '\u2028': 'u2028',
  14228. '\u2029': 'u2029'
  14229. };
  14230. /** Built-in method references without a dependency on `root`. */
  14231. var freeParseFloat = parseFloat,
  14232. freeParseInt = parseInt;
  14233. /** Detect free variable `global` from Node.js. */
  14234. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  14235. /** Detect free variable `self`. */
  14236. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  14237. /** Used as a reference to the global object. */
  14238. var root = freeGlobal || freeSelf || Function('return this')();
  14239. /** Detect free variable `exports`. */
  14240. var freeExports = true && exports && !exports.nodeType && exports;
  14241. /** Detect free variable `module`. */
  14242. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  14243. /** Detect the popular CommonJS extension `module.exports`. */
  14244. var moduleExports = freeModule && freeModule.exports === freeExports;
  14245. /** Detect free variable `process` from Node.js. */
  14246. var freeProcess = moduleExports && freeGlobal.process;
  14247. /** Used to access faster Node.js helpers. */
  14248. var nodeUtil = (function() {
  14249. try {
  14250. // Use `util.types` for Node.js 10+.
  14251. var types = freeModule && freeModule.require && freeModule.require('util').types;
  14252. if (types) {
  14253. return types;
  14254. }
  14255. // Legacy `process.binding('util')` for Node.js < 10.
  14256. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  14257. } catch (e) {}
  14258. }());
  14259. /* Node.js helper references. */
  14260. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  14261. nodeIsDate = nodeUtil && nodeUtil.isDate,
  14262. nodeIsMap = nodeUtil && nodeUtil.isMap,
  14263. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  14264. nodeIsSet = nodeUtil && nodeUtil.isSet,
  14265. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  14266. /*--------------------------------------------------------------------------*/
  14267. /**
  14268. * A faster alternative to `Function#apply`, this function invokes `func`
  14269. * with the `this` binding of `thisArg` and the arguments of `args`.
  14270. *
  14271. * @private
  14272. * @param {Function} func The function to invoke.
  14273. * @param {*} thisArg The `this` binding of `func`.
  14274. * @param {Array} args The arguments to invoke `func` with.
  14275. * @returns {*} Returns the result of `func`.
  14276. */
  14277. function apply(func, thisArg, args) {
  14278. switch (args.length) {
  14279. case 0: return func.call(thisArg);
  14280. case 1: return func.call(thisArg, args[0]);
  14281. case 2: return func.call(thisArg, args[0], args[1]);
  14282. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  14283. }
  14284. return func.apply(thisArg, args);
  14285. }
  14286. /**
  14287. * A specialized version of `baseAggregator` for arrays.
  14288. *
  14289. * @private
  14290. * @param {Array} [array] The array to iterate over.
  14291. * @param {Function} setter The function to set `accumulator` values.
  14292. * @param {Function} iteratee The iteratee to transform keys.
  14293. * @param {Object} accumulator The initial aggregated object.
  14294. * @returns {Function} Returns `accumulator`.
  14295. */
  14296. function arrayAggregator(array, setter, iteratee, accumulator) {
  14297. var index = -1,
  14298. length = array == null ? 0 : array.length;
  14299. while (++index < length) {
  14300. var value = array[index];
  14301. setter(accumulator, value, iteratee(value), array);
  14302. }
  14303. return accumulator;
  14304. }
  14305. /**
  14306. * A specialized version of `_.forEach` for arrays without support for
  14307. * iteratee shorthands.
  14308. *
  14309. * @private
  14310. * @param {Array} [array] The array to iterate over.
  14311. * @param {Function} iteratee The function invoked per iteration.
  14312. * @returns {Array} Returns `array`.
  14313. */
  14314. function arrayEach(array, iteratee) {
  14315. var index = -1,
  14316. length = array == null ? 0 : array.length;
  14317. while (++index < length) {
  14318. if (iteratee(array[index], index, array) === false) {
  14319. break;
  14320. }
  14321. }
  14322. return array;
  14323. }
  14324. /**
  14325. * A specialized version of `_.forEachRight` for arrays without support for
  14326. * iteratee shorthands.
  14327. *
  14328. * @private
  14329. * @param {Array} [array] The array to iterate over.
  14330. * @param {Function} iteratee The function invoked per iteration.
  14331. * @returns {Array} Returns `array`.
  14332. */
  14333. function arrayEachRight(array, iteratee) {
  14334. var length = array == null ? 0 : array.length;
  14335. while (length--) {
  14336. if (iteratee(array[length], length, array) === false) {
  14337. break;
  14338. }
  14339. }
  14340. return array;
  14341. }
  14342. /**
  14343. * A specialized version of `_.every` for arrays without support for
  14344. * iteratee shorthands.
  14345. *
  14346. * @private
  14347. * @param {Array} [array] The array to iterate over.
  14348. * @param {Function} predicate The function invoked per iteration.
  14349. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  14350. * else `false`.
  14351. */
  14352. function arrayEvery(array, predicate) {
  14353. var index = -1,
  14354. length = array == null ? 0 : array.length;
  14355. while (++index < length) {
  14356. if (!predicate(array[index], index, array)) {
  14357. return false;
  14358. }
  14359. }
  14360. return true;
  14361. }
  14362. /**
  14363. * A specialized version of `_.filter` for arrays without support for
  14364. * iteratee shorthands.
  14365. *
  14366. * @private
  14367. * @param {Array} [array] The array to iterate over.
  14368. * @param {Function} predicate The function invoked per iteration.
  14369. * @returns {Array} Returns the new filtered array.
  14370. */
  14371. function arrayFilter(array, predicate) {
  14372. var index = -1,
  14373. length = array == null ? 0 : array.length,
  14374. resIndex = 0,
  14375. result = [];
  14376. while (++index < length) {
  14377. var value = array[index];
  14378. if (predicate(value, index, array)) {
  14379. result[resIndex++] = value;
  14380. }
  14381. }
  14382. return result;
  14383. }
  14384. /**
  14385. * A specialized version of `_.includes` for arrays without support for
  14386. * specifying an index to search from.
  14387. *
  14388. * @private
  14389. * @param {Array} [array] The array to inspect.
  14390. * @param {*} target The value to search for.
  14391. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14392. */
  14393. function arrayIncludes(array, value) {
  14394. var length = array == null ? 0 : array.length;
  14395. return !!length && baseIndexOf(array, value, 0) > -1;
  14396. }
  14397. /**
  14398. * This function is like `arrayIncludes` except that it accepts a comparator.
  14399. *
  14400. * @private
  14401. * @param {Array} [array] The array to inspect.
  14402. * @param {*} target The value to search for.
  14403. * @param {Function} comparator The comparator invoked per element.
  14404. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14405. */
  14406. function arrayIncludesWith(array, value, comparator) {
  14407. var index = -1,
  14408. length = array == null ? 0 : array.length;
  14409. while (++index < length) {
  14410. if (comparator(value, array[index])) {
  14411. return true;
  14412. }
  14413. }
  14414. return false;
  14415. }
  14416. /**
  14417. * A specialized version of `_.map` for arrays without support for iteratee
  14418. * shorthands.
  14419. *
  14420. * @private
  14421. * @param {Array} [array] The array to iterate over.
  14422. * @param {Function} iteratee The function invoked per iteration.
  14423. * @returns {Array} Returns the new mapped array.
  14424. */
  14425. function arrayMap(array, iteratee) {
  14426. var index = -1,
  14427. length = array == null ? 0 : array.length,
  14428. result = Array(length);
  14429. while (++index < length) {
  14430. result[index] = iteratee(array[index], index, array);
  14431. }
  14432. return result;
  14433. }
  14434. /**
  14435. * Appends the elements of `values` to `array`.
  14436. *
  14437. * @private
  14438. * @param {Array} array The array to modify.
  14439. * @param {Array} values The values to append.
  14440. * @returns {Array} Returns `array`.
  14441. */
  14442. function arrayPush(array, values) {
  14443. var index = -1,
  14444. length = values.length,
  14445. offset = array.length;
  14446. while (++index < length) {
  14447. array[offset + index] = values[index];
  14448. }
  14449. return array;
  14450. }
  14451. /**
  14452. * A specialized version of `_.reduce` for arrays without support for
  14453. * iteratee shorthands.
  14454. *
  14455. * @private
  14456. * @param {Array} [array] The array to iterate over.
  14457. * @param {Function} iteratee The function invoked per iteration.
  14458. * @param {*} [accumulator] The initial value.
  14459. * @param {boolean} [initAccum] Specify using the first element of `array` as
  14460. * the initial value.
  14461. * @returns {*} Returns the accumulated value.
  14462. */
  14463. function arrayReduce(array, iteratee, accumulator, initAccum) {
  14464. var index = -1,
  14465. length = array == null ? 0 : array.length;
  14466. if (initAccum && length) {
  14467. accumulator = array[++index];
  14468. }
  14469. while (++index < length) {
  14470. accumulator = iteratee(accumulator, array[index], index, array);
  14471. }
  14472. return accumulator;
  14473. }
  14474. /**
  14475. * A specialized version of `_.reduceRight` for arrays without support for
  14476. * iteratee shorthands.
  14477. *
  14478. * @private
  14479. * @param {Array} [array] The array to iterate over.
  14480. * @param {Function} iteratee The function invoked per iteration.
  14481. * @param {*} [accumulator] The initial value.
  14482. * @param {boolean} [initAccum] Specify using the last element of `array` as
  14483. * the initial value.
  14484. * @returns {*} Returns the accumulated value.
  14485. */
  14486. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  14487. var length = array == null ? 0 : array.length;
  14488. if (initAccum && length) {
  14489. accumulator = array[--length];
  14490. }
  14491. while (length--) {
  14492. accumulator = iteratee(accumulator, array[length], length, array);
  14493. }
  14494. return accumulator;
  14495. }
  14496. /**
  14497. * A specialized version of `_.some` for arrays without support for iteratee
  14498. * shorthands.
  14499. *
  14500. * @private
  14501. * @param {Array} [array] The array to iterate over.
  14502. * @param {Function} predicate The function invoked per iteration.
  14503. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14504. * else `false`.
  14505. */
  14506. function arraySome(array, predicate) {
  14507. var index = -1,
  14508. length = array == null ? 0 : array.length;
  14509. while (++index < length) {
  14510. if (predicate(array[index], index, array)) {
  14511. return true;
  14512. }
  14513. }
  14514. return false;
  14515. }
  14516. /**
  14517. * Gets the size of an ASCII `string`.
  14518. *
  14519. * @private
  14520. * @param {string} string The string inspect.
  14521. * @returns {number} Returns the string size.
  14522. */
  14523. var asciiSize = baseProperty('length');
  14524. /**
  14525. * Converts an ASCII `string` to an array.
  14526. *
  14527. * @private
  14528. * @param {string} string The string to convert.
  14529. * @returns {Array} Returns the converted array.
  14530. */
  14531. function asciiToArray(string) {
  14532. return string.split('');
  14533. }
  14534. /**
  14535. * Splits an ASCII `string` into an array of its words.
  14536. *
  14537. * @private
  14538. * @param {string} The string to inspect.
  14539. * @returns {Array} Returns the words of `string`.
  14540. */
  14541. function asciiWords(string) {
  14542. return string.match(reAsciiWord) || [];
  14543. }
  14544. /**
  14545. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  14546. * without support for iteratee shorthands, which iterates over `collection`
  14547. * using `eachFunc`.
  14548. *
  14549. * @private
  14550. * @param {Array|Object} collection The collection to inspect.
  14551. * @param {Function} predicate The function invoked per iteration.
  14552. * @param {Function} eachFunc The function to iterate over `collection`.
  14553. * @returns {*} Returns the found element or its key, else `undefined`.
  14554. */
  14555. function baseFindKey(collection, predicate, eachFunc) {
  14556. var result;
  14557. eachFunc(collection, function(value, key, collection) {
  14558. if (predicate(value, key, collection)) {
  14559. result = key;
  14560. return false;
  14561. }
  14562. });
  14563. return result;
  14564. }
  14565. /**
  14566. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  14567. * support for iteratee shorthands.
  14568. *
  14569. * @private
  14570. * @param {Array} array The array to inspect.
  14571. * @param {Function} predicate The function invoked per iteration.
  14572. * @param {number} fromIndex The index to search from.
  14573. * @param {boolean} [fromRight] Specify iterating from right to left.
  14574. * @returns {number} Returns the index of the matched value, else `-1`.
  14575. */
  14576. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  14577. var length = array.length,
  14578. index = fromIndex + (fromRight ? 1 : -1);
  14579. while ((fromRight ? index-- : ++index < length)) {
  14580. if (predicate(array[index], index, array)) {
  14581. return index;
  14582. }
  14583. }
  14584. return -1;
  14585. }
  14586. /**
  14587. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  14588. *
  14589. * @private
  14590. * @param {Array} array The array to inspect.
  14591. * @param {*} value The value to search for.
  14592. * @param {number} fromIndex The index to search from.
  14593. * @returns {number} Returns the index of the matched value, else `-1`.
  14594. */
  14595. function baseIndexOf(array, value, fromIndex) {
  14596. return value === value
  14597. ? strictIndexOf(array, value, fromIndex)
  14598. : baseFindIndex(array, baseIsNaN, fromIndex);
  14599. }
  14600. /**
  14601. * This function is like `baseIndexOf` except that it accepts a comparator.
  14602. *
  14603. * @private
  14604. * @param {Array} array The array to inspect.
  14605. * @param {*} value The value to search for.
  14606. * @param {number} fromIndex The index to search from.
  14607. * @param {Function} comparator The comparator invoked per element.
  14608. * @returns {number} Returns the index of the matched value, else `-1`.
  14609. */
  14610. function baseIndexOfWith(array, value, fromIndex, comparator) {
  14611. var index = fromIndex - 1,
  14612. length = array.length;
  14613. while (++index < length) {
  14614. if (comparator(array[index], value)) {
  14615. return index;
  14616. }
  14617. }
  14618. return -1;
  14619. }
  14620. /**
  14621. * The base implementation of `_.isNaN` without support for number objects.
  14622. *
  14623. * @private
  14624. * @param {*} value The value to check.
  14625. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  14626. */
  14627. function baseIsNaN(value) {
  14628. return value !== value;
  14629. }
  14630. /**
  14631. * The base implementation of `_.mean` and `_.meanBy` without support for
  14632. * iteratee shorthands.
  14633. *
  14634. * @private
  14635. * @param {Array} array The array to iterate over.
  14636. * @param {Function} iteratee The function invoked per iteration.
  14637. * @returns {number} Returns the mean.
  14638. */
  14639. function baseMean(array, iteratee) {
  14640. var length = array == null ? 0 : array.length;
  14641. return length ? (baseSum(array, iteratee) / length) : NAN;
  14642. }
  14643. /**
  14644. * The base implementation of `_.property` without support for deep paths.
  14645. *
  14646. * @private
  14647. * @param {string} key The key of the property to get.
  14648. * @returns {Function} Returns the new accessor function.
  14649. */
  14650. function baseProperty(key) {
  14651. return function(object) {
  14652. return object == null ? undefined : object[key];
  14653. };
  14654. }
  14655. /**
  14656. * The base implementation of `_.propertyOf` without support for deep paths.
  14657. *
  14658. * @private
  14659. * @param {Object} object The object to query.
  14660. * @returns {Function} Returns the new accessor function.
  14661. */
  14662. function basePropertyOf(object) {
  14663. return function(key) {
  14664. return object == null ? undefined : object[key];
  14665. };
  14666. }
  14667. /**
  14668. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  14669. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  14670. *
  14671. * @private
  14672. * @param {Array|Object} collection The collection to iterate over.
  14673. * @param {Function} iteratee The function invoked per iteration.
  14674. * @param {*} accumulator The initial value.
  14675. * @param {boolean} initAccum Specify using the first or last element of
  14676. * `collection` as the initial value.
  14677. * @param {Function} eachFunc The function to iterate over `collection`.
  14678. * @returns {*} Returns the accumulated value.
  14679. */
  14680. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  14681. eachFunc(collection, function(value, index, collection) {
  14682. accumulator = initAccum
  14683. ? (initAccum = false, value)
  14684. : iteratee(accumulator, value, index, collection);
  14685. });
  14686. return accumulator;
  14687. }
  14688. /**
  14689. * The base implementation of `_.sortBy` which uses `comparer` to define the
  14690. * sort order of `array` and replaces criteria objects with their corresponding
  14691. * values.
  14692. *
  14693. * @private
  14694. * @param {Array} array The array to sort.
  14695. * @param {Function} comparer The function to define sort order.
  14696. * @returns {Array} Returns `array`.
  14697. */
  14698. function baseSortBy(array, comparer) {
  14699. var length = array.length;
  14700. array.sort(comparer);
  14701. while (length--) {
  14702. array[length] = array[length].value;
  14703. }
  14704. return array;
  14705. }
  14706. /**
  14707. * The base implementation of `_.sum` and `_.sumBy` without support for
  14708. * iteratee shorthands.
  14709. *
  14710. * @private
  14711. * @param {Array} array The array to iterate over.
  14712. * @param {Function} iteratee The function invoked per iteration.
  14713. * @returns {number} Returns the sum.
  14714. */
  14715. function baseSum(array, iteratee) {
  14716. var result,
  14717. index = -1,
  14718. length = array.length;
  14719. while (++index < length) {
  14720. var current = iteratee(array[index]);
  14721. if (current !== undefined) {
  14722. result = result === undefined ? current : (result + current);
  14723. }
  14724. }
  14725. return result;
  14726. }
  14727. /**
  14728. * The base implementation of `_.times` without support for iteratee shorthands
  14729. * or max array length checks.
  14730. *
  14731. * @private
  14732. * @param {number} n The number of times to invoke `iteratee`.
  14733. * @param {Function} iteratee The function invoked per iteration.
  14734. * @returns {Array} Returns the array of results.
  14735. */
  14736. function baseTimes(n, iteratee) {
  14737. var index = -1,
  14738. result = Array(n);
  14739. while (++index < n) {
  14740. result[index] = iteratee(index);
  14741. }
  14742. return result;
  14743. }
  14744. /**
  14745. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  14746. * of key-value pairs for `object` corresponding to the property names of `props`.
  14747. *
  14748. * @private
  14749. * @param {Object} object The object to query.
  14750. * @param {Array} props The property names to get values for.
  14751. * @returns {Object} Returns the key-value pairs.
  14752. */
  14753. function baseToPairs(object, props) {
  14754. return arrayMap(props, function(key) {
  14755. return [key, object[key]];
  14756. });
  14757. }
  14758. /**
  14759. * The base implementation of `_.unary` without support for storing metadata.
  14760. *
  14761. * @private
  14762. * @param {Function} func The function to cap arguments for.
  14763. * @returns {Function} Returns the new capped function.
  14764. */
  14765. function baseUnary(func) {
  14766. return function(value) {
  14767. return func(value);
  14768. };
  14769. }
  14770. /**
  14771. * The base implementation of `_.values` and `_.valuesIn` which creates an
  14772. * array of `object` property values corresponding to the property names
  14773. * of `props`.
  14774. *
  14775. * @private
  14776. * @param {Object} object The object to query.
  14777. * @param {Array} props The property names to get values for.
  14778. * @returns {Object} Returns the array of property values.
  14779. */
  14780. function baseValues(object, props) {
  14781. return arrayMap(props, function(key) {
  14782. return object[key];
  14783. });
  14784. }
  14785. /**
  14786. * Checks if a `cache` value for `key` exists.
  14787. *
  14788. * @private
  14789. * @param {Object} cache The cache to query.
  14790. * @param {string} key The key of the entry to check.
  14791. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  14792. */
  14793. function cacheHas(cache, key) {
  14794. return cache.has(key);
  14795. }
  14796. /**
  14797. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  14798. * that is not found in the character symbols.
  14799. *
  14800. * @private
  14801. * @param {Array} strSymbols The string symbols to inspect.
  14802. * @param {Array} chrSymbols The character symbols to find.
  14803. * @returns {number} Returns the index of the first unmatched string symbol.
  14804. */
  14805. function charsStartIndex(strSymbols, chrSymbols) {
  14806. var index = -1,
  14807. length = strSymbols.length;
  14808. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14809. return index;
  14810. }
  14811. /**
  14812. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  14813. * that is not found in the character symbols.
  14814. *
  14815. * @private
  14816. * @param {Array} strSymbols The string symbols to inspect.
  14817. * @param {Array} chrSymbols The character symbols to find.
  14818. * @returns {number} Returns the index of the last unmatched string symbol.
  14819. */
  14820. function charsEndIndex(strSymbols, chrSymbols) {
  14821. var index = strSymbols.length;
  14822. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14823. return index;
  14824. }
  14825. /**
  14826. * Gets the number of `placeholder` occurrences in `array`.
  14827. *
  14828. * @private
  14829. * @param {Array} array The array to inspect.
  14830. * @param {*} placeholder The placeholder to search for.
  14831. * @returns {number} Returns the placeholder count.
  14832. */
  14833. function countHolders(array, placeholder) {
  14834. var length = array.length,
  14835. result = 0;
  14836. while (length--) {
  14837. if (array[length] === placeholder) {
  14838. ++result;
  14839. }
  14840. }
  14841. return result;
  14842. }
  14843. /**
  14844. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  14845. * letters to basic Latin letters.
  14846. *
  14847. * @private
  14848. * @param {string} letter The matched letter to deburr.
  14849. * @returns {string} Returns the deburred letter.
  14850. */
  14851. var deburrLetter = basePropertyOf(deburredLetters);
  14852. /**
  14853. * Used by `_.escape` to convert characters to HTML entities.
  14854. *
  14855. * @private
  14856. * @param {string} chr The matched character to escape.
  14857. * @returns {string} Returns the escaped character.
  14858. */
  14859. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  14860. /**
  14861. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  14862. *
  14863. * @private
  14864. * @param {string} chr The matched character to escape.
  14865. * @returns {string} Returns the escaped character.
  14866. */
  14867. function escapeStringChar(chr) {
  14868. return '\\' + stringEscapes[chr];
  14869. }
  14870. /**
  14871. * Gets the value at `key` of `object`.
  14872. *
  14873. * @private
  14874. * @param {Object} [object] The object to query.
  14875. * @param {string} key The key of the property to get.
  14876. * @returns {*} Returns the property value.
  14877. */
  14878. function getValue(object, key) {
  14879. return object == null ? undefined : object[key];
  14880. }
  14881. /**
  14882. * Checks if `string` contains Unicode symbols.
  14883. *
  14884. * @private
  14885. * @param {string} string The string to inspect.
  14886. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  14887. */
  14888. function hasUnicode(string) {
  14889. return reHasUnicode.test(string);
  14890. }
  14891. /**
  14892. * Checks if `string` contains a word composed of Unicode symbols.
  14893. *
  14894. * @private
  14895. * @param {string} string The string to inspect.
  14896. * @returns {boolean} Returns `true` if a word is found, else `false`.
  14897. */
  14898. function hasUnicodeWord(string) {
  14899. return reHasUnicodeWord.test(string);
  14900. }
  14901. /**
  14902. * Converts `iterator` to an array.
  14903. *
  14904. * @private
  14905. * @param {Object} iterator The iterator to convert.
  14906. * @returns {Array} Returns the converted array.
  14907. */
  14908. function iteratorToArray(iterator) {
  14909. var data,
  14910. result = [];
  14911. while (!(data = iterator.next()).done) {
  14912. result.push(data.value);
  14913. }
  14914. return result;
  14915. }
  14916. /**
  14917. * Converts `map` to its key-value pairs.
  14918. *
  14919. * @private
  14920. * @param {Object} map The map to convert.
  14921. * @returns {Array} Returns the key-value pairs.
  14922. */
  14923. function mapToArray(map) {
  14924. var index = -1,
  14925. result = Array(map.size);
  14926. map.forEach(function(value, key) {
  14927. result[++index] = [key, value];
  14928. });
  14929. return result;
  14930. }
  14931. /**
  14932. * Creates a unary function that invokes `func` with its argument transformed.
  14933. *
  14934. * @private
  14935. * @param {Function} func The function to wrap.
  14936. * @param {Function} transform The argument transform.
  14937. * @returns {Function} Returns the new function.
  14938. */
  14939. function overArg(func, transform) {
  14940. return function(arg) {
  14941. return func(transform(arg));
  14942. };
  14943. }
  14944. /**
  14945. * Replaces all `placeholder` elements in `array` with an internal placeholder
  14946. * and returns an array of their indexes.
  14947. *
  14948. * @private
  14949. * @param {Array} array The array to modify.
  14950. * @param {*} placeholder The placeholder to replace.
  14951. * @returns {Array} Returns the new array of placeholder indexes.
  14952. */
  14953. function replaceHolders(array, placeholder) {
  14954. var index = -1,
  14955. length = array.length,
  14956. resIndex = 0,
  14957. result = [];
  14958. while (++index < length) {
  14959. var value = array[index];
  14960. if (value === placeholder || value === PLACEHOLDER) {
  14961. array[index] = PLACEHOLDER;
  14962. result[resIndex++] = index;
  14963. }
  14964. }
  14965. return result;
  14966. }
  14967. /**
  14968. * Converts `set` to an array of its values.
  14969. *
  14970. * @private
  14971. * @param {Object} set The set to convert.
  14972. * @returns {Array} Returns the values.
  14973. */
  14974. function setToArray(set) {
  14975. var index = -1,
  14976. result = Array(set.size);
  14977. set.forEach(function(value) {
  14978. result[++index] = value;
  14979. });
  14980. return result;
  14981. }
  14982. /**
  14983. * Converts `set` to its value-value pairs.
  14984. *
  14985. * @private
  14986. * @param {Object} set The set to convert.
  14987. * @returns {Array} Returns the value-value pairs.
  14988. */
  14989. function setToPairs(set) {
  14990. var index = -1,
  14991. result = Array(set.size);
  14992. set.forEach(function(value) {
  14993. result[++index] = [value, value];
  14994. });
  14995. return result;
  14996. }
  14997. /**
  14998. * A specialized version of `_.indexOf` which performs strict equality
  14999. * comparisons of values, i.e. `===`.
  15000. *
  15001. * @private
  15002. * @param {Array} array The array to inspect.
  15003. * @param {*} value The value to search for.
  15004. * @param {number} fromIndex The index to search from.
  15005. * @returns {number} Returns the index of the matched value, else `-1`.
  15006. */
  15007. function strictIndexOf(array, value, fromIndex) {
  15008. var index = fromIndex - 1,
  15009. length = array.length;
  15010. while (++index < length) {
  15011. if (array[index] === value) {
  15012. return index;
  15013. }
  15014. }
  15015. return -1;
  15016. }
  15017. /**
  15018. * A specialized version of `_.lastIndexOf` which performs strict equality
  15019. * comparisons of values, i.e. `===`.
  15020. *
  15021. * @private
  15022. * @param {Array} array The array to inspect.
  15023. * @param {*} value The value to search for.
  15024. * @param {number} fromIndex The index to search from.
  15025. * @returns {number} Returns the index of the matched value, else `-1`.
  15026. */
  15027. function strictLastIndexOf(array, value, fromIndex) {
  15028. var index = fromIndex + 1;
  15029. while (index--) {
  15030. if (array[index] === value) {
  15031. return index;
  15032. }
  15033. }
  15034. return index;
  15035. }
  15036. /**
  15037. * Gets the number of symbols in `string`.
  15038. *
  15039. * @private
  15040. * @param {string} string The string to inspect.
  15041. * @returns {number} Returns the string size.
  15042. */
  15043. function stringSize(string) {
  15044. return hasUnicode(string)
  15045. ? unicodeSize(string)
  15046. : asciiSize(string);
  15047. }
  15048. /**
  15049. * Converts `string` to an array.
  15050. *
  15051. * @private
  15052. * @param {string} string The string to convert.
  15053. * @returns {Array} Returns the converted array.
  15054. */
  15055. function stringToArray(string) {
  15056. return hasUnicode(string)
  15057. ? unicodeToArray(string)
  15058. : asciiToArray(string);
  15059. }
  15060. /**
  15061. * Used by `_.unescape` to convert HTML entities to characters.
  15062. *
  15063. * @private
  15064. * @param {string} chr The matched character to unescape.
  15065. * @returns {string} Returns the unescaped character.
  15066. */
  15067. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  15068. /**
  15069. * Gets the size of a Unicode `string`.
  15070. *
  15071. * @private
  15072. * @param {string} string The string inspect.
  15073. * @returns {number} Returns the string size.
  15074. */
  15075. function unicodeSize(string) {
  15076. var result = reUnicode.lastIndex = 0;
  15077. while (reUnicode.test(string)) {
  15078. ++result;
  15079. }
  15080. return result;
  15081. }
  15082. /**
  15083. * Converts a Unicode `string` to an array.
  15084. *
  15085. * @private
  15086. * @param {string} string The string to convert.
  15087. * @returns {Array} Returns the converted array.
  15088. */
  15089. function unicodeToArray(string) {
  15090. return string.match(reUnicode) || [];
  15091. }
  15092. /**
  15093. * Splits a Unicode `string` into an array of its words.
  15094. *
  15095. * @private
  15096. * @param {string} The string to inspect.
  15097. * @returns {Array} Returns the words of `string`.
  15098. */
  15099. function unicodeWords(string) {
  15100. return string.match(reUnicodeWord) || [];
  15101. }
  15102. /*--------------------------------------------------------------------------*/
  15103. /**
  15104. * Create a new pristine `lodash` function using the `context` object.
  15105. *
  15106. * @static
  15107. * @memberOf _
  15108. * @since 1.1.0
  15109. * @category Util
  15110. * @param {Object} [context=root] The context object.
  15111. * @returns {Function} Returns a new `lodash` function.
  15112. * @example
  15113. *
  15114. * _.mixin({ 'foo': _.constant('foo') });
  15115. *
  15116. * var lodash = _.runInContext();
  15117. * lodash.mixin({ 'bar': lodash.constant('bar') });
  15118. *
  15119. * _.isFunction(_.foo);
  15120. * // => true
  15121. * _.isFunction(_.bar);
  15122. * // => false
  15123. *
  15124. * lodash.isFunction(lodash.foo);
  15125. * // => false
  15126. * lodash.isFunction(lodash.bar);
  15127. * // => true
  15128. *
  15129. * // Create a suped-up `defer` in Node.js.
  15130. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  15131. */
  15132. var runInContext = (function runInContext(context) {
  15133. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  15134. /** Built-in constructor references. */
  15135. var Array = context.Array,
  15136. Date = context.Date,
  15137. Error = context.Error,
  15138. Function = context.Function,
  15139. Math = context.Math,
  15140. Object = context.Object,
  15141. RegExp = context.RegExp,
  15142. String = context.String,
  15143. TypeError = context.TypeError;
  15144. /** Used for built-in method references. */
  15145. var arrayProto = Array.prototype,
  15146. funcProto = Function.prototype,
  15147. objectProto = Object.prototype;
  15148. /** Used to detect overreaching core-js shims. */
  15149. var coreJsData = context['__core-js_shared__'];
  15150. /** Used to resolve the decompiled source of functions. */
  15151. var funcToString = funcProto.toString;
  15152. /** Used to check objects for own properties. */
  15153. var hasOwnProperty = objectProto.hasOwnProperty;
  15154. /** Used to generate unique IDs. */
  15155. var idCounter = 0;
  15156. /** Used to detect methods masquerading as native. */
  15157. var maskSrcKey = (function() {
  15158. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  15159. return uid ? ('Symbol(src)_1.' + uid) : '';
  15160. }());
  15161. /**
  15162. * Used to resolve the
  15163. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  15164. * of values.
  15165. */
  15166. var nativeObjectToString = objectProto.toString;
  15167. /** Used to infer the `Object` constructor. */
  15168. var objectCtorString = funcToString.call(Object);
  15169. /** Used to restore the original `_` reference in `_.noConflict`. */
  15170. var oldDash = root._;
  15171. /** Used to detect if a method is native. */
  15172. var reIsNative = RegExp('^' +
  15173. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  15174. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  15175. );
  15176. /** Built-in value references. */
  15177. var Buffer = moduleExports ? context.Buffer : undefined,
  15178. Symbol = context.Symbol,
  15179. Uint8Array = context.Uint8Array,
  15180. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  15181. getPrototype = overArg(Object.getPrototypeOf, Object),
  15182. objectCreate = Object.create,
  15183. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  15184. splice = arrayProto.splice,
  15185. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  15186. symIterator = Symbol ? Symbol.iterator : undefined,
  15187. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  15188. var defineProperty = (function() {
  15189. try {
  15190. var func = getNative(Object, 'defineProperty');
  15191. func({}, '', {});
  15192. return func;
  15193. } catch (e) {}
  15194. }());
  15195. /** Mocked built-ins. */
  15196. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  15197. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  15198. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  15199. /* Built-in method references for those with the same name as other `lodash` methods. */
  15200. var nativeCeil = Math.ceil,
  15201. nativeFloor = Math.floor,
  15202. nativeGetSymbols = Object.getOwnPropertySymbols,
  15203. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  15204. nativeIsFinite = context.isFinite,
  15205. nativeJoin = arrayProto.join,
  15206. nativeKeys = overArg(Object.keys, Object),
  15207. nativeMax = Math.max,
  15208. nativeMin = Math.min,
  15209. nativeNow = Date.now,
  15210. nativeParseInt = context.parseInt,
  15211. nativeRandom = Math.random,
  15212. nativeReverse = arrayProto.reverse;
  15213. /* Built-in method references that are verified to be native. */
  15214. var DataView = getNative(context, 'DataView'),
  15215. Map = getNative(context, 'Map'),
  15216. Promise = getNative(context, 'Promise'),
  15217. Set = getNative(context, 'Set'),
  15218. WeakMap = getNative(context, 'WeakMap'),
  15219. nativeCreate = getNative(Object, 'create');
  15220. /** Used to store function metadata. */
  15221. var metaMap = WeakMap && new WeakMap;
  15222. /** Used to lookup unminified function names. */
  15223. var realNames = {};
  15224. /** Used to detect maps, sets, and weakmaps. */
  15225. var dataViewCtorString = toSource(DataView),
  15226. mapCtorString = toSource(Map),
  15227. promiseCtorString = toSource(Promise),
  15228. setCtorString = toSource(Set),
  15229. weakMapCtorString = toSource(WeakMap);
  15230. /** Used to convert symbols to primitives and strings. */
  15231. var symbolProto = Symbol ? Symbol.prototype : undefined,
  15232. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  15233. symbolToString = symbolProto ? symbolProto.toString : undefined;
  15234. /*------------------------------------------------------------------------*/
  15235. /**
  15236. * Creates a `lodash` object which wraps `value` to enable implicit method
  15237. * chain sequences. Methods that operate on and return arrays, collections,
  15238. * and functions can be chained together. Methods that retrieve a single value
  15239. * or may return a primitive value will automatically end the chain sequence
  15240. * and return the unwrapped value. Otherwise, the value must be unwrapped
  15241. * with `_#value`.
  15242. *
  15243. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  15244. * enabled using `_.chain`.
  15245. *
  15246. * The execution of chained methods is lazy, that is, it's deferred until
  15247. * `_#value` is implicitly or explicitly called.
  15248. *
  15249. * Lazy evaluation allows several methods to support shortcut fusion.
  15250. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  15251. * the creation of intermediate arrays and can greatly reduce the number of
  15252. * iteratee executions. Sections of a chain sequence qualify for shortcut
  15253. * fusion if the section is applied to an array and iteratees accept only
  15254. * one argument. The heuristic for whether a section qualifies for shortcut
  15255. * fusion is subject to change.
  15256. *
  15257. * Chaining is supported in custom builds as long as the `_#value` method is
  15258. * directly or indirectly included in the build.
  15259. *
  15260. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  15261. *
  15262. * The wrapper `Array` methods are:
  15263. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  15264. *
  15265. * The wrapper `String` methods are:
  15266. * `replace` and `split`
  15267. *
  15268. * The wrapper methods that support shortcut fusion are:
  15269. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  15270. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  15271. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  15272. *
  15273. * The chainable wrapper methods are:
  15274. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  15275. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  15276. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  15277. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  15278. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  15279. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  15280. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  15281. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  15282. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  15283. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  15284. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  15285. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  15286. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  15287. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  15288. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  15289. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  15290. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  15291. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  15292. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  15293. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  15294. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  15295. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  15296. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  15297. * `zipObject`, `zipObjectDeep`, and `zipWith`
  15298. *
  15299. * The wrapper methods that are **not** chainable by default are:
  15300. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  15301. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  15302. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  15303. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  15304. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  15305. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  15306. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  15307. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  15308. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  15309. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  15310. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  15311. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  15312. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  15313. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  15314. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  15315. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  15316. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  15317. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  15318. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  15319. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  15320. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  15321. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  15322. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  15323. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  15324. * `upperFirst`, `value`, and `words`
  15325. *
  15326. * @name _
  15327. * @constructor
  15328. * @category Seq
  15329. * @param {*} value The value to wrap in a `lodash` instance.
  15330. * @returns {Object} Returns the new `lodash` wrapper instance.
  15331. * @example
  15332. *
  15333. * function square(n) {
  15334. * return n * n;
  15335. * }
  15336. *
  15337. * var wrapped = _([1, 2, 3]);
  15338. *
  15339. * // Returns an unwrapped value.
  15340. * wrapped.reduce(_.add);
  15341. * // => 6
  15342. *
  15343. * // Returns a wrapped value.
  15344. * var squares = wrapped.map(square);
  15345. *
  15346. * _.isArray(squares);
  15347. * // => false
  15348. *
  15349. * _.isArray(squares.value());
  15350. * // => true
  15351. */
  15352. function lodash(value) {
  15353. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  15354. if (value instanceof LodashWrapper) {
  15355. return value;
  15356. }
  15357. if (hasOwnProperty.call(value, '__wrapped__')) {
  15358. return wrapperClone(value);
  15359. }
  15360. }
  15361. return new LodashWrapper(value);
  15362. }
  15363. /**
  15364. * The base implementation of `_.create` without support for assigning
  15365. * properties to the created object.
  15366. *
  15367. * @private
  15368. * @param {Object} proto The object to inherit from.
  15369. * @returns {Object} Returns the new object.
  15370. */
  15371. var baseCreate = (function() {
  15372. function object() {}
  15373. return function(proto) {
  15374. if (!isObject(proto)) {
  15375. return {};
  15376. }
  15377. if (objectCreate) {
  15378. return objectCreate(proto);
  15379. }
  15380. object.prototype = proto;
  15381. var result = new object;
  15382. object.prototype = undefined;
  15383. return result;
  15384. };
  15385. }());
  15386. /**
  15387. * The function whose prototype chain sequence wrappers inherit from.
  15388. *
  15389. * @private
  15390. */
  15391. function baseLodash() {
  15392. // No operation performed.
  15393. }
  15394. /**
  15395. * The base constructor for creating `lodash` wrapper objects.
  15396. *
  15397. * @private
  15398. * @param {*} value The value to wrap.
  15399. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  15400. */
  15401. function LodashWrapper(value, chainAll) {
  15402. this.__wrapped__ = value;
  15403. this.__actions__ = [];
  15404. this.__chain__ = !!chainAll;
  15405. this.__index__ = 0;
  15406. this.__values__ = undefined;
  15407. }
  15408. /**
  15409. * By default, the template delimiters used by lodash are like those in
  15410. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  15411. * following template settings to use alternative delimiters.
  15412. *
  15413. * @static
  15414. * @memberOf _
  15415. * @type {Object}
  15416. */
  15417. lodash.templateSettings = {
  15418. /**
  15419. * Used to detect `data` property values to be HTML-escaped.
  15420. *
  15421. * @memberOf _.templateSettings
  15422. * @type {RegExp}
  15423. */
  15424. 'escape': reEscape,
  15425. /**
  15426. * Used to detect code to be evaluated.
  15427. *
  15428. * @memberOf _.templateSettings
  15429. * @type {RegExp}
  15430. */
  15431. 'evaluate': reEvaluate,
  15432. /**
  15433. * Used to detect `data` property values to inject.
  15434. *
  15435. * @memberOf _.templateSettings
  15436. * @type {RegExp}
  15437. */
  15438. 'interpolate': reInterpolate,
  15439. /**
  15440. * Used to reference the data object in the template text.
  15441. *
  15442. * @memberOf _.templateSettings
  15443. * @type {string}
  15444. */
  15445. 'variable': '',
  15446. /**
  15447. * Used to import variables into the compiled template.
  15448. *
  15449. * @memberOf _.templateSettings
  15450. * @type {Object}
  15451. */
  15452. 'imports': {
  15453. /**
  15454. * A reference to the `lodash` function.
  15455. *
  15456. * @memberOf _.templateSettings.imports
  15457. * @type {Function}
  15458. */
  15459. '_': lodash
  15460. }
  15461. };
  15462. // Ensure wrappers are instances of `baseLodash`.
  15463. lodash.prototype = baseLodash.prototype;
  15464. lodash.prototype.constructor = lodash;
  15465. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  15466. LodashWrapper.prototype.constructor = LodashWrapper;
  15467. /*------------------------------------------------------------------------*/
  15468. /**
  15469. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  15470. *
  15471. * @private
  15472. * @constructor
  15473. * @param {*} value The value to wrap.
  15474. */
  15475. function LazyWrapper(value) {
  15476. this.__wrapped__ = value;
  15477. this.__actions__ = [];
  15478. this.__dir__ = 1;
  15479. this.__filtered__ = false;
  15480. this.__iteratees__ = [];
  15481. this.__takeCount__ = MAX_ARRAY_LENGTH;
  15482. this.__views__ = [];
  15483. }
  15484. /**
  15485. * Creates a clone of the lazy wrapper object.
  15486. *
  15487. * @private
  15488. * @name clone
  15489. * @memberOf LazyWrapper
  15490. * @returns {Object} Returns the cloned `LazyWrapper` object.
  15491. */
  15492. function lazyClone() {
  15493. var result = new LazyWrapper(this.__wrapped__);
  15494. result.__actions__ = copyArray(this.__actions__);
  15495. result.__dir__ = this.__dir__;
  15496. result.__filtered__ = this.__filtered__;
  15497. result.__iteratees__ = copyArray(this.__iteratees__);
  15498. result.__takeCount__ = this.__takeCount__;
  15499. result.__views__ = copyArray(this.__views__);
  15500. return result;
  15501. }
  15502. /**
  15503. * Reverses the direction of lazy iteration.
  15504. *
  15505. * @private
  15506. * @name reverse
  15507. * @memberOf LazyWrapper
  15508. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  15509. */
  15510. function lazyReverse() {
  15511. if (this.__filtered__) {
  15512. var result = new LazyWrapper(this);
  15513. result.__dir__ = -1;
  15514. result.__filtered__ = true;
  15515. } else {
  15516. result = this.clone();
  15517. result.__dir__ *= -1;
  15518. }
  15519. return result;
  15520. }
  15521. /**
  15522. * Extracts the unwrapped value from its lazy wrapper.
  15523. *
  15524. * @private
  15525. * @name value
  15526. * @memberOf LazyWrapper
  15527. * @returns {*} Returns the unwrapped value.
  15528. */
  15529. function lazyValue() {
  15530. var array = this.__wrapped__.value(),
  15531. dir = this.__dir__,
  15532. isArr = isArray(array),
  15533. isRight = dir < 0,
  15534. arrLength = isArr ? array.length : 0,
  15535. view = getView(0, arrLength, this.__views__),
  15536. start = view.start,
  15537. end = view.end,
  15538. length = end - start,
  15539. index = isRight ? end : (start - 1),
  15540. iteratees = this.__iteratees__,
  15541. iterLength = iteratees.length,
  15542. resIndex = 0,
  15543. takeCount = nativeMin(length, this.__takeCount__);
  15544. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  15545. return baseWrapperValue(array, this.__actions__);
  15546. }
  15547. var result = [];
  15548. outer:
  15549. while (length-- && resIndex < takeCount) {
  15550. index += dir;
  15551. var iterIndex = -1,
  15552. value = array[index];
  15553. while (++iterIndex < iterLength) {
  15554. var data = iteratees[iterIndex],
  15555. iteratee = data.iteratee,
  15556. type = data.type,
  15557. computed = iteratee(value);
  15558. if (type == LAZY_MAP_FLAG) {
  15559. value = computed;
  15560. } else if (!computed) {
  15561. if (type == LAZY_FILTER_FLAG) {
  15562. continue outer;
  15563. } else {
  15564. break outer;
  15565. }
  15566. }
  15567. }
  15568. result[resIndex++] = value;
  15569. }
  15570. return result;
  15571. }
  15572. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  15573. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  15574. LazyWrapper.prototype.constructor = LazyWrapper;
  15575. /*------------------------------------------------------------------------*/
  15576. /**
  15577. * Creates a hash object.
  15578. *
  15579. * @private
  15580. * @constructor
  15581. * @param {Array} [entries] The key-value pairs to cache.
  15582. */
  15583. function Hash(entries) {
  15584. var index = -1,
  15585. length = entries == null ? 0 : entries.length;
  15586. this.clear();
  15587. while (++index < length) {
  15588. var entry = entries[index];
  15589. this.set(entry[0], entry[1]);
  15590. }
  15591. }
  15592. /**
  15593. * Removes all key-value entries from the hash.
  15594. *
  15595. * @private
  15596. * @name clear
  15597. * @memberOf Hash
  15598. */
  15599. function hashClear() {
  15600. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  15601. this.size = 0;
  15602. }
  15603. /**
  15604. * Removes `key` and its value from the hash.
  15605. *
  15606. * @private
  15607. * @name delete
  15608. * @memberOf Hash
  15609. * @param {Object} hash The hash to modify.
  15610. * @param {string} key The key of the value to remove.
  15611. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15612. */
  15613. function hashDelete(key) {
  15614. var result = this.has(key) && delete this.__data__[key];
  15615. this.size -= result ? 1 : 0;
  15616. return result;
  15617. }
  15618. /**
  15619. * Gets the hash value for `key`.
  15620. *
  15621. * @private
  15622. * @name get
  15623. * @memberOf Hash
  15624. * @param {string} key The key of the value to get.
  15625. * @returns {*} Returns the entry value.
  15626. */
  15627. function hashGet(key) {
  15628. var data = this.__data__;
  15629. if (nativeCreate) {
  15630. var result = data[key];
  15631. return result === HASH_UNDEFINED ? undefined : result;
  15632. }
  15633. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  15634. }
  15635. /**
  15636. * Checks if a hash value for `key` exists.
  15637. *
  15638. * @private
  15639. * @name has
  15640. * @memberOf Hash
  15641. * @param {string} key The key of the entry to check.
  15642. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15643. */
  15644. function hashHas(key) {
  15645. var data = this.__data__;
  15646. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  15647. }
  15648. /**
  15649. * Sets the hash `key` to `value`.
  15650. *
  15651. * @private
  15652. * @name set
  15653. * @memberOf Hash
  15654. * @param {string} key The key of the value to set.
  15655. * @param {*} value The value to set.
  15656. * @returns {Object} Returns the hash instance.
  15657. */
  15658. function hashSet(key, value) {
  15659. var data = this.__data__;
  15660. this.size += this.has(key) ? 0 : 1;
  15661. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  15662. return this;
  15663. }
  15664. // Add methods to `Hash`.
  15665. Hash.prototype.clear = hashClear;
  15666. Hash.prototype['delete'] = hashDelete;
  15667. Hash.prototype.get = hashGet;
  15668. Hash.prototype.has = hashHas;
  15669. Hash.prototype.set = hashSet;
  15670. /*------------------------------------------------------------------------*/
  15671. /**
  15672. * Creates an list cache object.
  15673. *
  15674. * @private
  15675. * @constructor
  15676. * @param {Array} [entries] The key-value pairs to cache.
  15677. */
  15678. function ListCache(entries) {
  15679. var index = -1,
  15680. length = entries == null ? 0 : entries.length;
  15681. this.clear();
  15682. while (++index < length) {
  15683. var entry = entries[index];
  15684. this.set(entry[0], entry[1]);
  15685. }
  15686. }
  15687. /**
  15688. * Removes all key-value entries from the list cache.
  15689. *
  15690. * @private
  15691. * @name clear
  15692. * @memberOf ListCache
  15693. */
  15694. function listCacheClear() {
  15695. this.__data__ = [];
  15696. this.size = 0;
  15697. }
  15698. /**
  15699. * Removes `key` and its value from the list cache.
  15700. *
  15701. * @private
  15702. * @name delete
  15703. * @memberOf ListCache
  15704. * @param {string} key The key of the value to remove.
  15705. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15706. */
  15707. function listCacheDelete(key) {
  15708. var data = this.__data__,
  15709. index = assocIndexOf(data, key);
  15710. if (index < 0) {
  15711. return false;
  15712. }
  15713. var lastIndex = data.length - 1;
  15714. if (index == lastIndex) {
  15715. data.pop();
  15716. } else {
  15717. splice.call(data, index, 1);
  15718. }
  15719. --this.size;
  15720. return true;
  15721. }
  15722. /**
  15723. * Gets the list cache value for `key`.
  15724. *
  15725. * @private
  15726. * @name get
  15727. * @memberOf ListCache
  15728. * @param {string} key The key of the value to get.
  15729. * @returns {*} Returns the entry value.
  15730. */
  15731. function listCacheGet(key) {
  15732. var data = this.__data__,
  15733. index = assocIndexOf(data, key);
  15734. return index < 0 ? undefined : data[index][1];
  15735. }
  15736. /**
  15737. * Checks if a list cache value for `key` exists.
  15738. *
  15739. * @private
  15740. * @name has
  15741. * @memberOf ListCache
  15742. * @param {string} key The key of the entry to check.
  15743. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15744. */
  15745. function listCacheHas(key) {
  15746. return assocIndexOf(this.__data__, key) > -1;
  15747. }
  15748. /**
  15749. * Sets the list cache `key` to `value`.
  15750. *
  15751. * @private
  15752. * @name set
  15753. * @memberOf ListCache
  15754. * @param {string} key The key of the value to set.
  15755. * @param {*} value The value to set.
  15756. * @returns {Object} Returns the list cache instance.
  15757. */
  15758. function listCacheSet(key, value) {
  15759. var data = this.__data__,
  15760. index = assocIndexOf(data, key);
  15761. if (index < 0) {
  15762. ++this.size;
  15763. data.push([key, value]);
  15764. } else {
  15765. data[index][1] = value;
  15766. }
  15767. return this;
  15768. }
  15769. // Add methods to `ListCache`.
  15770. ListCache.prototype.clear = listCacheClear;
  15771. ListCache.prototype['delete'] = listCacheDelete;
  15772. ListCache.prototype.get = listCacheGet;
  15773. ListCache.prototype.has = listCacheHas;
  15774. ListCache.prototype.set = listCacheSet;
  15775. /*------------------------------------------------------------------------*/
  15776. /**
  15777. * Creates a map cache object to store key-value pairs.
  15778. *
  15779. * @private
  15780. * @constructor
  15781. * @param {Array} [entries] The key-value pairs to cache.
  15782. */
  15783. function MapCache(entries) {
  15784. var index = -1,
  15785. length = entries == null ? 0 : entries.length;
  15786. this.clear();
  15787. while (++index < length) {
  15788. var entry = entries[index];
  15789. this.set(entry[0], entry[1]);
  15790. }
  15791. }
  15792. /**
  15793. * Removes all key-value entries from the map.
  15794. *
  15795. * @private
  15796. * @name clear
  15797. * @memberOf MapCache
  15798. */
  15799. function mapCacheClear() {
  15800. this.size = 0;
  15801. this.__data__ = {
  15802. 'hash': new Hash,
  15803. 'map': new (Map || ListCache),
  15804. 'string': new Hash
  15805. };
  15806. }
  15807. /**
  15808. * Removes `key` and its value from the map.
  15809. *
  15810. * @private
  15811. * @name delete
  15812. * @memberOf MapCache
  15813. * @param {string} key The key of the value to remove.
  15814. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15815. */
  15816. function mapCacheDelete(key) {
  15817. var result = getMapData(this, key)['delete'](key);
  15818. this.size -= result ? 1 : 0;
  15819. return result;
  15820. }
  15821. /**
  15822. * Gets the map value for `key`.
  15823. *
  15824. * @private
  15825. * @name get
  15826. * @memberOf MapCache
  15827. * @param {string} key The key of the value to get.
  15828. * @returns {*} Returns the entry value.
  15829. */
  15830. function mapCacheGet(key) {
  15831. return getMapData(this, key).get(key);
  15832. }
  15833. /**
  15834. * Checks if a map value for `key` exists.
  15835. *
  15836. * @private
  15837. * @name has
  15838. * @memberOf MapCache
  15839. * @param {string} key The key of the entry to check.
  15840. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15841. */
  15842. function mapCacheHas(key) {
  15843. return getMapData(this, key).has(key);
  15844. }
  15845. /**
  15846. * Sets the map `key` to `value`.
  15847. *
  15848. * @private
  15849. * @name set
  15850. * @memberOf MapCache
  15851. * @param {string} key The key of the value to set.
  15852. * @param {*} value The value to set.
  15853. * @returns {Object} Returns the map cache instance.
  15854. */
  15855. function mapCacheSet(key, value) {
  15856. var data = getMapData(this, key),
  15857. size = data.size;
  15858. data.set(key, value);
  15859. this.size += data.size == size ? 0 : 1;
  15860. return this;
  15861. }
  15862. // Add methods to `MapCache`.
  15863. MapCache.prototype.clear = mapCacheClear;
  15864. MapCache.prototype['delete'] = mapCacheDelete;
  15865. MapCache.prototype.get = mapCacheGet;
  15866. MapCache.prototype.has = mapCacheHas;
  15867. MapCache.prototype.set = mapCacheSet;
  15868. /*------------------------------------------------------------------------*/
  15869. /**
  15870. *
  15871. * Creates an array cache object to store unique values.
  15872. *
  15873. * @private
  15874. * @constructor
  15875. * @param {Array} [values] The values to cache.
  15876. */
  15877. function SetCache(values) {
  15878. var index = -1,
  15879. length = values == null ? 0 : values.length;
  15880. this.__data__ = new MapCache;
  15881. while (++index < length) {
  15882. this.add(values[index]);
  15883. }
  15884. }
  15885. /**
  15886. * Adds `value` to the array cache.
  15887. *
  15888. * @private
  15889. * @name add
  15890. * @memberOf SetCache
  15891. * @alias push
  15892. * @param {*} value The value to cache.
  15893. * @returns {Object} Returns the cache instance.
  15894. */
  15895. function setCacheAdd(value) {
  15896. this.__data__.set(value, HASH_UNDEFINED);
  15897. return this;
  15898. }
  15899. /**
  15900. * Checks if `value` is in the array cache.
  15901. *
  15902. * @private
  15903. * @name has
  15904. * @memberOf SetCache
  15905. * @param {*} value The value to search for.
  15906. * @returns {number} Returns `true` if `value` is found, else `false`.
  15907. */
  15908. function setCacheHas(value) {
  15909. return this.__data__.has(value);
  15910. }
  15911. // Add methods to `SetCache`.
  15912. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  15913. SetCache.prototype.has = setCacheHas;
  15914. /*------------------------------------------------------------------------*/
  15915. /**
  15916. * Creates a stack cache object to store key-value pairs.
  15917. *
  15918. * @private
  15919. * @constructor
  15920. * @param {Array} [entries] The key-value pairs to cache.
  15921. */
  15922. function Stack(entries) {
  15923. var data = this.__data__ = new ListCache(entries);
  15924. this.size = data.size;
  15925. }
  15926. /**
  15927. * Removes all key-value entries from the stack.
  15928. *
  15929. * @private
  15930. * @name clear
  15931. * @memberOf Stack
  15932. */
  15933. function stackClear() {
  15934. this.__data__ = new ListCache;
  15935. this.size = 0;
  15936. }
  15937. /**
  15938. * Removes `key` and its value from the stack.
  15939. *
  15940. * @private
  15941. * @name delete
  15942. * @memberOf Stack
  15943. * @param {string} key The key of the value to remove.
  15944. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15945. */
  15946. function stackDelete(key) {
  15947. var data = this.__data__,
  15948. result = data['delete'](key);
  15949. this.size = data.size;
  15950. return result;
  15951. }
  15952. /**
  15953. * Gets the stack value for `key`.
  15954. *
  15955. * @private
  15956. * @name get
  15957. * @memberOf Stack
  15958. * @param {string} key The key of the value to get.
  15959. * @returns {*} Returns the entry value.
  15960. */
  15961. function stackGet(key) {
  15962. return this.__data__.get(key);
  15963. }
  15964. /**
  15965. * Checks if a stack value for `key` exists.
  15966. *
  15967. * @private
  15968. * @name has
  15969. * @memberOf Stack
  15970. * @param {string} key The key of the entry to check.
  15971. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15972. */
  15973. function stackHas(key) {
  15974. return this.__data__.has(key);
  15975. }
  15976. /**
  15977. * Sets the stack `key` to `value`.
  15978. *
  15979. * @private
  15980. * @name set
  15981. * @memberOf Stack
  15982. * @param {string} key The key of the value to set.
  15983. * @param {*} value The value to set.
  15984. * @returns {Object} Returns the stack cache instance.
  15985. */
  15986. function stackSet(key, value) {
  15987. var data = this.__data__;
  15988. if (data instanceof ListCache) {
  15989. var pairs = data.__data__;
  15990. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  15991. pairs.push([key, value]);
  15992. this.size = ++data.size;
  15993. return this;
  15994. }
  15995. data = this.__data__ = new MapCache(pairs);
  15996. }
  15997. data.set(key, value);
  15998. this.size = data.size;
  15999. return this;
  16000. }
  16001. // Add methods to `Stack`.
  16002. Stack.prototype.clear = stackClear;
  16003. Stack.prototype['delete'] = stackDelete;
  16004. Stack.prototype.get = stackGet;
  16005. Stack.prototype.has = stackHas;
  16006. Stack.prototype.set = stackSet;
  16007. /*------------------------------------------------------------------------*/
  16008. /**
  16009. * Creates an array of the enumerable property names of the array-like `value`.
  16010. *
  16011. * @private
  16012. * @param {*} value The value to query.
  16013. * @param {boolean} inherited Specify returning inherited property names.
  16014. * @returns {Array} Returns the array of property names.
  16015. */
  16016. function arrayLikeKeys(value, inherited) {
  16017. var isArr = isArray(value),
  16018. isArg = !isArr && isArguments(value),
  16019. isBuff = !isArr && !isArg && isBuffer(value),
  16020. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  16021. skipIndexes = isArr || isArg || isBuff || isType,
  16022. result = skipIndexes ? baseTimes(value.length, String) : [],
  16023. length = result.length;
  16024. for (var key in value) {
  16025. if ((inherited || hasOwnProperty.call(value, key)) &&
  16026. !(skipIndexes && (
  16027. // Safari 9 has enumerable `arguments.length` in strict mode.
  16028. key == 'length' ||
  16029. // Node.js 0.10 has enumerable non-index properties on buffers.
  16030. (isBuff && (key == 'offset' || key == 'parent')) ||
  16031. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  16032. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  16033. // Skip index properties.
  16034. isIndex(key, length)
  16035. ))) {
  16036. result.push(key);
  16037. }
  16038. }
  16039. return result;
  16040. }
  16041. /**
  16042. * A specialized version of `_.sample` for arrays.
  16043. *
  16044. * @private
  16045. * @param {Array} array The array to sample.
  16046. * @returns {*} Returns the random element.
  16047. */
  16048. function arraySample(array) {
  16049. var length = array.length;
  16050. return length ? array[baseRandom(0, length - 1)] : undefined;
  16051. }
  16052. /**
  16053. * A specialized version of `_.sampleSize` for arrays.
  16054. *
  16055. * @private
  16056. * @param {Array} array The array to sample.
  16057. * @param {number} n The number of elements to sample.
  16058. * @returns {Array} Returns the random elements.
  16059. */
  16060. function arraySampleSize(array, n) {
  16061. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  16062. }
  16063. /**
  16064. * A specialized version of `_.shuffle` for arrays.
  16065. *
  16066. * @private
  16067. * @param {Array} array The array to shuffle.
  16068. * @returns {Array} Returns the new shuffled array.
  16069. */
  16070. function arrayShuffle(array) {
  16071. return shuffleSelf(copyArray(array));
  16072. }
  16073. /**
  16074. * This function is like `assignValue` except that it doesn't assign
  16075. * `undefined` values.
  16076. *
  16077. * @private
  16078. * @param {Object} object The object to modify.
  16079. * @param {string} key The key of the property to assign.
  16080. * @param {*} value The value to assign.
  16081. */
  16082. function assignMergeValue(object, key, value) {
  16083. if ((value !== undefined && !eq(object[key], value)) ||
  16084. (value === undefined && !(key in object))) {
  16085. baseAssignValue(object, key, value);
  16086. }
  16087. }
  16088. /**
  16089. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  16090. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16091. * for equality comparisons.
  16092. *
  16093. * @private
  16094. * @param {Object} object The object to modify.
  16095. * @param {string} key The key of the property to assign.
  16096. * @param {*} value The value to assign.
  16097. */
  16098. function assignValue(object, key, value) {
  16099. var objValue = object[key];
  16100. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  16101. (value === undefined && !(key in object))) {
  16102. baseAssignValue(object, key, value);
  16103. }
  16104. }
  16105. /**
  16106. * Gets the index at which the `key` is found in `array` of key-value pairs.
  16107. *
  16108. * @private
  16109. * @param {Array} array The array to inspect.
  16110. * @param {*} key The key to search for.
  16111. * @returns {number} Returns the index of the matched value, else `-1`.
  16112. */
  16113. function assocIndexOf(array, key) {
  16114. var length = array.length;
  16115. while (length--) {
  16116. if (eq(array[length][0], key)) {
  16117. return length;
  16118. }
  16119. }
  16120. return -1;
  16121. }
  16122. /**
  16123. * Aggregates elements of `collection` on `accumulator` with keys transformed
  16124. * by `iteratee` and values set by `setter`.
  16125. *
  16126. * @private
  16127. * @param {Array|Object} collection The collection to iterate over.
  16128. * @param {Function} setter The function to set `accumulator` values.
  16129. * @param {Function} iteratee The iteratee to transform keys.
  16130. * @param {Object} accumulator The initial aggregated object.
  16131. * @returns {Function} Returns `accumulator`.
  16132. */
  16133. function baseAggregator(collection, setter, iteratee, accumulator) {
  16134. baseEach(collection, function(value, key, collection) {
  16135. setter(accumulator, value, iteratee(value), collection);
  16136. });
  16137. return accumulator;
  16138. }
  16139. /**
  16140. * The base implementation of `_.assign` without support for multiple sources
  16141. * or `customizer` functions.
  16142. *
  16143. * @private
  16144. * @param {Object} object The destination object.
  16145. * @param {Object} source The source object.
  16146. * @returns {Object} Returns `object`.
  16147. */
  16148. function baseAssign(object, source) {
  16149. return object && copyObject(source, keys(source), object);
  16150. }
  16151. /**
  16152. * The base implementation of `_.assignIn` without support for multiple sources
  16153. * or `customizer` functions.
  16154. *
  16155. * @private
  16156. * @param {Object} object The destination object.
  16157. * @param {Object} source The source object.
  16158. * @returns {Object} Returns `object`.
  16159. */
  16160. function baseAssignIn(object, source) {
  16161. return object && copyObject(source, keysIn(source), object);
  16162. }
  16163. /**
  16164. * The base implementation of `assignValue` and `assignMergeValue` without
  16165. * value checks.
  16166. *
  16167. * @private
  16168. * @param {Object} object The object to modify.
  16169. * @param {string} key The key of the property to assign.
  16170. * @param {*} value The value to assign.
  16171. */
  16172. function baseAssignValue(object, key, value) {
  16173. if (key == '__proto__' && defineProperty) {
  16174. defineProperty(object, key, {
  16175. 'configurable': true,
  16176. 'enumerable': true,
  16177. 'value': value,
  16178. 'writable': true
  16179. });
  16180. } else {
  16181. object[key] = value;
  16182. }
  16183. }
  16184. /**
  16185. * The base implementation of `_.at` without support for individual paths.
  16186. *
  16187. * @private
  16188. * @param {Object} object The object to iterate over.
  16189. * @param {string[]} paths The property paths to pick.
  16190. * @returns {Array} Returns the picked elements.
  16191. */
  16192. function baseAt(object, paths) {
  16193. var index = -1,
  16194. length = paths.length,
  16195. result = Array(length),
  16196. skip = object == null;
  16197. while (++index < length) {
  16198. result[index] = skip ? undefined : get(object, paths[index]);
  16199. }
  16200. return result;
  16201. }
  16202. /**
  16203. * The base implementation of `_.clamp` which doesn't coerce arguments.
  16204. *
  16205. * @private
  16206. * @param {number} number The number to clamp.
  16207. * @param {number} [lower] The lower bound.
  16208. * @param {number} upper The upper bound.
  16209. * @returns {number} Returns the clamped number.
  16210. */
  16211. function baseClamp(number, lower, upper) {
  16212. if (number === number) {
  16213. if (upper !== undefined) {
  16214. number = number <= upper ? number : upper;
  16215. }
  16216. if (lower !== undefined) {
  16217. number = number >= lower ? number : lower;
  16218. }
  16219. }
  16220. return number;
  16221. }
  16222. /**
  16223. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  16224. * traversed objects.
  16225. *
  16226. * @private
  16227. * @param {*} value The value to clone.
  16228. * @param {boolean} bitmask The bitmask flags.
  16229. * 1 - Deep clone
  16230. * 2 - Flatten inherited properties
  16231. * 4 - Clone symbols
  16232. * @param {Function} [customizer] The function to customize cloning.
  16233. * @param {string} [key] The key of `value`.
  16234. * @param {Object} [object] The parent object of `value`.
  16235. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  16236. * @returns {*} Returns the cloned value.
  16237. */
  16238. function baseClone(value, bitmask, customizer, key, object, stack) {
  16239. var result,
  16240. isDeep = bitmask & CLONE_DEEP_FLAG,
  16241. isFlat = bitmask & CLONE_FLAT_FLAG,
  16242. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  16243. if (customizer) {
  16244. result = object ? customizer(value, key, object, stack) : customizer(value);
  16245. }
  16246. if (result !== undefined) {
  16247. return result;
  16248. }
  16249. if (!isObject(value)) {
  16250. return value;
  16251. }
  16252. var isArr = isArray(value);
  16253. if (isArr) {
  16254. result = initCloneArray(value);
  16255. if (!isDeep) {
  16256. return copyArray(value, result);
  16257. }
  16258. } else {
  16259. var tag = getTag(value),
  16260. isFunc = tag == funcTag || tag == genTag;
  16261. if (isBuffer(value)) {
  16262. return cloneBuffer(value, isDeep);
  16263. }
  16264. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  16265. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  16266. if (!isDeep) {
  16267. return isFlat
  16268. ? copySymbolsIn(value, baseAssignIn(result, value))
  16269. : copySymbols(value, baseAssign(result, value));
  16270. }
  16271. } else {
  16272. if (!cloneableTags[tag]) {
  16273. return object ? value : {};
  16274. }
  16275. result = initCloneByTag(value, tag, isDeep);
  16276. }
  16277. }
  16278. // Check for circular references and return its corresponding clone.
  16279. stack || (stack = new Stack);
  16280. var stacked = stack.get(value);
  16281. if (stacked) {
  16282. return stacked;
  16283. }
  16284. stack.set(value, result);
  16285. if (isSet(value)) {
  16286. value.forEach(function(subValue) {
  16287. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  16288. });
  16289. } else if (isMap(value)) {
  16290. value.forEach(function(subValue, key) {
  16291. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16292. });
  16293. }
  16294. var keysFunc = isFull
  16295. ? (isFlat ? getAllKeysIn : getAllKeys)
  16296. : (isFlat ? keysIn : keys);
  16297. var props = isArr ? undefined : keysFunc(value);
  16298. arrayEach(props || value, function(subValue, key) {
  16299. if (props) {
  16300. key = subValue;
  16301. subValue = value[key];
  16302. }
  16303. // Recursively populate clone (susceptible to call stack limits).
  16304. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16305. });
  16306. return result;
  16307. }
  16308. /**
  16309. * The base implementation of `_.conforms` which doesn't clone `source`.
  16310. *
  16311. * @private
  16312. * @param {Object} source The object of property predicates to conform to.
  16313. * @returns {Function} Returns the new spec function.
  16314. */
  16315. function baseConforms(source) {
  16316. var props = keys(source);
  16317. return function(object) {
  16318. return baseConformsTo(object, source, props);
  16319. };
  16320. }
  16321. /**
  16322. * The base implementation of `_.conformsTo` which accepts `props` to check.
  16323. *
  16324. * @private
  16325. * @param {Object} object The object to inspect.
  16326. * @param {Object} source The object of property predicates to conform to.
  16327. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  16328. */
  16329. function baseConformsTo(object, source, props) {
  16330. var length = props.length;
  16331. if (object == null) {
  16332. return !length;
  16333. }
  16334. object = Object(object);
  16335. while (length--) {
  16336. var key = props[length],
  16337. predicate = source[key],
  16338. value = object[key];
  16339. if ((value === undefined && !(key in object)) || !predicate(value)) {
  16340. return false;
  16341. }
  16342. }
  16343. return true;
  16344. }
  16345. /**
  16346. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  16347. * to provide to `func`.
  16348. *
  16349. * @private
  16350. * @param {Function} func The function to delay.
  16351. * @param {number} wait The number of milliseconds to delay invocation.
  16352. * @param {Array} args The arguments to provide to `func`.
  16353. * @returns {number|Object} Returns the timer id or timeout object.
  16354. */
  16355. function baseDelay(func, wait, args) {
  16356. if (typeof func != 'function') {
  16357. throw new TypeError(FUNC_ERROR_TEXT);
  16358. }
  16359. return setTimeout(function() { func.apply(undefined, args); }, wait);
  16360. }
  16361. /**
  16362. * The base implementation of methods like `_.difference` without support
  16363. * for excluding multiple arrays or iteratee shorthands.
  16364. *
  16365. * @private
  16366. * @param {Array} array The array to inspect.
  16367. * @param {Array} values The values to exclude.
  16368. * @param {Function} [iteratee] The iteratee invoked per element.
  16369. * @param {Function} [comparator] The comparator invoked per element.
  16370. * @returns {Array} Returns the new array of filtered values.
  16371. */
  16372. function baseDifference(array, values, iteratee, comparator) {
  16373. var index = -1,
  16374. includes = arrayIncludes,
  16375. isCommon = true,
  16376. length = array.length,
  16377. result = [],
  16378. valuesLength = values.length;
  16379. if (!length) {
  16380. return result;
  16381. }
  16382. if (iteratee) {
  16383. values = arrayMap(values, baseUnary(iteratee));
  16384. }
  16385. if (comparator) {
  16386. includes = arrayIncludesWith;
  16387. isCommon = false;
  16388. }
  16389. else if (values.length >= LARGE_ARRAY_SIZE) {
  16390. includes = cacheHas;
  16391. isCommon = false;
  16392. values = new SetCache(values);
  16393. }
  16394. outer:
  16395. while (++index < length) {
  16396. var value = array[index],
  16397. computed = iteratee == null ? value : iteratee(value);
  16398. value = (comparator || value !== 0) ? value : 0;
  16399. if (isCommon && computed === computed) {
  16400. var valuesIndex = valuesLength;
  16401. while (valuesIndex--) {
  16402. if (values[valuesIndex] === computed) {
  16403. continue outer;
  16404. }
  16405. }
  16406. result.push(value);
  16407. }
  16408. else if (!includes(values, computed, comparator)) {
  16409. result.push(value);
  16410. }
  16411. }
  16412. return result;
  16413. }
  16414. /**
  16415. * The base implementation of `_.forEach` without support for iteratee shorthands.
  16416. *
  16417. * @private
  16418. * @param {Array|Object} collection The collection to iterate over.
  16419. * @param {Function} iteratee The function invoked per iteration.
  16420. * @returns {Array|Object} Returns `collection`.
  16421. */
  16422. var baseEach = createBaseEach(baseForOwn);
  16423. /**
  16424. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  16425. *
  16426. * @private
  16427. * @param {Array|Object} collection The collection to iterate over.
  16428. * @param {Function} iteratee The function invoked per iteration.
  16429. * @returns {Array|Object} Returns `collection`.
  16430. */
  16431. var baseEachRight = createBaseEach(baseForOwnRight, true);
  16432. /**
  16433. * The base implementation of `_.every` without support for iteratee shorthands.
  16434. *
  16435. * @private
  16436. * @param {Array|Object} collection The collection to iterate over.
  16437. * @param {Function} predicate The function invoked per iteration.
  16438. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  16439. * else `false`
  16440. */
  16441. function baseEvery(collection, predicate) {
  16442. var result = true;
  16443. baseEach(collection, function(value, index, collection) {
  16444. result = !!predicate(value, index, collection);
  16445. return result;
  16446. });
  16447. return result;
  16448. }
  16449. /**
  16450. * The base implementation of methods like `_.max` and `_.min` which accepts a
  16451. * `comparator` to determine the extremum value.
  16452. *
  16453. * @private
  16454. * @param {Array} array The array to iterate over.
  16455. * @param {Function} iteratee The iteratee invoked per iteration.
  16456. * @param {Function} comparator The comparator used to compare values.
  16457. * @returns {*} Returns the extremum value.
  16458. */
  16459. function baseExtremum(array, iteratee, comparator) {
  16460. var index = -1,
  16461. length = array.length;
  16462. while (++index < length) {
  16463. var value = array[index],
  16464. current = iteratee(value);
  16465. if (current != null && (computed === undefined
  16466. ? (current === current && !isSymbol(current))
  16467. : comparator(current, computed)
  16468. )) {
  16469. var computed = current,
  16470. result = value;
  16471. }
  16472. }
  16473. return result;
  16474. }
  16475. /**
  16476. * The base implementation of `_.fill` without an iteratee call guard.
  16477. *
  16478. * @private
  16479. * @param {Array} array The array to fill.
  16480. * @param {*} value The value to fill `array` with.
  16481. * @param {number} [start=0] The start position.
  16482. * @param {number} [end=array.length] The end position.
  16483. * @returns {Array} Returns `array`.
  16484. */
  16485. function baseFill(array, value, start, end) {
  16486. var length = array.length;
  16487. start = toInteger(start);
  16488. if (start < 0) {
  16489. start = -start > length ? 0 : (length + start);
  16490. }
  16491. end = (end === undefined || end > length) ? length : toInteger(end);
  16492. if (end < 0) {
  16493. end += length;
  16494. }
  16495. end = start > end ? 0 : toLength(end);
  16496. while (start < end) {
  16497. array[start++] = value;
  16498. }
  16499. return array;
  16500. }
  16501. /**
  16502. * The base implementation of `_.filter` without support for iteratee shorthands.
  16503. *
  16504. * @private
  16505. * @param {Array|Object} collection The collection to iterate over.
  16506. * @param {Function} predicate The function invoked per iteration.
  16507. * @returns {Array} Returns the new filtered array.
  16508. */
  16509. function baseFilter(collection, predicate) {
  16510. var result = [];
  16511. baseEach(collection, function(value, index, collection) {
  16512. if (predicate(value, index, collection)) {
  16513. result.push(value);
  16514. }
  16515. });
  16516. return result;
  16517. }
  16518. /**
  16519. * The base implementation of `_.flatten` with support for restricting flattening.
  16520. *
  16521. * @private
  16522. * @param {Array} array The array to flatten.
  16523. * @param {number} depth The maximum recursion depth.
  16524. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  16525. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  16526. * @param {Array} [result=[]] The initial result value.
  16527. * @returns {Array} Returns the new flattened array.
  16528. */
  16529. function baseFlatten(array, depth, predicate, isStrict, result) {
  16530. var index = -1,
  16531. length = array.length;
  16532. predicate || (predicate = isFlattenable);
  16533. result || (result = []);
  16534. while (++index < length) {
  16535. var value = array[index];
  16536. if (depth > 0 && predicate(value)) {
  16537. if (depth > 1) {
  16538. // Recursively flatten arrays (susceptible to call stack limits).
  16539. baseFlatten(value, depth - 1, predicate, isStrict, result);
  16540. } else {
  16541. arrayPush(result, value);
  16542. }
  16543. } else if (!isStrict) {
  16544. result[result.length] = value;
  16545. }
  16546. }
  16547. return result;
  16548. }
  16549. /**
  16550. * The base implementation of `baseForOwn` which iterates over `object`
  16551. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  16552. * Iteratee functions may exit iteration early by explicitly returning `false`.
  16553. *
  16554. * @private
  16555. * @param {Object} object The object to iterate over.
  16556. * @param {Function} iteratee The function invoked per iteration.
  16557. * @param {Function} keysFunc The function to get the keys of `object`.
  16558. * @returns {Object} Returns `object`.
  16559. */
  16560. var baseFor = createBaseFor();
  16561. /**
  16562. * This function is like `baseFor` except that it iterates over properties
  16563. * in the opposite order.
  16564. *
  16565. * @private
  16566. * @param {Object} object The object to iterate over.
  16567. * @param {Function} iteratee The function invoked per iteration.
  16568. * @param {Function} keysFunc The function to get the keys of `object`.
  16569. * @returns {Object} Returns `object`.
  16570. */
  16571. var baseForRight = createBaseFor(true);
  16572. /**
  16573. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  16574. *
  16575. * @private
  16576. * @param {Object} object The object to iterate over.
  16577. * @param {Function} iteratee The function invoked per iteration.
  16578. * @returns {Object} Returns `object`.
  16579. */
  16580. function baseForOwn(object, iteratee) {
  16581. return object && baseFor(object, iteratee, keys);
  16582. }
  16583. /**
  16584. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  16585. *
  16586. * @private
  16587. * @param {Object} object The object to iterate over.
  16588. * @param {Function} iteratee The function invoked per iteration.
  16589. * @returns {Object} Returns `object`.
  16590. */
  16591. function baseForOwnRight(object, iteratee) {
  16592. return object && baseForRight(object, iteratee, keys);
  16593. }
  16594. /**
  16595. * The base implementation of `_.functions` which creates an array of
  16596. * `object` function property names filtered from `props`.
  16597. *
  16598. * @private
  16599. * @param {Object} object The object to inspect.
  16600. * @param {Array} props The property names to filter.
  16601. * @returns {Array} Returns the function names.
  16602. */
  16603. function baseFunctions(object, props) {
  16604. return arrayFilter(props, function(key) {
  16605. return isFunction(object[key]);
  16606. });
  16607. }
  16608. /**
  16609. * The base implementation of `_.get` without support for default values.
  16610. *
  16611. * @private
  16612. * @param {Object} object The object to query.
  16613. * @param {Array|string} path The path of the property to get.
  16614. * @returns {*} Returns the resolved value.
  16615. */
  16616. function baseGet(object, path) {
  16617. path = castPath(path, object);
  16618. var index = 0,
  16619. length = path.length;
  16620. while (object != null && index < length) {
  16621. object = object[toKey(path[index++])];
  16622. }
  16623. return (index && index == length) ? object : undefined;
  16624. }
  16625. /**
  16626. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  16627. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  16628. * symbols of `object`.
  16629. *
  16630. * @private
  16631. * @param {Object} object The object to query.
  16632. * @param {Function} keysFunc The function to get the keys of `object`.
  16633. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  16634. * @returns {Array} Returns the array of property names and symbols.
  16635. */
  16636. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  16637. var result = keysFunc(object);
  16638. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  16639. }
  16640. /**
  16641. * The base implementation of `getTag` without fallbacks for buggy environments.
  16642. *
  16643. * @private
  16644. * @param {*} value The value to query.
  16645. * @returns {string} Returns the `toStringTag`.
  16646. */
  16647. function baseGetTag(value) {
  16648. if (value == null) {
  16649. return value === undefined ? undefinedTag : nullTag;
  16650. }
  16651. return (symToStringTag && symToStringTag in Object(value))
  16652. ? getRawTag(value)
  16653. : objectToString(value);
  16654. }
  16655. /**
  16656. * The base implementation of `_.gt` which doesn't coerce arguments.
  16657. *
  16658. * @private
  16659. * @param {*} value The value to compare.
  16660. * @param {*} other The other value to compare.
  16661. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  16662. * else `false`.
  16663. */
  16664. function baseGt(value, other) {
  16665. return value > other;
  16666. }
  16667. /**
  16668. * The base implementation of `_.has` without support for deep paths.
  16669. *
  16670. * @private
  16671. * @param {Object} [object] The object to query.
  16672. * @param {Array|string} key The key to check.
  16673. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16674. */
  16675. function baseHas(object, key) {
  16676. return object != null && hasOwnProperty.call(object, key);
  16677. }
  16678. /**
  16679. * The base implementation of `_.hasIn` without support for deep paths.
  16680. *
  16681. * @private
  16682. * @param {Object} [object] The object to query.
  16683. * @param {Array|string} key The key to check.
  16684. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16685. */
  16686. function baseHasIn(object, key) {
  16687. return object != null && key in Object(object);
  16688. }
  16689. /**
  16690. * The base implementation of `_.inRange` which doesn't coerce arguments.
  16691. *
  16692. * @private
  16693. * @param {number} number The number to check.
  16694. * @param {number} start The start of the range.
  16695. * @param {number} end The end of the range.
  16696. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  16697. */
  16698. function baseInRange(number, start, end) {
  16699. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  16700. }
  16701. /**
  16702. * The base implementation of methods like `_.intersection`, without support
  16703. * for iteratee shorthands, that accepts an array of arrays to inspect.
  16704. *
  16705. * @private
  16706. * @param {Array} arrays The arrays to inspect.
  16707. * @param {Function} [iteratee] The iteratee invoked per element.
  16708. * @param {Function} [comparator] The comparator invoked per element.
  16709. * @returns {Array} Returns the new array of shared values.
  16710. */
  16711. function baseIntersection(arrays, iteratee, comparator) {
  16712. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  16713. length = arrays[0].length,
  16714. othLength = arrays.length,
  16715. othIndex = othLength,
  16716. caches = Array(othLength),
  16717. maxLength = Infinity,
  16718. result = [];
  16719. while (othIndex--) {
  16720. var array = arrays[othIndex];
  16721. if (othIndex && iteratee) {
  16722. array = arrayMap(array, baseUnary(iteratee));
  16723. }
  16724. maxLength = nativeMin(array.length, maxLength);
  16725. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  16726. ? new SetCache(othIndex && array)
  16727. : undefined;
  16728. }
  16729. array = arrays[0];
  16730. var index = -1,
  16731. seen = caches[0];
  16732. outer:
  16733. while (++index < length && result.length < maxLength) {
  16734. var value = array[index],
  16735. computed = iteratee ? iteratee(value) : value;
  16736. value = (comparator || value !== 0) ? value : 0;
  16737. if (!(seen
  16738. ? cacheHas(seen, computed)
  16739. : includes(result, computed, comparator)
  16740. )) {
  16741. othIndex = othLength;
  16742. while (--othIndex) {
  16743. var cache = caches[othIndex];
  16744. if (!(cache
  16745. ? cacheHas(cache, computed)
  16746. : includes(arrays[othIndex], computed, comparator))
  16747. ) {
  16748. continue outer;
  16749. }
  16750. }
  16751. if (seen) {
  16752. seen.push(computed);
  16753. }
  16754. result.push(value);
  16755. }
  16756. }
  16757. return result;
  16758. }
  16759. /**
  16760. * The base implementation of `_.invert` and `_.invertBy` which inverts
  16761. * `object` with values transformed by `iteratee` and set by `setter`.
  16762. *
  16763. * @private
  16764. * @param {Object} object The object to iterate over.
  16765. * @param {Function} setter The function to set `accumulator` values.
  16766. * @param {Function} iteratee The iteratee to transform values.
  16767. * @param {Object} accumulator The initial inverted object.
  16768. * @returns {Function} Returns `accumulator`.
  16769. */
  16770. function baseInverter(object, setter, iteratee, accumulator) {
  16771. baseForOwn(object, function(value, key, object) {
  16772. setter(accumulator, iteratee(value), key, object);
  16773. });
  16774. return accumulator;
  16775. }
  16776. /**
  16777. * The base implementation of `_.invoke` without support for individual
  16778. * method arguments.
  16779. *
  16780. * @private
  16781. * @param {Object} object The object to query.
  16782. * @param {Array|string} path The path of the method to invoke.
  16783. * @param {Array} args The arguments to invoke the method with.
  16784. * @returns {*} Returns the result of the invoked method.
  16785. */
  16786. function baseInvoke(object, path, args) {
  16787. path = castPath(path, object);
  16788. object = parent(object, path);
  16789. var func = object == null ? object : object[toKey(last(path))];
  16790. return func == null ? undefined : apply(func, object, args);
  16791. }
  16792. /**
  16793. * The base implementation of `_.isArguments`.
  16794. *
  16795. * @private
  16796. * @param {*} value The value to check.
  16797. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  16798. */
  16799. function baseIsArguments(value) {
  16800. return isObjectLike(value) && baseGetTag(value) == argsTag;
  16801. }
  16802. /**
  16803. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  16804. *
  16805. * @private
  16806. * @param {*} value The value to check.
  16807. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  16808. */
  16809. function baseIsArrayBuffer(value) {
  16810. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  16811. }
  16812. /**
  16813. * The base implementation of `_.isDate` without Node.js optimizations.
  16814. *
  16815. * @private
  16816. * @param {*} value The value to check.
  16817. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  16818. */
  16819. function baseIsDate(value) {
  16820. return isObjectLike(value) && baseGetTag(value) == dateTag;
  16821. }
  16822. /**
  16823. * The base implementation of `_.isEqual` which supports partial comparisons
  16824. * and tracks traversed objects.
  16825. *
  16826. * @private
  16827. * @param {*} value The value to compare.
  16828. * @param {*} other The other value to compare.
  16829. * @param {boolean} bitmask The bitmask flags.
  16830. * 1 - Unordered comparison
  16831. * 2 - Partial comparison
  16832. * @param {Function} [customizer] The function to customize comparisons.
  16833. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  16834. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16835. */
  16836. function baseIsEqual(value, other, bitmask, customizer, stack) {
  16837. if (value === other) {
  16838. return true;
  16839. }
  16840. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  16841. return value !== value && other !== other;
  16842. }
  16843. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  16844. }
  16845. /**
  16846. * A specialized version of `baseIsEqual` for arrays and objects which performs
  16847. * deep comparisons and tracks traversed objects enabling objects with circular
  16848. * references to be compared.
  16849. *
  16850. * @private
  16851. * @param {Object} object The object to compare.
  16852. * @param {Object} other The other object to compare.
  16853. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  16854. * @param {Function} customizer The function to customize comparisons.
  16855. * @param {Function} equalFunc The function to determine equivalents of values.
  16856. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  16857. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  16858. */
  16859. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  16860. var objIsArr = isArray(object),
  16861. othIsArr = isArray(other),
  16862. objTag = objIsArr ? arrayTag : getTag(object),
  16863. othTag = othIsArr ? arrayTag : getTag(other);
  16864. objTag = objTag == argsTag ? objectTag : objTag;
  16865. othTag = othTag == argsTag ? objectTag : othTag;
  16866. var objIsObj = objTag == objectTag,
  16867. othIsObj = othTag == objectTag,
  16868. isSameTag = objTag == othTag;
  16869. if (isSameTag && isBuffer(object)) {
  16870. if (!isBuffer(other)) {
  16871. return false;
  16872. }
  16873. objIsArr = true;
  16874. objIsObj = false;
  16875. }
  16876. if (isSameTag && !objIsObj) {
  16877. stack || (stack = new Stack);
  16878. return (objIsArr || isTypedArray(object))
  16879. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  16880. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  16881. }
  16882. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  16883. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  16884. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  16885. if (objIsWrapped || othIsWrapped) {
  16886. var objUnwrapped = objIsWrapped ? object.value() : object,
  16887. othUnwrapped = othIsWrapped ? other.value() : other;
  16888. stack || (stack = new Stack);
  16889. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  16890. }
  16891. }
  16892. if (!isSameTag) {
  16893. return false;
  16894. }
  16895. stack || (stack = new Stack);
  16896. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  16897. }
  16898. /**
  16899. * The base implementation of `_.isMap` without Node.js optimizations.
  16900. *
  16901. * @private
  16902. * @param {*} value The value to check.
  16903. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  16904. */
  16905. function baseIsMap(value) {
  16906. return isObjectLike(value) && getTag(value) == mapTag;
  16907. }
  16908. /**
  16909. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  16910. *
  16911. * @private
  16912. * @param {Object} object The object to inspect.
  16913. * @param {Object} source The object of property values to match.
  16914. * @param {Array} matchData The property names, values, and compare flags to match.
  16915. * @param {Function} [customizer] The function to customize comparisons.
  16916. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  16917. */
  16918. function baseIsMatch(object, source, matchData, customizer) {
  16919. var index = matchData.length,
  16920. length = index,
  16921. noCustomizer = !customizer;
  16922. if (object == null) {
  16923. return !length;
  16924. }
  16925. object = Object(object);
  16926. while (index--) {
  16927. var data = matchData[index];
  16928. if ((noCustomizer && data[2])
  16929. ? data[1] !== object[data[0]]
  16930. : !(data[0] in object)
  16931. ) {
  16932. return false;
  16933. }
  16934. }
  16935. while (++index < length) {
  16936. data = matchData[index];
  16937. var key = data[0],
  16938. objValue = object[key],
  16939. srcValue = data[1];
  16940. if (noCustomizer && data[2]) {
  16941. if (objValue === undefined && !(key in object)) {
  16942. return false;
  16943. }
  16944. } else {
  16945. var stack = new Stack;
  16946. if (customizer) {
  16947. var result = customizer(objValue, srcValue, key, object, source, stack);
  16948. }
  16949. if (!(result === undefined
  16950. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  16951. : result
  16952. )) {
  16953. return false;
  16954. }
  16955. }
  16956. }
  16957. return true;
  16958. }
  16959. /**
  16960. * The base implementation of `_.isNative` without bad shim checks.
  16961. *
  16962. * @private
  16963. * @param {*} value The value to check.
  16964. * @returns {boolean} Returns `true` if `value` is a native function,
  16965. * else `false`.
  16966. */
  16967. function baseIsNative(value) {
  16968. if (!isObject(value) || isMasked(value)) {
  16969. return false;
  16970. }
  16971. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  16972. return pattern.test(toSource(value));
  16973. }
  16974. /**
  16975. * The base implementation of `_.isRegExp` without Node.js optimizations.
  16976. *
  16977. * @private
  16978. * @param {*} value The value to check.
  16979. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  16980. */
  16981. function baseIsRegExp(value) {
  16982. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  16983. }
  16984. /**
  16985. * The base implementation of `_.isSet` without Node.js optimizations.
  16986. *
  16987. * @private
  16988. * @param {*} value The value to check.
  16989. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  16990. */
  16991. function baseIsSet(value) {
  16992. return isObjectLike(value) && getTag(value) == setTag;
  16993. }
  16994. /**
  16995. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  16996. *
  16997. * @private
  16998. * @param {*} value The value to check.
  16999. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  17000. */
  17001. function baseIsTypedArray(value) {
  17002. return isObjectLike(value) &&
  17003. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  17004. }
  17005. /**
  17006. * The base implementation of `_.iteratee`.
  17007. *
  17008. * @private
  17009. * @param {*} [value=_.identity] The value to convert to an iteratee.
  17010. * @returns {Function} Returns the iteratee.
  17011. */
  17012. function baseIteratee(value) {
  17013. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  17014. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  17015. if (typeof value == 'function') {
  17016. return value;
  17017. }
  17018. if (value == null) {
  17019. return identity;
  17020. }
  17021. if (typeof value == 'object') {
  17022. return isArray(value)
  17023. ? baseMatchesProperty(value[0], value[1])
  17024. : baseMatches(value);
  17025. }
  17026. return property(value);
  17027. }
  17028. /**
  17029. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  17030. *
  17031. * @private
  17032. * @param {Object} object The object to query.
  17033. * @returns {Array} Returns the array of property names.
  17034. */
  17035. function baseKeys(object) {
  17036. if (!isPrototype(object)) {
  17037. return nativeKeys(object);
  17038. }
  17039. var result = [];
  17040. for (var key in Object(object)) {
  17041. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  17042. result.push(key);
  17043. }
  17044. }
  17045. return result;
  17046. }
  17047. /**
  17048. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  17049. *
  17050. * @private
  17051. * @param {Object} object The object to query.
  17052. * @returns {Array} Returns the array of property names.
  17053. */
  17054. function baseKeysIn(object) {
  17055. if (!isObject(object)) {
  17056. return nativeKeysIn(object);
  17057. }
  17058. var isProto = isPrototype(object),
  17059. result = [];
  17060. for (var key in object) {
  17061. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  17062. result.push(key);
  17063. }
  17064. }
  17065. return result;
  17066. }
  17067. /**
  17068. * The base implementation of `_.lt` which doesn't coerce arguments.
  17069. *
  17070. * @private
  17071. * @param {*} value The value to compare.
  17072. * @param {*} other The other value to compare.
  17073. * @returns {boolean} Returns `true` if `value` is less than `other`,
  17074. * else `false`.
  17075. */
  17076. function baseLt(value, other) {
  17077. return value < other;
  17078. }
  17079. /**
  17080. * The base implementation of `_.map` without support for iteratee shorthands.
  17081. *
  17082. * @private
  17083. * @param {Array|Object} collection The collection to iterate over.
  17084. * @param {Function} iteratee The function invoked per iteration.
  17085. * @returns {Array} Returns the new mapped array.
  17086. */
  17087. function baseMap(collection, iteratee) {
  17088. var index = -1,
  17089. result = isArrayLike(collection) ? Array(collection.length) : [];
  17090. baseEach(collection, function(value, key, collection) {
  17091. result[++index] = iteratee(value, key, collection);
  17092. });
  17093. return result;
  17094. }
  17095. /**
  17096. * The base implementation of `_.matches` which doesn't clone `source`.
  17097. *
  17098. * @private
  17099. * @param {Object} source The object of property values to match.
  17100. * @returns {Function} Returns the new spec function.
  17101. */
  17102. function baseMatches(source) {
  17103. var matchData = getMatchData(source);
  17104. if (matchData.length == 1 && matchData[0][2]) {
  17105. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  17106. }
  17107. return function(object) {
  17108. return object === source || baseIsMatch(object, source, matchData);
  17109. };
  17110. }
  17111. /**
  17112. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  17113. *
  17114. * @private
  17115. * @param {string} path The path of the property to get.
  17116. * @param {*} srcValue The value to match.
  17117. * @returns {Function} Returns the new spec function.
  17118. */
  17119. function baseMatchesProperty(path, srcValue) {
  17120. if (isKey(path) && isStrictComparable(srcValue)) {
  17121. return matchesStrictComparable(toKey(path), srcValue);
  17122. }
  17123. return function(object) {
  17124. var objValue = get(object, path);
  17125. return (objValue === undefined && objValue === srcValue)
  17126. ? hasIn(object, path)
  17127. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  17128. };
  17129. }
  17130. /**
  17131. * The base implementation of `_.merge` without support for multiple sources.
  17132. *
  17133. * @private
  17134. * @param {Object} object The destination object.
  17135. * @param {Object} source The source object.
  17136. * @param {number} srcIndex The index of `source`.
  17137. * @param {Function} [customizer] The function to customize merged values.
  17138. * @param {Object} [stack] Tracks traversed source values and their merged
  17139. * counterparts.
  17140. */
  17141. function baseMerge(object, source, srcIndex, customizer, stack) {
  17142. if (object === source) {
  17143. return;
  17144. }
  17145. baseFor(source, function(srcValue, key) {
  17146. stack || (stack = new Stack);
  17147. if (isObject(srcValue)) {
  17148. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  17149. }
  17150. else {
  17151. var newValue = customizer
  17152. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  17153. : undefined;
  17154. if (newValue === undefined) {
  17155. newValue = srcValue;
  17156. }
  17157. assignMergeValue(object, key, newValue);
  17158. }
  17159. }, keysIn);
  17160. }
  17161. /**
  17162. * A specialized version of `baseMerge` for arrays and objects which performs
  17163. * deep merges and tracks traversed objects enabling objects with circular
  17164. * references to be merged.
  17165. *
  17166. * @private
  17167. * @param {Object} object The destination object.
  17168. * @param {Object} source The source object.
  17169. * @param {string} key The key of the value to merge.
  17170. * @param {number} srcIndex The index of `source`.
  17171. * @param {Function} mergeFunc The function to merge values.
  17172. * @param {Function} [customizer] The function to customize assigned values.
  17173. * @param {Object} [stack] Tracks traversed source values and their merged
  17174. * counterparts.
  17175. */
  17176. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  17177. var objValue = safeGet(object, key),
  17178. srcValue = safeGet(source, key),
  17179. stacked = stack.get(srcValue);
  17180. if (stacked) {
  17181. assignMergeValue(object, key, stacked);
  17182. return;
  17183. }
  17184. var newValue = customizer
  17185. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  17186. : undefined;
  17187. var isCommon = newValue === undefined;
  17188. if (isCommon) {
  17189. var isArr = isArray(srcValue),
  17190. isBuff = !isArr && isBuffer(srcValue),
  17191. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  17192. newValue = srcValue;
  17193. if (isArr || isBuff || isTyped) {
  17194. if (isArray(objValue)) {
  17195. newValue = objValue;
  17196. }
  17197. else if (isArrayLikeObject(objValue)) {
  17198. newValue = copyArray(objValue);
  17199. }
  17200. else if (isBuff) {
  17201. isCommon = false;
  17202. newValue = cloneBuffer(srcValue, true);
  17203. }
  17204. else if (isTyped) {
  17205. isCommon = false;
  17206. newValue = cloneTypedArray(srcValue, true);
  17207. }
  17208. else {
  17209. newValue = [];
  17210. }
  17211. }
  17212. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  17213. newValue = objValue;
  17214. if (isArguments(objValue)) {
  17215. newValue = toPlainObject(objValue);
  17216. }
  17217. else if (!isObject(objValue) || isFunction(objValue)) {
  17218. newValue = initCloneObject(srcValue);
  17219. }
  17220. }
  17221. else {
  17222. isCommon = false;
  17223. }
  17224. }
  17225. if (isCommon) {
  17226. // Recursively merge objects and arrays (susceptible to call stack limits).
  17227. stack.set(srcValue, newValue);
  17228. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  17229. stack['delete'](srcValue);
  17230. }
  17231. assignMergeValue(object, key, newValue);
  17232. }
  17233. /**
  17234. * The base implementation of `_.nth` which doesn't coerce arguments.
  17235. *
  17236. * @private
  17237. * @param {Array} array The array to query.
  17238. * @param {number} n The index of the element to return.
  17239. * @returns {*} Returns the nth element of `array`.
  17240. */
  17241. function baseNth(array, n) {
  17242. var length = array.length;
  17243. if (!length) {
  17244. return;
  17245. }
  17246. n += n < 0 ? length : 0;
  17247. return isIndex(n, length) ? array[n] : undefined;
  17248. }
  17249. /**
  17250. * The base implementation of `_.orderBy` without param guards.
  17251. *
  17252. * @private
  17253. * @param {Array|Object} collection The collection to iterate over.
  17254. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  17255. * @param {string[]} orders The sort orders of `iteratees`.
  17256. * @returns {Array} Returns the new sorted array.
  17257. */
  17258. function baseOrderBy(collection, iteratees, orders) {
  17259. var index = -1;
  17260. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  17261. var result = baseMap(collection, function(value, key, collection) {
  17262. var criteria = arrayMap(iteratees, function(iteratee) {
  17263. return iteratee(value);
  17264. });
  17265. return { 'criteria': criteria, 'index': ++index, 'value': value };
  17266. });
  17267. return baseSortBy(result, function(object, other) {
  17268. return compareMultiple(object, other, orders);
  17269. });
  17270. }
  17271. /**
  17272. * The base implementation of `_.pick` without support for individual
  17273. * property identifiers.
  17274. *
  17275. * @private
  17276. * @param {Object} object The source object.
  17277. * @param {string[]} paths The property paths to pick.
  17278. * @returns {Object} Returns the new object.
  17279. */
  17280. function basePick(object, paths) {
  17281. return basePickBy(object, paths, function(value, path) {
  17282. return hasIn(object, path);
  17283. });
  17284. }
  17285. /**
  17286. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  17287. *
  17288. * @private
  17289. * @param {Object} object The source object.
  17290. * @param {string[]} paths The property paths to pick.
  17291. * @param {Function} predicate The function invoked per property.
  17292. * @returns {Object} Returns the new object.
  17293. */
  17294. function basePickBy(object, paths, predicate) {
  17295. var index = -1,
  17296. length = paths.length,
  17297. result = {};
  17298. while (++index < length) {
  17299. var path = paths[index],
  17300. value = baseGet(object, path);
  17301. if (predicate(value, path)) {
  17302. baseSet(result, castPath(path, object), value);
  17303. }
  17304. }
  17305. return result;
  17306. }
  17307. /**
  17308. * A specialized version of `baseProperty` which supports deep paths.
  17309. *
  17310. * @private
  17311. * @param {Array|string} path The path of the property to get.
  17312. * @returns {Function} Returns the new accessor function.
  17313. */
  17314. function basePropertyDeep(path) {
  17315. return function(object) {
  17316. return baseGet(object, path);
  17317. };
  17318. }
  17319. /**
  17320. * The base implementation of `_.pullAllBy` without support for iteratee
  17321. * shorthands.
  17322. *
  17323. * @private
  17324. * @param {Array} array The array to modify.
  17325. * @param {Array} values The values to remove.
  17326. * @param {Function} [iteratee] The iteratee invoked per element.
  17327. * @param {Function} [comparator] The comparator invoked per element.
  17328. * @returns {Array} Returns `array`.
  17329. */
  17330. function basePullAll(array, values, iteratee, comparator) {
  17331. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  17332. index = -1,
  17333. length = values.length,
  17334. seen = array;
  17335. if (array === values) {
  17336. values = copyArray(values);
  17337. }
  17338. if (iteratee) {
  17339. seen = arrayMap(array, baseUnary(iteratee));
  17340. }
  17341. while (++index < length) {
  17342. var fromIndex = 0,
  17343. value = values[index],
  17344. computed = iteratee ? iteratee(value) : value;
  17345. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  17346. if (seen !== array) {
  17347. splice.call(seen, fromIndex, 1);
  17348. }
  17349. splice.call(array, fromIndex, 1);
  17350. }
  17351. }
  17352. return array;
  17353. }
  17354. /**
  17355. * The base implementation of `_.pullAt` without support for individual
  17356. * indexes or capturing the removed elements.
  17357. *
  17358. * @private
  17359. * @param {Array} array The array to modify.
  17360. * @param {number[]} indexes The indexes of elements to remove.
  17361. * @returns {Array} Returns `array`.
  17362. */
  17363. function basePullAt(array, indexes) {
  17364. var length = array ? indexes.length : 0,
  17365. lastIndex = length - 1;
  17366. while (length--) {
  17367. var index = indexes[length];
  17368. if (length == lastIndex || index !== previous) {
  17369. var previous = index;
  17370. if (isIndex(index)) {
  17371. splice.call(array, index, 1);
  17372. } else {
  17373. baseUnset(array, index);
  17374. }
  17375. }
  17376. }
  17377. return array;
  17378. }
  17379. /**
  17380. * The base implementation of `_.random` without support for returning
  17381. * floating-point numbers.
  17382. *
  17383. * @private
  17384. * @param {number} lower The lower bound.
  17385. * @param {number} upper The upper bound.
  17386. * @returns {number} Returns the random number.
  17387. */
  17388. function baseRandom(lower, upper) {
  17389. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  17390. }
  17391. /**
  17392. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  17393. * coerce arguments.
  17394. *
  17395. * @private
  17396. * @param {number} start The start of the range.
  17397. * @param {number} end The end of the range.
  17398. * @param {number} step The value to increment or decrement by.
  17399. * @param {boolean} [fromRight] Specify iterating from right to left.
  17400. * @returns {Array} Returns the range of numbers.
  17401. */
  17402. function baseRange(start, end, step, fromRight) {
  17403. var index = -1,
  17404. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  17405. result = Array(length);
  17406. while (length--) {
  17407. result[fromRight ? length : ++index] = start;
  17408. start += step;
  17409. }
  17410. return result;
  17411. }
  17412. /**
  17413. * The base implementation of `_.repeat` which doesn't coerce arguments.
  17414. *
  17415. * @private
  17416. * @param {string} string The string to repeat.
  17417. * @param {number} n The number of times to repeat the string.
  17418. * @returns {string} Returns the repeated string.
  17419. */
  17420. function baseRepeat(string, n) {
  17421. var result = '';
  17422. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  17423. return result;
  17424. }
  17425. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  17426. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  17427. do {
  17428. if (n % 2) {
  17429. result += string;
  17430. }
  17431. n = nativeFloor(n / 2);
  17432. if (n) {
  17433. string += string;
  17434. }
  17435. } while (n);
  17436. return result;
  17437. }
  17438. /**
  17439. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  17440. *
  17441. * @private
  17442. * @param {Function} func The function to apply a rest parameter to.
  17443. * @param {number} [start=func.length-1] The start position of the rest parameter.
  17444. * @returns {Function} Returns the new function.
  17445. */
  17446. function baseRest(func, start) {
  17447. return setToString(overRest(func, start, identity), func + '');
  17448. }
  17449. /**
  17450. * The base implementation of `_.sample`.
  17451. *
  17452. * @private
  17453. * @param {Array|Object} collection The collection to sample.
  17454. * @returns {*} Returns the random element.
  17455. */
  17456. function baseSample(collection) {
  17457. return arraySample(values(collection));
  17458. }
  17459. /**
  17460. * The base implementation of `_.sampleSize` without param guards.
  17461. *
  17462. * @private
  17463. * @param {Array|Object} collection The collection to sample.
  17464. * @param {number} n The number of elements to sample.
  17465. * @returns {Array} Returns the random elements.
  17466. */
  17467. function baseSampleSize(collection, n) {
  17468. var array = values(collection);
  17469. return shuffleSelf(array, baseClamp(n, 0, array.length));
  17470. }
  17471. /**
  17472. * The base implementation of `_.set`.
  17473. *
  17474. * @private
  17475. * @param {Object} object The object to modify.
  17476. * @param {Array|string} path The path of the property to set.
  17477. * @param {*} value The value to set.
  17478. * @param {Function} [customizer] The function to customize path creation.
  17479. * @returns {Object} Returns `object`.
  17480. */
  17481. function baseSet(object, path, value, customizer) {
  17482. if (!isObject(object)) {
  17483. return object;
  17484. }
  17485. path = castPath(path, object);
  17486. var index = -1,
  17487. length = path.length,
  17488. lastIndex = length - 1,
  17489. nested = object;
  17490. while (nested != null && ++index < length) {
  17491. var key = toKey(path[index]),
  17492. newValue = value;
  17493. if (index != lastIndex) {
  17494. var objValue = nested[key];
  17495. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  17496. if (newValue === undefined) {
  17497. newValue = isObject(objValue)
  17498. ? objValue
  17499. : (isIndex(path[index + 1]) ? [] : {});
  17500. }
  17501. }
  17502. assignValue(nested, key, newValue);
  17503. nested = nested[key];
  17504. }
  17505. return object;
  17506. }
  17507. /**
  17508. * The base implementation of `setData` without support for hot loop shorting.
  17509. *
  17510. * @private
  17511. * @param {Function} func The function to associate metadata with.
  17512. * @param {*} data The metadata.
  17513. * @returns {Function} Returns `func`.
  17514. */
  17515. var baseSetData = !metaMap ? identity : function(func, data) {
  17516. metaMap.set(func, data);
  17517. return func;
  17518. };
  17519. /**
  17520. * The base implementation of `setToString` without support for hot loop shorting.
  17521. *
  17522. * @private
  17523. * @param {Function} func The function to modify.
  17524. * @param {Function} string The `toString` result.
  17525. * @returns {Function} Returns `func`.
  17526. */
  17527. var baseSetToString = !defineProperty ? identity : function(func, string) {
  17528. return defineProperty(func, 'toString', {
  17529. 'configurable': true,
  17530. 'enumerable': false,
  17531. 'value': constant(string),
  17532. 'writable': true
  17533. });
  17534. };
  17535. /**
  17536. * The base implementation of `_.shuffle`.
  17537. *
  17538. * @private
  17539. * @param {Array|Object} collection The collection to shuffle.
  17540. * @returns {Array} Returns the new shuffled array.
  17541. */
  17542. function baseShuffle(collection) {
  17543. return shuffleSelf(values(collection));
  17544. }
  17545. /**
  17546. * The base implementation of `_.slice` without an iteratee call guard.
  17547. *
  17548. * @private
  17549. * @param {Array} array The array to slice.
  17550. * @param {number} [start=0] The start position.
  17551. * @param {number} [end=array.length] The end position.
  17552. * @returns {Array} Returns the slice of `array`.
  17553. */
  17554. function baseSlice(array, start, end) {
  17555. var index = -1,
  17556. length = array.length;
  17557. if (start < 0) {
  17558. start = -start > length ? 0 : (length + start);
  17559. }
  17560. end = end > length ? length : end;
  17561. if (end < 0) {
  17562. end += length;
  17563. }
  17564. length = start > end ? 0 : ((end - start) >>> 0);
  17565. start >>>= 0;
  17566. var result = Array(length);
  17567. while (++index < length) {
  17568. result[index] = array[index + start];
  17569. }
  17570. return result;
  17571. }
  17572. /**
  17573. * The base implementation of `_.some` without support for iteratee shorthands.
  17574. *
  17575. * @private
  17576. * @param {Array|Object} collection The collection to iterate over.
  17577. * @param {Function} predicate The function invoked per iteration.
  17578. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17579. * else `false`.
  17580. */
  17581. function baseSome(collection, predicate) {
  17582. var result;
  17583. baseEach(collection, function(value, index, collection) {
  17584. result = predicate(value, index, collection);
  17585. return !result;
  17586. });
  17587. return !!result;
  17588. }
  17589. /**
  17590. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  17591. * performs a binary search of `array` to determine the index at which `value`
  17592. * should be inserted into `array` in order to maintain its sort order.
  17593. *
  17594. * @private
  17595. * @param {Array} array The sorted array to inspect.
  17596. * @param {*} value The value to evaluate.
  17597. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17598. * @returns {number} Returns the index at which `value` should be inserted
  17599. * into `array`.
  17600. */
  17601. function baseSortedIndex(array, value, retHighest) {
  17602. var low = 0,
  17603. high = array == null ? low : array.length;
  17604. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  17605. while (low < high) {
  17606. var mid = (low + high) >>> 1,
  17607. computed = array[mid];
  17608. if (computed !== null && !isSymbol(computed) &&
  17609. (retHighest ? (computed <= value) : (computed < value))) {
  17610. low = mid + 1;
  17611. } else {
  17612. high = mid;
  17613. }
  17614. }
  17615. return high;
  17616. }
  17617. return baseSortedIndexBy(array, value, identity, retHighest);
  17618. }
  17619. /**
  17620. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  17621. * which invokes `iteratee` for `value` and each element of `array` to compute
  17622. * their sort ranking. The iteratee is invoked with one argument; (value).
  17623. *
  17624. * @private
  17625. * @param {Array} array The sorted array to inspect.
  17626. * @param {*} value The value to evaluate.
  17627. * @param {Function} iteratee The iteratee invoked per element.
  17628. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17629. * @returns {number} Returns the index at which `value` should be inserted
  17630. * into `array`.
  17631. */
  17632. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  17633. value = iteratee(value);
  17634. var low = 0,
  17635. high = array == null ? 0 : array.length,
  17636. valIsNaN = value !== value,
  17637. valIsNull = value === null,
  17638. valIsSymbol = isSymbol(value),
  17639. valIsUndefined = value === undefined;
  17640. while (low < high) {
  17641. var mid = nativeFloor((low + high) / 2),
  17642. computed = iteratee(array[mid]),
  17643. othIsDefined = computed !== undefined,
  17644. othIsNull = computed === null,
  17645. othIsReflexive = computed === computed,
  17646. othIsSymbol = isSymbol(computed);
  17647. if (valIsNaN) {
  17648. var setLow = retHighest || othIsReflexive;
  17649. } else if (valIsUndefined) {
  17650. setLow = othIsReflexive && (retHighest || othIsDefined);
  17651. } else if (valIsNull) {
  17652. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  17653. } else if (valIsSymbol) {
  17654. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  17655. } else if (othIsNull || othIsSymbol) {
  17656. setLow = false;
  17657. } else {
  17658. setLow = retHighest ? (computed <= value) : (computed < value);
  17659. }
  17660. if (setLow) {
  17661. low = mid + 1;
  17662. } else {
  17663. high = mid;
  17664. }
  17665. }
  17666. return nativeMin(high, MAX_ARRAY_INDEX);
  17667. }
  17668. /**
  17669. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  17670. * support for iteratee shorthands.
  17671. *
  17672. * @private
  17673. * @param {Array} array The array to inspect.
  17674. * @param {Function} [iteratee] The iteratee invoked per element.
  17675. * @returns {Array} Returns the new duplicate free array.
  17676. */
  17677. function baseSortedUniq(array, iteratee) {
  17678. var index = -1,
  17679. length = array.length,
  17680. resIndex = 0,
  17681. result = [];
  17682. while (++index < length) {
  17683. var value = array[index],
  17684. computed = iteratee ? iteratee(value) : value;
  17685. if (!index || !eq(computed, seen)) {
  17686. var seen = computed;
  17687. result[resIndex++] = value === 0 ? 0 : value;
  17688. }
  17689. }
  17690. return result;
  17691. }
  17692. /**
  17693. * The base implementation of `_.toNumber` which doesn't ensure correct
  17694. * conversions of binary, hexadecimal, or octal string values.
  17695. *
  17696. * @private
  17697. * @param {*} value The value to process.
  17698. * @returns {number} Returns the number.
  17699. */
  17700. function baseToNumber(value) {
  17701. if (typeof value == 'number') {
  17702. return value;
  17703. }
  17704. if (isSymbol(value)) {
  17705. return NAN;
  17706. }
  17707. return +value;
  17708. }
  17709. /**
  17710. * The base implementation of `_.toString` which doesn't convert nullish
  17711. * values to empty strings.
  17712. *
  17713. * @private
  17714. * @param {*} value The value to process.
  17715. * @returns {string} Returns the string.
  17716. */
  17717. function baseToString(value) {
  17718. // Exit early for strings to avoid a performance hit in some environments.
  17719. if (typeof value == 'string') {
  17720. return value;
  17721. }
  17722. if (isArray(value)) {
  17723. // Recursively convert values (susceptible to call stack limits).
  17724. return arrayMap(value, baseToString) + '';
  17725. }
  17726. if (isSymbol(value)) {
  17727. return symbolToString ? symbolToString.call(value) : '';
  17728. }
  17729. var result = (value + '');
  17730. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  17731. }
  17732. /**
  17733. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  17734. *
  17735. * @private
  17736. * @param {Array} array The array to inspect.
  17737. * @param {Function} [iteratee] The iteratee invoked per element.
  17738. * @param {Function} [comparator] The comparator invoked per element.
  17739. * @returns {Array} Returns the new duplicate free array.
  17740. */
  17741. function baseUniq(array, iteratee, comparator) {
  17742. var index = -1,
  17743. includes = arrayIncludes,
  17744. length = array.length,
  17745. isCommon = true,
  17746. result = [],
  17747. seen = result;
  17748. if (comparator) {
  17749. isCommon = false;
  17750. includes = arrayIncludesWith;
  17751. }
  17752. else if (length >= LARGE_ARRAY_SIZE) {
  17753. var set = iteratee ? null : createSet(array);
  17754. if (set) {
  17755. return setToArray(set);
  17756. }
  17757. isCommon = false;
  17758. includes = cacheHas;
  17759. seen = new SetCache;
  17760. }
  17761. else {
  17762. seen = iteratee ? [] : result;
  17763. }
  17764. outer:
  17765. while (++index < length) {
  17766. var value = array[index],
  17767. computed = iteratee ? iteratee(value) : value;
  17768. value = (comparator || value !== 0) ? value : 0;
  17769. if (isCommon && computed === computed) {
  17770. var seenIndex = seen.length;
  17771. while (seenIndex--) {
  17772. if (seen[seenIndex] === computed) {
  17773. continue outer;
  17774. }
  17775. }
  17776. if (iteratee) {
  17777. seen.push(computed);
  17778. }
  17779. result.push(value);
  17780. }
  17781. else if (!includes(seen, computed, comparator)) {
  17782. if (seen !== result) {
  17783. seen.push(computed);
  17784. }
  17785. result.push(value);
  17786. }
  17787. }
  17788. return result;
  17789. }
  17790. /**
  17791. * The base implementation of `_.unset`.
  17792. *
  17793. * @private
  17794. * @param {Object} object The object to modify.
  17795. * @param {Array|string} path The property path to unset.
  17796. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17797. */
  17798. function baseUnset(object, path) {
  17799. path = castPath(path, object);
  17800. object = parent(object, path);
  17801. return object == null || delete object[toKey(last(path))];
  17802. }
  17803. /**
  17804. * The base implementation of `_.update`.
  17805. *
  17806. * @private
  17807. * @param {Object} object The object to modify.
  17808. * @param {Array|string} path The path of the property to update.
  17809. * @param {Function} updater The function to produce the updated value.
  17810. * @param {Function} [customizer] The function to customize path creation.
  17811. * @returns {Object} Returns `object`.
  17812. */
  17813. function baseUpdate(object, path, updater, customizer) {
  17814. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  17815. }
  17816. /**
  17817. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  17818. * without support for iteratee shorthands.
  17819. *
  17820. * @private
  17821. * @param {Array} array The array to query.
  17822. * @param {Function} predicate The function invoked per iteration.
  17823. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  17824. * @param {boolean} [fromRight] Specify iterating from right to left.
  17825. * @returns {Array} Returns the slice of `array`.
  17826. */
  17827. function baseWhile(array, predicate, isDrop, fromRight) {
  17828. var length = array.length,
  17829. index = fromRight ? length : -1;
  17830. while ((fromRight ? index-- : ++index < length) &&
  17831. predicate(array[index], index, array)) {}
  17832. return isDrop
  17833. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  17834. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  17835. }
  17836. /**
  17837. * The base implementation of `wrapperValue` which returns the result of
  17838. * performing a sequence of actions on the unwrapped `value`, where each
  17839. * successive action is supplied the return value of the previous.
  17840. *
  17841. * @private
  17842. * @param {*} value The unwrapped value.
  17843. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  17844. * @returns {*} Returns the resolved value.
  17845. */
  17846. function baseWrapperValue(value, actions) {
  17847. var result = value;
  17848. if (result instanceof LazyWrapper) {
  17849. result = result.value();
  17850. }
  17851. return arrayReduce(actions, function(result, action) {
  17852. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  17853. }, result);
  17854. }
  17855. /**
  17856. * The base implementation of methods like `_.xor`, without support for
  17857. * iteratee shorthands, that accepts an array of arrays to inspect.
  17858. *
  17859. * @private
  17860. * @param {Array} arrays The arrays to inspect.
  17861. * @param {Function} [iteratee] The iteratee invoked per element.
  17862. * @param {Function} [comparator] The comparator invoked per element.
  17863. * @returns {Array} Returns the new array of values.
  17864. */
  17865. function baseXor(arrays, iteratee, comparator) {
  17866. var length = arrays.length;
  17867. if (length < 2) {
  17868. return length ? baseUniq(arrays[0]) : [];
  17869. }
  17870. var index = -1,
  17871. result = Array(length);
  17872. while (++index < length) {
  17873. var array = arrays[index],
  17874. othIndex = -1;
  17875. while (++othIndex < length) {
  17876. if (othIndex != index) {
  17877. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  17878. }
  17879. }
  17880. }
  17881. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  17882. }
  17883. /**
  17884. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  17885. *
  17886. * @private
  17887. * @param {Array} props The property identifiers.
  17888. * @param {Array} values The property values.
  17889. * @param {Function} assignFunc The function to assign values.
  17890. * @returns {Object} Returns the new object.
  17891. */
  17892. function baseZipObject(props, values, assignFunc) {
  17893. var index = -1,
  17894. length = props.length,
  17895. valsLength = values.length,
  17896. result = {};
  17897. while (++index < length) {
  17898. var value = index < valsLength ? values[index] : undefined;
  17899. assignFunc(result, props[index], value);
  17900. }
  17901. return result;
  17902. }
  17903. /**
  17904. * Casts `value` to an empty array if it's not an array like object.
  17905. *
  17906. * @private
  17907. * @param {*} value The value to inspect.
  17908. * @returns {Array|Object} Returns the cast array-like object.
  17909. */
  17910. function castArrayLikeObject(value) {
  17911. return isArrayLikeObject(value) ? value : [];
  17912. }
  17913. /**
  17914. * Casts `value` to `identity` if it's not a function.
  17915. *
  17916. * @private
  17917. * @param {*} value The value to inspect.
  17918. * @returns {Function} Returns cast function.
  17919. */
  17920. function castFunction(value) {
  17921. return typeof value == 'function' ? value : identity;
  17922. }
  17923. /**
  17924. * Casts `value` to a path array if it's not one.
  17925. *
  17926. * @private
  17927. * @param {*} value The value to inspect.
  17928. * @param {Object} [object] The object to query keys on.
  17929. * @returns {Array} Returns the cast property path array.
  17930. */
  17931. function castPath(value, object) {
  17932. if (isArray(value)) {
  17933. return value;
  17934. }
  17935. return isKey(value, object) ? [value] : stringToPath(toString(value));
  17936. }
  17937. /**
  17938. * A `baseRest` alias which can be replaced with `identity` by module
  17939. * replacement plugins.
  17940. *
  17941. * @private
  17942. * @type {Function}
  17943. * @param {Function} func The function to apply a rest parameter to.
  17944. * @returns {Function} Returns the new function.
  17945. */
  17946. var castRest = baseRest;
  17947. /**
  17948. * Casts `array` to a slice if it's needed.
  17949. *
  17950. * @private
  17951. * @param {Array} array The array to inspect.
  17952. * @param {number} start The start position.
  17953. * @param {number} [end=array.length] The end position.
  17954. * @returns {Array} Returns the cast slice.
  17955. */
  17956. function castSlice(array, start, end) {
  17957. var length = array.length;
  17958. end = end === undefined ? length : end;
  17959. return (!start && end >= length) ? array : baseSlice(array, start, end);
  17960. }
  17961. /**
  17962. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  17963. *
  17964. * @private
  17965. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  17966. */
  17967. var clearTimeout = ctxClearTimeout || function(id) {
  17968. return root.clearTimeout(id);
  17969. };
  17970. /**
  17971. * Creates a clone of `buffer`.
  17972. *
  17973. * @private
  17974. * @param {Buffer} buffer The buffer to clone.
  17975. * @param {boolean} [isDeep] Specify a deep clone.
  17976. * @returns {Buffer} Returns the cloned buffer.
  17977. */
  17978. function cloneBuffer(buffer, isDeep) {
  17979. if (isDeep) {
  17980. return buffer.slice();
  17981. }
  17982. var length = buffer.length,
  17983. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  17984. buffer.copy(result);
  17985. return result;
  17986. }
  17987. /**
  17988. * Creates a clone of `arrayBuffer`.
  17989. *
  17990. * @private
  17991. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  17992. * @returns {ArrayBuffer} Returns the cloned array buffer.
  17993. */
  17994. function cloneArrayBuffer(arrayBuffer) {
  17995. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  17996. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  17997. return result;
  17998. }
  17999. /**
  18000. * Creates a clone of `dataView`.
  18001. *
  18002. * @private
  18003. * @param {Object} dataView The data view to clone.
  18004. * @param {boolean} [isDeep] Specify a deep clone.
  18005. * @returns {Object} Returns the cloned data view.
  18006. */
  18007. function cloneDataView(dataView, isDeep) {
  18008. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  18009. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  18010. }
  18011. /**
  18012. * Creates a clone of `regexp`.
  18013. *
  18014. * @private
  18015. * @param {Object} regexp The regexp to clone.
  18016. * @returns {Object} Returns the cloned regexp.
  18017. */
  18018. function cloneRegExp(regexp) {
  18019. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  18020. result.lastIndex = regexp.lastIndex;
  18021. return result;
  18022. }
  18023. /**
  18024. * Creates a clone of the `symbol` object.
  18025. *
  18026. * @private
  18027. * @param {Object} symbol The symbol object to clone.
  18028. * @returns {Object} Returns the cloned symbol object.
  18029. */
  18030. function cloneSymbol(symbol) {
  18031. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  18032. }
  18033. /**
  18034. * Creates a clone of `typedArray`.
  18035. *
  18036. * @private
  18037. * @param {Object} typedArray The typed array to clone.
  18038. * @param {boolean} [isDeep] Specify a deep clone.
  18039. * @returns {Object} Returns the cloned typed array.
  18040. */
  18041. function cloneTypedArray(typedArray, isDeep) {
  18042. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  18043. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  18044. }
  18045. /**
  18046. * Compares values to sort them in ascending order.
  18047. *
  18048. * @private
  18049. * @param {*} value The value to compare.
  18050. * @param {*} other The other value to compare.
  18051. * @returns {number} Returns the sort order indicator for `value`.
  18052. */
  18053. function compareAscending(value, other) {
  18054. if (value !== other) {
  18055. var valIsDefined = value !== undefined,
  18056. valIsNull = value === null,
  18057. valIsReflexive = value === value,
  18058. valIsSymbol = isSymbol(value);
  18059. var othIsDefined = other !== undefined,
  18060. othIsNull = other === null,
  18061. othIsReflexive = other === other,
  18062. othIsSymbol = isSymbol(other);
  18063. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  18064. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  18065. (valIsNull && othIsDefined && othIsReflexive) ||
  18066. (!valIsDefined && othIsReflexive) ||
  18067. !valIsReflexive) {
  18068. return 1;
  18069. }
  18070. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  18071. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  18072. (othIsNull && valIsDefined && valIsReflexive) ||
  18073. (!othIsDefined && valIsReflexive) ||
  18074. !othIsReflexive) {
  18075. return -1;
  18076. }
  18077. }
  18078. return 0;
  18079. }
  18080. /**
  18081. * Used by `_.orderBy` to compare multiple properties of a value to another
  18082. * and stable sort them.
  18083. *
  18084. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  18085. * specify an order of "desc" for descending or "asc" for ascending sort order
  18086. * of corresponding values.
  18087. *
  18088. * @private
  18089. * @param {Object} object The object to compare.
  18090. * @param {Object} other The other object to compare.
  18091. * @param {boolean[]|string[]} orders The order to sort by for each property.
  18092. * @returns {number} Returns the sort order indicator for `object`.
  18093. */
  18094. function compareMultiple(object, other, orders) {
  18095. var index = -1,
  18096. objCriteria = object.criteria,
  18097. othCriteria = other.criteria,
  18098. length = objCriteria.length,
  18099. ordersLength = orders.length;
  18100. while (++index < length) {
  18101. var result = compareAscending(objCriteria[index], othCriteria[index]);
  18102. if (result) {
  18103. if (index >= ordersLength) {
  18104. return result;
  18105. }
  18106. var order = orders[index];
  18107. return result * (order == 'desc' ? -1 : 1);
  18108. }
  18109. }
  18110. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  18111. // that causes it, under certain circumstances, to provide the same value for
  18112. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  18113. // for more details.
  18114. //
  18115. // This also ensures a stable sort in V8 and other engines.
  18116. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  18117. return object.index - other.index;
  18118. }
  18119. /**
  18120. * Creates an array that is the composition of partially applied arguments,
  18121. * placeholders, and provided arguments into a single array of arguments.
  18122. *
  18123. * @private
  18124. * @param {Array} args The provided arguments.
  18125. * @param {Array} partials The arguments to prepend to those provided.
  18126. * @param {Array} holders The `partials` placeholder indexes.
  18127. * @params {boolean} [isCurried] Specify composing for a curried function.
  18128. * @returns {Array} Returns the new array of composed arguments.
  18129. */
  18130. function composeArgs(args, partials, holders, isCurried) {
  18131. var argsIndex = -1,
  18132. argsLength = args.length,
  18133. holdersLength = holders.length,
  18134. leftIndex = -1,
  18135. leftLength = partials.length,
  18136. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18137. result = Array(leftLength + rangeLength),
  18138. isUncurried = !isCurried;
  18139. while (++leftIndex < leftLength) {
  18140. result[leftIndex] = partials[leftIndex];
  18141. }
  18142. while (++argsIndex < holdersLength) {
  18143. if (isUncurried || argsIndex < argsLength) {
  18144. result[holders[argsIndex]] = args[argsIndex];
  18145. }
  18146. }
  18147. while (rangeLength--) {
  18148. result[leftIndex++] = args[argsIndex++];
  18149. }
  18150. return result;
  18151. }
  18152. /**
  18153. * This function is like `composeArgs` except that the arguments composition
  18154. * is tailored for `_.partialRight`.
  18155. *
  18156. * @private
  18157. * @param {Array} args The provided arguments.
  18158. * @param {Array} partials The arguments to append to those provided.
  18159. * @param {Array} holders The `partials` placeholder indexes.
  18160. * @params {boolean} [isCurried] Specify composing for a curried function.
  18161. * @returns {Array} Returns the new array of composed arguments.
  18162. */
  18163. function composeArgsRight(args, partials, holders, isCurried) {
  18164. var argsIndex = -1,
  18165. argsLength = args.length,
  18166. holdersIndex = -1,
  18167. holdersLength = holders.length,
  18168. rightIndex = -1,
  18169. rightLength = partials.length,
  18170. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18171. result = Array(rangeLength + rightLength),
  18172. isUncurried = !isCurried;
  18173. while (++argsIndex < rangeLength) {
  18174. result[argsIndex] = args[argsIndex];
  18175. }
  18176. var offset = argsIndex;
  18177. while (++rightIndex < rightLength) {
  18178. result[offset + rightIndex] = partials[rightIndex];
  18179. }
  18180. while (++holdersIndex < holdersLength) {
  18181. if (isUncurried || argsIndex < argsLength) {
  18182. result[offset + holders[holdersIndex]] = args[argsIndex++];
  18183. }
  18184. }
  18185. return result;
  18186. }
  18187. /**
  18188. * Copies the values of `source` to `array`.
  18189. *
  18190. * @private
  18191. * @param {Array} source The array to copy values from.
  18192. * @param {Array} [array=[]] The array to copy values to.
  18193. * @returns {Array} Returns `array`.
  18194. */
  18195. function copyArray(source, array) {
  18196. var index = -1,
  18197. length = source.length;
  18198. array || (array = Array(length));
  18199. while (++index < length) {
  18200. array[index] = source[index];
  18201. }
  18202. return array;
  18203. }
  18204. /**
  18205. * Copies properties of `source` to `object`.
  18206. *
  18207. * @private
  18208. * @param {Object} source The object to copy properties from.
  18209. * @param {Array} props The property identifiers to copy.
  18210. * @param {Object} [object={}] The object to copy properties to.
  18211. * @param {Function} [customizer] The function to customize copied values.
  18212. * @returns {Object} Returns `object`.
  18213. */
  18214. function copyObject(source, props, object, customizer) {
  18215. var isNew = !object;
  18216. object || (object = {});
  18217. var index = -1,
  18218. length = props.length;
  18219. while (++index < length) {
  18220. var key = props[index];
  18221. var newValue = customizer
  18222. ? customizer(object[key], source[key], key, object, source)
  18223. : undefined;
  18224. if (newValue === undefined) {
  18225. newValue = source[key];
  18226. }
  18227. if (isNew) {
  18228. baseAssignValue(object, key, newValue);
  18229. } else {
  18230. assignValue(object, key, newValue);
  18231. }
  18232. }
  18233. return object;
  18234. }
  18235. /**
  18236. * Copies own symbols of `source` to `object`.
  18237. *
  18238. * @private
  18239. * @param {Object} source The object to copy symbols from.
  18240. * @param {Object} [object={}] The object to copy symbols to.
  18241. * @returns {Object} Returns `object`.
  18242. */
  18243. function copySymbols(source, object) {
  18244. return copyObject(source, getSymbols(source), object);
  18245. }
  18246. /**
  18247. * Copies own and inherited symbols of `source` to `object`.
  18248. *
  18249. * @private
  18250. * @param {Object} source The object to copy symbols from.
  18251. * @param {Object} [object={}] The object to copy symbols to.
  18252. * @returns {Object} Returns `object`.
  18253. */
  18254. function copySymbolsIn(source, object) {
  18255. return copyObject(source, getSymbolsIn(source), object);
  18256. }
  18257. /**
  18258. * Creates a function like `_.groupBy`.
  18259. *
  18260. * @private
  18261. * @param {Function} setter The function to set accumulator values.
  18262. * @param {Function} [initializer] The accumulator object initializer.
  18263. * @returns {Function} Returns the new aggregator function.
  18264. */
  18265. function createAggregator(setter, initializer) {
  18266. return function(collection, iteratee) {
  18267. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  18268. accumulator = initializer ? initializer() : {};
  18269. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  18270. };
  18271. }
  18272. /**
  18273. * Creates a function like `_.assign`.
  18274. *
  18275. * @private
  18276. * @param {Function} assigner The function to assign values.
  18277. * @returns {Function} Returns the new assigner function.
  18278. */
  18279. function createAssigner(assigner) {
  18280. return baseRest(function(object, sources) {
  18281. var index = -1,
  18282. length = sources.length,
  18283. customizer = length > 1 ? sources[length - 1] : undefined,
  18284. guard = length > 2 ? sources[2] : undefined;
  18285. customizer = (assigner.length > 3 && typeof customizer == 'function')
  18286. ? (length--, customizer)
  18287. : undefined;
  18288. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  18289. customizer = length < 3 ? undefined : customizer;
  18290. length = 1;
  18291. }
  18292. object = Object(object);
  18293. while (++index < length) {
  18294. var source = sources[index];
  18295. if (source) {
  18296. assigner(object, source, index, customizer);
  18297. }
  18298. }
  18299. return object;
  18300. });
  18301. }
  18302. /**
  18303. * Creates a `baseEach` or `baseEachRight` function.
  18304. *
  18305. * @private
  18306. * @param {Function} eachFunc The function to iterate over a collection.
  18307. * @param {boolean} [fromRight] Specify iterating from right to left.
  18308. * @returns {Function} Returns the new base function.
  18309. */
  18310. function createBaseEach(eachFunc, fromRight) {
  18311. return function(collection, iteratee) {
  18312. if (collection == null) {
  18313. return collection;
  18314. }
  18315. if (!isArrayLike(collection)) {
  18316. return eachFunc(collection, iteratee);
  18317. }
  18318. var length = collection.length,
  18319. index = fromRight ? length : -1,
  18320. iterable = Object(collection);
  18321. while ((fromRight ? index-- : ++index < length)) {
  18322. if (iteratee(iterable[index], index, iterable) === false) {
  18323. break;
  18324. }
  18325. }
  18326. return collection;
  18327. };
  18328. }
  18329. /**
  18330. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  18331. *
  18332. * @private
  18333. * @param {boolean} [fromRight] Specify iterating from right to left.
  18334. * @returns {Function} Returns the new base function.
  18335. */
  18336. function createBaseFor(fromRight) {
  18337. return function(object, iteratee, keysFunc) {
  18338. var index = -1,
  18339. iterable = Object(object),
  18340. props = keysFunc(object),
  18341. length = props.length;
  18342. while (length--) {
  18343. var key = props[fromRight ? length : ++index];
  18344. if (iteratee(iterable[key], key, iterable) === false) {
  18345. break;
  18346. }
  18347. }
  18348. return object;
  18349. };
  18350. }
  18351. /**
  18352. * Creates a function that wraps `func` to invoke it with the optional `this`
  18353. * binding of `thisArg`.
  18354. *
  18355. * @private
  18356. * @param {Function} func The function to wrap.
  18357. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18358. * @param {*} [thisArg] The `this` binding of `func`.
  18359. * @returns {Function} Returns the new wrapped function.
  18360. */
  18361. function createBind(func, bitmask, thisArg) {
  18362. var isBind = bitmask & WRAP_BIND_FLAG,
  18363. Ctor = createCtor(func);
  18364. function wrapper() {
  18365. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18366. return fn.apply(isBind ? thisArg : this, arguments);
  18367. }
  18368. return wrapper;
  18369. }
  18370. /**
  18371. * Creates a function like `_.lowerFirst`.
  18372. *
  18373. * @private
  18374. * @param {string} methodName The name of the `String` case method to use.
  18375. * @returns {Function} Returns the new case function.
  18376. */
  18377. function createCaseFirst(methodName) {
  18378. return function(string) {
  18379. string = toString(string);
  18380. var strSymbols = hasUnicode(string)
  18381. ? stringToArray(string)
  18382. : undefined;
  18383. var chr = strSymbols
  18384. ? strSymbols[0]
  18385. : string.charAt(0);
  18386. var trailing = strSymbols
  18387. ? castSlice(strSymbols, 1).join('')
  18388. : string.slice(1);
  18389. return chr[methodName]() + trailing;
  18390. };
  18391. }
  18392. /**
  18393. * Creates a function like `_.camelCase`.
  18394. *
  18395. * @private
  18396. * @param {Function} callback The function to combine each word.
  18397. * @returns {Function} Returns the new compounder function.
  18398. */
  18399. function createCompounder(callback) {
  18400. return function(string) {
  18401. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  18402. };
  18403. }
  18404. /**
  18405. * Creates a function that produces an instance of `Ctor` regardless of
  18406. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  18407. *
  18408. * @private
  18409. * @param {Function} Ctor The constructor to wrap.
  18410. * @returns {Function} Returns the new wrapped function.
  18411. */
  18412. function createCtor(Ctor) {
  18413. return function() {
  18414. // Use a `switch` statement to work with class constructors. See
  18415. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  18416. // for more details.
  18417. var args = arguments;
  18418. switch (args.length) {
  18419. case 0: return new Ctor;
  18420. case 1: return new Ctor(args[0]);
  18421. case 2: return new Ctor(args[0], args[1]);
  18422. case 3: return new Ctor(args[0], args[1], args[2]);
  18423. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  18424. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  18425. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  18426. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  18427. }
  18428. var thisBinding = baseCreate(Ctor.prototype),
  18429. result = Ctor.apply(thisBinding, args);
  18430. // Mimic the constructor's `return` behavior.
  18431. // See https://es5.github.io/#x13.2.2 for more details.
  18432. return isObject(result) ? result : thisBinding;
  18433. };
  18434. }
  18435. /**
  18436. * Creates a function that wraps `func` to enable currying.
  18437. *
  18438. * @private
  18439. * @param {Function} func The function to wrap.
  18440. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18441. * @param {number} arity The arity of `func`.
  18442. * @returns {Function} Returns the new wrapped function.
  18443. */
  18444. function createCurry(func, bitmask, arity) {
  18445. var Ctor = createCtor(func);
  18446. function wrapper() {
  18447. var length = arguments.length,
  18448. args = Array(length),
  18449. index = length,
  18450. placeholder = getHolder(wrapper);
  18451. while (index--) {
  18452. args[index] = arguments[index];
  18453. }
  18454. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  18455. ? []
  18456. : replaceHolders(args, placeholder);
  18457. length -= holders.length;
  18458. if (length < arity) {
  18459. return createRecurry(
  18460. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  18461. args, holders, undefined, undefined, arity - length);
  18462. }
  18463. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18464. return apply(fn, this, args);
  18465. }
  18466. return wrapper;
  18467. }
  18468. /**
  18469. * Creates a `_.find` or `_.findLast` function.
  18470. *
  18471. * @private
  18472. * @param {Function} findIndexFunc The function to find the collection index.
  18473. * @returns {Function} Returns the new find function.
  18474. */
  18475. function createFind(findIndexFunc) {
  18476. return function(collection, predicate, fromIndex) {
  18477. var iterable = Object(collection);
  18478. if (!isArrayLike(collection)) {
  18479. var iteratee = getIteratee(predicate, 3);
  18480. collection = keys(collection);
  18481. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  18482. }
  18483. var index = findIndexFunc(collection, predicate, fromIndex);
  18484. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  18485. };
  18486. }
  18487. /**
  18488. * Creates a `_.flow` or `_.flowRight` function.
  18489. *
  18490. * @private
  18491. * @param {boolean} [fromRight] Specify iterating from right to left.
  18492. * @returns {Function} Returns the new flow function.
  18493. */
  18494. function createFlow(fromRight) {
  18495. return flatRest(function(funcs) {
  18496. var length = funcs.length,
  18497. index = length,
  18498. prereq = LodashWrapper.prototype.thru;
  18499. if (fromRight) {
  18500. funcs.reverse();
  18501. }
  18502. while (index--) {
  18503. var func = funcs[index];
  18504. if (typeof func != 'function') {
  18505. throw new TypeError(FUNC_ERROR_TEXT);
  18506. }
  18507. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  18508. var wrapper = new LodashWrapper([], true);
  18509. }
  18510. }
  18511. index = wrapper ? index : length;
  18512. while (++index < length) {
  18513. func = funcs[index];
  18514. var funcName = getFuncName(func),
  18515. data = funcName == 'wrapper' ? getData(func) : undefined;
  18516. if (data && isLaziable(data[0]) &&
  18517. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  18518. !data[4].length && data[9] == 1
  18519. ) {
  18520. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  18521. } else {
  18522. wrapper = (func.length == 1 && isLaziable(func))
  18523. ? wrapper[funcName]()
  18524. : wrapper.thru(func);
  18525. }
  18526. }
  18527. return function() {
  18528. var args = arguments,
  18529. value = args[0];
  18530. if (wrapper && args.length == 1 && isArray(value)) {
  18531. return wrapper.plant(value).value();
  18532. }
  18533. var index = 0,
  18534. result = length ? funcs[index].apply(this, args) : value;
  18535. while (++index < length) {
  18536. result = funcs[index].call(this, result);
  18537. }
  18538. return result;
  18539. };
  18540. });
  18541. }
  18542. /**
  18543. * Creates a function that wraps `func` to invoke it with optional `this`
  18544. * binding of `thisArg`, partial application, and currying.
  18545. *
  18546. * @private
  18547. * @param {Function|string} func The function or method name to wrap.
  18548. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18549. * @param {*} [thisArg] The `this` binding of `func`.
  18550. * @param {Array} [partials] The arguments to prepend to those provided to
  18551. * the new function.
  18552. * @param {Array} [holders] The `partials` placeholder indexes.
  18553. * @param {Array} [partialsRight] The arguments to append to those provided
  18554. * to the new function.
  18555. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  18556. * @param {Array} [argPos] The argument positions of the new function.
  18557. * @param {number} [ary] The arity cap of `func`.
  18558. * @param {number} [arity] The arity of `func`.
  18559. * @returns {Function} Returns the new wrapped function.
  18560. */
  18561. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  18562. var isAry = bitmask & WRAP_ARY_FLAG,
  18563. isBind = bitmask & WRAP_BIND_FLAG,
  18564. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  18565. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  18566. isFlip = bitmask & WRAP_FLIP_FLAG,
  18567. Ctor = isBindKey ? undefined : createCtor(func);
  18568. function wrapper() {
  18569. var length = arguments.length,
  18570. args = Array(length),
  18571. index = length;
  18572. while (index--) {
  18573. args[index] = arguments[index];
  18574. }
  18575. if (isCurried) {
  18576. var placeholder = getHolder(wrapper),
  18577. holdersCount = countHolders(args, placeholder);
  18578. }
  18579. if (partials) {
  18580. args = composeArgs(args, partials, holders, isCurried);
  18581. }
  18582. if (partialsRight) {
  18583. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  18584. }
  18585. length -= holdersCount;
  18586. if (isCurried && length < arity) {
  18587. var newHolders = replaceHolders(args, placeholder);
  18588. return createRecurry(
  18589. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  18590. args, newHolders, argPos, ary, arity - length
  18591. );
  18592. }
  18593. var thisBinding = isBind ? thisArg : this,
  18594. fn = isBindKey ? thisBinding[func] : func;
  18595. length = args.length;
  18596. if (argPos) {
  18597. args = reorder(args, argPos);
  18598. } else if (isFlip && length > 1) {
  18599. args.reverse();
  18600. }
  18601. if (isAry && ary < length) {
  18602. args.length = ary;
  18603. }
  18604. if (this && this !== root && this instanceof wrapper) {
  18605. fn = Ctor || createCtor(fn);
  18606. }
  18607. return fn.apply(thisBinding, args);
  18608. }
  18609. return wrapper;
  18610. }
  18611. /**
  18612. * Creates a function like `_.invertBy`.
  18613. *
  18614. * @private
  18615. * @param {Function} setter The function to set accumulator values.
  18616. * @param {Function} toIteratee The function to resolve iteratees.
  18617. * @returns {Function} Returns the new inverter function.
  18618. */
  18619. function createInverter(setter, toIteratee) {
  18620. return function(object, iteratee) {
  18621. return baseInverter(object, setter, toIteratee(iteratee), {});
  18622. };
  18623. }
  18624. /**
  18625. * Creates a function that performs a mathematical operation on two values.
  18626. *
  18627. * @private
  18628. * @param {Function} operator The function to perform the operation.
  18629. * @param {number} [defaultValue] The value used for `undefined` arguments.
  18630. * @returns {Function} Returns the new mathematical operation function.
  18631. */
  18632. function createMathOperation(operator, defaultValue) {
  18633. return function(value, other) {
  18634. var result;
  18635. if (value === undefined && other === undefined) {
  18636. return defaultValue;
  18637. }
  18638. if (value !== undefined) {
  18639. result = value;
  18640. }
  18641. if (other !== undefined) {
  18642. if (result === undefined) {
  18643. return other;
  18644. }
  18645. if (typeof value == 'string' || typeof other == 'string') {
  18646. value = baseToString(value);
  18647. other = baseToString(other);
  18648. } else {
  18649. value = baseToNumber(value);
  18650. other = baseToNumber(other);
  18651. }
  18652. result = operator(value, other);
  18653. }
  18654. return result;
  18655. };
  18656. }
  18657. /**
  18658. * Creates a function like `_.over`.
  18659. *
  18660. * @private
  18661. * @param {Function} arrayFunc The function to iterate over iteratees.
  18662. * @returns {Function} Returns the new over function.
  18663. */
  18664. function createOver(arrayFunc) {
  18665. return flatRest(function(iteratees) {
  18666. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  18667. return baseRest(function(args) {
  18668. var thisArg = this;
  18669. return arrayFunc(iteratees, function(iteratee) {
  18670. return apply(iteratee, thisArg, args);
  18671. });
  18672. });
  18673. });
  18674. }
  18675. /**
  18676. * Creates the padding for `string` based on `length`. The `chars` string
  18677. * is truncated if the number of characters exceeds `length`.
  18678. *
  18679. * @private
  18680. * @param {number} length The padding length.
  18681. * @param {string} [chars=' '] The string used as padding.
  18682. * @returns {string} Returns the padding for `string`.
  18683. */
  18684. function createPadding(length, chars) {
  18685. chars = chars === undefined ? ' ' : baseToString(chars);
  18686. var charsLength = chars.length;
  18687. if (charsLength < 2) {
  18688. return charsLength ? baseRepeat(chars, length) : chars;
  18689. }
  18690. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  18691. return hasUnicode(chars)
  18692. ? castSlice(stringToArray(result), 0, length).join('')
  18693. : result.slice(0, length);
  18694. }
  18695. /**
  18696. * Creates a function that wraps `func` to invoke it with the `this` binding
  18697. * of `thisArg` and `partials` prepended to the arguments it receives.
  18698. *
  18699. * @private
  18700. * @param {Function} func The function to wrap.
  18701. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18702. * @param {*} thisArg The `this` binding of `func`.
  18703. * @param {Array} partials The arguments to prepend to those provided to
  18704. * the new function.
  18705. * @returns {Function} Returns the new wrapped function.
  18706. */
  18707. function createPartial(func, bitmask, thisArg, partials) {
  18708. var isBind = bitmask & WRAP_BIND_FLAG,
  18709. Ctor = createCtor(func);
  18710. function wrapper() {
  18711. var argsIndex = -1,
  18712. argsLength = arguments.length,
  18713. leftIndex = -1,
  18714. leftLength = partials.length,
  18715. args = Array(leftLength + argsLength),
  18716. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18717. while (++leftIndex < leftLength) {
  18718. args[leftIndex] = partials[leftIndex];
  18719. }
  18720. while (argsLength--) {
  18721. args[leftIndex++] = arguments[++argsIndex];
  18722. }
  18723. return apply(fn, isBind ? thisArg : this, args);
  18724. }
  18725. return wrapper;
  18726. }
  18727. /**
  18728. * Creates a `_.range` or `_.rangeRight` function.
  18729. *
  18730. * @private
  18731. * @param {boolean} [fromRight] Specify iterating from right to left.
  18732. * @returns {Function} Returns the new range function.
  18733. */
  18734. function createRange(fromRight) {
  18735. return function(start, end, step) {
  18736. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  18737. end = step = undefined;
  18738. }
  18739. // Ensure the sign of `-0` is preserved.
  18740. start = toFinite(start);
  18741. if (end === undefined) {
  18742. end = start;
  18743. start = 0;
  18744. } else {
  18745. end = toFinite(end);
  18746. }
  18747. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  18748. return baseRange(start, end, step, fromRight);
  18749. };
  18750. }
  18751. /**
  18752. * Creates a function that performs a relational operation on two values.
  18753. *
  18754. * @private
  18755. * @param {Function} operator The function to perform the operation.
  18756. * @returns {Function} Returns the new relational operation function.
  18757. */
  18758. function createRelationalOperation(operator) {
  18759. return function(value, other) {
  18760. if (!(typeof value == 'string' && typeof other == 'string')) {
  18761. value = toNumber(value);
  18762. other = toNumber(other);
  18763. }
  18764. return operator(value, other);
  18765. };
  18766. }
  18767. /**
  18768. * Creates a function that wraps `func` to continue currying.
  18769. *
  18770. * @private
  18771. * @param {Function} func The function to wrap.
  18772. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18773. * @param {Function} wrapFunc The function to create the `func` wrapper.
  18774. * @param {*} placeholder The placeholder value.
  18775. * @param {*} [thisArg] The `this` binding of `func`.
  18776. * @param {Array} [partials] The arguments to prepend to those provided to
  18777. * the new function.
  18778. * @param {Array} [holders] The `partials` placeholder indexes.
  18779. * @param {Array} [argPos] The argument positions of the new function.
  18780. * @param {number} [ary] The arity cap of `func`.
  18781. * @param {number} [arity] The arity of `func`.
  18782. * @returns {Function} Returns the new wrapped function.
  18783. */
  18784. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  18785. var isCurry = bitmask & WRAP_CURRY_FLAG,
  18786. newHolders = isCurry ? holders : undefined,
  18787. newHoldersRight = isCurry ? undefined : holders,
  18788. newPartials = isCurry ? partials : undefined,
  18789. newPartialsRight = isCurry ? undefined : partials;
  18790. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  18791. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  18792. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  18793. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  18794. }
  18795. var newData = [
  18796. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  18797. newHoldersRight, argPos, ary, arity
  18798. ];
  18799. var result = wrapFunc.apply(undefined, newData);
  18800. if (isLaziable(func)) {
  18801. setData(result, newData);
  18802. }
  18803. result.placeholder = placeholder;
  18804. return setWrapToString(result, func, bitmask);
  18805. }
  18806. /**
  18807. * Creates a function like `_.round`.
  18808. *
  18809. * @private
  18810. * @param {string} methodName The name of the `Math` method to use when rounding.
  18811. * @returns {Function} Returns the new round function.
  18812. */
  18813. function createRound(methodName) {
  18814. var func = Math[methodName];
  18815. return function(number, precision) {
  18816. number = toNumber(number);
  18817. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  18818. if (precision && nativeIsFinite(number)) {
  18819. // Shift with exponential notation to avoid floating-point issues.
  18820. // See [MDN](https://mdn.io/round#Examples) for more details.
  18821. var pair = (toString(number) + 'e').split('e'),
  18822. value = func(pair[0] + 'e' + (+pair[1] + precision));
  18823. pair = (toString(value) + 'e').split('e');
  18824. return +(pair[0] + 'e' + (+pair[1] - precision));
  18825. }
  18826. return func(number);
  18827. };
  18828. }
  18829. /**
  18830. * Creates a set object of `values`.
  18831. *
  18832. * @private
  18833. * @param {Array} values The values to add to the set.
  18834. * @returns {Object} Returns the new set.
  18835. */
  18836. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  18837. return new Set(values);
  18838. };
  18839. /**
  18840. * Creates a `_.toPairs` or `_.toPairsIn` function.
  18841. *
  18842. * @private
  18843. * @param {Function} keysFunc The function to get the keys of a given object.
  18844. * @returns {Function} Returns the new pairs function.
  18845. */
  18846. function createToPairs(keysFunc) {
  18847. return function(object) {
  18848. var tag = getTag(object);
  18849. if (tag == mapTag) {
  18850. return mapToArray(object);
  18851. }
  18852. if (tag == setTag) {
  18853. return setToPairs(object);
  18854. }
  18855. return baseToPairs(object, keysFunc(object));
  18856. };
  18857. }
  18858. /**
  18859. * Creates a function that either curries or invokes `func` with optional
  18860. * `this` binding and partially applied arguments.
  18861. *
  18862. * @private
  18863. * @param {Function|string} func The function or method name to wrap.
  18864. * @param {number} bitmask The bitmask flags.
  18865. * 1 - `_.bind`
  18866. * 2 - `_.bindKey`
  18867. * 4 - `_.curry` or `_.curryRight` of a bound function
  18868. * 8 - `_.curry`
  18869. * 16 - `_.curryRight`
  18870. * 32 - `_.partial`
  18871. * 64 - `_.partialRight`
  18872. * 128 - `_.rearg`
  18873. * 256 - `_.ary`
  18874. * 512 - `_.flip`
  18875. * @param {*} [thisArg] The `this` binding of `func`.
  18876. * @param {Array} [partials] The arguments to be partially applied.
  18877. * @param {Array} [holders] The `partials` placeholder indexes.
  18878. * @param {Array} [argPos] The argument positions of the new function.
  18879. * @param {number} [ary] The arity cap of `func`.
  18880. * @param {number} [arity] The arity of `func`.
  18881. * @returns {Function} Returns the new wrapped function.
  18882. */
  18883. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  18884. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  18885. if (!isBindKey && typeof func != 'function') {
  18886. throw new TypeError(FUNC_ERROR_TEXT);
  18887. }
  18888. var length = partials ? partials.length : 0;
  18889. if (!length) {
  18890. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  18891. partials = holders = undefined;
  18892. }
  18893. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  18894. arity = arity === undefined ? arity : toInteger(arity);
  18895. length -= holders ? holders.length : 0;
  18896. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  18897. var partialsRight = partials,
  18898. holdersRight = holders;
  18899. partials = holders = undefined;
  18900. }
  18901. var data = isBindKey ? undefined : getData(func);
  18902. var newData = [
  18903. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  18904. argPos, ary, arity
  18905. ];
  18906. if (data) {
  18907. mergeData(newData, data);
  18908. }
  18909. func = newData[0];
  18910. bitmask = newData[1];
  18911. thisArg = newData[2];
  18912. partials = newData[3];
  18913. holders = newData[4];
  18914. arity = newData[9] = newData[9] === undefined
  18915. ? (isBindKey ? 0 : func.length)
  18916. : nativeMax(newData[9] - length, 0);
  18917. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  18918. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  18919. }
  18920. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  18921. var result = createBind(func, bitmask, thisArg);
  18922. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  18923. result = createCurry(func, bitmask, arity);
  18924. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  18925. result = createPartial(func, bitmask, thisArg, partials);
  18926. } else {
  18927. result = createHybrid.apply(undefined, newData);
  18928. }
  18929. var setter = data ? baseSetData : setData;
  18930. return setWrapToString(setter(result, newData), func, bitmask);
  18931. }
  18932. /**
  18933. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  18934. * of source objects to the destination object for all destination properties
  18935. * that resolve to `undefined`.
  18936. *
  18937. * @private
  18938. * @param {*} objValue The destination value.
  18939. * @param {*} srcValue The source value.
  18940. * @param {string} key The key of the property to assign.
  18941. * @param {Object} object The parent object of `objValue`.
  18942. * @returns {*} Returns the value to assign.
  18943. */
  18944. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  18945. if (objValue === undefined ||
  18946. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  18947. return srcValue;
  18948. }
  18949. return objValue;
  18950. }
  18951. /**
  18952. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  18953. * objects into destination objects that are passed thru.
  18954. *
  18955. * @private
  18956. * @param {*} objValue The destination value.
  18957. * @param {*} srcValue The source value.
  18958. * @param {string} key The key of the property to merge.
  18959. * @param {Object} object The parent object of `objValue`.
  18960. * @param {Object} source The parent object of `srcValue`.
  18961. * @param {Object} [stack] Tracks traversed source values and their merged
  18962. * counterparts.
  18963. * @returns {*} Returns the value to assign.
  18964. */
  18965. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  18966. if (isObject(objValue) && isObject(srcValue)) {
  18967. // Recursively merge objects and arrays (susceptible to call stack limits).
  18968. stack.set(srcValue, objValue);
  18969. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  18970. stack['delete'](srcValue);
  18971. }
  18972. return objValue;
  18973. }
  18974. /**
  18975. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  18976. * objects.
  18977. *
  18978. * @private
  18979. * @param {*} value The value to inspect.
  18980. * @param {string} key The key of the property to inspect.
  18981. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  18982. */
  18983. function customOmitClone(value) {
  18984. return isPlainObject(value) ? undefined : value;
  18985. }
  18986. /**
  18987. * A specialized version of `baseIsEqualDeep` for arrays with support for
  18988. * partial deep comparisons.
  18989. *
  18990. * @private
  18991. * @param {Array} array The array to compare.
  18992. * @param {Array} other The other array to compare.
  18993. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  18994. * @param {Function} customizer The function to customize comparisons.
  18995. * @param {Function} equalFunc The function to determine equivalents of values.
  18996. * @param {Object} stack Tracks traversed `array` and `other` objects.
  18997. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  18998. */
  18999. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  19000. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19001. arrLength = array.length,
  19002. othLength = other.length;
  19003. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  19004. return false;
  19005. }
  19006. // Assume cyclic values are equal.
  19007. var stacked = stack.get(array);
  19008. if (stacked && stack.get(other)) {
  19009. return stacked == other;
  19010. }
  19011. var index = -1,
  19012. result = true,
  19013. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  19014. stack.set(array, other);
  19015. stack.set(other, array);
  19016. // Ignore non-index properties.
  19017. while (++index < arrLength) {
  19018. var arrValue = array[index],
  19019. othValue = other[index];
  19020. if (customizer) {
  19021. var compared = isPartial
  19022. ? customizer(othValue, arrValue, index, other, array, stack)
  19023. : customizer(arrValue, othValue, index, array, other, stack);
  19024. }
  19025. if (compared !== undefined) {
  19026. if (compared) {
  19027. continue;
  19028. }
  19029. result = false;
  19030. break;
  19031. }
  19032. // Recursively compare arrays (susceptible to call stack limits).
  19033. if (seen) {
  19034. if (!arraySome(other, function(othValue, othIndex) {
  19035. if (!cacheHas(seen, othIndex) &&
  19036. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  19037. return seen.push(othIndex);
  19038. }
  19039. })) {
  19040. result = false;
  19041. break;
  19042. }
  19043. } else if (!(
  19044. arrValue === othValue ||
  19045. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  19046. )) {
  19047. result = false;
  19048. break;
  19049. }
  19050. }
  19051. stack['delete'](array);
  19052. stack['delete'](other);
  19053. return result;
  19054. }
  19055. /**
  19056. * A specialized version of `baseIsEqualDeep` for comparing objects of
  19057. * the same `toStringTag`.
  19058. *
  19059. * **Note:** This function only supports comparing values with tags of
  19060. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  19061. *
  19062. * @private
  19063. * @param {Object} object The object to compare.
  19064. * @param {Object} other The other object to compare.
  19065. * @param {string} tag The `toStringTag` of the objects to compare.
  19066. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19067. * @param {Function} customizer The function to customize comparisons.
  19068. * @param {Function} equalFunc The function to determine equivalents of values.
  19069. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19070. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19071. */
  19072. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  19073. switch (tag) {
  19074. case dataViewTag:
  19075. if ((object.byteLength != other.byteLength) ||
  19076. (object.byteOffset != other.byteOffset)) {
  19077. return false;
  19078. }
  19079. object = object.buffer;
  19080. other = other.buffer;
  19081. case arrayBufferTag:
  19082. if ((object.byteLength != other.byteLength) ||
  19083. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  19084. return false;
  19085. }
  19086. return true;
  19087. case boolTag:
  19088. case dateTag:
  19089. case numberTag:
  19090. // Coerce booleans to `1` or `0` and dates to milliseconds.
  19091. // Invalid dates are coerced to `NaN`.
  19092. return eq(+object, +other);
  19093. case errorTag:
  19094. return object.name == other.name && object.message == other.message;
  19095. case regexpTag:
  19096. case stringTag:
  19097. // Coerce regexes to strings and treat strings, primitives and objects,
  19098. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  19099. // for more details.
  19100. return object == (other + '');
  19101. case mapTag:
  19102. var convert = mapToArray;
  19103. case setTag:
  19104. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  19105. convert || (convert = setToArray);
  19106. if (object.size != other.size && !isPartial) {
  19107. return false;
  19108. }
  19109. // Assume cyclic values are equal.
  19110. var stacked = stack.get(object);
  19111. if (stacked) {
  19112. return stacked == other;
  19113. }
  19114. bitmask |= COMPARE_UNORDERED_FLAG;
  19115. // Recursively compare objects (susceptible to call stack limits).
  19116. stack.set(object, other);
  19117. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  19118. stack['delete'](object);
  19119. return result;
  19120. case symbolTag:
  19121. if (symbolValueOf) {
  19122. return symbolValueOf.call(object) == symbolValueOf.call(other);
  19123. }
  19124. }
  19125. return false;
  19126. }
  19127. /**
  19128. * A specialized version of `baseIsEqualDeep` for objects with support for
  19129. * partial deep comparisons.
  19130. *
  19131. * @private
  19132. * @param {Object} object The object to compare.
  19133. * @param {Object} other The other object to compare.
  19134. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19135. * @param {Function} customizer The function to customize comparisons.
  19136. * @param {Function} equalFunc The function to determine equivalents of values.
  19137. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19138. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19139. */
  19140. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  19141. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19142. objProps = getAllKeys(object),
  19143. objLength = objProps.length,
  19144. othProps = getAllKeys(other),
  19145. othLength = othProps.length;
  19146. if (objLength != othLength && !isPartial) {
  19147. return false;
  19148. }
  19149. var index = objLength;
  19150. while (index--) {
  19151. var key = objProps[index];
  19152. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  19153. return false;
  19154. }
  19155. }
  19156. // Assume cyclic values are equal.
  19157. var stacked = stack.get(object);
  19158. if (stacked && stack.get(other)) {
  19159. return stacked == other;
  19160. }
  19161. var result = true;
  19162. stack.set(object, other);
  19163. stack.set(other, object);
  19164. var skipCtor = isPartial;
  19165. while (++index < objLength) {
  19166. key = objProps[index];
  19167. var objValue = object[key],
  19168. othValue = other[key];
  19169. if (customizer) {
  19170. var compared = isPartial
  19171. ? customizer(othValue, objValue, key, other, object, stack)
  19172. : customizer(objValue, othValue, key, object, other, stack);
  19173. }
  19174. // Recursively compare objects (susceptible to call stack limits).
  19175. if (!(compared === undefined
  19176. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  19177. : compared
  19178. )) {
  19179. result = false;
  19180. break;
  19181. }
  19182. skipCtor || (skipCtor = key == 'constructor');
  19183. }
  19184. if (result && !skipCtor) {
  19185. var objCtor = object.constructor,
  19186. othCtor = other.constructor;
  19187. // Non `Object` object instances with different constructors are not equal.
  19188. if (objCtor != othCtor &&
  19189. ('constructor' in object && 'constructor' in other) &&
  19190. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  19191. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  19192. result = false;
  19193. }
  19194. }
  19195. stack['delete'](object);
  19196. stack['delete'](other);
  19197. return result;
  19198. }
  19199. /**
  19200. * A specialized version of `baseRest` which flattens the rest array.
  19201. *
  19202. * @private
  19203. * @param {Function} func The function to apply a rest parameter to.
  19204. * @returns {Function} Returns the new function.
  19205. */
  19206. function flatRest(func) {
  19207. return setToString(overRest(func, undefined, flatten), func + '');
  19208. }
  19209. /**
  19210. * Creates an array of own enumerable property names and symbols of `object`.
  19211. *
  19212. * @private
  19213. * @param {Object} object The object to query.
  19214. * @returns {Array} Returns the array of property names and symbols.
  19215. */
  19216. function getAllKeys(object) {
  19217. return baseGetAllKeys(object, keys, getSymbols);
  19218. }
  19219. /**
  19220. * Creates an array of own and inherited enumerable property names and
  19221. * symbols of `object`.
  19222. *
  19223. * @private
  19224. * @param {Object} object The object to query.
  19225. * @returns {Array} Returns the array of property names and symbols.
  19226. */
  19227. function getAllKeysIn(object) {
  19228. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  19229. }
  19230. /**
  19231. * Gets metadata for `func`.
  19232. *
  19233. * @private
  19234. * @param {Function} func The function to query.
  19235. * @returns {*} Returns the metadata for `func`.
  19236. */
  19237. var getData = !metaMap ? noop : function(func) {
  19238. return metaMap.get(func);
  19239. };
  19240. /**
  19241. * Gets the name of `func`.
  19242. *
  19243. * @private
  19244. * @param {Function} func The function to query.
  19245. * @returns {string} Returns the function name.
  19246. */
  19247. function getFuncName(func) {
  19248. var result = (func.name + ''),
  19249. array = realNames[result],
  19250. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  19251. while (length--) {
  19252. var data = array[length],
  19253. otherFunc = data.func;
  19254. if (otherFunc == null || otherFunc == func) {
  19255. return data.name;
  19256. }
  19257. }
  19258. return result;
  19259. }
  19260. /**
  19261. * Gets the argument placeholder value for `func`.
  19262. *
  19263. * @private
  19264. * @param {Function} func The function to inspect.
  19265. * @returns {*} Returns the placeholder value.
  19266. */
  19267. function getHolder(func) {
  19268. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  19269. return object.placeholder;
  19270. }
  19271. /**
  19272. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  19273. * this function returns the custom method, otherwise it returns `baseIteratee`.
  19274. * If arguments are provided, the chosen function is invoked with them and
  19275. * its result is returned.
  19276. *
  19277. * @private
  19278. * @param {*} [value] The value to convert to an iteratee.
  19279. * @param {number} [arity] The arity of the created iteratee.
  19280. * @returns {Function} Returns the chosen function or its result.
  19281. */
  19282. function getIteratee() {
  19283. var result = lodash.iteratee || iteratee;
  19284. result = result === iteratee ? baseIteratee : result;
  19285. return arguments.length ? result(arguments[0], arguments[1]) : result;
  19286. }
  19287. /**
  19288. * Gets the data for `map`.
  19289. *
  19290. * @private
  19291. * @param {Object} map The map to query.
  19292. * @param {string} key The reference key.
  19293. * @returns {*} Returns the map data.
  19294. */
  19295. function getMapData(map, key) {
  19296. var data = map.__data__;
  19297. return isKeyable(key)
  19298. ? data[typeof key == 'string' ? 'string' : 'hash']
  19299. : data.map;
  19300. }
  19301. /**
  19302. * Gets the property names, values, and compare flags of `object`.
  19303. *
  19304. * @private
  19305. * @param {Object} object The object to query.
  19306. * @returns {Array} Returns the match data of `object`.
  19307. */
  19308. function getMatchData(object) {
  19309. var result = keys(object),
  19310. length = result.length;
  19311. while (length--) {
  19312. var key = result[length],
  19313. value = object[key];
  19314. result[length] = [key, value, isStrictComparable(value)];
  19315. }
  19316. return result;
  19317. }
  19318. /**
  19319. * Gets the native function at `key` of `object`.
  19320. *
  19321. * @private
  19322. * @param {Object} object The object to query.
  19323. * @param {string} key The key of the method to get.
  19324. * @returns {*} Returns the function if it's native, else `undefined`.
  19325. */
  19326. function getNative(object, key) {
  19327. var value = getValue(object, key);
  19328. return baseIsNative(value) ? value : undefined;
  19329. }
  19330. /**
  19331. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  19332. *
  19333. * @private
  19334. * @param {*} value The value to query.
  19335. * @returns {string} Returns the raw `toStringTag`.
  19336. */
  19337. function getRawTag(value) {
  19338. var isOwn = hasOwnProperty.call(value, symToStringTag),
  19339. tag = value[symToStringTag];
  19340. try {
  19341. value[symToStringTag] = undefined;
  19342. var unmasked = true;
  19343. } catch (e) {}
  19344. var result = nativeObjectToString.call(value);
  19345. if (unmasked) {
  19346. if (isOwn) {
  19347. value[symToStringTag] = tag;
  19348. } else {
  19349. delete value[symToStringTag];
  19350. }
  19351. }
  19352. return result;
  19353. }
  19354. /**
  19355. * Creates an array of the own enumerable symbols of `object`.
  19356. *
  19357. * @private
  19358. * @param {Object} object The object to query.
  19359. * @returns {Array} Returns the array of symbols.
  19360. */
  19361. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  19362. if (object == null) {
  19363. return [];
  19364. }
  19365. object = Object(object);
  19366. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  19367. return propertyIsEnumerable.call(object, symbol);
  19368. });
  19369. };
  19370. /**
  19371. * Creates an array of the own and inherited enumerable symbols of `object`.
  19372. *
  19373. * @private
  19374. * @param {Object} object The object to query.
  19375. * @returns {Array} Returns the array of symbols.
  19376. */
  19377. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  19378. var result = [];
  19379. while (object) {
  19380. arrayPush(result, getSymbols(object));
  19381. object = getPrototype(object);
  19382. }
  19383. return result;
  19384. };
  19385. /**
  19386. * Gets the `toStringTag` of `value`.
  19387. *
  19388. * @private
  19389. * @param {*} value The value to query.
  19390. * @returns {string} Returns the `toStringTag`.
  19391. */
  19392. var getTag = baseGetTag;
  19393. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  19394. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  19395. (Map && getTag(new Map) != mapTag) ||
  19396. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  19397. (Set && getTag(new Set) != setTag) ||
  19398. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  19399. getTag = function(value) {
  19400. var result = baseGetTag(value),
  19401. Ctor = result == objectTag ? value.constructor : undefined,
  19402. ctorString = Ctor ? toSource(Ctor) : '';
  19403. if (ctorString) {
  19404. switch (ctorString) {
  19405. case dataViewCtorString: return dataViewTag;
  19406. case mapCtorString: return mapTag;
  19407. case promiseCtorString: return promiseTag;
  19408. case setCtorString: return setTag;
  19409. case weakMapCtorString: return weakMapTag;
  19410. }
  19411. }
  19412. return result;
  19413. };
  19414. }
  19415. /**
  19416. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  19417. *
  19418. * @private
  19419. * @param {number} start The start of the view.
  19420. * @param {number} end The end of the view.
  19421. * @param {Array} transforms The transformations to apply to the view.
  19422. * @returns {Object} Returns an object containing the `start` and `end`
  19423. * positions of the view.
  19424. */
  19425. function getView(start, end, transforms) {
  19426. var index = -1,
  19427. length = transforms.length;
  19428. while (++index < length) {
  19429. var data = transforms[index],
  19430. size = data.size;
  19431. switch (data.type) {
  19432. case 'drop': start += size; break;
  19433. case 'dropRight': end -= size; break;
  19434. case 'take': end = nativeMin(end, start + size); break;
  19435. case 'takeRight': start = nativeMax(start, end - size); break;
  19436. }
  19437. }
  19438. return { 'start': start, 'end': end };
  19439. }
  19440. /**
  19441. * Extracts wrapper details from the `source` body comment.
  19442. *
  19443. * @private
  19444. * @param {string} source The source to inspect.
  19445. * @returns {Array} Returns the wrapper details.
  19446. */
  19447. function getWrapDetails(source) {
  19448. var match = source.match(reWrapDetails);
  19449. return match ? match[1].split(reSplitDetails) : [];
  19450. }
  19451. /**
  19452. * Checks if `path` exists on `object`.
  19453. *
  19454. * @private
  19455. * @param {Object} object The object to query.
  19456. * @param {Array|string} path The path to check.
  19457. * @param {Function} hasFunc The function to check properties.
  19458. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  19459. */
  19460. function hasPath(object, path, hasFunc) {
  19461. path = castPath(path, object);
  19462. var index = -1,
  19463. length = path.length,
  19464. result = false;
  19465. while (++index < length) {
  19466. var key = toKey(path[index]);
  19467. if (!(result = object != null && hasFunc(object, key))) {
  19468. break;
  19469. }
  19470. object = object[key];
  19471. }
  19472. if (result || ++index != length) {
  19473. return result;
  19474. }
  19475. length = object == null ? 0 : object.length;
  19476. return !!length && isLength(length) && isIndex(key, length) &&
  19477. (isArray(object) || isArguments(object));
  19478. }
  19479. /**
  19480. * Initializes an array clone.
  19481. *
  19482. * @private
  19483. * @param {Array} array The array to clone.
  19484. * @returns {Array} Returns the initialized clone.
  19485. */
  19486. function initCloneArray(array) {
  19487. var length = array.length,
  19488. result = new array.constructor(length);
  19489. // Add properties assigned by `RegExp#exec`.
  19490. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  19491. result.index = array.index;
  19492. result.input = array.input;
  19493. }
  19494. return result;
  19495. }
  19496. /**
  19497. * Initializes an object clone.
  19498. *
  19499. * @private
  19500. * @param {Object} object The object to clone.
  19501. * @returns {Object} Returns the initialized clone.
  19502. */
  19503. function initCloneObject(object) {
  19504. return (typeof object.constructor == 'function' && !isPrototype(object))
  19505. ? baseCreate(getPrototype(object))
  19506. : {};
  19507. }
  19508. /**
  19509. * Initializes an object clone based on its `toStringTag`.
  19510. *
  19511. * **Note:** This function only supports cloning values with tags of
  19512. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  19513. *
  19514. * @private
  19515. * @param {Object} object The object to clone.
  19516. * @param {string} tag The `toStringTag` of the object to clone.
  19517. * @param {boolean} [isDeep] Specify a deep clone.
  19518. * @returns {Object} Returns the initialized clone.
  19519. */
  19520. function initCloneByTag(object, tag, isDeep) {
  19521. var Ctor = object.constructor;
  19522. switch (tag) {
  19523. case arrayBufferTag:
  19524. return cloneArrayBuffer(object);
  19525. case boolTag:
  19526. case dateTag:
  19527. return new Ctor(+object);
  19528. case dataViewTag:
  19529. return cloneDataView(object, isDeep);
  19530. case float32Tag: case float64Tag:
  19531. case int8Tag: case int16Tag: case int32Tag:
  19532. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  19533. return cloneTypedArray(object, isDeep);
  19534. case mapTag:
  19535. return new Ctor;
  19536. case numberTag:
  19537. case stringTag:
  19538. return new Ctor(object);
  19539. case regexpTag:
  19540. return cloneRegExp(object);
  19541. case setTag:
  19542. return new Ctor;
  19543. case symbolTag:
  19544. return cloneSymbol(object);
  19545. }
  19546. }
  19547. /**
  19548. * Inserts wrapper `details` in a comment at the top of the `source` body.
  19549. *
  19550. * @private
  19551. * @param {string} source The source to modify.
  19552. * @returns {Array} details The details to insert.
  19553. * @returns {string} Returns the modified source.
  19554. */
  19555. function insertWrapDetails(source, details) {
  19556. var length = details.length;
  19557. if (!length) {
  19558. return source;
  19559. }
  19560. var lastIndex = length - 1;
  19561. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  19562. details = details.join(length > 2 ? ', ' : ' ');
  19563. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  19564. }
  19565. /**
  19566. * Checks if `value` is a flattenable `arguments` object or array.
  19567. *
  19568. * @private
  19569. * @param {*} value The value to check.
  19570. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  19571. */
  19572. function isFlattenable(value) {
  19573. return isArray(value) || isArguments(value) ||
  19574. !!(spreadableSymbol && value && value[spreadableSymbol]);
  19575. }
  19576. /**
  19577. * Checks if `value` is a valid array-like index.
  19578. *
  19579. * @private
  19580. * @param {*} value The value to check.
  19581. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  19582. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  19583. */
  19584. function isIndex(value, length) {
  19585. var type = typeof value;
  19586. length = length == null ? MAX_SAFE_INTEGER : length;
  19587. return !!length &&
  19588. (type == 'number' ||
  19589. (type != 'symbol' && reIsUint.test(value))) &&
  19590. (value > -1 && value % 1 == 0 && value < length);
  19591. }
  19592. /**
  19593. * Checks if the given arguments are from an iteratee call.
  19594. *
  19595. * @private
  19596. * @param {*} value The potential iteratee value argument.
  19597. * @param {*} index The potential iteratee index or key argument.
  19598. * @param {*} object The potential iteratee object argument.
  19599. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  19600. * else `false`.
  19601. */
  19602. function isIterateeCall(value, index, object) {
  19603. if (!isObject(object)) {
  19604. return false;
  19605. }
  19606. var type = typeof index;
  19607. if (type == 'number'
  19608. ? (isArrayLike(object) && isIndex(index, object.length))
  19609. : (type == 'string' && index in object)
  19610. ) {
  19611. return eq(object[index], value);
  19612. }
  19613. return false;
  19614. }
  19615. /**
  19616. * Checks if `value` is a property name and not a property path.
  19617. *
  19618. * @private
  19619. * @param {*} value The value to check.
  19620. * @param {Object} [object] The object to query keys on.
  19621. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  19622. */
  19623. function isKey(value, object) {
  19624. if (isArray(value)) {
  19625. return false;
  19626. }
  19627. var type = typeof value;
  19628. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  19629. value == null || isSymbol(value)) {
  19630. return true;
  19631. }
  19632. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  19633. (object != null && value in Object(object));
  19634. }
  19635. /**
  19636. * Checks if `value` is suitable for use as unique object key.
  19637. *
  19638. * @private
  19639. * @param {*} value The value to check.
  19640. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  19641. */
  19642. function isKeyable(value) {
  19643. var type = typeof value;
  19644. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  19645. ? (value !== '__proto__')
  19646. : (value === null);
  19647. }
  19648. /**
  19649. * Checks if `func` has a lazy counterpart.
  19650. *
  19651. * @private
  19652. * @param {Function} func The function to check.
  19653. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  19654. * else `false`.
  19655. */
  19656. function isLaziable(func) {
  19657. var funcName = getFuncName(func),
  19658. other = lodash[funcName];
  19659. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  19660. return false;
  19661. }
  19662. if (func === other) {
  19663. return true;
  19664. }
  19665. var data = getData(other);
  19666. return !!data && func === data[0];
  19667. }
  19668. /**
  19669. * Checks if `func` has its source masked.
  19670. *
  19671. * @private
  19672. * @param {Function} func The function to check.
  19673. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  19674. */
  19675. function isMasked(func) {
  19676. return !!maskSrcKey && (maskSrcKey in func);
  19677. }
  19678. /**
  19679. * Checks if `func` is capable of being masked.
  19680. *
  19681. * @private
  19682. * @param {*} value The value to check.
  19683. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  19684. */
  19685. var isMaskable = coreJsData ? isFunction : stubFalse;
  19686. /**
  19687. * Checks if `value` is likely a prototype object.
  19688. *
  19689. * @private
  19690. * @param {*} value The value to check.
  19691. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  19692. */
  19693. function isPrototype(value) {
  19694. var Ctor = value && value.constructor,
  19695. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  19696. return value === proto;
  19697. }
  19698. /**
  19699. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  19700. *
  19701. * @private
  19702. * @param {*} value The value to check.
  19703. * @returns {boolean} Returns `true` if `value` if suitable for strict
  19704. * equality comparisons, else `false`.
  19705. */
  19706. function isStrictComparable(value) {
  19707. return value === value && !isObject(value);
  19708. }
  19709. /**
  19710. * A specialized version of `matchesProperty` for source values suitable
  19711. * for strict equality comparisons, i.e. `===`.
  19712. *
  19713. * @private
  19714. * @param {string} key The key of the property to get.
  19715. * @param {*} srcValue The value to match.
  19716. * @returns {Function} Returns the new spec function.
  19717. */
  19718. function matchesStrictComparable(key, srcValue) {
  19719. return function(object) {
  19720. if (object == null) {
  19721. return false;
  19722. }
  19723. return object[key] === srcValue &&
  19724. (srcValue !== undefined || (key in Object(object)));
  19725. };
  19726. }
  19727. /**
  19728. * A specialized version of `_.memoize` which clears the memoized function's
  19729. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  19730. *
  19731. * @private
  19732. * @param {Function} func The function to have its output memoized.
  19733. * @returns {Function} Returns the new memoized function.
  19734. */
  19735. function memoizeCapped(func) {
  19736. var result = memoize(func, function(key) {
  19737. if (cache.size === MAX_MEMOIZE_SIZE) {
  19738. cache.clear();
  19739. }
  19740. return key;
  19741. });
  19742. var cache = result.cache;
  19743. return result;
  19744. }
  19745. /**
  19746. * Merges the function metadata of `source` into `data`.
  19747. *
  19748. * Merging metadata reduces the number of wrappers used to invoke a function.
  19749. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  19750. * may be applied regardless of execution order. Methods like `_.ary` and
  19751. * `_.rearg` modify function arguments, making the order in which they are
  19752. * executed important, preventing the merging of metadata. However, we make
  19753. * an exception for a safe combined case where curried functions have `_.ary`
  19754. * and or `_.rearg` applied.
  19755. *
  19756. * @private
  19757. * @param {Array} data The destination metadata.
  19758. * @param {Array} source The source metadata.
  19759. * @returns {Array} Returns `data`.
  19760. */
  19761. function mergeData(data, source) {
  19762. var bitmask = data[1],
  19763. srcBitmask = source[1],
  19764. newBitmask = bitmask | srcBitmask,
  19765. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  19766. var isCombo =
  19767. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  19768. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  19769. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  19770. // Exit early if metadata can't be merged.
  19771. if (!(isCommon || isCombo)) {
  19772. return data;
  19773. }
  19774. // Use source `thisArg` if available.
  19775. if (srcBitmask & WRAP_BIND_FLAG) {
  19776. data[2] = source[2];
  19777. // Set when currying a bound function.
  19778. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  19779. }
  19780. // Compose partial arguments.
  19781. var value = source[3];
  19782. if (value) {
  19783. var partials = data[3];
  19784. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  19785. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  19786. }
  19787. // Compose partial right arguments.
  19788. value = source[5];
  19789. if (value) {
  19790. partials = data[5];
  19791. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  19792. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  19793. }
  19794. // Use source `argPos` if available.
  19795. value = source[7];
  19796. if (value) {
  19797. data[7] = value;
  19798. }
  19799. // Use source `ary` if it's smaller.
  19800. if (srcBitmask & WRAP_ARY_FLAG) {
  19801. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  19802. }
  19803. // Use source `arity` if one is not provided.
  19804. if (data[9] == null) {
  19805. data[9] = source[9];
  19806. }
  19807. // Use source `func` and merge bitmasks.
  19808. data[0] = source[0];
  19809. data[1] = newBitmask;
  19810. return data;
  19811. }
  19812. /**
  19813. * This function is like
  19814. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  19815. * except that it includes inherited enumerable properties.
  19816. *
  19817. * @private
  19818. * @param {Object} object The object to query.
  19819. * @returns {Array} Returns the array of property names.
  19820. */
  19821. function nativeKeysIn(object) {
  19822. var result = [];
  19823. if (object != null) {
  19824. for (var key in Object(object)) {
  19825. result.push(key);
  19826. }
  19827. }
  19828. return result;
  19829. }
  19830. /**
  19831. * Converts `value` to a string using `Object.prototype.toString`.
  19832. *
  19833. * @private
  19834. * @param {*} value The value to convert.
  19835. * @returns {string} Returns the converted string.
  19836. */
  19837. function objectToString(value) {
  19838. return nativeObjectToString.call(value);
  19839. }
  19840. /**
  19841. * A specialized version of `baseRest` which transforms the rest array.
  19842. *
  19843. * @private
  19844. * @param {Function} func The function to apply a rest parameter to.
  19845. * @param {number} [start=func.length-1] The start position of the rest parameter.
  19846. * @param {Function} transform The rest array transform.
  19847. * @returns {Function} Returns the new function.
  19848. */
  19849. function overRest(func, start, transform) {
  19850. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  19851. return function() {
  19852. var args = arguments,
  19853. index = -1,
  19854. length = nativeMax(args.length - start, 0),
  19855. array = Array(length);
  19856. while (++index < length) {
  19857. array[index] = args[start + index];
  19858. }
  19859. index = -1;
  19860. var otherArgs = Array(start + 1);
  19861. while (++index < start) {
  19862. otherArgs[index] = args[index];
  19863. }
  19864. otherArgs[start] = transform(array);
  19865. return apply(func, this, otherArgs);
  19866. };
  19867. }
  19868. /**
  19869. * Gets the parent value at `path` of `object`.
  19870. *
  19871. * @private
  19872. * @param {Object} object The object to query.
  19873. * @param {Array} path The path to get the parent value of.
  19874. * @returns {*} Returns the parent value.
  19875. */
  19876. function parent(object, path) {
  19877. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  19878. }
  19879. /**
  19880. * Reorder `array` according to the specified indexes where the element at
  19881. * the first index is assigned as the first element, the element at
  19882. * the second index is assigned as the second element, and so on.
  19883. *
  19884. * @private
  19885. * @param {Array} array The array to reorder.
  19886. * @param {Array} indexes The arranged array indexes.
  19887. * @returns {Array} Returns `array`.
  19888. */
  19889. function reorder(array, indexes) {
  19890. var arrLength = array.length,
  19891. length = nativeMin(indexes.length, arrLength),
  19892. oldArray = copyArray(array);
  19893. while (length--) {
  19894. var index = indexes[length];
  19895. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  19896. }
  19897. return array;
  19898. }
  19899. /**
  19900. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  19901. *
  19902. * @private
  19903. * @param {Object} object The object to query.
  19904. * @param {string} key The key of the property to get.
  19905. * @returns {*} Returns the property value.
  19906. */
  19907. function safeGet(object, key) {
  19908. if (key === 'constructor' && typeof object[key] === 'function') {
  19909. return;
  19910. }
  19911. if (key == '__proto__') {
  19912. return;
  19913. }
  19914. return object[key];
  19915. }
  19916. /**
  19917. * Sets metadata for `func`.
  19918. *
  19919. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  19920. * period of time, it will trip its breaker and transition to an identity
  19921. * function to avoid garbage collection pauses in V8. See
  19922. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  19923. * for more details.
  19924. *
  19925. * @private
  19926. * @param {Function} func The function to associate metadata with.
  19927. * @param {*} data The metadata.
  19928. * @returns {Function} Returns `func`.
  19929. */
  19930. var setData = shortOut(baseSetData);
  19931. /**
  19932. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  19933. *
  19934. * @private
  19935. * @param {Function} func The function to delay.
  19936. * @param {number} wait The number of milliseconds to delay invocation.
  19937. * @returns {number|Object} Returns the timer id or timeout object.
  19938. */
  19939. var setTimeout = ctxSetTimeout || function(func, wait) {
  19940. return root.setTimeout(func, wait);
  19941. };
  19942. /**
  19943. * Sets the `toString` method of `func` to return `string`.
  19944. *
  19945. * @private
  19946. * @param {Function} func The function to modify.
  19947. * @param {Function} string The `toString` result.
  19948. * @returns {Function} Returns `func`.
  19949. */
  19950. var setToString = shortOut(baseSetToString);
  19951. /**
  19952. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  19953. * with wrapper details in a comment at the top of the source body.
  19954. *
  19955. * @private
  19956. * @param {Function} wrapper The function to modify.
  19957. * @param {Function} reference The reference function.
  19958. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  19959. * @returns {Function} Returns `wrapper`.
  19960. */
  19961. function setWrapToString(wrapper, reference, bitmask) {
  19962. var source = (reference + '');
  19963. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  19964. }
  19965. /**
  19966. * Creates a function that'll short out and invoke `identity` instead
  19967. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  19968. * milliseconds.
  19969. *
  19970. * @private
  19971. * @param {Function} func The function to restrict.
  19972. * @returns {Function} Returns the new shortable function.
  19973. */
  19974. function shortOut(func) {
  19975. var count = 0,
  19976. lastCalled = 0;
  19977. return function() {
  19978. var stamp = nativeNow(),
  19979. remaining = HOT_SPAN - (stamp - lastCalled);
  19980. lastCalled = stamp;
  19981. if (remaining > 0) {
  19982. if (++count >= HOT_COUNT) {
  19983. return arguments[0];
  19984. }
  19985. } else {
  19986. count = 0;
  19987. }
  19988. return func.apply(undefined, arguments);
  19989. };
  19990. }
  19991. /**
  19992. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  19993. *
  19994. * @private
  19995. * @param {Array} array The array to shuffle.
  19996. * @param {number} [size=array.length] The size of `array`.
  19997. * @returns {Array} Returns `array`.
  19998. */
  19999. function shuffleSelf(array, size) {
  20000. var index = -1,
  20001. length = array.length,
  20002. lastIndex = length - 1;
  20003. size = size === undefined ? length : size;
  20004. while (++index < size) {
  20005. var rand = baseRandom(index, lastIndex),
  20006. value = array[rand];
  20007. array[rand] = array[index];
  20008. array[index] = value;
  20009. }
  20010. array.length = size;
  20011. return array;
  20012. }
  20013. /**
  20014. * Converts `string` to a property path array.
  20015. *
  20016. * @private
  20017. * @param {string} string The string to convert.
  20018. * @returns {Array} Returns the property path array.
  20019. */
  20020. var stringToPath = memoizeCapped(function(string) {
  20021. var result = [];
  20022. if (string.charCodeAt(0) === 46 /* . */) {
  20023. result.push('');
  20024. }
  20025. string.replace(rePropName, function(match, number, quote, subString) {
  20026. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  20027. });
  20028. return result;
  20029. });
  20030. /**
  20031. * Converts `value` to a string key if it's not a string or symbol.
  20032. *
  20033. * @private
  20034. * @param {*} value The value to inspect.
  20035. * @returns {string|symbol} Returns the key.
  20036. */
  20037. function toKey(value) {
  20038. if (typeof value == 'string' || isSymbol(value)) {
  20039. return value;
  20040. }
  20041. var result = (value + '');
  20042. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20043. }
  20044. /**
  20045. * Converts `func` to its source code.
  20046. *
  20047. * @private
  20048. * @param {Function} func The function to convert.
  20049. * @returns {string} Returns the source code.
  20050. */
  20051. function toSource(func) {
  20052. if (func != null) {
  20053. try {
  20054. return funcToString.call(func);
  20055. } catch (e) {}
  20056. try {
  20057. return (func + '');
  20058. } catch (e) {}
  20059. }
  20060. return '';
  20061. }
  20062. /**
  20063. * Updates wrapper `details` based on `bitmask` flags.
  20064. *
  20065. * @private
  20066. * @returns {Array} details The details to modify.
  20067. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  20068. * @returns {Array} Returns `details`.
  20069. */
  20070. function updateWrapDetails(details, bitmask) {
  20071. arrayEach(wrapFlags, function(pair) {
  20072. var value = '_.' + pair[0];
  20073. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  20074. details.push(value);
  20075. }
  20076. });
  20077. return details.sort();
  20078. }
  20079. /**
  20080. * Creates a clone of `wrapper`.
  20081. *
  20082. * @private
  20083. * @param {Object} wrapper The wrapper to clone.
  20084. * @returns {Object} Returns the cloned wrapper.
  20085. */
  20086. function wrapperClone(wrapper) {
  20087. if (wrapper instanceof LazyWrapper) {
  20088. return wrapper.clone();
  20089. }
  20090. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  20091. result.__actions__ = copyArray(wrapper.__actions__);
  20092. result.__index__ = wrapper.__index__;
  20093. result.__values__ = wrapper.__values__;
  20094. return result;
  20095. }
  20096. /*------------------------------------------------------------------------*/
  20097. /**
  20098. * Creates an array of elements split into groups the length of `size`.
  20099. * If `array` can't be split evenly, the final chunk will be the remaining
  20100. * elements.
  20101. *
  20102. * @static
  20103. * @memberOf _
  20104. * @since 3.0.0
  20105. * @category Array
  20106. * @param {Array} array The array to process.
  20107. * @param {number} [size=1] The length of each chunk
  20108. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20109. * @returns {Array} Returns the new array of chunks.
  20110. * @example
  20111. *
  20112. * _.chunk(['a', 'b', 'c', 'd'], 2);
  20113. * // => [['a', 'b'], ['c', 'd']]
  20114. *
  20115. * _.chunk(['a', 'b', 'c', 'd'], 3);
  20116. * // => [['a', 'b', 'c'], ['d']]
  20117. */
  20118. function chunk(array, size, guard) {
  20119. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  20120. size = 1;
  20121. } else {
  20122. size = nativeMax(toInteger(size), 0);
  20123. }
  20124. var length = array == null ? 0 : array.length;
  20125. if (!length || size < 1) {
  20126. return [];
  20127. }
  20128. var index = 0,
  20129. resIndex = 0,
  20130. result = Array(nativeCeil(length / size));
  20131. while (index < length) {
  20132. result[resIndex++] = baseSlice(array, index, (index += size));
  20133. }
  20134. return result;
  20135. }
  20136. /**
  20137. * Creates an array with all falsey values removed. The values `false`, `null`,
  20138. * `0`, `""`, `undefined`, and `NaN` are falsey.
  20139. *
  20140. * @static
  20141. * @memberOf _
  20142. * @since 0.1.0
  20143. * @category Array
  20144. * @param {Array} array The array to compact.
  20145. * @returns {Array} Returns the new array of filtered values.
  20146. * @example
  20147. *
  20148. * _.compact([0, 1, false, 2, '', 3]);
  20149. * // => [1, 2, 3]
  20150. */
  20151. function compact(array) {
  20152. var index = -1,
  20153. length = array == null ? 0 : array.length,
  20154. resIndex = 0,
  20155. result = [];
  20156. while (++index < length) {
  20157. var value = array[index];
  20158. if (value) {
  20159. result[resIndex++] = value;
  20160. }
  20161. }
  20162. return result;
  20163. }
  20164. /**
  20165. * Creates a new array concatenating `array` with any additional arrays
  20166. * and/or values.
  20167. *
  20168. * @static
  20169. * @memberOf _
  20170. * @since 4.0.0
  20171. * @category Array
  20172. * @param {Array} array The array to concatenate.
  20173. * @param {...*} [values] The values to concatenate.
  20174. * @returns {Array} Returns the new concatenated array.
  20175. * @example
  20176. *
  20177. * var array = [1];
  20178. * var other = _.concat(array, 2, [3], [[4]]);
  20179. *
  20180. * console.log(other);
  20181. * // => [1, 2, 3, [4]]
  20182. *
  20183. * console.log(array);
  20184. * // => [1]
  20185. */
  20186. function concat() {
  20187. var length = arguments.length;
  20188. if (!length) {
  20189. return [];
  20190. }
  20191. var args = Array(length - 1),
  20192. array = arguments[0],
  20193. index = length;
  20194. while (index--) {
  20195. args[index - 1] = arguments[index];
  20196. }
  20197. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  20198. }
  20199. /**
  20200. * Creates an array of `array` values not included in the other given arrays
  20201. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20202. * for equality comparisons. The order and references of result values are
  20203. * determined by the first array.
  20204. *
  20205. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  20206. *
  20207. * @static
  20208. * @memberOf _
  20209. * @since 0.1.0
  20210. * @category Array
  20211. * @param {Array} array The array to inspect.
  20212. * @param {...Array} [values] The values to exclude.
  20213. * @returns {Array} Returns the new array of filtered values.
  20214. * @see _.without, _.xor
  20215. * @example
  20216. *
  20217. * _.difference([2, 1], [2, 3]);
  20218. * // => [1]
  20219. */
  20220. var difference = baseRest(function(array, values) {
  20221. return isArrayLikeObject(array)
  20222. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  20223. : [];
  20224. });
  20225. /**
  20226. * This method is like `_.difference` except that it accepts `iteratee` which
  20227. * is invoked for each element of `array` and `values` to generate the criterion
  20228. * by which they're compared. The order and references of result values are
  20229. * determined by the first array. The iteratee is invoked with one argument:
  20230. * (value).
  20231. *
  20232. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  20233. *
  20234. * @static
  20235. * @memberOf _
  20236. * @since 4.0.0
  20237. * @category Array
  20238. * @param {Array} array The array to inspect.
  20239. * @param {...Array} [values] The values to exclude.
  20240. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20241. * @returns {Array} Returns the new array of filtered values.
  20242. * @example
  20243. *
  20244. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20245. * // => [1.2]
  20246. *
  20247. * // The `_.property` iteratee shorthand.
  20248. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  20249. * // => [{ 'x': 2 }]
  20250. */
  20251. var differenceBy = baseRest(function(array, values) {
  20252. var iteratee = last(values);
  20253. if (isArrayLikeObject(iteratee)) {
  20254. iteratee = undefined;
  20255. }
  20256. return isArrayLikeObject(array)
  20257. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  20258. : [];
  20259. });
  20260. /**
  20261. * This method is like `_.difference` except that it accepts `comparator`
  20262. * which is invoked to compare elements of `array` to `values`. The order and
  20263. * references of result values are determined by the first array. The comparator
  20264. * is invoked with two arguments: (arrVal, othVal).
  20265. *
  20266. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  20267. *
  20268. * @static
  20269. * @memberOf _
  20270. * @since 4.0.0
  20271. * @category Array
  20272. * @param {Array} array The array to inspect.
  20273. * @param {...Array} [values] The values to exclude.
  20274. * @param {Function} [comparator] The comparator invoked per element.
  20275. * @returns {Array} Returns the new array of filtered values.
  20276. * @example
  20277. *
  20278. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20279. *
  20280. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  20281. * // => [{ 'x': 2, 'y': 1 }]
  20282. */
  20283. var differenceWith = baseRest(function(array, values) {
  20284. var comparator = last(values);
  20285. if (isArrayLikeObject(comparator)) {
  20286. comparator = undefined;
  20287. }
  20288. return isArrayLikeObject(array)
  20289. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  20290. : [];
  20291. });
  20292. /**
  20293. * Creates a slice of `array` with `n` elements dropped from the beginning.
  20294. *
  20295. * @static
  20296. * @memberOf _
  20297. * @since 0.5.0
  20298. * @category Array
  20299. * @param {Array} array The array to query.
  20300. * @param {number} [n=1] The number of elements to drop.
  20301. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20302. * @returns {Array} Returns the slice of `array`.
  20303. * @example
  20304. *
  20305. * _.drop([1, 2, 3]);
  20306. * // => [2, 3]
  20307. *
  20308. * _.drop([1, 2, 3], 2);
  20309. * // => [3]
  20310. *
  20311. * _.drop([1, 2, 3], 5);
  20312. * // => []
  20313. *
  20314. * _.drop([1, 2, 3], 0);
  20315. * // => [1, 2, 3]
  20316. */
  20317. function drop(array, n, guard) {
  20318. var length = array == null ? 0 : array.length;
  20319. if (!length) {
  20320. return [];
  20321. }
  20322. n = (guard || n === undefined) ? 1 : toInteger(n);
  20323. return baseSlice(array, n < 0 ? 0 : n, length);
  20324. }
  20325. /**
  20326. * Creates a slice of `array` with `n` elements dropped from the end.
  20327. *
  20328. * @static
  20329. * @memberOf _
  20330. * @since 3.0.0
  20331. * @category Array
  20332. * @param {Array} array The array to query.
  20333. * @param {number} [n=1] The number of elements to drop.
  20334. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20335. * @returns {Array} Returns the slice of `array`.
  20336. * @example
  20337. *
  20338. * _.dropRight([1, 2, 3]);
  20339. * // => [1, 2]
  20340. *
  20341. * _.dropRight([1, 2, 3], 2);
  20342. * // => [1]
  20343. *
  20344. * _.dropRight([1, 2, 3], 5);
  20345. * // => []
  20346. *
  20347. * _.dropRight([1, 2, 3], 0);
  20348. * // => [1, 2, 3]
  20349. */
  20350. function dropRight(array, n, guard) {
  20351. var length = array == null ? 0 : array.length;
  20352. if (!length) {
  20353. return [];
  20354. }
  20355. n = (guard || n === undefined) ? 1 : toInteger(n);
  20356. n = length - n;
  20357. return baseSlice(array, 0, n < 0 ? 0 : n);
  20358. }
  20359. /**
  20360. * Creates a slice of `array` excluding elements dropped from the end.
  20361. * Elements are dropped until `predicate` returns falsey. The predicate is
  20362. * invoked with three arguments: (value, index, array).
  20363. *
  20364. * @static
  20365. * @memberOf _
  20366. * @since 3.0.0
  20367. * @category Array
  20368. * @param {Array} array The array to query.
  20369. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20370. * @returns {Array} Returns the slice of `array`.
  20371. * @example
  20372. *
  20373. * var users = [
  20374. * { 'user': 'barney', 'active': true },
  20375. * { 'user': 'fred', 'active': false },
  20376. * { 'user': 'pebbles', 'active': false }
  20377. * ];
  20378. *
  20379. * _.dropRightWhile(users, function(o) { return !o.active; });
  20380. * // => objects for ['barney']
  20381. *
  20382. * // The `_.matches` iteratee shorthand.
  20383. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  20384. * // => objects for ['barney', 'fred']
  20385. *
  20386. * // The `_.matchesProperty` iteratee shorthand.
  20387. * _.dropRightWhile(users, ['active', false]);
  20388. * // => objects for ['barney']
  20389. *
  20390. * // The `_.property` iteratee shorthand.
  20391. * _.dropRightWhile(users, 'active');
  20392. * // => objects for ['barney', 'fred', 'pebbles']
  20393. */
  20394. function dropRightWhile(array, predicate) {
  20395. return (array && array.length)
  20396. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  20397. : [];
  20398. }
  20399. /**
  20400. * Creates a slice of `array` excluding elements dropped from the beginning.
  20401. * Elements are dropped until `predicate` returns falsey. The predicate is
  20402. * invoked with three arguments: (value, index, array).
  20403. *
  20404. * @static
  20405. * @memberOf _
  20406. * @since 3.0.0
  20407. * @category Array
  20408. * @param {Array} array The array to query.
  20409. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20410. * @returns {Array} Returns the slice of `array`.
  20411. * @example
  20412. *
  20413. * var users = [
  20414. * { 'user': 'barney', 'active': false },
  20415. * { 'user': 'fred', 'active': false },
  20416. * { 'user': 'pebbles', 'active': true }
  20417. * ];
  20418. *
  20419. * _.dropWhile(users, function(o) { return !o.active; });
  20420. * // => objects for ['pebbles']
  20421. *
  20422. * // The `_.matches` iteratee shorthand.
  20423. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  20424. * // => objects for ['fred', 'pebbles']
  20425. *
  20426. * // The `_.matchesProperty` iteratee shorthand.
  20427. * _.dropWhile(users, ['active', false]);
  20428. * // => objects for ['pebbles']
  20429. *
  20430. * // The `_.property` iteratee shorthand.
  20431. * _.dropWhile(users, 'active');
  20432. * // => objects for ['barney', 'fred', 'pebbles']
  20433. */
  20434. function dropWhile(array, predicate) {
  20435. return (array && array.length)
  20436. ? baseWhile(array, getIteratee(predicate, 3), true)
  20437. : [];
  20438. }
  20439. /**
  20440. * Fills elements of `array` with `value` from `start` up to, but not
  20441. * including, `end`.
  20442. *
  20443. * **Note:** This method mutates `array`.
  20444. *
  20445. * @static
  20446. * @memberOf _
  20447. * @since 3.2.0
  20448. * @category Array
  20449. * @param {Array} array The array to fill.
  20450. * @param {*} value The value to fill `array` with.
  20451. * @param {number} [start=0] The start position.
  20452. * @param {number} [end=array.length] The end position.
  20453. * @returns {Array} Returns `array`.
  20454. * @example
  20455. *
  20456. * var array = [1, 2, 3];
  20457. *
  20458. * _.fill(array, 'a');
  20459. * console.log(array);
  20460. * // => ['a', 'a', 'a']
  20461. *
  20462. * _.fill(Array(3), 2);
  20463. * // => [2, 2, 2]
  20464. *
  20465. * _.fill([4, 6, 8, 10], '*', 1, 3);
  20466. * // => [4, '*', '*', 10]
  20467. */
  20468. function fill(array, value, start, end) {
  20469. var length = array == null ? 0 : array.length;
  20470. if (!length) {
  20471. return [];
  20472. }
  20473. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  20474. start = 0;
  20475. end = length;
  20476. }
  20477. return baseFill(array, value, start, end);
  20478. }
  20479. /**
  20480. * This method is like `_.find` except that it returns the index of the first
  20481. * element `predicate` returns truthy for instead of the element itself.
  20482. *
  20483. * @static
  20484. * @memberOf _
  20485. * @since 1.1.0
  20486. * @category Array
  20487. * @param {Array} array The array to inspect.
  20488. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20489. * @param {number} [fromIndex=0] The index to search from.
  20490. * @returns {number} Returns the index of the found element, else `-1`.
  20491. * @example
  20492. *
  20493. * var users = [
  20494. * { 'user': 'barney', 'active': false },
  20495. * { 'user': 'fred', 'active': false },
  20496. * { 'user': 'pebbles', 'active': true }
  20497. * ];
  20498. *
  20499. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  20500. * // => 0
  20501. *
  20502. * // The `_.matches` iteratee shorthand.
  20503. * _.findIndex(users, { 'user': 'fred', 'active': false });
  20504. * // => 1
  20505. *
  20506. * // The `_.matchesProperty` iteratee shorthand.
  20507. * _.findIndex(users, ['active', false]);
  20508. * // => 0
  20509. *
  20510. * // The `_.property` iteratee shorthand.
  20511. * _.findIndex(users, 'active');
  20512. * // => 2
  20513. */
  20514. function findIndex(array, predicate, fromIndex) {
  20515. var length = array == null ? 0 : array.length;
  20516. if (!length) {
  20517. return -1;
  20518. }
  20519. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20520. if (index < 0) {
  20521. index = nativeMax(length + index, 0);
  20522. }
  20523. return baseFindIndex(array, getIteratee(predicate, 3), index);
  20524. }
  20525. /**
  20526. * This method is like `_.findIndex` except that it iterates over elements
  20527. * of `collection` from right to left.
  20528. *
  20529. * @static
  20530. * @memberOf _
  20531. * @since 2.0.0
  20532. * @category Array
  20533. * @param {Array} array The array to inspect.
  20534. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20535. * @param {number} [fromIndex=array.length-1] The index to search from.
  20536. * @returns {number} Returns the index of the found element, else `-1`.
  20537. * @example
  20538. *
  20539. * var users = [
  20540. * { 'user': 'barney', 'active': true },
  20541. * { 'user': 'fred', 'active': false },
  20542. * { 'user': 'pebbles', 'active': false }
  20543. * ];
  20544. *
  20545. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  20546. * // => 2
  20547. *
  20548. * // The `_.matches` iteratee shorthand.
  20549. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  20550. * // => 0
  20551. *
  20552. * // The `_.matchesProperty` iteratee shorthand.
  20553. * _.findLastIndex(users, ['active', false]);
  20554. * // => 2
  20555. *
  20556. * // The `_.property` iteratee shorthand.
  20557. * _.findLastIndex(users, 'active');
  20558. * // => 0
  20559. */
  20560. function findLastIndex(array, predicate, fromIndex) {
  20561. var length = array == null ? 0 : array.length;
  20562. if (!length) {
  20563. return -1;
  20564. }
  20565. var index = length - 1;
  20566. if (fromIndex !== undefined) {
  20567. index = toInteger(fromIndex);
  20568. index = fromIndex < 0
  20569. ? nativeMax(length + index, 0)
  20570. : nativeMin(index, length - 1);
  20571. }
  20572. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  20573. }
  20574. /**
  20575. * Flattens `array` a single level deep.
  20576. *
  20577. * @static
  20578. * @memberOf _
  20579. * @since 0.1.0
  20580. * @category Array
  20581. * @param {Array} array The array to flatten.
  20582. * @returns {Array} Returns the new flattened array.
  20583. * @example
  20584. *
  20585. * _.flatten([1, [2, [3, [4]], 5]]);
  20586. * // => [1, 2, [3, [4]], 5]
  20587. */
  20588. function flatten(array) {
  20589. var length = array == null ? 0 : array.length;
  20590. return length ? baseFlatten(array, 1) : [];
  20591. }
  20592. /**
  20593. * Recursively flattens `array`.
  20594. *
  20595. * @static
  20596. * @memberOf _
  20597. * @since 3.0.0
  20598. * @category Array
  20599. * @param {Array} array The array to flatten.
  20600. * @returns {Array} Returns the new flattened array.
  20601. * @example
  20602. *
  20603. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  20604. * // => [1, 2, 3, 4, 5]
  20605. */
  20606. function flattenDeep(array) {
  20607. var length = array == null ? 0 : array.length;
  20608. return length ? baseFlatten(array, INFINITY) : [];
  20609. }
  20610. /**
  20611. * Recursively flatten `array` up to `depth` times.
  20612. *
  20613. * @static
  20614. * @memberOf _
  20615. * @since 4.4.0
  20616. * @category Array
  20617. * @param {Array} array The array to flatten.
  20618. * @param {number} [depth=1] The maximum recursion depth.
  20619. * @returns {Array} Returns the new flattened array.
  20620. * @example
  20621. *
  20622. * var array = [1, [2, [3, [4]], 5]];
  20623. *
  20624. * _.flattenDepth(array, 1);
  20625. * // => [1, 2, [3, [4]], 5]
  20626. *
  20627. * _.flattenDepth(array, 2);
  20628. * // => [1, 2, 3, [4], 5]
  20629. */
  20630. function flattenDepth(array, depth) {
  20631. var length = array == null ? 0 : array.length;
  20632. if (!length) {
  20633. return [];
  20634. }
  20635. depth = depth === undefined ? 1 : toInteger(depth);
  20636. return baseFlatten(array, depth);
  20637. }
  20638. /**
  20639. * The inverse of `_.toPairs`; this method returns an object composed
  20640. * from key-value `pairs`.
  20641. *
  20642. * @static
  20643. * @memberOf _
  20644. * @since 4.0.0
  20645. * @category Array
  20646. * @param {Array} pairs The key-value pairs.
  20647. * @returns {Object} Returns the new object.
  20648. * @example
  20649. *
  20650. * _.fromPairs([['a', 1], ['b', 2]]);
  20651. * // => { 'a': 1, 'b': 2 }
  20652. */
  20653. function fromPairs(pairs) {
  20654. var index = -1,
  20655. length = pairs == null ? 0 : pairs.length,
  20656. result = {};
  20657. while (++index < length) {
  20658. var pair = pairs[index];
  20659. result[pair[0]] = pair[1];
  20660. }
  20661. return result;
  20662. }
  20663. /**
  20664. * Gets the first element of `array`.
  20665. *
  20666. * @static
  20667. * @memberOf _
  20668. * @since 0.1.0
  20669. * @alias first
  20670. * @category Array
  20671. * @param {Array} array The array to query.
  20672. * @returns {*} Returns the first element of `array`.
  20673. * @example
  20674. *
  20675. * _.head([1, 2, 3]);
  20676. * // => 1
  20677. *
  20678. * _.head([]);
  20679. * // => undefined
  20680. */
  20681. function head(array) {
  20682. return (array && array.length) ? array[0] : undefined;
  20683. }
  20684. /**
  20685. * Gets the index at which the first occurrence of `value` is found in `array`
  20686. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20687. * for equality comparisons. If `fromIndex` is negative, it's used as the
  20688. * offset from the end of `array`.
  20689. *
  20690. * @static
  20691. * @memberOf _
  20692. * @since 0.1.0
  20693. * @category Array
  20694. * @param {Array} array The array to inspect.
  20695. * @param {*} value The value to search for.
  20696. * @param {number} [fromIndex=0] The index to search from.
  20697. * @returns {number} Returns the index of the matched value, else `-1`.
  20698. * @example
  20699. *
  20700. * _.indexOf([1, 2, 1, 2], 2);
  20701. * // => 1
  20702. *
  20703. * // Search from the `fromIndex`.
  20704. * _.indexOf([1, 2, 1, 2], 2, 2);
  20705. * // => 3
  20706. */
  20707. function indexOf(array, value, fromIndex) {
  20708. var length = array == null ? 0 : array.length;
  20709. if (!length) {
  20710. return -1;
  20711. }
  20712. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20713. if (index < 0) {
  20714. index = nativeMax(length + index, 0);
  20715. }
  20716. return baseIndexOf(array, value, index);
  20717. }
  20718. /**
  20719. * Gets all but the last element of `array`.
  20720. *
  20721. * @static
  20722. * @memberOf _
  20723. * @since 0.1.0
  20724. * @category Array
  20725. * @param {Array} array The array to query.
  20726. * @returns {Array} Returns the slice of `array`.
  20727. * @example
  20728. *
  20729. * _.initial([1, 2, 3]);
  20730. * // => [1, 2]
  20731. */
  20732. function initial(array) {
  20733. var length = array == null ? 0 : array.length;
  20734. return length ? baseSlice(array, 0, -1) : [];
  20735. }
  20736. /**
  20737. * Creates an array of unique values that are included in all given arrays
  20738. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20739. * for equality comparisons. The order and references of result values are
  20740. * determined by the first array.
  20741. *
  20742. * @static
  20743. * @memberOf _
  20744. * @since 0.1.0
  20745. * @category Array
  20746. * @param {...Array} [arrays] The arrays to inspect.
  20747. * @returns {Array} Returns the new array of intersecting values.
  20748. * @example
  20749. *
  20750. * _.intersection([2, 1], [2, 3]);
  20751. * // => [2]
  20752. */
  20753. var intersection = baseRest(function(arrays) {
  20754. var mapped = arrayMap(arrays, castArrayLikeObject);
  20755. return (mapped.length && mapped[0] === arrays[0])
  20756. ? baseIntersection(mapped)
  20757. : [];
  20758. });
  20759. /**
  20760. * This method is like `_.intersection` except that it accepts `iteratee`
  20761. * which is invoked for each element of each `arrays` to generate the criterion
  20762. * by which they're compared. The order and references of result values are
  20763. * determined by the first array. The iteratee is invoked with one argument:
  20764. * (value).
  20765. *
  20766. * @static
  20767. * @memberOf _
  20768. * @since 4.0.0
  20769. * @category Array
  20770. * @param {...Array} [arrays] The arrays to inspect.
  20771. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20772. * @returns {Array} Returns the new array of intersecting values.
  20773. * @example
  20774. *
  20775. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20776. * // => [2.1]
  20777. *
  20778. * // The `_.property` iteratee shorthand.
  20779. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  20780. * // => [{ 'x': 1 }]
  20781. */
  20782. var intersectionBy = baseRest(function(arrays) {
  20783. var iteratee = last(arrays),
  20784. mapped = arrayMap(arrays, castArrayLikeObject);
  20785. if (iteratee === last(mapped)) {
  20786. iteratee = undefined;
  20787. } else {
  20788. mapped.pop();
  20789. }
  20790. return (mapped.length && mapped[0] === arrays[0])
  20791. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  20792. : [];
  20793. });
  20794. /**
  20795. * This method is like `_.intersection` except that it accepts `comparator`
  20796. * which is invoked to compare elements of `arrays`. The order and references
  20797. * of result values are determined by the first array. The comparator is
  20798. * invoked with two arguments: (arrVal, othVal).
  20799. *
  20800. * @static
  20801. * @memberOf _
  20802. * @since 4.0.0
  20803. * @category Array
  20804. * @param {...Array} [arrays] The arrays to inspect.
  20805. * @param {Function} [comparator] The comparator invoked per element.
  20806. * @returns {Array} Returns the new array of intersecting values.
  20807. * @example
  20808. *
  20809. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20810. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  20811. *
  20812. * _.intersectionWith(objects, others, _.isEqual);
  20813. * // => [{ 'x': 1, 'y': 2 }]
  20814. */
  20815. var intersectionWith = baseRest(function(arrays) {
  20816. var comparator = last(arrays),
  20817. mapped = arrayMap(arrays, castArrayLikeObject);
  20818. comparator = typeof comparator == 'function' ? comparator : undefined;
  20819. if (comparator) {
  20820. mapped.pop();
  20821. }
  20822. return (mapped.length && mapped[0] === arrays[0])
  20823. ? baseIntersection(mapped, undefined, comparator)
  20824. : [];
  20825. });
  20826. /**
  20827. * Converts all elements in `array` into a string separated by `separator`.
  20828. *
  20829. * @static
  20830. * @memberOf _
  20831. * @since 4.0.0
  20832. * @category Array
  20833. * @param {Array} array The array to convert.
  20834. * @param {string} [separator=','] The element separator.
  20835. * @returns {string} Returns the joined string.
  20836. * @example
  20837. *
  20838. * _.join(['a', 'b', 'c'], '~');
  20839. * // => 'a~b~c'
  20840. */
  20841. function join(array, separator) {
  20842. return array == null ? '' : nativeJoin.call(array, separator);
  20843. }
  20844. /**
  20845. * Gets the last element of `array`.
  20846. *
  20847. * @static
  20848. * @memberOf _
  20849. * @since 0.1.0
  20850. * @category Array
  20851. * @param {Array} array The array to query.
  20852. * @returns {*} Returns the last element of `array`.
  20853. * @example
  20854. *
  20855. * _.last([1, 2, 3]);
  20856. * // => 3
  20857. */
  20858. function last(array) {
  20859. var length = array == null ? 0 : array.length;
  20860. return length ? array[length - 1] : undefined;
  20861. }
  20862. /**
  20863. * This method is like `_.indexOf` except that it iterates over elements of
  20864. * `array` from right to left.
  20865. *
  20866. * @static
  20867. * @memberOf _
  20868. * @since 0.1.0
  20869. * @category Array
  20870. * @param {Array} array The array to inspect.
  20871. * @param {*} value The value to search for.
  20872. * @param {number} [fromIndex=array.length-1] The index to search from.
  20873. * @returns {number} Returns the index of the matched value, else `-1`.
  20874. * @example
  20875. *
  20876. * _.lastIndexOf([1, 2, 1, 2], 2);
  20877. * // => 3
  20878. *
  20879. * // Search from the `fromIndex`.
  20880. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  20881. * // => 1
  20882. */
  20883. function lastIndexOf(array, value, fromIndex) {
  20884. var length = array == null ? 0 : array.length;
  20885. if (!length) {
  20886. return -1;
  20887. }
  20888. var index = length;
  20889. if (fromIndex !== undefined) {
  20890. index = toInteger(fromIndex);
  20891. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  20892. }
  20893. return value === value
  20894. ? strictLastIndexOf(array, value, index)
  20895. : baseFindIndex(array, baseIsNaN, index, true);
  20896. }
  20897. /**
  20898. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  20899. * element from the end is returned.
  20900. *
  20901. * @static
  20902. * @memberOf _
  20903. * @since 4.11.0
  20904. * @category Array
  20905. * @param {Array} array The array to query.
  20906. * @param {number} [n=0] The index of the element to return.
  20907. * @returns {*} Returns the nth element of `array`.
  20908. * @example
  20909. *
  20910. * var array = ['a', 'b', 'c', 'd'];
  20911. *
  20912. * _.nth(array, 1);
  20913. * // => 'b'
  20914. *
  20915. * _.nth(array, -2);
  20916. * // => 'c';
  20917. */
  20918. function nth(array, n) {
  20919. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  20920. }
  20921. /**
  20922. * Removes all given values from `array` using
  20923. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20924. * for equality comparisons.
  20925. *
  20926. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  20927. * to remove elements from an array by predicate.
  20928. *
  20929. * @static
  20930. * @memberOf _
  20931. * @since 2.0.0
  20932. * @category Array
  20933. * @param {Array} array The array to modify.
  20934. * @param {...*} [values] The values to remove.
  20935. * @returns {Array} Returns `array`.
  20936. * @example
  20937. *
  20938. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  20939. *
  20940. * _.pull(array, 'a', 'c');
  20941. * console.log(array);
  20942. * // => ['b', 'b']
  20943. */
  20944. var pull = baseRest(pullAll);
  20945. /**
  20946. * This method is like `_.pull` except that it accepts an array of values to remove.
  20947. *
  20948. * **Note:** Unlike `_.difference`, this method mutates `array`.
  20949. *
  20950. * @static
  20951. * @memberOf _
  20952. * @since 4.0.0
  20953. * @category Array
  20954. * @param {Array} array The array to modify.
  20955. * @param {Array} values The values to remove.
  20956. * @returns {Array} Returns `array`.
  20957. * @example
  20958. *
  20959. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  20960. *
  20961. * _.pullAll(array, ['a', 'c']);
  20962. * console.log(array);
  20963. * // => ['b', 'b']
  20964. */
  20965. function pullAll(array, values) {
  20966. return (array && array.length && values && values.length)
  20967. ? basePullAll(array, values)
  20968. : array;
  20969. }
  20970. /**
  20971. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  20972. * invoked for each element of `array` and `values` to generate the criterion
  20973. * by which they're compared. The iteratee is invoked with one argument: (value).
  20974. *
  20975. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  20976. *
  20977. * @static
  20978. * @memberOf _
  20979. * @since 4.0.0
  20980. * @category Array
  20981. * @param {Array} array The array to modify.
  20982. * @param {Array} values The values to remove.
  20983. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20984. * @returns {Array} Returns `array`.
  20985. * @example
  20986. *
  20987. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  20988. *
  20989. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  20990. * console.log(array);
  20991. * // => [{ 'x': 2 }]
  20992. */
  20993. function pullAllBy(array, values, iteratee) {
  20994. return (array && array.length && values && values.length)
  20995. ? basePullAll(array, values, getIteratee(iteratee, 2))
  20996. : array;
  20997. }
  20998. /**
  20999. * This method is like `_.pullAll` except that it accepts `comparator` which
  21000. * is invoked to compare elements of `array` to `values`. The comparator is
  21001. * invoked with two arguments: (arrVal, othVal).
  21002. *
  21003. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  21004. *
  21005. * @static
  21006. * @memberOf _
  21007. * @since 4.6.0
  21008. * @category Array
  21009. * @param {Array} array The array to modify.
  21010. * @param {Array} values The values to remove.
  21011. * @param {Function} [comparator] The comparator invoked per element.
  21012. * @returns {Array} Returns `array`.
  21013. * @example
  21014. *
  21015. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  21016. *
  21017. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  21018. * console.log(array);
  21019. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  21020. */
  21021. function pullAllWith(array, values, comparator) {
  21022. return (array && array.length && values && values.length)
  21023. ? basePullAll(array, values, undefined, comparator)
  21024. : array;
  21025. }
  21026. /**
  21027. * Removes elements from `array` corresponding to `indexes` and returns an
  21028. * array of removed elements.
  21029. *
  21030. * **Note:** Unlike `_.at`, this method mutates `array`.
  21031. *
  21032. * @static
  21033. * @memberOf _
  21034. * @since 3.0.0
  21035. * @category Array
  21036. * @param {Array} array The array to modify.
  21037. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  21038. * @returns {Array} Returns the new array of removed elements.
  21039. * @example
  21040. *
  21041. * var array = ['a', 'b', 'c', 'd'];
  21042. * var pulled = _.pullAt(array, [1, 3]);
  21043. *
  21044. * console.log(array);
  21045. * // => ['a', 'c']
  21046. *
  21047. * console.log(pulled);
  21048. * // => ['b', 'd']
  21049. */
  21050. var pullAt = flatRest(function(array, indexes) {
  21051. var length = array == null ? 0 : array.length,
  21052. result = baseAt(array, indexes);
  21053. basePullAt(array, arrayMap(indexes, function(index) {
  21054. return isIndex(index, length) ? +index : index;
  21055. }).sort(compareAscending));
  21056. return result;
  21057. });
  21058. /**
  21059. * Removes all elements from `array` that `predicate` returns truthy for
  21060. * and returns an array of the removed elements. The predicate is invoked
  21061. * with three arguments: (value, index, array).
  21062. *
  21063. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  21064. * to pull elements from an array by value.
  21065. *
  21066. * @static
  21067. * @memberOf _
  21068. * @since 2.0.0
  21069. * @category Array
  21070. * @param {Array} array The array to modify.
  21071. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21072. * @returns {Array} Returns the new array of removed elements.
  21073. * @example
  21074. *
  21075. * var array = [1, 2, 3, 4];
  21076. * var evens = _.remove(array, function(n) {
  21077. * return n % 2 == 0;
  21078. * });
  21079. *
  21080. * console.log(array);
  21081. * // => [1, 3]
  21082. *
  21083. * console.log(evens);
  21084. * // => [2, 4]
  21085. */
  21086. function remove(array, predicate) {
  21087. var result = [];
  21088. if (!(array && array.length)) {
  21089. return result;
  21090. }
  21091. var index = -1,
  21092. indexes = [],
  21093. length = array.length;
  21094. predicate = getIteratee(predicate, 3);
  21095. while (++index < length) {
  21096. var value = array[index];
  21097. if (predicate(value, index, array)) {
  21098. result.push(value);
  21099. indexes.push(index);
  21100. }
  21101. }
  21102. basePullAt(array, indexes);
  21103. return result;
  21104. }
  21105. /**
  21106. * Reverses `array` so that the first element becomes the last, the second
  21107. * element becomes the second to last, and so on.
  21108. *
  21109. * **Note:** This method mutates `array` and is based on
  21110. * [`Array#reverse`](https://mdn.io/Array/reverse).
  21111. *
  21112. * @static
  21113. * @memberOf _
  21114. * @since 4.0.0
  21115. * @category Array
  21116. * @param {Array} array The array to modify.
  21117. * @returns {Array} Returns `array`.
  21118. * @example
  21119. *
  21120. * var array = [1, 2, 3];
  21121. *
  21122. * _.reverse(array);
  21123. * // => [3, 2, 1]
  21124. *
  21125. * console.log(array);
  21126. * // => [3, 2, 1]
  21127. */
  21128. function reverse(array) {
  21129. return array == null ? array : nativeReverse.call(array);
  21130. }
  21131. /**
  21132. * Creates a slice of `array` from `start` up to, but not including, `end`.
  21133. *
  21134. * **Note:** This method is used instead of
  21135. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  21136. * returned.
  21137. *
  21138. * @static
  21139. * @memberOf _
  21140. * @since 3.0.0
  21141. * @category Array
  21142. * @param {Array} array The array to slice.
  21143. * @param {number} [start=0] The start position.
  21144. * @param {number} [end=array.length] The end position.
  21145. * @returns {Array} Returns the slice of `array`.
  21146. */
  21147. function slice(array, start, end) {
  21148. var length = array == null ? 0 : array.length;
  21149. if (!length) {
  21150. return [];
  21151. }
  21152. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  21153. start = 0;
  21154. end = length;
  21155. }
  21156. else {
  21157. start = start == null ? 0 : toInteger(start);
  21158. end = end === undefined ? length : toInteger(end);
  21159. }
  21160. return baseSlice(array, start, end);
  21161. }
  21162. /**
  21163. * Uses a binary search to determine the lowest index at which `value`
  21164. * should be inserted into `array` in order to maintain its sort order.
  21165. *
  21166. * @static
  21167. * @memberOf _
  21168. * @since 0.1.0
  21169. * @category Array
  21170. * @param {Array} array The sorted array to inspect.
  21171. * @param {*} value The value to evaluate.
  21172. * @returns {number} Returns the index at which `value` should be inserted
  21173. * into `array`.
  21174. * @example
  21175. *
  21176. * _.sortedIndex([30, 50], 40);
  21177. * // => 1
  21178. */
  21179. function sortedIndex(array, value) {
  21180. return baseSortedIndex(array, value);
  21181. }
  21182. /**
  21183. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  21184. * which is invoked for `value` and each element of `array` to compute their
  21185. * sort ranking. The iteratee is invoked with one argument: (value).
  21186. *
  21187. * @static
  21188. * @memberOf _
  21189. * @since 4.0.0
  21190. * @category Array
  21191. * @param {Array} array The sorted array to inspect.
  21192. * @param {*} value The value to evaluate.
  21193. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21194. * @returns {number} Returns the index at which `value` should be inserted
  21195. * into `array`.
  21196. * @example
  21197. *
  21198. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21199. *
  21200. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21201. * // => 0
  21202. *
  21203. * // The `_.property` iteratee shorthand.
  21204. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  21205. * // => 0
  21206. */
  21207. function sortedIndexBy(array, value, iteratee) {
  21208. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  21209. }
  21210. /**
  21211. * This method is like `_.indexOf` except that it performs a binary
  21212. * search on a sorted `array`.
  21213. *
  21214. * @static
  21215. * @memberOf _
  21216. * @since 4.0.0
  21217. * @category Array
  21218. * @param {Array} array The array to inspect.
  21219. * @param {*} value The value to search for.
  21220. * @returns {number} Returns the index of the matched value, else `-1`.
  21221. * @example
  21222. *
  21223. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  21224. * // => 1
  21225. */
  21226. function sortedIndexOf(array, value) {
  21227. var length = array == null ? 0 : array.length;
  21228. if (length) {
  21229. var index = baseSortedIndex(array, value);
  21230. if (index < length && eq(array[index], value)) {
  21231. return index;
  21232. }
  21233. }
  21234. return -1;
  21235. }
  21236. /**
  21237. * This method is like `_.sortedIndex` except that it returns the highest
  21238. * index at which `value` should be inserted into `array` in order to
  21239. * maintain its sort order.
  21240. *
  21241. * @static
  21242. * @memberOf _
  21243. * @since 3.0.0
  21244. * @category Array
  21245. * @param {Array} array The sorted array to inspect.
  21246. * @param {*} value The value to evaluate.
  21247. * @returns {number} Returns the index at which `value` should be inserted
  21248. * into `array`.
  21249. * @example
  21250. *
  21251. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  21252. * // => 4
  21253. */
  21254. function sortedLastIndex(array, value) {
  21255. return baseSortedIndex(array, value, true);
  21256. }
  21257. /**
  21258. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  21259. * which is invoked for `value` and each element of `array` to compute their
  21260. * sort ranking. The iteratee is invoked with one argument: (value).
  21261. *
  21262. * @static
  21263. * @memberOf _
  21264. * @since 4.0.0
  21265. * @category Array
  21266. * @param {Array} array The sorted array to inspect.
  21267. * @param {*} value The value to evaluate.
  21268. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21269. * @returns {number} Returns the index at which `value` should be inserted
  21270. * into `array`.
  21271. * @example
  21272. *
  21273. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21274. *
  21275. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21276. * // => 1
  21277. *
  21278. * // The `_.property` iteratee shorthand.
  21279. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  21280. * // => 1
  21281. */
  21282. function sortedLastIndexBy(array, value, iteratee) {
  21283. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  21284. }
  21285. /**
  21286. * This method is like `_.lastIndexOf` except that it performs a binary
  21287. * search on a sorted `array`.
  21288. *
  21289. * @static
  21290. * @memberOf _
  21291. * @since 4.0.0
  21292. * @category Array
  21293. * @param {Array} array The array to inspect.
  21294. * @param {*} value The value to search for.
  21295. * @returns {number} Returns the index of the matched value, else `-1`.
  21296. * @example
  21297. *
  21298. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  21299. * // => 3
  21300. */
  21301. function sortedLastIndexOf(array, value) {
  21302. var length = array == null ? 0 : array.length;
  21303. if (length) {
  21304. var index = baseSortedIndex(array, value, true) - 1;
  21305. if (eq(array[index], value)) {
  21306. return index;
  21307. }
  21308. }
  21309. return -1;
  21310. }
  21311. /**
  21312. * This method is like `_.uniq` except that it's designed and optimized
  21313. * for sorted arrays.
  21314. *
  21315. * @static
  21316. * @memberOf _
  21317. * @since 4.0.0
  21318. * @category Array
  21319. * @param {Array} array The array to inspect.
  21320. * @returns {Array} Returns the new duplicate free array.
  21321. * @example
  21322. *
  21323. * _.sortedUniq([1, 1, 2]);
  21324. * // => [1, 2]
  21325. */
  21326. function sortedUniq(array) {
  21327. return (array && array.length)
  21328. ? baseSortedUniq(array)
  21329. : [];
  21330. }
  21331. /**
  21332. * This method is like `_.uniqBy` except that it's designed and optimized
  21333. * for sorted arrays.
  21334. *
  21335. * @static
  21336. * @memberOf _
  21337. * @since 4.0.0
  21338. * @category Array
  21339. * @param {Array} array The array to inspect.
  21340. * @param {Function} [iteratee] The iteratee invoked per element.
  21341. * @returns {Array} Returns the new duplicate free array.
  21342. * @example
  21343. *
  21344. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  21345. * // => [1.1, 2.3]
  21346. */
  21347. function sortedUniqBy(array, iteratee) {
  21348. return (array && array.length)
  21349. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  21350. : [];
  21351. }
  21352. /**
  21353. * Gets all but the first element of `array`.
  21354. *
  21355. * @static
  21356. * @memberOf _
  21357. * @since 4.0.0
  21358. * @category Array
  21359. * @param {Array} array The array to query.
  21360. * @returns {Array} Returns the slice of `array`.
  21361. * @example
  21362. *
  21363. * _.tail([1, 2, 3]);
  21364. * // => [2, 3]
  21365. */
  21366. function tail(array) {
  21367. var length = array == null ? 0 : array.length;
  21368. return length ? baseSlice(array, 1, length) : [];
  21369. }
  21370. /**
  21371. * Creates a slice of `array` with `n` elements taken from the beginning.
  21372. *
  21373. * @static
  21374. * @memberOf _
  21375. * @since 0.1.0
  21376. * @category Array
  21377. * @param {Array} array The array to query.
  21378. * @param {number} [n=1] The number of elements to take.
  21379. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21380. * @returns {Array} Returns the slice of `array`.
  21381. * @example
  21382. *
  21383. * _.take([1, 2, 3]);
  21384. * // => [1]
  21385. *
  21386. * _.take([1, 2, 3], 2);
  21387. * // => [1, 2]
  21388. *
  21389. * _.take([1, 2, 3], 5);
  21390. * // => [1, 2, 3]
  21391. *
  21392. * _.take([1, 2, 3], 0);
  21393. * // => []
  21394. */
  21395. function take(array, n, guard) {
  21396. if (!(array && array.length)) {
  21397. return [];
  21398. }
  21399. n = (guard || n === undefined) ? 1 : toInteger(n);
  21400. return baseSlice(array, 0, n < 0 ? 0 : n);
  21401. }
  21402. /**
  21403. * Creates a slice of `array` with `n` elements taken from the end.
  21404. *
  21405. * @static
  21406. * @memberOf _
  21407. * @since 3.0.0
  21408. * @category Array
  21409. * @param {Array} array The array to query.
  21410. * @param {number} [n=1] The number of elements to take.
  21411. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21412. * @returns {Array} Returns the slice of `array`.
  21413. * @example
  21414. *
  21415. * _.takeRight([1, 2, 3]);
  21416. * // => [3]
  21417. *
  21418. * _.takeRight([1, 2, 3], 2);
  21419. * // => [2, 3]
  21420. *
  21421. * _.takeRight([1, 2, 3], 5);
  21422. * // => [1, 2, 3]
  21423. *
  21424. * _.takeRight([1, 2, 3], 0);
  21425. * // => []
  21426. */
  21427. function takeRight(array, n, guard) {
  21428. var length = array == null ? 0 : array.length;
  21429. if (!length) {
  21430. return [];
  21431. }
  21432. n = (guard || n === undefined) ? 1 : toInteger(n);
  21433. n = length - n;
  21434. return baseSlice(array, n < 0 ? 0 : n, length);
  21435. }
  21436. /**
  21437. * Creates a slice of `array` with elements taken from the end. Elements are
  21438. * taken until `predicate` returns falsey. The predicate is invoked with
  21439. * three arguments: (value, index, array).
  21440. *
  21441. * @static
  21442. * @memberOf _
  21443. * @since 3.0.0
  21444. * @category Array
  21445. * @param {Array} array The array to query.
  21446. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21447. * @returns {Array} Returns the slice of `array`.
  21448. * @example
  21449. *
  21450. * var users = [
  21451. * { 'user': 'barney', 'active': true },
  21452. * { 'user': 'fred', 'active': false },
  21453. * { 'user': 'pebbles', 'active': false }
  21454. * ];
  21455. *
  21456. * _.takeRightWhile(users, function(o) { return !o.active; });
  21457. * // => objects for ['fred', 'pebbles']
  21458. *
  21459. * // The `_.matches` iteratee shorthand.
  21460. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  21461. * // => objects for ['pebbles']
  21462. *
  21463. * // The `_.matchesProperty` iteratee shorthand.
  21464. * _.takeRightWhile(users, ['active', false]);
  21465. * // => objects for ['fred', 'pebbles']
  21466. *
  21467. * // The `_.property` iteratee shorthand.
  21468. * _.takeRightWhile(users, 'active');
  21469. * // => []
  21470. */
  21471. function takeRightWhile(array, predicate) {
  21472. return (array && array.length)
  21473. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  21474. : [];
  21475. }
  21476. /**
  21477. * Creates a slice of `array` with elements taken from the beginning. Elements
  21478. * are taken until `predicate` returns falsey. The predicate is invoked with
  21479. * three arguments: (value, index, array).
  21480. *
  21481. * @static
  21482. * @memberOf _
  21483. * @since 3.0.0
  21484. * @category Array
  21485. * @param {Array} array The array to query.
  21486. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21487. * @returns {Array} Returns the slice of `array`.
  21488. * @example
  21489. *
  21490. * var users = [
  21491. * { 'user': 'barney', 'active': false },
  21492. * { 'user': 'fred', 'active': false },
  21493. * { 'user': 'pebbles', 'active': true }
  21494. * ];
  21495. *
  21496. * _.takeWhile(users, function(o) { return !o.active; });
  21497. * // => objects for ['barney', 'fred']
  21498. *
  21499. * // The `_.matches` iteratee shorthand.
  21500. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  21501. * // => objects for ['barney']
  21502. *
  21503. * // The `_.matchesProperty` iteratee shorthand.
  21504. * _.takeWhile(users, ['active', false]);
  21505. * // => objects for ['barney', 'fred']
  21506. *
  21507. * // The `_.property` iteratee shorthand.
  21508. * _.takeWhile(users, 'active');
  21509. * // => []
  21510. */
  21511. function takeWhile(array, predicate) {
  21512. return (array && array.length)
  21513. ? baseWhile(array, getIteratee(predicate, 3))
  21514. : [];
  21515. }
  21516. /**
  21517. * Creates an array of unique values, in order, from all given arrays using
  21518. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21519. * for equality comparisons.
  21520. *
  21521. * @static
  21522. * @memberOf _
  21523. * @since 0.1.0
  21524. * @category Array
  21525. * @param {...Array} [arrays] The arrays to inspect.
  21526. * @returns {Array} Returns the new array of combined values.
  21527. * @example
  21528. *
  21529. * _.union([2], [1, 2]);
  21530. * // => [2, 1]
  21531. */
  21532. var union = baseRest(function(arrays) {
  21533. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  21534. });
  21535. /**
  21536. * This method is like `_.union` except that it accepts `iteratee` which is
  21537. * invoked for each element of each `arrays` to generate the criterion by
  21538. * which uniqueness is computed. Result values are chosen from the first
  21539. * array in which the value occurs. The iteratee is invoked with one argument:
  21540. * (value).
  21541. *
  21542. * @static
  21543. * @memberOf _
  21544. * @since 4.0.0
  21545. * @category Array
  21546. * @param {...Array} [arrays] The arrays to inspect.
  21547. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21548. * @returns {Array} Returns the new array of combined values.
  21549. * @example
  21550. *
  21551. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  21552. * // => [2.1, 1.2]
  21553. *
  21554. * // The `_.property` iteratee shorthand.
  21555. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21556. * // => [{ 'x': 1 }, { 'x': 2 }]
  21557. */
  21558. var unionBy = baseRest(function(arrays) {
  21559. var iteratee = last(arrays);
  21560. if (isArrayLikeObject(iteratee)) {
  21561. iteratee = undefined;
  21562. }
  21563. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  21564. });
  21565. /**
  21566. * This method is like `_.union` except that it accepts `comparator` which
  21567. * is invoked to compare elements of `arrays`. Result values are chosen from
  21568. * the first array in which the value occurs. The comparator is invoked
  21569. * with two arguments: (arrVal, othVal).
  21570. *
  21571. * @static
  21572. * @memberOf _
  21573. * @since 4.0.0
  21574. * @category Array
  21575. * @param {...Array} [arrays] The arrays to inspect.
  21576. * @param {Function} [comparator] The comparator invoked per element.
  21577. * @returns {Array} Returns the new array of combined values.
  21578. * @example
  21579. *
  21580. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21581. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21582. *
  21583. * _.unionWith(objects, others, _.isEqual);
  21584. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21585. */
  21586. var unionWith = baseRest(function(arrays) {
  21587. var comparator = last(arrays);
  21588. comparator = typeof comparator == 'function' ? comparator : undefined;
  21589. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  21590. });
  21591. /**
  21592. * Creates a duplicate-free version of an array, using
  21593. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21594. * for equality comparisons, in which only the first occurrence of each element
  21595. * is kept. The order of result values is determined by the order they occur
  21596. * in the array.
  21597. *
  21598. * @static
  21599. * @memberOf _
  21600. * @since 0.1.0
  21601. * @category Array
  21602. * @param {Array} array The array to inspect.
  21603. * @returns {Array} Returns the new duplicate free array.
  21604. * @example
  21605. *
  21606. * _.uniq([2, 1, 2]);
  21607. * // => [2, 1]
  21608. */
  21609. function uniq(array) {
  21610. return (array && array.length) ? baseUniq(array) : [];
  21611. }
  21612. /**
  21613. * This method is like `_.uniq` except that it accepts `iteratee` which is
  21614. * invoked for each element in `array` to generate the criterion by which
  21615. * uniqueness is computed. The order of result values is determined by the
  21616. * order they occur in the array. The iteratee is invoked with one argument:
  21617. * (value).
  21618. *
  21619. * @static
  21620. * @memberOf _
  21621. * @since 4.0.0
  21622. * @category Array
  21623. * @param {Array} array The array to inspect.
  21624. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21625. * @returns {Array} Returns the new duplicate free array.
  21626. * @example
  21627. *
  21628. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  21629. * // => [2.1, 1.2]
  21630. *
  21631. * // The `_.property` iteratee shorthand.
  21632. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  21633. * // => [{ 'x': 1 }, { 'x': 2 }]
  21634. */
  21635. function uniqBy(array, iteratee) {
  21636. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  21637. }
  21638. /**
  21639. * This method is like `_.uniq` except that it accepts `comparator` which
  21640. * is invoked to compare elements of `array`. The order of result values is
  21641. * determined by the order they occur in the array.The comparator is invoked
  21642. * with two arguments: (arrVal, othVal).
  21643. *
  21644. * @static
  21645. * @memberOf _
  21646. * @since 4.0.0
  21647. * @category Array
  21648. * @param {Array} array The array to inspect.
  21649. * @param {Function} [comparator] The comparator invoked per element.
  21650. * @returns {Array} Returns the new duplicate free array.
  21651. * @example
  21652. *
  21653. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21654. *
  21655. * _.uniqWith(objects, _.isEqual);
  21656. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  21657. */
  21658. function uniqWith(array, comparator) {
  21659. comparator = typeof comparator == 'function' ? comparator : undefined;
  21660. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  21661. }
  21662. /**
  21663. * This method is like `_.zip` except that it accepts an array of grouped
  21664. * elements and creates an array regrouping the elements to their pre-zip
  21665. * configuration.
  21666. *
  21667. * @static
  21668. * @memberOf _
  21669. * @since 1.2.0
  21670. * @category Array
  21671. * @param {Array} array The array of grouped elements to process.
  21672. * @returns {Array} Returns the new array of regrouped elements.
  21673. * @example
  21674. *
  21675. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  21676. * // => [['a', 1, true], ['b', 2, false]]
  21677. *
  21678. * _.unzip(zipped);
  21679. * // => [['a', 'b'], [1, 2], [true, false]]
  21680. */
  21681. function unzip(array) {
  21682. if (!(array && array.length)) {
  21683. return [];
  21684. }
  21685. var length = 0;
  21686. array = arrayFilter(array, function(group) {
  21687. if (isArrayLikeObject(group)) {
  21688. length = nativeMax(group.length, length);
  21689. return true;
  21690. }
  21691. });
  21692. return baseTimes(length, function(index) {
  21693. return arrayMap(array, baseProperty(index));
  21694. });
  21695. }
  21696. /**
  21697. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  21698. * how regrouped values should be combined. The iteratee is invoked with the
  21699. * elements of each group: (...group).
  21700. *
  21701. * @static
  21702. * @memberOf _
  21703. * @since 3.8.0
  21704. * @category Array
  21705. * @param {Array} array The array of grouped elements to process.
  21706. * @param {Function} [iteratee=_.identity] The function to combine
  21707. * regrouped values.
  21708. * @returns {Array} Returns the new array of regrouped elements.
  21709. * @example
  21710. *
  21711. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  21712. * // => [[1, 10, 100], [2, 20, 200]]
  21713. *
  21714. * _.unzipWith(zipped, _.add);
  21715. * // => [3, 30, 300]
  21716. */
  21717. function unzipWith(array, iteratee) {
  21718. if (!(array && array.length)) {
  21719. return [];
  21720. }
  21721. var result = unzip(array);
  21722. if (iteratee == null) {
  21723. return result;
  21724. }
  21725. return arrayMap(result, function(group) {
  21726. return apply(iteratee, undefined, group);
  21727. });
  21728. }
  21729. /**
  21730. * Creates an array excluding all given values using
  21731. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21732. * for equality comparisons.
  21733. *
  21734. * **Note:** Unlike `_.pull`, this method returns a new array.
  21735. *
  21736. * @static
  21737. * @memberOf _
  21738. * @since 0.1.0
  21739. * @category Array
  21740. * @param {Array} array The array to inspect.
  21741. * @param {...*} [values] The values to exclude.
  21742. * @returns {Array} Returns the new array of filtered values.
  21743. * @see _.difference, _.xor
  21744. * @example
  21745. *
  21746. * _.without([2, 1, 2, 3], 1, 2);
  21747. * // => [3]
  21748. */
  21749. var without = baseRest(function(array, values) {
  21750. return isArrayLikeObject(array)
  21751. ? baseDifference(array, values)
  21752. : [];
  21753. });
  21754. /**
  21755. * Creates an array of unique values that is the
  21756. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  21757. * of the given arrays. The order of result values is determined by the order
  21758. * they occur in the arrays.
  21759. *
  21760. * @static
  21761. * @memberOf _
  21762. * @since 2.4.0
  21763. * @category Array
  21764. * @param {...Array} [arrays] The arrays to inspect.
  21765. * @returns {Array} Returns the new array of filtered values.
  21766. * @see _.difference, _.without
  21767. * @example
  21768. *
  21769. * _.xor([2, 1], [2, 3]);
  21770. * // => [1, 3]
  21771. */
  21772. var xor = baseRest(function(arrays) {
  21773. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  21774. });
  21775. /**
  21776. * This method is like `_.xor` except that it accepts `iteratee` which is
  21777. * invoked for each element of each `arrays` to generate the criterion by
  21778. * which by which they're compared. The order of result values is determined
  21779. * by the order they occur in the arrays. The iteratee is invoked with one
  21780. * argument: (value).
  21781. *
  21782. * @static
  21783. * @memberOf _
  21784. * @since 4.0.0
  21785. * @category Array
  21786. * @param {...Array} [arrays] The arrays to inspect.
  21787. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21788. * @returns {Array} Returns the new array of filtered values.
  21789. * @example
  21790. *
  21791. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  21792. * // => [1.2, 3.4]
  21793. *
  21794. * // The `_.property` iteratee shorthand.
  21795. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21796. * // => [{ 'x': 2 }]
  21797. */
  21798. var xorBy = baseRest(function(arrays) {
  21799. var iteratee = last(arrays);
  21800. if (isArrayLikeObject(iteratee)) {
  21801. iteratee = undefined;
  21802. }
  21803. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  21804. });
  21805. /**
  21806. * This method is like `_.xor` except that it accepts `comparator` which is
  21807. * invoked to compare elements of `arrays`. The order of result values is
  21808. * determined by the order they occur in the arrays. The comparator is invoked
  21809. * with two arguments: (arrVal, othVal).
  21810. *
  21811. * @static
  21812. * @memberOf _
  21813. * @since 4.0.0
  21814. * @category Array
  21815. * @param {...Array} [arrays] The arrays to inspect.
  21816. * @param {Function} [comparator] The comparator invoked per element.
  21817. * @returns {Array} Returns the new array of filtered values.
  21818. * @example
  21819. *
  21820. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21821. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21822. *
  21823. * _.xorWith(objects, others, _.isEqual);
  21824. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21825. */
  21826. var xorWith = baseRest(function(arrays) {
  21827. var comparator = last(arrays);
  21828. comparator = typeof comparator == 'function' ? comparator : undefined;
  21829. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  21830. });
  21831. /**
  21832. * Creates an array of grouped elements, the first of which contains the
  21833. * first elements of the given arrays, the second of which contains the
  21834. * second elements of the given arrays, and so on.
  21835. *
  21836. * @static
  21837. * @memberOf _
  21838. * @since 0.1.0
  21839. * @category Array
  21840. * @param {...Array} [arrays] The arrays to process.
  21841. * @returns {Array} Returns the new array of grouped elements.
  21842. * @example
  21843. *
  21844. * _.zip(['a', 'b'], [1, 2], [true, false]);
  21845. * // => [['a', 1, true], ['b', 2, false]]
  21846. */
  21847. var zip = baseRest(unzip);
  21848. /**
  21849. * This method is like `_.fromPairs` except that it accepts two arrays,
  21850. * one of property identifiers and one of corresponding values.
  21851. *
  21852. * @static
  21853. * @memberOf _
  21854. * @since 0.4.0
  21855. * @category Array
  21856. * @param {Array} [props=[]] The property identifiers.
  21857. * @param {Array} [values=[]] The property values.
  21858. * @returns {Object} Returns the new object.
  21859. * @example
  21860. *
  21861. * _.zipObject(['a', 'b'], [1, 2]);
  21862. * // => { 'a': 1, 'b': 2 }
  21863. */
  21864. function zipObject(props, values) {
  21865. return baseZipObject(props || [], values || [], assignValue);
  21866. }
  21867. /**
  21868. * This method is like `_.zipObject` except that it supports property paths.
  21869. *
  21870. * @static
  21871. * @memberOf _
  21872. * @since 4.1.0
  21873. * @category Array
  21874. * @param {Array} [props=[]] The property identifiers.
  21875. * @param {Array} [values=[]] The property values.
  21876. * @returns {Object} Returns the new object.
  21877. * @example
  21878. *
  21879. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  21880. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  21881. */
  21882. function zipObjectDeep(props, values) {
  21883. return baseZipObject(props || [], values || [], baseSet);
  21884. }
  21885. /**
  21886. * This method is like `_.zip` except that it accepts `iteratee` to specify
  21887. * how grouped values should be combined. The iteratee is invoked with the
  21888. * elements of each group: (...group).
  21889. *
  21890. * @static
  21891. * @memberOf _
  21892. * @since 3.8.0
  21893. * @category Array
  21894. * @param {...Array} [arrays] The arrays to process.
  21895. * @param {Function} [iteratee=_.identity] The function to combine
  21896. * grouped values.
  21897. * @returns {Array} Returns the new array of grouped elements.
  21898. * @example
  21899. *
  21900. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  21901. * return a + b + c;
  21902. * });
  21903. * // => [111, 222]
  21904. */
  21905. var zipWith = baseRest(function(arrays) {
  21906. var length = arrays.length,
  21907. iteratee = length > 1 ? arrays[length - 1] : undefined;
  21908. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  21909. return unzipWith(arrays, iteratee);
  21910. });
  21911. /*------------------------------------------------------------------------*/
  21912. /**
  21913. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  21914. * chain sequences enabled. The result of such sequences must be unwrapped
  21915. * with `_#value`.
  21916. *
  21917. * @static
  21918. * @memberOf _
  21919. * @since 1.3.0
  21920. * @category Seq
  21921. * @param {*} value The value to wrap.
  21922. * @returns {Object} Returns the new `lodash` wrapper instance.
  21923. * @example
  21924. *
  21925. * var users = [
  21926. * { 'user': 'barney', 'age': 36 },
  21927. * { 'user': 'fred', 'age': 40 },
  21928. * { 'user': 'pebbles', 'age': 1 }
  21929. * ];
  21930. *
  21931. * var youngest = _
  21932. * .chain(users)
  21933. * .sortBy('age')
  21934. * .map(function(o) {
  21935. * return o.user + ' is ' + o.age;
  21936. * })
  21937. * .head()
  21938. * .value();
  21939. * // => 'pebbles is 1'
  21940. */
  21941. function chain(value) {
  21942. var result = lodash(value);
  21943. result.__chain__ = true;
  21944. return result;
  21945. }
  21946. /**
  21947. * This method invokes `interceptor` and returns `value`. The interceptor
  21948. * is invoked with one argument; (value). The purpose of this method is to
  21949. * "tap into" a method chain sequence in order to modify intermediate results.
  21950. *
  21951. * @static
  21952. * @memberOf _
  21953. * @since 0.1.0
  21954. * @category Seq
  21955. * @param {*} value The value to provide to `interceptor`.
  21956. * @param {Function} interceptor The function to invoke.
  21957. * @returns {*} Returns `value`.
  21958. * @example
  21959. *
  21960. * _([1, 2, 3])
  21961. * .tap(function(array) {
  21962. * // Mutate input array.
  21963. * array.pop();
  21964. * })
  21965. * .reverse()
  21966. * .value();
  21967. * // => [2, 1]
  21968. */
  21969. function tap(value, interceptor) {
  21970. interceptor(value);
  21971. return value;
  21972. }
  21973. /**
  21974. * This method is like `_.tap` except that it returns the result of `interceptor`.
  21975. * The purpose of this method is to "pass thru" values replacing intermediate
  21976. * results in a method chain sequence.
  21977. *
  21978. * @static
  21979. * @memberOf _
  21980. * @since 3.0.0
  21981. * @category Seq
  21982. * @param {*} value The value to provide to `interceptor`.
  21983. * @param {Function} interceptor The function to invoke.
  21984. * @returns {*} Returns the result of `interceptor`.
  21985. * @example
  21986. *
  21987. * _(' abc ')
  21988. * .chain()
  21989. * .trim()
  21990. * .thru(function(value) {
  21991. * return [value];
  21992. * })
  21993. * .value();
  21994. * // => ['abc']
  21995. */
  21996. function thru(value, interceptor) {
  21997. return interceptor(value);
  21998. }
  21999. /**
  22000. * This method is the wrapper version of `_.at`.
  22001. *
  22002. * @name at
  22003. * @memberOf _
  22004. * @since 1.0.0
  22005. * @category Seq
  22006. * @param {...(string|string[])} [paths] The property paths to pick.
  22007. * @returns {Object} Returns the new `lodash` wrapper instance.
  22008. * @example
  22009. *
  22010. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  22011. *
  22012. * _(object).at(['a[0].b.c', 'a[1]']).value();
  22013. * // => [3, 4]
  22014. */
  22015. var wrapperAt = flatRest(function(paths) {
  22016. var length = paths.length,
  22017. start = length ? paths[0] : 0,
  22018. value = this.__wrapped__,
  22019. interceptor = function(object) { return baseAt(object, paths); };
  22020. if (length > 1 || this.__actions__.length ||
  22021. !(value instanceof LazyWrapper) || !isIndex(start)) {
  22022. return this.thru(interceptor);
  22023. }
  22024. value = value.slice(start, +start + (length ? 1 : 0));
  22025. value.__actions__.push({
  22026. 'func': thru,
  22027. 'args': [interceptor],
  22028. 'thisArg': undefined
  22029. });
  22030. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  22031. if (length && !array.length) {
  22032. array.push(undefined);
  22033. }
  22034. return array;
  22035. });
  22036. });
  22037. /**
  22038. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  22039. *
  22040. * @name chain
  22041. * @memberOf _
  22042. * @since 0.1.0
  22043. * @category Seq
  22044. * @returns {Object} Returns the new `lodash` wrapper instance.
  22045. * @example
  22046. *
  22047. * var users = [
  22048. * { 'user': 'barney', 'age': 36 },
  22049. * { 'user': 'fred', 'age': 40 }
  22050. * ];
  22051. *
  22052. * // A sequence without explicit chaining.
  22053. * _(users).head();
  22054. * // => { 'user': 'barney', 'age': 36 }
  22055. *
  22056. * // A sequence with explicit chaining.
  22057. * _(users)
  22058. * .chain()
  22059. * .head()
  22060. * .pick('user')
  22061. * .value();
  22062. * // => { 'user': 'barney' }
  22063. */
  22064. function wrapperChain() {
  22065. return chain(this);
  22066. }
  22067. /**
  22068. * Executes the chain sequence and returns the wrapped result.
  22069. *
  22070. * @name commit
  22071. * @memberOf _
  22072. * @since 3.2.0
  22073. * @category Seq
  22074. * @returns {Object} Returns the new `lodash` wrapper instance.
  22075. * @example
  22076. *
  22077. * var array = [1, 2];
  22078. * var wrapped = _(array).push(3);
  22079. *
  22080. * console.log(array);
  22081. * // => [1, 2]
  22082. *
  22083. * wrapped = wrapped.commit();
  22084. * console.log(array);
  22085. * // => [1, 2, 3]
  22086. *
  22087. * wrapped.last();
  22088. * // => 3
  22089. *
  22090. * console.log(array);
  22091. * // => [1, 2, 3]
  22092. */
  22093. function wrapperCommit() {
  22094. return new LodashWrapper(this.value(), this.__chain__);
  22095. }
  22096. /**
  22097. * Gets the next value on a wrapped object following the
  22098. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  22099. *
  22100. * @name next
  22101. * @memberOf _
  22102. * @since 4.0.0
  22103. * @category Seq
  22104. * @returns {Object} Returns the next iterator value.
  22105. * @example
  22106. *
  22107. * var wrapped = _([1, 2]);
  22108. *
  22109. * wrapped.next();
  22110. * // => { 'done': false, 'value': 1 }
  22111. *
  22112. * wrapped.next();
  22113. * // => { 'done': false, 'value': 2 }
  22114. *
  22115. * wrapped.next();
  22116. * // => { 'done': true, 'value': undefined }
  22117. */
  22118. function wrapperNext() {
  22119. if (this.__values__ === undefined) {
  22120. this.__values__ = toArray(this.value());
  22121. }
  22122. var done = this.__index__ >= this.__values__.length,
  22123. value = done ? undefined : this.__values__[this.__index__++];
  22124. return { 'done': done, 'value': value };
  22125. }
  22126. /**
  22127. * Enables the wrapper to be iterable.
  22128. *
  22129. * @name Symbol.iterator
  22130. * @memberOf _
  22131. * @since 4.0.0
  22132. * @category Seq
  22133. * @returns {Object} Returns the wrapper object.
  22134. * @example
  22135. *
  22136. * var wrapped = _([1, 2]);
  22137. *
  22138. * wrapped[Symbol.iterator]() === wrapped;
  22139. * // => true
  22140. *
  22141. * Array.from(wrapped);
  22142. * // => [1, 2]
  22143. */
  22144. function wrapperToIterator() {
  22145. return this;
  22146. }
  22147. /**
  22148. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  22149. *
  22150. * @name plant
  22151. * @memberOf _
  22152. * @since 3.2.0
  22153. * @category Seq
  22154. * @param {*} value The value to plant.
  22155. * @returns {Object} Returns the new `lodash` wrapper instance.
  22156. * @example
  22157. *
  22158. * function square(n) {
  22159. * return n * n;
  22160. * }
  22161. *
  22162. * var wrapped = _([1, 2]).map(square);
  22163. * var other = wrapped.plant([3, 4]);
  22164. *
  22165. * other.value();
  22166. * // => [9, 16]
  22167. *
  22168. * wrapped.value();
  22169. * // => [1, 4]
  22170. */
  22171. function wrapperPlant(value) {
  22172. var result,
  22173. parent = this;
  22174. while (parent instanceof baseLodash) {
  22175. var clone = wrapperClone(parent);
  22176. clone.__index__ = 0;
  22177. clone.__values__ = undefined;
  22178. if (result) {
  22179. previous.__wrapped__ = clone;
  22180. } else {
  22181. result = clone;
  22182. }
  22183. var previous = clone;
  22184. parent = parent.__wrapped__;
  22185. }
  22186. previous.__wrapped__ = value;
  22187. return result;
  22188. }
  22189. /**
  22190. * This method is the wrapper version of `_.reverse`.
  22191. *
  22192. * **Note:** This method mutates the wrapped array.
  22193. *
  22194. * @name reverse
  22195. * @memberOf _
  22196. * @since 0.1.0
  22197. * @category Seq
  22198. * @returns {Object} Returns the new `lodash` wrapper instance.
  22199. * @example
  22200. *
  22201. * var array = [1, 2, 3];
  22202. *
  22203. * _(array).reverse().value()
  22204. * // => [3, 2, 1]
  22205. *
  22206. * console.log(array);
  22207. * // => [3, 2, 1]
  22208. */
  22209. function wrapperReverse() {
  22210. var value = this.__wrapped__;
  22211. if (value instanceof LazyWrapper) {
  22212. var wrapped = value;
  22213. if (this.__actions__.length) {
  22214. wrapped = new LazyWrapper(this);
  22215. }
  22216. wrapped = wrapped.reverse();
  22217. wrapped.__actions__.push({
  22218. 'func': thru,
  22219. 'args': [reverse],
  22220. 'thisArg': undefined
  22221. });
  22222. return new LodashWrapper(wrapped, this.__chain__);
  22223. }
  22224. return this.thru(reverse);
  22225. }
  22226. /**
  22227. * Executes the chain sequence to resolve the unwrapped value.
  22228. *
  22229. * @name value
  22230. * @memberOf _
  22231. * @since 0.1.0
  22232. * @alias toJSON, valueOf
  22233. * @category Seq
  22234. * @returns {*} Returns the resolved unwrapped value.
  22235. * @example
  22236. *
  22237. * _([1, 2, 3]).value();
  22238. * // => [1, 2, 3]
  22239. */
  22240. function wrapperValue() {
  22241. return baseWrapperValue(this.__wrapped__, this.__actions__);
  22242. }
  22243. /*------------------------------------------------------------------------*/
  22244. /**
  22245. * Creates an object composed of keys generated from the results of running
  22246. * each element of `collection` thru `iteratee`. The corresponding value of
  22247. * each key is the number of times the key was returned by `iteratee`. The
  22248. * iteratee is invoked with one argument: (value).
  22249. *
  22250. * @static
  22251. * @memberOf _
  22252. * @since 0.5.0
  22253. * @category Collection
  22254. * @param {Array|Object} collection The collection to iterate over.
  22255. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22256. * @returns {Object} Returns the composed aggregate object.
  22257. * @example
  22258. *
  22259. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  22260. * // => { '4': 1, '6': 2 }
  22261. *
  22262. * // The `_.property` iteratee shorthand.
  22263. * _.countBy(['one', 'two', 'three'], 'length');
  22264. * // => { '3': 2, '5': 1 }
  22265. */
  22266. var countBy = createAggregator(function(result, value, key) {
  22267. if (hasOwnProperty.call(result, key)) {
  22268. ++result[key];
  22269. } else {
  22270. baseAssignValue(result, key, 1);
  22271. }
  22272. });
  22273. /**
  22274. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  22275. * Iteration is stopped once `predicate` returns falsey. The predicate is
  22276. * invoked with three arguments: (value, index|key, collection).
  22277. *
  22278. * **Note:** This method returns `true` for
  22279. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  22280. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  22281. * elements of empty collections.
  22282. *
  22283. * @static
  22284. * @memberOf _
  22285. * @since 0.1.0
  22286. * @category Collection
  22287. * @param {Array|Object} collection The collection to iterate over.
  22288. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22289. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22290. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  22291. * else `false`.
  22292. * @example
  22293. *
  22294. * _.every([true, 1, null, 'yes'], Boolean);
  22295. * // => false
  22296. *
  22297. * var users = [
  22298. * { 'user': 'barney', 'age': 36, 'active': false },
  22299. * { 'user': 'fred', 'age': 40, 'active': false }
  22300. * ];
  22301. *
  22302. * // The `_.matches` iteratee shorthand.
  22303. * _.every(users, { 'user': 'barney', 'active': false });
  22304. * // => false
  22305. *
  22306. * // The `_.matchesProperty` iteratee shorthand.
  22307. * _.every(users, ['active', false]);
  22308. * // => true
  22309. *
  22310. * // The `_.property` iteratee shorthand.
  22311. * _.every(users, 'active');
  22312. * // => false
  22313. */
  22314. function every(collection, predicate, guard) {
  22315. var func = isArray(collection) ? arrayEvery : baseEvery;
  22316. if (guard && isIterateeCall(collection, predicate, guard)) {
  22317. predicate = undefined;
  22318. }
  22319. return func(collection, getIteratee(predicate, 3));
  22320. }
  22321. /**
  22322. * Iterates over elements of `collection`, returning an array of all elements
  22323. * `predicate` returns truthy for. The predicate is invoked with three
  22324. * arguments: (value, index|key, collection).
  22325. *
  22326. * **Note:** Unlike `_.remove`, this method returns a new array.
  22327. *
  22328. * @static
  22329. * @memberOf _
  22330. * @since 0.1.0
  22331. * @category Collection
  22332. * @param {Array|Object} collection The collection to iterate over.
  22333. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22334. * @returns {Array} Returns the new filtered array.
  22335. * @see _.reject
  22336. * @example
  22337. *
  22338. * var users = [
  22339. * { 'user': 'barney', 'age': 36, 'active': true },
  22340. * { 'user': 'fred', 'age': 40, 'active': false }
  22341. * ];
  22342. *
  22343. * _.filter(users, function(o) { return !o.active; });
  22344. * // => objects for ['fred']
  22345. *
  22346. * // The `_.matches` iteratee shorthand.
  22347. * _.filter(users, { 'age': 36, 'active': true });
  22348. * // => objects for ['barney']
  22349. *
  22350. * // The `_.matchesProperty` iteratee shorthand.
  22351. * _.filter(users, ['active', false]);
  22352. * // => objects for ['fred']
  22353. *
  22354. * // The `_.property` iteratee shorthand.
  22355. * _.filter(users, 'active');
  22356. * // => objects for ['barney']
  22357. */
  22358. function filter(collection, predicate) {
  22359. var func = isArray(collection) ? arrayFilter : baseFilter;
  22360. return func(collection, getIteratee(predicate, 3));
  22361. }
  22362. /**
  22363. * Iterates over elements of `collection`, returning the first element
  22364. * `predicate` returns truthy for. The predicate is invoked with three
  22365. * arguments: (value, index|key, collection).
  22366. *
  22367. * @static
  22368. * @memberOf _
  22369. * @since 0.1.0
  22370. * @category Collection
  22371. * @param {Array|Object} collection The collection to inspect.
  22372. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22373. * @param {number} [fromIndex=0] The index to search from.
  22374. * @returns {*} Returns the matched element, else `undefined`.
  22375. * @example
  22376. *
  22377. * var users = [
  22378. * { 'user': 'barney', 'age': 36, 'active': true },
  22379. * { 'user': 'fred', 'age': 40, 'active': false },
  22380. * { 'user': 'pebbles', 'age': 1, 'active': true }
  22381. * ];
  22382. *
  22383. * _.find(users, function(o) { return o.age < 40; });
  22384. * // => object for 'barney'
  22385. *
  22386. * // The `_.matches` iteratee shorthand.
  22387. * _.find(users, { 'age': 1, 'active': true });
  22388. * // => object for 'pebbles'
  22389. *
  22390. * // The `_.matchesProperty` iteratee shorthand.
  22391. * _.find(users, ['active', false]);
  22392. * // => object for 'fred'
  22393. *
  22394. * // The `_.property` iteratee shorthand.
  22395. * _.find(users, 'active');
  22396. * // => object for 'barney'
  22397. */
  22398. var find = createFind(findIndex);
  22399. /**
  22400. * This method is like `_.find` except that it iterates over elements of
  22401. * `collection` from right to left.
  22402. *
  22403. * @static
  22404. * @memberOf _
  22405. * @since 2.0.0
  22406. * @category Collection
  22407. * @param {Array|Object} collection The collection to inspect.
  22408. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22409. * @param {number} [fromIndex=collection.length-1] The index to search from.
  22410. * @returns {*} Returns the matched element, else `undefined`.
  22411. * @example
  22412. *
  22413. * _.findLast([1, 2, 3, 4], function(n) {
  22414. * return n % 2 == 1;
  22415. * });
  22416. * // => 3
  22417. */
  22418. var findLast = createFind(findLastIndex);
  22419. /**
  22420. * Creates a flattened array of values by running each element in `collection`
  22421. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  22422. * with three arguments: (value, index|key, collection).
  22423. *
  22424. * @static
  22425. * @memberOf _
  22426. * @since 4.0.0
  22427. * @category Collection
  22428. * @param {Array|Object} collection The collection to iterate over.
  22429. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22430. * @returns {Array} Returns the new flattened array.
  22431. * @example
  22432. *
  22433. * function duplicate(n) {
  22434. * return [n, n];
  22435. * }
  22436. *
  22437. * _.flatMap([1, 2], duplicate);
  22438. * // => [1, 1, 2, 2]
  22439. */
  22440. function flatMap(collection, iteratee) {
  22441. return baseFlatten(map(collection, iteratee), 1);
  22442. }
  22443. /**
  22444. * This method is like `_.flatMap` except that it recursively flattens the
  22445. * mapped results.
  22446. *
  22447. * @static
  22448. * @memberOf _
  22449. * @since 4.7.0
  22450. * @category Collection
  22451. * @param {Array|Object} collection The collection to iterate over.
  22452. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22453. * @returns {Array} Returns the new flattened array.
  22454. * @example
  22455. *
  22456. * function duplicate(n) {
  22457. * return [[[n, n]]];
  22458. * }
  22459. *
  22460. * _.flatMapDeep([1, 2], duplicate);
  22461. * // => [1, 1, 2, 2]
  22462. */
  22463. function flatMapDeep(collection, iteratee) {
  22464. return baseFlatten(map(collection, iteratee), INFINITY);
  22465. }
  22466. /**
  22467. * This method is like `_.flatMap` except that it recursively flattens the
  22468. * mapped results up to `depth` times.
  22469. *
  22470. * @static
  22471. * @memberOf _
  22472. * @since 4.7.0
  22473. * @category Collection
  22474. * @param {Array|Object} collection The collection to iterate over.
  22475. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22476. * @param {number} [depth=1] The maximum recursion depth.
  22477. * @returns {Array} Returns the new flattened array.
  22478. * @example
  22479. *
  22480. * function duplicate(n) {
  22481. * return [[[n, n]]];
  22482. * }
  22483. *
  22484. * _.flatMapDepth([1, 2], duplicate, 2);
  22485. * // => [[1, 1], [2, 2]]
  22486. */
  22487. function flatMapDepth(collection, iteratee, depth) {
  22488. depth = depth === undefined ? 1 : toInteger(depth);
  22489. return baseFlatten(map(collection, iteratee), depth);
  22490. }
  22491. /**
  22492. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  22493. * The iteratee is invoked with three arguments: (value, index|key, collection).
  22494. * Iteratee functions may exit iteration early by explicitly returning `false`.
  22495. *
  22496. * **Note:** As with other "Collections" methods, objects with a "length"
  22497. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  22498. * or `_.forOwn` for object iteration.
  22499. *
  22500. * @static
  22501. * @memberOf _
  22502. * @since 0.1.0
  22503. * @alias each
  22504. * @category Collection
  22505. * @param {Array|Object} collection The collection to iterate over.
  22506. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22507. * @returns {Array|Object} Returns `collection`.
  22508. * @see _.forEachRight
  22509. * @example
  22510. *
  22511. * _.forEach([1, 2], function(value) {
  22512. * console.log(value);
  22513. * });
  22514. * // => Logs `1` then `2`.
  22515. *
  22516. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  22517. * console.log(key);
  22518. * });
  22519. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  22520. */
  22521. function forEach(collection, iteratee) {
  22522. var func = isArray(collection) ? arrayEach : baseEach;
  22523. return func(collection, getIteratee(iteratee, 3));
  22524. }
  22525. /**
  22526. * This method is like `_.forEach` except that it iterates over elements of
  22527. * `collection` from right to left.
  22528. *
  22529. * @static
  22530. * @memberOf _
  22531. * @since 2.0.0
  22532. * @alias eachRight
  22533. * @category Collection
  22534. * @param {Array|Object} collection The collection to iterate over.
  22535. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22536. * @returns {Array|Object} Returns `collection`.
  22537. * @see _.forEach
  22538. * @example
  22539. *
  22540. * _.forEachRight([1, 2], function(value) {
  22541. * console.log(value);
  22542. * });
  22543. * // => Logs `2` then `1`.
  22544. */
  22545. function forEachRight(collection, iteratee) {
  22546. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  22547. return func(collection, getIteratee(iteratee, 3));
  22548. }
  22549. /**
  22550. * Creates an object composed of keys generated from the results of running
  22551. * each element of `collection` thru `iteratee`. The order of grouped values
  22552. * is determined by the order they occur in `collection`. The corresponding
  22553. * value of each key is an array of elements responsible for generating the
  22554. * key. The iteratee is invoked with one argument: (value).
  22555. *
  22556. * @static
  22557. * @memberOf _
  22558. * @since 0.1.0
  22559. * @category Collection
  22560. * @param {Array|Object} collection The collection to iterate over.
  22561. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22562. * @returns {Object} Returns the composed aggregate object.
  22563. * @example
  22564. *
  22565. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  22566. * // => { '4': [4.2], '6': [6.1, 6.3] }
  22567. *
  22568. * // The `_.property` iteratee shorthand.
  22569. * _.groupBy(['one', 'two', 'three'], 'length');
  22570. * // => { '3': ['one', 'two'], '5': ['three'] }
  22571. */
  22572. var groupBy = createAggregator(function(result, value, key) {
  22573. if (hasOwnProperty.call(result, key)) {
  22574. result[key].push(value);
  22575. } else {
  22576. baseAssignValue(result, key, [value]);
  22577. }
  22578. });
  22579. /**
  22580. * Checks if `value` is in `collection`. If `collection` is a string, it's
  22581. * checked for a substring of `value`, otherwise
  22582. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  22583. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  22584. * the offset from the end of `collection`.
  22585. *
  22586. * @static
  22587. * @memberOf _
  22588. * @since 0.1.0
  22589. * @category Collection
  22590. * @param {Array|Object|string} collection The collection to inspect.
  22591. * @param {*} value The value to search for.
  22592. * @param {number} [fromIndex=0] The index to search from.
  22593. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22594. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  22595. * @example
  22596. *
  22597. * _.includes([1, 2, 3], 1);
  22598. * // => true
  22599. *
  22600. * _.includes([1, 2, 3], 1, 2);
  22601. * // => false
  22602. *
  22603. * _.includes({ 'a': 1, 'b': 2 }, 1);
  22604. * // => true
  22605. *
  22606. * _.includes('abcd', 'bc');
  22607. * // => true
  22608. */
  22609. function includes(collection, value, fromIndex, guard) {
  22610. collection = isArrayLike(collection) ? collection : values(collection);
  22611. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  22612. var length = collection.length;
  22613. if (fromIndex < 0) {
  22614. fromIndex = nativeMax(length + fromIndex, 0);
  22615. }
  22616. return isString(collection)
  22617. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  22618. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  22619. }
  22620. /**
  22621. * Invokes the method at `path` of each element in `collection`, returning
  22622. * an array of the results of each invoked method. Any additional arguments
  22623. * are provided to each invoked method. If `path` is a function, it's invoked
  22624. * for, and `this` bound to, each element in `collection`.
  22625. *
  22626. * @static
  22627. * @memberOf _
  22628. * @since 4.0.0
  22629. * @category Collection
  22630. * @param {Array|Object} collection The collection to iterate over.
  22631. * @param {Array|Function|string} path The path of the method to invoke or
  22632. * the function invoked per iteration.
  22633. * @param {...*} [args] The arguments to invoke each method with.
  22634. * @returns {Array} Returns the array of results.
  22635. * @example
  22636. *
  22637. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  22638. * // => [[1, 5, 7], [1, 2, 3]]
  22639. *
  22640. * _.invokeMap([123, 456], String.prototype.split, '');
  22641. * // => [['1', '2', '3'], ['4', '5', '6']]
  22642. */
  22643. var invokeMap = baseRest(function(collection, path, args) {
  22644. var index = -1,
  22645. isFunc = typeof path == 'function',
  22646. result = isArrayLike(collection) ? Array(collection.length) : [];
  22647. baseEach(collection, function(value) {
  22648. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  22649. });
  22650. return result;
  22651. });
  22652. /**
  22653. * Creates an object composed of keys generated from the results of running
  22654. * each element of `collection` thru `iteratee`. The corresponding value of
  22655. * each key is the last element responsible for generating the key. The
  22656. * iteratee is invoked with one argument: (value).
  22657. *
  22658. * @static
  22659. * @memberOf _
  22660. * @since 4.0.0
  22661. * @category Collection
  22662. * @param {Array|Object} collection The collection to iterate over.
  22663. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22664. * @returns {Object} Returns the composed aggregate object.
  22665. * @example
  22666. *
  22667. * var array = [
  22668. * { 'dir': 'left', 'code': 97 },
  22669. * { 'dir': 'right', 'code': 100 }
  22670. * ];
  22671. *
  22672. * _.keyBy(array, function(o) {
  22673. * return String.fromCharCode(o.code);
  22674. * });
  22675. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  22676. *
  22677. * _.keyBy(array, 'dir');
  22678. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  22679. */
  22680. var keyBy = createAggregator(function(result, value, key) {
  22681. baseAssignValue(result, key, value);
  22682. });
  22683. /**
  22684. * Creates an array of values by running each element in `collection` thru
  22685. * `iteratee`. The iteratee is invoked with three arguments:
  22686. * (value, index|key, collection).
  22687. *
  22688. * Many lodash methods are guarded to work as iteratees for methods like
  22689. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  22690. *
  22691. * The guarded methods are:
  22692. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  22693. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  22694. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  22695. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  22696. *
  22697. * @static
  22698. * @memberOf _
  22699. * @since 0.1.0
  22700. * @category Collection
  22701. * @param {Array|Object} collection The collection to iterate over.
  22702. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22703. * @returns {Array} Returns the new mapped array.
  22704. * @example
  22705. *
  22706. * function square(n) {
  22707. * return n * n;
  22708. * }
  22709. *
  22710. * _.map([4, 8], square);
  22711. * // => [16, 64]
  22712. *
  22713. * _.map({ 'a': 4, 'b': 8 }, square);
  22714. * // => [16, 64] (iteration order is not guaranteed)
  22715. *
  22716. * var users = [
  22717. * { 'user': 'barney' },
  22718. * { 'user': 'fred' }
  22719. * ];
  22720. *
  22721. * // The `_.property` iteratee shorthand.
  22722. * _.map(users, 'user');
  22723. * // => ['barney', 'fred']
  22724. */
  22725. function map(collection, iteratee) {
  22726. var func = isArray(collection) ? arrayMap : baseMap;
  22727. return func(collection, getIteratee(iteratee, 3));
  22728. }
  22729. /**
  22730. * This method is like `_.sortBy` except that it allows specifying the sort
  22731. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  22732. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  22733. * descending or "asc" for ascending sort order of corresponding values.
  22734. *
  22735. * @static
  22736. * @memberOf _
  22737. * @since 4.0.0
  22738. * @category Collection
  22739. * @param {Array|Object} collection The collection to iterate over.
  22740. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  22741. * The iteratees to sort by.
  22742. * @param {string[]} [orders] The sort orders of `iteratees`.
  22743. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22744. * @returns {Array} Returns the new sorted array.
  22745. * @example
  22746. *
  22747. * var users = [
  22748. * { 'user': 'fred', 'age': 48 },
  22749. * { 'user': 'barney', 'age': 34 },
  22750. * { 'user': 'fred', 'age': 40 },
  22751. * { 'user': 'barney', 'age': 36 }
  22752. * ];
  22753. *
  22754. * // Sort by `user` in ascending order and by `age` in descending order.
  22755. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  22756. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  22757. */
  22758. function orderBy(collection, iteratees, orders, guard) {
  22759. if (collection == null) {
  22760. return [];
  22761. }
  22762. if (!isArray(iteratees)) {
  22763. iteratees = iteratees == null ? [] : [iteratees];
  22764. }
  22765. orders = guard ? undefined : orders;
  22766. if (!isArray(orders)) {
  22767. orders = orders == null ? [] : [orders];
  22768. }
  22769. return baseOrderBy(collection, iteratees, orders);
  22770. }
  22771. /**
  22772. * Creates an array of elements split into two groups, the first of which
  22773. * contains elements `predicate` returns truthy for, the second of which
  22774. * contains elements `predicate` returns falsey for. The predicate is
  22775. * invoked with one argument: (value).
  22776. *
  22777. * @static
  22778. * @memberOf _
  22779. * @since 3.0.0
  22780. * @category Collection
  22781. * @param {Array|Object} collection The collection to iterate over.
  22782. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22783. * @returns {Array} Returns the array of grouped elements.
  22784. * @example
  22785. *
  22786. * var users = [
  22787. * { 'user': 'barney', 'age': 36, 'active': false },
  22788. * { 'user': 'fred', 'age': 40, 'active': true },
  22789. * { 'user': 'pebbles', 'age': 1, 'active': false }
  22790. * ];
  22791. *
  22792. * _.partition(users, function(o) { return o.active; });
  22793. * // => objects for [['fred'], ['barney', 'pebbles']]
  22794. *
  22795. * // The `_.matches` iteratee shorthand.
  22796. * _.partition(users, { 'age': 1, 'active': false });
  22797. * // => objects for [['pebbles'], ['barney', 'fred']]
  22798. *
  22799. * // The `_.matchesProperty` iteratee shorthand.
  22800. * _.partition(users, ['active', false]);
  22801. * // => objects for [['barney', 'pebbles'], ['fred']]
  22802. *
  22803. * // The `_.property` iteratee shorthand.
  22804. * _.partition(users, 'active');
  22805. * // => objects for [['fred'], ['barney', 'pebbles']]
  22806. */
  22807. var partition = createAggregator(function(result, value, key) {
  22808. result[key ? 0 : 1].push(value);
  22809. }, function() { return [[], []]; });
  22810. /**
  22811. * Reduces `collection` to a value which is the accumulated result of running
  22812. * each element in `collection` thru `iteratee`, where each successive
  22813. * invocation is supplied the return value of the previous. If `accumulator`
  22814. * is not given, the first element of `collection` is used as the initial
  22815. * value. The iteratee is invoked with four arguments:
  22816. * (accumulator, value, index|key, collection).
  22817. *
  22818. * Many lodash methods are guarded to work as iteratees for methods like
  22819. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  22820. *
  22821. * The guarded methods are:
  22822. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  22823. * and `sortBy`
  22824. *
  22825. * @static
  22826. * @memberOf _
  22827. * @since 0.1.0
  22828. * @category Collection
  22829. * @param {Array|Object} collection The collection to iterate over.
  22830. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22831. * @param {*} [accumulator] The initial value.
  22832. * @returns {*} Returns the accumulated value.
  22833. * @see _.reduceRight
  22834. * @example
  22835. *
  22836. * _.reduce([1, 2], function(sum, n) {
  22837. * return sum + n;
  22838. * }, 0);
  22839. * // => 3
  22840. *
  22841. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  22842. * (result[value] || (result[value] = [])).push(key);
  22843. * return result;
  22844. * }, {});
  22845. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  22846. */
  22847. function reduce(collection, iteratee, accumulator) {
  22848. var func = isArray(collection) ? arrayReduce : baseReduce,
  22849. initAccum = arguments.length < 3;
  22850. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  22851. }
  22852. /**
  22853. * This method is like `_.reduce` except that it iterates over elements of
  22854. * `collection` from right to left.
  22855. *
  22856. * @static
  22857. * @memberOf _
  22858. * @since 0.1.0
  22859. * @category Collection
  22860. * @param {Array|Object} collection The collection to iterate over.
  22861. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22862. * @param {*} [accumulator] The initial value.
  22863. * @returns {*} Returns the accumulated value.
  22864. * @see _.reduce
  22865. * @example
  22866. *
  22867. * var array = [[0, 1], [2, 3], [4, 5]];
  22868. *
  22869. * _.reduceRight(array, function(flattened, other) {
  22870. * return flattened.concat(other);
  22871. * }, []);
  22872. * // => [4, 5, 2, 3, 0, 1]
  22873. */
  22874. function reduceRight(collection, iteratee, accumulator) {
  22875. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  22876. initAccum = arguments.length < 3;
  22877. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  22878. }
  22879. /**
  22880. * The opposite of `_.filter`; this method returns the elements of `collection`
  22881. * that `predicate` does **not** return truthy for.
  22882. *
  22883. * @static
  22884. * @memberOf _
  22885. * @since 0.1.0
  22886. * @category Collection
  22887. * @param {Array|Object} collection The collection to iterate over.
  22888. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22889. * @returns {Array} Returns the new filtered array.
  22890. * @see _.filter
  22891. * @example
  22892. *
  22893. * var users = [
  22894. * { 'user': 'barney', 'age': 36, 'active': false },
  22895. * { 'user': 'fred', 'age': 40, 'active': true }
  22896. * ];
  22897. *
  22898. * _.reject(users, function(o) { return !o.active; });
  22899. * // => objects for ['fred']
  22900. *
  22901. * // The `_.matches` iteratee shorthand.
  22902. * _.reject(users, { 'age': 40, 'active': true });
  22903. * // => objects for ['barney']
  22904. *
  22905. * // The `_.matchesProperty` iteratee shorthand.
  22906. * _.reject(users, ['active', false]);
  22907. * // => objects for ['fred']
  22908. *
  22909. * // The `_.property` iteratee shorthand.
  22910. * _.reject(users, 'active');
  22911. * // => objects for ['barney']
  22912. */
  22913. function reject(collection, predicate) {
  22914. var func = isArray(collection) ? arrayFilter : baseFilter;
  22915. return func(collection, negate(getIteratee(predicate, 3)));
  22916. }
  22917. /**
  22918. * Gets a random element from `collection`.
  22919. *
  22920. * @static
  22921. * @memberOf _
  22922. * @since 2.0.0
  22923. * @category Collection
  22924. * @param {Array|Object} collection The collection to sample.
  22925. * @returns {*} Returns the random element.
  22926. * @example
  22927. *
  22928. * _.sample([1, 2, 3, 4]);
  22929. * // => 2
  22930. */
  22931. function sample(collection) {
  22932. var func = isArray(collection) ? arraySample : baseSample;
  22933. return func(collection);
  22934. }
  22935. /**
  22936. * Gets `n` random elements at unique keys from `collection` up to the
  22937. * size of `collection`.
  22938. *
  22939. * @static
  22940. * @memberOf _
  22941. * @since 4.0.0
  22942. * @category Collection
  22943. * @param {Array|Object} collection The collection to sample.
  22944. * @param {number} [n=1] The number of elements to sample.
  22945. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22946. * @returns {Array} Returns the random elements.
  22947. * @example
  22948. *
  22949. * _.sampleSize([1, 2, 3], 2);
  22950. * // => [3, 1]
  22951. *
  22952. * _.sampleSize([1, 2, 3], 4);
  22953. * // => [2, 3, 1]
  22954. */
  22955. function sampleSize(collection, n, guard) {
  22956. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  22957. n = 1;
  22958. } else {
  22959. n = toInteger(n);
  22960. }
  22961. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  22962. return func(collection, n);
  22963. }
  22964. /**
  22965. * Creates an array of shuffled values, using a version of the
  22966. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  22967. *
  22968. * @static
  22969. * @memberOf _
  22970. * @since 0.1.0
  22971. * @category Collection
  22972. * @param {Array|Object} collection The collection to shuffle.
  22973. * @returns {Array} Returns the new shuffled array.
  22974. * @example
  22975. *
  22976. * _.shuffle([1, 2, 3, 4]);
  22977. * // => [4, 1, 3, 2]
  22978. */
  22979. function shuffle(collection) {
  22980. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  22981. return func(collection);
  22982. }
  22983. /**
  22984. * Gets the size of `collection` by returning its length for array-like
  22985. * values or the number of own enumerable string keyed properties for objects.
  22986. *
  22987. * @static
  22988. * @memberOf _
  22989. * @since 0.1.0
  22990. * @category Collection
  22991. * @param {Array|Object|string} collection The collection to inspect.
  22992. * @returns {number} Returns the collection size.
  22993. * @example
  22994. *
  22995. * _.size([1, 2, 3]);
  22996. * // => 3
  22997. *
  22998. * _.size({ 'a': 1, 'b': 2 });
  22999. * // => 2
  23000. *
  23001. * _.size('pebbles');
  23002. * // => 7
  23003. */
  23004. function size(collection) {
  23005. if (collection == null) {
  23006. return 0;
  23007. }
  23008. if (isArrayLike(collection)) {
  23009. return isString(collection) ? stringSize(collection) : collection.length;
  23010. }
  23011. var tag = getTag(collection);
  23012. if (tag == mapTag || tag == setTag) {
  23013. return collection.size;
  23014. }
  23015. return baseKeys(collection).length;
  23016. }
  23017. /**
  23018. * Checks if `predicate` returns truthy for **any** element of `collection`.
  23019. * Iteration is stopped once `predicate` returns truthy. The predicate is
  23020. * invoked with three arguments: (value, index|key, collection).
  23021. *
  23022. * @static
  23023. * @memberOf _
  23024. * @since 0.1.0
  23025. * @category Collection
  23026. * @param {Array|Object} collection The collection to iterate over.
  23027. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23028. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23029. * @returns {boolean} Returns `true` if any element passes the predicate check,
  23030. * else `false`.
  23031. * @example
  23032. *
  23033. * _.some([null, 0, 'yes', false], Boolean);
  23034. * // => true
  23035. *
  23036. * var users = [
  23037. * { 'user': 'barney', 'active': true },
  23038. * { 'user': 'fred', 'active': false }
  23039. * ];
  23040. *
  23041. * // The `_.matches` iteratee shorthand.
  23042. * _.some(users, { 'user': 'barney', 'active': false });
  23043. * // => false
  23044. *
  23045. * // The `_.matchesProperty` iteratee shorthand.
  23046. * _.some(users, ['active', false]);
  23047. * // => true
  23048. *
  23049. * // The `_.property` iteratee shorthand.
  23050. * _.some(users, 'active');
  23051. * // => true
  23052. */
  23053. function some(collection, predicate, guard) {
  23054. var func = isArray(collection) ? arraySome : baseSome;
  23055. if (guard && isIterateeCall(collection, predicate, guard)) {
  23056. predicate = undefined;
  23057. }
  23058. return func(collection, getIteratee(predicate, 3));
  23059. }
  23060. /**
  23061. * Creates an array of elements, sorted in ascending order by the results of
  23062. * running each element in a collection thru each iteratee. This method
  23063. * performs a stable sort, that is, it preserves the original sort order of
  23064. * equal elements. The iteratees are invoked with one argument: (value).
  23065. *
  23066. * @static
  23067. * @memberOf _
  23068. * @since 0.1.0
  23069. * @category Collection
  23070. * @param {Array|Object} collection The collection to iterate over.
  23071. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  23072. * The iteratees to sort by.
  23073. * @returns {Array} Returns the new sorted array.
  23074. * @example
  23075. *
  23076. * var users = [
  23077. * { 'user': 'fred', 'age': 48 },
  23078. * { 'user': 'barney', 'age': 36 },
  23079. * { 'user': 'fred', 'age': 40 },
  23080. * { 'user': 'barney', 'age': 34 }
  23081. * ];
  23082. *
  23083. * _.sortBy(users, [function(o) { return o.user; }]);
  23084. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  23085. *
  23086. * _.sortBy(users, ['user', 'age']);
  23087. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  23088. */
  23089. var sortBy = baseRest(function(collection, iteratees) {
  23090. if (collection == null) {
  23091. return [];
  23092. }
  23093. var length = iteratees.length;
  23094. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  23095. iteratees = [];
  23096. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  23097. iteratees = [iteratees[0]];
  23098. }
  23099. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  23100. });
  23101. /*------------------------------------------------------------------------*/
  23102. /**
  23103. * Gets the timestamp of the number of milliseconds that have elapsed since
  23104. * the Unix epoch (1 January 1970 00:00:00 UTC).
  23105. *
  23106. * @static
  23107. * @memberOf _
  23108. * @since 2.4.0
  23109. * @category Date
  23110. * @returns {number} Returns the timestamp.
  23111. * @example
  23112. *
  23113. * _.defer(function(stamp) {
  23114. * console.log(_.now() - stamp);
  23115. * }, _.now());
  23116. * // => Logs the number of milliseconds it took for the deferred invocation.
  23117. */
  23118. var now = ctxNow || function() {
  23119. return root.Date.now();
  23120. };
  23121. /*------------------------------------------------------------------------*/
  23122. /**
  23123. * The opposite of `_.before`; this method creates a function that invokes
  23124. * `func` once it's called `n` or more times.
  23125. *
  23126. * @static
  23127. * @memberOf _
  23128. * @since 0.1.0
  23129. * @category Function
  23130. * @param {number} n The number of calls before `func` is invoked.
  23131. * @param {Function} func The function to restrict.
  23132. * @returns {Function} Returns the new restricted function.
  23133. * @example
  23134. *
  23135. * var saves = ['profile', 'settings'];
  23136. *
  23137. * var done = _.after(saves.length, function() {
  23138. * console.log('done saving!');
  23139. * });
  23140. *
  23141. * _.forEach(saves, function(type) {
  23142. * asyncSave({ 'type': type, 'complete': done });
  23143. * });
  23144. * // => Logs 'done saving!' after the two async saves have completed.
  23145. */
  23146. function after(n, func) {
  23147. if (typeof func != 'function') {
  23148. throw new TypeError(FUNC_ERROR_TEXT);
  23149. }
  23150. n = toInteger(n);
  23151. return function() {
  23152. if (--n < 1) {
  23153. return func.apply(this, arguments);
  23154. }
  23155. };
  23156. }
  23157. /**
  23158. * Creates a function that invokes `func`, with up to `n` arguments,
  23159. * ignoring any additional arguments.
  23160. *
  23161. * @static
  23162. * @memberOf _
  23163. * @since 3.0.0
  23164. * @category Function
  23165. * @param {Function} func The function to cap arguments for.
  23166. * @param {number} [n=func.length] The arity cap.
  23167. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23168. * @returns {Function} Returns the new capped function.
  23169. * @example
  23170. *
  23171. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  23172. * // => [6, 8, 10]
  23173. */
  23174. function ary(func, n, guard) {
  23175. n = guard ? undefined : n;
  23176. n = (func && n == null) ? func.length : n;
  23177. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  23178. }
  23179. /**
  23180. * Creates a function that invokes `func`, with the `this` binding and arguments
  23181. * of the created function, while it's called less than `n` times. Subsequent
  23182. * calls to the created function return the result of the last `func` invocation.
  23183. *
  23184. * @static
  23185. * @memberOf _
  23186. * @since 3.0.0
  23187. * @category Function
  23188. * @param {number} n The number of calls at which `func` is no longer invoked.
  23189. * @param {Function} func The function to restrict.
  23190. * @returns {Function} Returns the new restricted function.
  23191. * @example
  23192. *
  23193. * jQuery(element).on('click', _.before(5, addContactToList));
  23194. * // => Allows adding up to 4 contacts to the list.
  23195. */
  23196. function before(n, func) {
  23197. var result;
  23198. if (typeof func != 'function') {
  23199. throw new TypeError(FUNC_ERROR_TEXT);
  23200. }
  23201. n = toInteger(n);
  23202. return function() {
  23203. if (--n > 0) {
  23204. result = func.apply(this, arguments);
  23205. }
  23206. if (n <= 1) {
  23207. func = undefined;
  23208. }
  23209. return result;
  23210. };
  23211. }
  23212. /**
  23213. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  23214. * and `partials` prepended to the arguments it receives.
  23215. *
  23216. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  23217. * may be used as a placeholder for partially applied arguments.
  23218. *
  23219. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  23220. * property of bound functions.
  23221. *
  23222. * @static
  23223. * @memberOf _
  23224. * @since 0.1.0
  23225. * @category Function
  23226. * @param {Function} func The function to bind.
  23227. * @param {*} thisArg The `this` binding of `func`.
  23228. * @param {...*} [partials] The arguments to be partially applied.
  23229. * @returns {Function} Returns the new bound function.
  23230. * @example
  23231. *
  23232. * function greet(greeting, punctuation) {
  23233. * return greeting + ' ' + this.user + punctuation;
  23234. * }
  23235. *
  23236. * var object = { 'user': 'fred' };
  23237. *
  23238. * var bound = _.bind(greet, object, 'hi');
  23239. * bound('!');
  23240. * // => 'hi fred!'
  23241. *
  23242. * // Bound with placeholders.
  23243. * var bound = _.bind(greet, object, _, '!');
  23244. * bound('hi');
  23245. * // => 'hi fred!'
  23246. */
  23247. var bind = baseRest(function(func, thisArg, partials) {
  23248. var bitmask = WRAP_BIND_FLAG;
  23249. if (partials.length) {
  23250. var holders = replaceHolders(partials, getHolder(bind));
  23251. bitmask |= WRAP_PARTIAL_FLAG;
  23252. }
  23253. return createWrap(func, bitmask, thisArg, partials, holders);
  23254. });
  23255. /**
  23256. * Creates a function that invokes the method at `object[key]` with `partials`
  23257. * prepended to the arguments it receives.
  23258. *
  23259. * This method differs from `_.bind` by allowing bound functions to reference
  23260. * methods that may be redefined or don't yet exist. See
  23261. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  23262. * for more details.
  23263. *
  23264. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  23265. * builds, may be used as a placeholder for partially applied arguments.
  23266. *
  23267. * @static
  23268. * @memberOf _
  23269. * @since 0.10.0
  23270. * @category Function
  23271. * @param {Object} object The object to invoke the method on.
  23272. * @param {string} key The key of the method.
  23273. * @param {...*} [partials] The arguments to be partially applied.
  23274. * @returns {Function} Returns the new bound function.
  23275. * @example
  23276. *
  23277. * var object = {
  23278. * 'user': 'fred',
  23279. * 'greet': function(greeting, punctuation) {
  23280. * return greeting + ' ' + this.user + punctuation;
  23281. * }
  23282. * };
  23283. *
  23284. * var bound = _.bindKey(object, 'greet', 'hi');
  23285. * bound('!');
  23286. * // => 'hi fred!'
  23287. *
  23288. * object.greet = function(greeting, punctuation) {
  23289. * return greeting + 'ya ' + this.user + punctuation;
  23290. * };
  23291. *
  23292. * bound('!');
  23293. * // => 'hiya fred!'
  23294. *
  23295. * // Bound with placeholders.
  23296. * var bound = _.bindKey(object, 'greet', _, '!');
  23297. * bound('hi');
  23298. * // => 'hiya fred!'
  23299. */
  23300. var bindKey = baseRest(function(object, key, partials) {
  23301. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  23302. if (partials.length) {
  23303. var holders = replaceHolders(partials, getHolder(bindKey));
  23304. bitmask |= WRAP_PARTIAL_FLAG;
  23305. }
  23306. return createWrap(key, bitmask, object, partials, holders);
  23307. });
  23308. /**
  23309. * Creates a function that accepts arguments of `func` and either invokes
  23310. * `func` returning its result, if at least `arity` number of arguments have
  23311. * been provided, or returns a function that accepts the remaining `func`
  23312. * arguments, and so on. The arity of `func` may be specified if `func.length`
  23313. * is not sufficient.
  23314. *
  23315. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  23316. * may be used as a placeholder for provided arguments.
  23317. *
  23318. * **Note:** This method doesn't set the "length" property of curried functions.
  23319. *
  23320. * @static
  23321. * @memberOf _
  23322. * @since 2.0.0
  23323. * @category Function
  23324. * @param {Function} func The function to curry.
  23325. * @param {number} [arity=func.length] The arity of `func`.
  23326. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23327. * @returns {Function} Returns the new curried function.
  23328. * @example
  23329. *
  23330. * var abc = function(a, b, c) {
  23331. * return [a, b, c];
  23332. * };
  23333. *
  23334. * var curried = _.curry(abc);
  23335. *
  23336. * curried(1)(2)(3);
  23337. * // => [1, 2, 3]
  23338. *
  23339. * curried(1, 2)(3);
  23340. * // => [1, 2, 3]
  23341. *
  23342. * curried(1, 2, 3);
  23343. * // => [1, 2, 3]
  23344. *
  23345. * // Curried with placeholders.
  23346. * curried(1)(_, 3)(2);
  23347. * // => [1, 2, 3]
  23348. */
  23349. function curry(func, arity, guard) {
  23350. arity = guard ? undefined : arity;
  23351. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23352. result.placeholder = curry.placeholder;
  23353. return result;
  23354. }
  23355. /**
  23356. * This method is like `_.curry` except that arguments are applied to `func`
  23357. * in the manner of `_.partialRight` instead of `_.partial`.
  23358. *
  23359. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  23360. * builds, may be used as a placeholder for provided arguments.
  23361. *
  23362. * **Note:** This method doesn't set the "length" property of curried functions.
  23363. *
  23364. * @static
  23365. * @memberOf _
  23366. * @since 3.0.0
  23367. * @category Function
  23368. * @param {Function} func The function to curry.
  23369. * @param {number} [arity=func.length] The arity of `func`.
  23370. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23371. * @returns {Function} Returns the new curried function.
  23372. * @example
  23373. *
  23374. * var abc = function(a, b, c) {
  23375. * return [a, b, c];
  23376. * };
  23377. *
  23378. * var curried = _.curryRight(abc);
  23379. *
  23380. * curried(3)(2)(1);
  23381. * // => [1, 2, 3]
  23382. *
  23383. * curried(2, 3)(1);
  23384. * // => [1, 2, 3]
  23385. *
  23386. * curried(1, 2, 3);
  23387. * // => [1, 2, 3]
  23388. *
  23389. * // Curried with placeholders.
  23390. * curried(3)(1, _)(2);
  23391. * // => [1, 2, 3]
  23392. */
  23393. function curryRight(func, arity, guard) {
  23394. arity = guard ? undefined : arity;
  23395. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23396. result.placeholder = curryRight.placeholder;
  23397. return result;
  23398. }
  23399. /**
  23400. * Creates a debounced function that delays invoking `func` until after `wait`
  23401. * milliseconds have elapsed since the last time the debounced function was
  23402. * invoked. The debounced function comes with a `cancel` method to cancel
  23403. * delayed `func` invocations and a `flush` method to immediately invoke them.
  23404. * Provide `options` to indicate whether `func` should be invoked on the
  23405. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  23406. * with the last arguments provided to the debounced function. Subsequent
  23407. * calls to the debounced function return the result of the last `func`
  23408. * invocation.
  23409. *
  23410. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23411. * invoked on the trailing edge of the timeout only if the debounced function
  23412. * is invoked more than once during the `wait` timeout.
  23413. *
  23414. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23415. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23416. *
  23417. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23418. * for details over the differences between `_.debounce` and `_.throttle`.
  23419. *
  23420. * @static
  23421. * @memberOf _
  23422. * @since 0.1.0
  23423. * @category Function
  23424. * @param {Function} func The function to debounce.
  23425. * @param {number} [wait=0] The number of milliseconds to delay.
  23426. * @param {Object} [options={}] The options object.
  23427. * @param {boolean} [options.leading=false]
  23428. * Specify invoking on the leading edge of the timeout.
  23429. * @param {number} [options.maxWait]
  23430. * The maximum time `func` is allowed to be delayed before it's invoked.
  23431. * @param {boolean} [options.trailing=true]
  23432. * Specify invoking on the trailing edge of the timeout.
  23433. * @returns {Function} Returns the new debounced function.
  23434. * @example
  23435. *
  23436. * // Avoid costly calculations while the window size is in flux.
  23437. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  23438. *
  23439. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  23440. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  23441. * 'leading': true,
  23442. * 'trailing': false
  23443. * }));
  23444. *
  23445. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  23446. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  23447. * var source = new EventSource('/stream');
  23448. * jQuery(source).on('message', debounced);
  23449. *
  23450. * // Cancel the trailing debounced invocation.
  23451. * jQuery(window).on('popstate', debounced.cancel);
  23452. */
  23453. function debounce(func, wait, options) {
  23454. var lastArgs,
  23455. lastThis,
  23456. maxWait,
  23457. result,
  23458. timerId,
  23459. lastCallTime,
  23460. lastInvokeTime = 0,
  23461. leading = false,
  23462. maxing = false,
  23463. trailing = true;
  23464. if (typeof func != 'function') {
  23465. throw new TypeError(FUNC_ERROR_TEXT);
  23466. }
  23467. wait = toNumber(wait) || 0;
  23468. if (isObject(options)) {
  23469. leading = !!options.leading;
  23470. maxing = 'maxWait' in options;
  23471. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  23472. trailing = 'trailing' in options ? !!options.trailing : trailing;
  23473. }
  23474. function invokeFunc(time) {
  23475. var args = lastArgs,
  23476. thisArg = lastThis;
  23477. lastArgs = lastThis = undefined;
  23478. lastInvokeTime = time;
  23479. result = func.apply(thisArg, args);
  23480. return result;
  23481. }
  23482. function leadingEdge(time) {
  23483. // Reset any `maxWait` timer.
  23484. lastInvokeTime = time;
  23485. // Start the timer for the trailing edge.
  23486. timerId = setTimeout(timerExpired, wait);
  23487. // Invoke the leading edge.
  23488. return leading ? invokeFunc(time) : result;
  23489. }
  23490. function remainingWait(time) {
  23491. var timeSinceLastCall = time - lastCallTime,
  23492. timeSinceLastInvoke = time - lastInvokeTime,
  23493. timeWaiting = wait - timeSinceLastCall;
  23494. return maxing
  23495. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  23496. : timeWaiting;
  23497. }
  23498. function shouldInvoke(time) {
  23499. var timeSinceLastCall = time - lastCallTime,
  23500. timeSinceLastInvoke = time - lastInvokeTime;
  23501. // Either this is the first call, activity has stopped and we're at the
  23502. // trailing edge, the system time has gone backwards and we're treating
  23503. // it as the trailing edge, or we've hit the `maxWait` limit.
  23504. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  23505. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  23506. }
  23507. function timerExpired() {
  23508. var time = now();
  23509. if (shouldInvoke(time)) {
  23510. return trailingEdge(time);
  23511. }
  23512. // Restart the timer.
  23513. timerId = setTimeout(timerExpired, remainingWait(time));
  23514. }
  23515. function trailingEdge(time) {
  23516. timerId = undefined;
  23517. // Only invoke if we have `lastArgs` which means `func` has been
  23518. // debounced at least once.
  23519. if (trailing && lastArgs) {
  23520. return invokeFunc(time);
  23521. }
  23522. lastArgs = lastThis = undefined;
  23523. return result;
  23524. }
  23525. function cancel() {
  23526. if (timerId !== undefined) {
  23527. clearTimeout(timerId);
  23528. }
  23529. lastInvokeTime = 0;
  23530. lastArgs = lastCallTime = lastThis = timerId = undefined;
  23531. }
  23532. function flush() {
  23533. return timerId === undefined ? result : trailingEdge(now());
  23534. }
  23535. function debounced() {
  23536. var time = now(),
  23537. isInvoking = shouldInvoke(time);
  23538. lastArgs = arguments;
  23539. lastThis = this;
  23540. lastCallTime = time;
  23541. if (isInvoking) {
  23542. if (timerId === undefined) {
  23543. return leadingEdge(lastCallTime);
  23544. }
  23545. if (maxing) {
  23546. // Handle invocations in a tight loop.
  23547. clearTimeout(timerId);
  23548. timerId = setTimeout(timerExpired, wait);
  23549. return invokeFunc(lastCallTime);
  23550. }
  23551. }
  23552. if (timerId === undefined) {
  23553. timerId = setTimeout(timerExpired, wait);
  23554. }
  23555. return result;
  23556. }
  23557. debounced.cancel = cancel;
  23558. debounced.flush = flush;
  23559. return debounced;
  23560. }
  23561. /**
  23562. * Defers invoking the `func` until the current call stack has cleared. Any
  23563. * additional arguments are provided to `func` when it's invoked.
  23564. *
  23565. * @static
  23566. * @memberOf _
  23567. * @since 0.1.0
  23568. * @category Function
  23569. * @param {Function} func The function to defer.
  23570. * @param {...*} [args] The arguments to invoke `func` with.
  23571. * @returns {number} Returns the timer id.
  23572. * @example
  23573. *
  23574. * _.defer(function(text) {
  23575. * console.log(text);
  23576. * }, 'deferred');
  23577. * // => Logs 'deferred' after one millisecond.
  23578. */
  23579. var defer = baseRest(function(func, args) {
  23580. return baseDelay(func, 1, args);
  23581. });
  23582. /**
  23583. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  23584. * provided to `func` when it's invoked.
  23585. *
  23586. * @static
  23587. * @memberOf _
  23588. * @since 0.1.0
  23589. * @category Function
  23590. * @param {Function} func The function to delay.
  23591. * @param {number} wait The number of milliseconds to delay invocation.
  23592. * @param {...*} [args] The arguments to invoke `func` with.
  23593. * @returns {number} Returns the timer id.
  23594. * @example
  23595. *
  23596. * _.delay(function(text) {
  23597. * console.log(text);
  23598. * }, 1000, 'later');
  23599. * // => Logs 'later' after one second.
  23600. */
  23601. var delay = baseRest(function(func, wait, args) {
  23602. return baseDelay(func, toNumber(wait) || 0, args);
  23603. });
  23604. /**
  23605. * Creates a function that invokes `func` with arguments reversed.
  23606. *
  23607. * @static
  23608. * @memberOf _
  23609. * @since 4.0.0
  23610. * @category Function
  23611. * @param {Function} func The function to flip arguments for.
  23612. * @returns {Function} Returns the new flipped function.
  23613. * @example
  23614. *
  23615. * var flipped = _.flip(function() {
  23616. * return _.toArray(arguments);
  23617. * });
  23618. *
  23619. * flipped('a', 'b', 'c', 'd');
  23620. * // => ['d', 'c', 'b', 'a']
  23621. */
  23622. function flip(func) {
  23623. return createWrap(func, WRAP_FLIP_FLAG);
  23624. }
  23625. /**
  23626. * Creates a function that memoizes the result of `func`. If `resolver` is
  23627. * provided, it determines the cache key for storing the result based on the
  23628. * arguments provided to the memoized function. By default, the first argument
  23629. * provided to the memoized function is used as the map cache key. The `func`
  23630. * is invoked with the `this` binding of the memoized function.
  23631. *
  23632. * **Note:** The cache is exposed as the `cache` property on the memoized
  23633. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  23634. * constructor with one whose instances implement the
  23635. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  23636. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  23637. *
  23638. * @static
  23639. * @memberOf _
  23640. * @since 0.1.0
  23641. * @category Function
  23642. * @param {Function} func The function to have its output memoized.
  23643. * @param {Function} [resolver] The function to resolve the cache key.
  23644. * @returns {Function} Returns the new memoized function.
  23645. * @example
  23646. *
  23647. * var object = { 'a': 1, 'b': 2 };
  23648. * var other = { 'c': 3, 'd': 4 };
  23649. *
  23650. * var values = _.memoize(_.values);
  23651. * values(object);
  23652. * // => [1, 2]
  23653. *
  23654. * values(other);
  23655. * // => [3, 4]
  23656. *
  23657. * object.a = 2;
  23658. * values(object);
  23659. * // => [1, 2]
  23660. *
  23661. * // Modify the result cache.
  23662. * values.cache.set(object, ['a', 'b']);
  23663. * values(object);
  23664. * // => ['a', 'b']
  23665. *
  23666. * // Replace `_.memoize.Cache`.
  23667. * _.memoize.Cache = WeakMap;
  23668. */
  23669. function memoize(func, resolver) {
  23670. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  23671. throw new TypeError(FUNC_ERROR_TEXT);
  23672. }
  23673. var memoized = function() {
  23674. var args = arguments,
  23675. key = resolver ? resolver.apply(this, args) : args[0],
  23676. cache = memoized.cache;
  23677. if (cache.has(key)) {
  23678. return cache.get(key);
  23679. }
  23680. var result = func.apply(this, args);
  23681. memoized.cache = cache.set(key, result) || cache;
  23682. return result;
  23683. };
  23684. memoized.cache = new (memoize.Cache || MapCache);
  23685. return memoized;
  23686. }
  23687. // Expose `MapCache`.
  23688. memoize.Cache = MapCache;
  23689. /**
  23690. * Creates a function that negates the result of the predicate `func`. The
  23691. * `func` predicate is invoked with the `this` binding and arguments of the
  23692. * created function.
  23693. *
  23694. * @static
  23695. * @memberOf _
  23696. * @since 3.0.0
  23697. * @category Function
  23698. * @param {Function} predicate The predicate to negate.
  23699. * @returns {Function} Returns the new negated function.
  23700. * @example
  23701. *
  23702. * function isEven(n) {
  23703. * return n % 2 == 0;
  23704. * }
  23705. *
  23706. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  23707. * // => [1, 3, 5]
  23708. */
  23709. function negate(predicate) {
  23710. if (typeof predicate != 'function') {
  23711. throw new TypeError(FUNC_ERROR_TEXT);
  23712. }
  23713. return function() {
  23714. var args = arguments;
  23715. switch (args.length) {
  23716. case 0: return !predicate.call(this);
  23717. case 1: return !predicate.call(this, args[0]);
  23718. case 2: return !predicate.call(this, args[0], args[1]);
  23719. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  23720. }
  23721. return !predicate.apply(this, args);
  23722. };
  23723. }
  23724. /**
  23725. * Creates a function that is restricted to invoking `func` once. Repeat calls
  23726. * to the function return the value of the first invocation. The `func` is
  23727. * invoked with the `this` binding and arguments of the created function.
  23728. *
  23729. * @static
  23730. * @memberOf _
  23731. * @since 0.1.0
  23732. * @category Function
  23733. * @param {Function} func The function to restrict.
  23734. * @returns {Function} Returns the new restricted function.
  23735. * @example
  23736. *
  23737. * var initialize = _.once(createApplication);
  23738. * initialize();
  23739. * initialize();
  23740. * // => `createApplication` is invoked once
  23741. */
  23742. function once(func) {
  23743. return before(2, func);
  23744. }
  23745. /**
  23746. * Creates a function that invokes `func` with its arguments transformed.
  23747. *
  23748. * @static
  23749. * @since 4.0.0
  23750. * @memberOf _
  23751. * @category Function
  23752. * @param {Function} func The function to wrap.
  23753. * @param {...(Function|Function[])} [transforms=[_.identity]]
  23754. * The argument transforms.
  23755. * @returns {Function} Returns the new function.
  23756. * @example
  23757. *
  23758. * function doubled(n) {
  23759. * return n * 2;
  23760. * }
  23761. *
  23762. * function square(n) {
  23763. * return n * n;
  23764. * }
  23765. *
  23766. * var func = _.overArgs(function(x, y) {
  23767. * return [x, y];
  23768. * }, [square, doubled]);
  23769. *
  23770. * func(9, 3);
  23771. * // => [81, 6]
  23772. *
  23773. * func(10, 5);
  23774. * // => [100, 10]
  23775. */
  23776. var overArgs = castRest(function(func, transforms) {
  23777. transforms = (transforms.length == 1 && isArray(transforms[0]))
  23778. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  23779. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  23780. var funcsLength = transforms.length;
  23781. return baseRest(function(args) {
  23782. var index = -1,
  23783. length = nativeMin(args.length, funcsLength);
  23784. while (++index < length) {
  23785. args[index] = transforms[index].call(this, args[index]);
  23786. }
  23787. return apply(func, this, args);
  23788. });
  23789. });
  23790. /**
  23791. * Creates a function that invokes `func` with `partials` prepended to the
  23792. * arguments it receives. This method is like `_.bind` except it does **not**
  23793. * alter the `this` binding.
  23794. *
  23795. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  23796. * builds, may be used as a placeholder for partially applied arguments.
  23797. *
  23798. * **Note:** This method doesn't set the "length" property of partially
  23799. * applied functions.
  23800. *
  23801. * @static
  23802. * @memberOf _
  23803. * @since 0.2.0
  23804. * @category Function
  23805. * @param {Function} func The function to partially apply arguments to.
  23806. * @param {...*} [partials] The arguments to be partially applied.
  23807. * @returns {Function} Returns the new partially applied function.
  23808. * @example
  23809. *
  23810. * function greet(greeting, name) {
  23811. * return greeting + ' ' + name;
  23812. * }
  23813. *
  23814. * var sayHelloTo = _.partial(greet, 'hello');
  23815. * sayHelloTo('fred');
  23816. * // => 'hello fred'
  23817. *
  23818. * // Partially applied with placeholders.
  23819. * var greetFred = _.partial(greet, _, 'fred');
  23820. * greetFred('hi');
  23821. * // => 'hi fred'
  23822. */
  23823. var partial = baseRest(function(func, partials) {
  23824. var holders = replaceHolders(partials, getHolder(partial));
  23825. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  23826. });
  23827. /**
  23828. * This method is like `_.partial` except that partially applied arguments
  23829. * are appended to the arguments it receives.
  23830. *
  23831. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  23832. * builds, may be used as a placeholder for partially applied arguments.
  23833. *
  23834. * **Note:** This method doesn't set the "length" property of partially
  23835. * applied functions.
  23836. *
  23837. * @static
  23838. * @memberOf _
  23839. * @since 1.0.0
  23840. * @category Function
  23841. * @param {Function} func The function to partially apply arguments to.
  23842. * @param {...*} [partials] The arguments to be partially applied.
  23843. * @returns {Function} Returns the new partially applied function.
  23844. * @example
  23845. *
  23846. * function greet(greeting, name) {
  23847. * return greeting + ' ' + name;
  23848. * }
  23849. *
  23850. * var greetFred = _.partialRight(greet, 'fred');
  23851. * greetFred('hi');
  23852. * // => 'hi fred'
  23853. *
  23854. * // Partially applied with placeholders.
  23855. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  23856. * sayHelloTo('fred');
  23857. * // => 'hello fred'
  23858. */
  23859. var partialRight = baseRest(function(func, partials) {
  23860. var holders = replaceHolders(partials, getHolder(partialRight));
  23861. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  23862. });
  23863. /**
  23864. * Creates a function that invokes `func` with arguments arranged according
  23865. * to the specified `indexes` where the argument value at the first index is
  23866. * provided as the first argument, the argument value at the second index is
  23867. * provided as the second argument, and so on.
  23868. *
  23869. * @static
  23870. * @memberOf _
  23871. * @since 3.0.0
  23872. * @category Function
  23873. * @param {Function} func The function to rearrange arguments for.
  23874. * @param {...(number|number[])} indexes The arranged argument indexes.
  23875. * @returns {Function} Returns the new function.
  23876. * @example
  23877. *
  23878. * var rearged = _.rearg(function(a, b, c) {
  23879. * return [a, b, c];
  23880. * }, [2, 0, 1]);
  23881. *
  23882. * rearged('b', 'c', 'a')
  23883. * // => ['a', 'b', 'c']
  23884. */
  23885. var rearg = flatRest(function(func, indexes) {
  23886. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  23887. });
  23888. /**
  23889. * Creates a function that invokes `func` with the `this` binding of the
  23890. * created function and arguments from `start` and beyond provided as
  23891. * an array.
  23892. *
  23893. * **Note:** This method is based on the
  23894. * [rest parameter](https://mdn.io/rest_parameters).
  23895. *
  23896. * @static
  23897. * @memberOf _
  23898. * @since 4.0.0
  23899. * @category Function
  23900. * @param {Function} func The function to apply a rest parameter to.
  23901. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23902. * @returns {Function} Returns the new function.
  23903. * @example
  23904. *
  23905. * var say = _.rest(function(what, names) {
  23906. * return what + ' ' + _.initial(names).join(', ') +
  23907. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  23908. * });
  23909. *
  23910. * say('hello', 'fred', 'barney', 'pebbles');
  23911. * // => 'hello fred, barney, & pebbles'
  23912. */
  23913. function rest(func, start) {
  23914. if (typeof func != 'function') {
  23915. throw new TypeError(FUNC_ERROR_TEXT);
  23916. }
  23917. start = start === undefined ? start : toInteger(start);
  23918. return baseRest(func, start);
  23919. }
  23920. /**
  23921. * Creates a function that invokes `func` with the `this` binding of the
  23922. * create function and an array of arguments much like
  23923. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  23924. *
  23925. * **Note:** This method is based on the
  23926. * [spread operator](https://mdn.io/spread_operator).
  23927. *
  23928. * @static
  23929. * @memberOf _
  23930. * @since 3.2.0
  23931. * @category Function
  23932. * @param {Function} func The function to spread arguments over.
  23933. * @param {number} [start=0] The start position of the spread.
  23934. * @returns {Function} Returns the new function.
  23935. * @example
  23936. *
  23937. * var say = _.spread(function(who, what) {
  23938. * return who + ' says ' + what;
  23939. * });
  23940. *
  23941. * say(['fred', 'hello']);
  23942. * // => 'fred says hello'
  23943. *
  23944. * var numbers = Promise.all([
  23945. * Promise.resolve(40),
  23946. * Promise.resolve(36)
  23947. * ]);
  23948. *
  23949. * numbers.then(_.spread(function(x, y) {
  23950. * return x + y;
  23951. * }));
  23952. * // => a Promise of 76
  23953. */
  23954. function spread(func, start) {
  23955. if (typeof func != 'function') {
  23956. throw new TypeError(FUNC_ERROR_TEXT);
  23957. }
  23958. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  23959. return baseRest(function(args) {
  23960. var array = args[start],
  23961. otherArgs = castSlice(args, 0, start);
  23962. if (array) {
  23963. arrayPush(otherArgs, array);
  23964. }
  23965. return apply(func, this, otherArgs);
  23966. });
  23967. }
  23968. /**
  23969. * Creates a throttled function that only invokes `func` at most once per
  23970. * every `wait` milliseconds. The throttled function comes with a `cancel`
  23971. * method to cancel delayed `func` invocations and a `flush` method to
  23972. * immediately invoke them. Provide `options` to indicate whether `func`
  23973. * should be invoked on the leading and/or trailing edge of the `wait`
  23974. * timeout. The `func` is invoked with the last arguments provided to the
  23975. * throttled function. Subsequent calls to the throttled function return the
  23976. * result of the last `func` invocation.
  23977. *
  23978. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23979. * invoked on the trailing edge of the timeout only if the throttled function
  23980. * is invoked more than once during the `wait` timeout.
  23981. *
  23982. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23983. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23984. *
  23985. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23986. * for details over the differences between `_.throttle` and `_.debounce`.
  23987. *
  23988. * @static
  23989. * @memberOf _
  23990. * @since 0.1.0
  23991. * @category Function
  23992. * @param {Function} func The function to throttle.
  23993. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  23994. * @param {Object} [options={}] The options object.
  23995. * @param {boolean} [options.leading=true]
  23996. * Specify invoking on the leading edge of the timeout.
  23997. * @param {boolean} [options.trailing=true]
  23998. * Specify invoking on the trailing edge of the timeout.
  23999. * @returns {Function} Returns the new throttled function.
  24000. * @example
  24001. *
  24002. * // Avoid excessively updating the position while scrolling.
  24003. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  24004. *
  24005. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  24006. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  24007. * jQuery(element).on('click', throttled);
  24008. *
  24009. * // Cancel the trailing throttled invocation.
  24010. * jQuery(window).on('popstate', throttled.cancel);
  24011. */
  24012. function throttle(func, wait, options) {
  24013. var leading = true,
  24014. trailing = true;
  24015. if (typeof func != 'function') {
  24016. throw new TypeError(FUNC_ERROR_TEXT);
  24017. }
  24018. if (isObject(options)) {
  24019. leading = 'leading' in options ? !!options.leading : leading;
  24020. trailing = 'trailing' in options ? !!options.trailing : trailing;
  24021. }
  24022. return debounce(func, wait, {
  24023. 'leading': leading,
  24024. 'maxWait': wait,
  24025. 'trailing': trailing
  24026. });
  24027. }
  24028. /**
  24029. * Creates a function that accepts up to one argument, ignoring any
  24030. * additional arguments.
  24031. *
  24032. * @static
  24033. * @memberOf _
  24034. * @since 4.0.0
  24035. * @category Function
  24036. * @param {Function} func The function to cap arguments for.
  24037. * @returns {Function} Returns the new capped function.
  24038. * @example
  24039. *
  24040. * _.map(['6', '8', '10'], _.unary(parseInt));
  24041. * // => [6, 8, 10]
  24042. */
  24043. function unary(func) {
  24044. return ary(func, 1);
  24045. }
  24046. /**
  24047. * Creates a function that provides `value` to `wrapper` as its first
  24048. * argument. Any additional arguments provided to the function are appended
  24049. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  24050. * binding of the created function.
  24051. *
  24052. * @static
  24053. * @memberOf _
  24054. * @since 0.1.0
  24055. * @category Function
  24056. * @param {*} value The value to wrap.
  24057. * @param {Function} [wrapper=identity] The wrapper function.
  24058. * @returns {Function} Returns the new function.
  24059. * @example
  24060. *
  24061. * var p = _.wrap(_.escape, function(func, text) {
  24062. * return '<p>' + func(text) + '</p>';
  24063. * });
  24064. *
  24065. * p('fred, barney, & pebbles');
  24066. * // => '<p>fred, barney, &amp; pebbles</p>'
  24067. */
  24068. function wrap(value, wrapper) {
  24069. return partial(castFunction(wrapper), value);
  24070. }
  24071. /*------------------------------------------------------------------------*/
  24072. /**
  24073. * Casts `value` as an array if it's not one.
  24074. *
  24075. * @static
  24076. * @memberOf _
  24077. * @since 4.4.0
  24078. * @category Lang
  24079. * @param {*} value The value to inspect.
  24080. * @returns {Array} Returns the cast array.
  24081. * @example
  24082. *
  24083. * _.castArray(1);
  24084. * // => [1]
  24085. *
  24086. * _.castArray({ 'a': 1 });
  24087. * // => [{ 'a': 1 }]
  24088. *
  24089. * _.castArray('abc');
  24090. * // => ['abc']
  24091. *
  24092. * _.castArray(null);
  24093. * // => [null]
  24094. *
  24095. * _.castArray(undefined);
  24096. * // => [undefined]
  24097. *
  24098. * _.castArray();
  24099. * // => []
  24100. *
  24101. * var array = [1, 2, 3];
  24102. * console.log(_.castArray(array) === array);
  24103. * // => true
  24104. */
  24105. function castArray() {
  24106. if (!arguments.length) {
  24107. return [];
  24108. }
  24109. var value = arguments[0];
  24110. return isArray(value) ? value : [value];
  24111. }
  24112. /**
  24113. * Creates a shallow clone of `value`.
  24114. *
  24115. * **Note:** This method is loosely based on the
  24116. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  24117. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  24118. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  24119. * arrays. The own enumerable properties of `arguments` objects are cloned
  24120. * as plain objects. An empty object is returned for uncloneable values such
  24121. * as error objects, functions, DOM nodes, and WeakMaps.
  24122. *
  24123. * @static
  24124. * @memberOf _
  24125. * @since 0.1.0
  24126. * @category Lang
  24127. * @param {*} value The value to clone.
  24128. * @returns {*} Returns the cloned value.
  24129. * @see _.cloneDeep
  24130. * @example
  24131. *
  24132. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24133. *
  24134. * var shallow = _.clone(objects);
  24135. * console.log(shallow[0] === objects[0]);
  24136. * // => true
  24137. */
  24138. function clone(value) {
  24139. return baseClone(value, CLONE_SYMBOLS_FLAG);
  24140. }
  24141. /**
  24142. * This method is like `_.clone` except that it accepts `customizer` which
  24143. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  24144. * cloning is handled by the method instead. The `customizer` is invoked with
  24145. * up to four arguments; (value [, index|key, object, stack]).
  24146. *
  24147. * @static
  24148. * @memberOf _
  24149. * @since 4.0.0
  24150. * @category Lang
  24151. * @param {*} value The value to clone.
  24152. * @param {Function} [customizer] The function to customize cloning.
  24153. * @returns {*} Returns the cloned value.
  24154. * @see _.cloneDeepWith
  24155. * @example
  24156. *
  24157. * function customizer(value) {
  24158. * if (_.isElement(value)) {
  24159. * return value.cloneNode(false);
  24160. * }
  24161. * }
  24162. *
  24163. * var el = _.cloneWith(document.body, customizer);
  24164. *
  24165. * console.log(el === document.body);
  24166. * // => false
  24167. * console.log(el.nodeName);
  24168. * // => 'BODY'
  24169. * console.log(el.childNodes.length);
  24170. * // => 0
  24171. */
  24172. function cloneWith(value, customizer) {
  24173. customizer = typeof customizer == 'function' ? customizer : undefined;
  24174. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  24175. }
  24176. /**
  24177. * This method is like `_.clone` except that it recursively clones `value`.
  24178. *
  24179. * @static
  24180. * @memberOf _
  24181. * @since 1.0.0
  24182. * @category Lang
  24183. * @param {*} value The value to recursively clone.
  24184. * @returns {*} Returns the deep cloned value.
  24185. * @see _.clone
  24186. * @example
  24187. *
  24188. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24189. *
  24190. * var deep = _.cloneDeep(objects);
  24191. * console.log(deep[0] === objects[0]);
  24192. * // => false
  24193. */
  24194. function cloneDeep(value) {
  24195. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  24196. }
  24197. /**
  24198. * This method is like `_.cloneWith` except that it recursively clones `value`.
  24199. *
  24200. * @static
  24201. * @memberOf _
  24202. * @since 4.0.0
  24203. * @category Lang
  24204. * @param {*} value The value to recursively clone.
  24205. * @param {Function} [customizer] The function to customize cloning.
  24206. * @returns {*} Returns the deep cloned value.
  24207. * @see _.cloneWith
  24208. * @example
  24209. *
  24210. * function customizer(value) {
  24211. * if (_.isElement(value)) {
  24212. * return value.cloneNode(true);
  24213. * }
  24214. * }
  24215. *
  24216. * var el = _.cloneDeepWith(document.body, customizer);
  24217. *
  24218. * console.log(el === document.body);
  24219. * // => false
  24220. * console.log(el.nodeName);
  24221. * // => 'BODY'
  24222. * console.log(el.childNodes.length);
  24223. * // => 20
  24224. */
  24225. function cloneDeepWith(value, customizer) {
  24226. customizer = typeof customizer == 'function' ? customizer : undefined;
  24227. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  24228. }
  24229. /**
  24230. * Checks if `object` conforms to `source` by invoking the predicate
  24231. * properties of `source` with the corresponding property values of `object`.
  24232. *
  24233. * **Note:** This method is equivalent to `_.conforms` when `source` is
  24234. * partially applied.
  24235. *
  24236. * @static
  24237. * @memberOf _
  24238. * @since 4.14.0
  24239. * @category Lang
  24240. * @param {Object} object The object to inspect.
  24241. * @param {Object} source The object of property predicates to conform to.
  24242. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  24243. * @example
  24244. *
  24245. * var object = { 'a': 1, 'b': 2 };
  24246. *
  24247. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  24248. * // => true
  24249. *
  24250. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  24251. * // => false
  24252. */
  24253. function conformsTo(object, source) {
  24254. return source == null || baseConformsTo(object, source, keys(source));
  24255. }
  24256. /**
  24257. * Performs a
  24258. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24259. * comparison between two values to determine if they are equivalent.
  24260. *
  24261. * @static
  24262. * @memberOf _
  24263. * @since 4.0.0
  24264. * @category Lang
  24265. * @param {*} value The value to compare.
  24266. * @param {*} other The other value to compare.
  24267. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24268. * @example
  24269. *
  24270. * var object = { 'a': 1 };
  24271. * var other = { 'a': 1 };
  24272. *
  24273. * _.eq(object, object);
  24274. * // => true
  24275. *
  24276. * _.eq(object, other);
  24277. * // => false
  24278. *
  24279. * _.eq('a', 'a');
  24280. * // => true
  24281. *
  24282. * _.eq('a', Object('a'));
  24283. * // => false
  24284. *
  24285. * _.eq(NaN, NaN);
  24286. * // => true
  24287. */
  24288. function eq(value, other) {
  24289. return value === other || (value !== value && other !== other);
  24290. }
  24291. /**
  24292. * Checks if `value` is greater than `other`.
  24293. *
  24294. * @static
  24295. * @memberOf _
  24296. * @since 3.9.0
  24297. * @category Lang
  24298. * @param {*} value The value to compare.
  24299. * @param {*} other The other value to compare.
  24300. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  24301. * else `false`.
  24302. * @see _.lt
  24303. * @example
  24304. *
  24305. * _.gt(3, 1);
  24306. * // => true
  24307. *
  24308. * _.gt(3, 3);
  24309. * // => false
  24310. *
  24311. * _.gt(1, 3);
  24312. * // => false
  24313. */
  24314. var gt = createRelationalOperation(baseGt);
  24315. /**
  24316. * Checks if `value` is greater than or equal to `other`.
  24317. *
  24318. * @static
  24319. * @memberOf _
  24320. * @since 3.9.0
  24321. * @category Lang
  24322. * @param {*} value The value to compare.
  24323. * @param {*} other The other value to compare.
  24324. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  24325. * `other`, else `false`.
  24326. * @see _.lte
  24327. * @example
  24328. *
  24329. * _.gte(3, 1);
  24330. * // => true
  24331. *
  24332. * _.gte(3, 3);
  24333. * // => true
  24334. *
  24335. * _.gte(1, 3);
  24336. * // => false
  24337. */
  24338. var gte = createRelationalOperation(function(value, other) {
  24339. return value >= other;
  24340. });
  24341. /**
  24342. * Checks if `value` is likely an `arguments` object.
  24343. *
  24344. * @static
  24345. * @memberOf _
  24346. * @since 0.1.0
  24347. * @category Lang
  24348. * @param {*} value The value to check.
  24349. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  24350. * else `false`.
  24351. * @example
  24352. *
  24353. * _.isArguments(function() { return arguments; }());
  24354. * // => true
  24355. *
  24356. * _.isArguments([1, 2, 3]);
  24357. * // => false
  24358. */
  24359. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  24360. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  24361. !propertyIsEnumerable.call(value, 'callee');
  24362. };
  24363. /**
  24364. * Checks if `value` is classified as an `Array` object.
  24365. *
  24366. * @static
  24367. * @memberOf _
  24368. * @since 0.1.0
  24369. * @category Lang
  24370. * @param {*} value The value to check.
  24371. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  24372. * @example
  24373. *
  24374. * _.isArray([1, 2, 3]);
  24375. * // => true
  24376. *
  24377. * _.isArray(document.body.children);
  24378. * // => false
  24379. *
  24380. * _.isArray('abc');
  24381. * // => false
  24382. *
  24383. * _.isArray(_.noop);
  24384. * // => false
  24385. */
  24386. var isArray = Array.isArray;
  24387. /**
  24388. * Checks if `value` is classified as an `ArrayBuffer` object.
  24389. *
  24390. * @static
  24391. * @memberOf _
  24392. * @since 4.3.0
  24393. * @category Lang
  24394. * @param {*} value The value to check.
  24395. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  24396. * @example
  24397. *
  24398. * _.isArrayBuffer(new ArrayBuffer(2));
  24399. * // => true
  24400. *
  24401. * _.isArrayBuffer(new Array(2));
  24402. * // => false
  24403. */
  24404. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  24405. /**
  24406. * Checks if `value` is array-like. A value is considered array-like if it's
  24407. * not a function and has a `value.length` that's an integer greater than or
  24408. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  24409. *
  24410. * @static
  24411. * @memberOf _
  24412. * @since 4.0.0
  24413. * @category Lang
  24414. * @param {*} value The value to check.
  24415. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  24416. * @example
  24417. *
  24418. * _.isArrayLike([1, 2, 3]);
  24419. * // => true
  24420. *
  24421. * _.isArrayLike(document.body.children);
  24422. * // => true
  24423. *
  24424. * _.isArrayLike('abc');
  24425. * // => true
  24426. *
  24427. * _.isArrayLike(_.noop);
  24428. * // => false
  24429. */
  24430. function isArrayLike(value) {
  24431. return value != null && isLength(value.length) && !isFunction(value);
  24432. }
  24433. /**
  24434. * This method is like `_.isArrayLike` except that it also checks if `value`
  24435. * is an object.
  24436. *
  24437. * @static
  24438. * @memberOf _
  24439. * @since 4.0.0
  24440. * @category Lang
  24441. * @param {*} value The value to check.
  24442. * @returns {boolean} Returns `true` if `value` is an array-like object,
  24443. * else `false`.
  24444. * @example
  24445. *
  24446. * _.isArrayLikeObject([1, 2, 3]);
  24447. * // => true
  24448. *
  24449. * _.isArrayLikeObject(document.body.children);
  24450. * // => true
  24451. *
  24452. * _.isArrayLikeObject('abc');
  24453. * // => false
  24454. *
  24455. * _.isArrayLikeObject(_.noop);
  24456. * // => false
  24457. */
  24458. function isArrayLikeObject(value) {
  24459. return isObjectLike(value) && isArrayLike(value);
  24460. }
  24461. /**
  24462. * Checks if `value` is classified as a boolean primitive or object.
  24463. *
  24464. * @static
  24465. * @memberOf _
  24466. * @since 0.1.0
  24467. * @category Lang
  24468. * @param {*} value The value to check.
  24469. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  24470. * @example
  24471. *
  24472. * _.isBoolean(false);
  24473. * // => true
  24474. *
  24475. * _.isBoolean(null);
  24476. * // => false
  24477. */
  24478. function isBoolean(value) {
  24479. return value === true || value === false ||
  24480. (isObjectLike(value) && baseGetTag(value) == boolTag);
  24481. }
  24482. /**
  24483. * Checks if `value` is a buffer.
  24484. *
  24485. * @static
  24486. * @memberOf _
  24487. * @since 4.3.0
  24488. * @category Lang
  24489. * @param {*} value The value to check.
  24490. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  24491. * @example
  24492. *
  24493. * _.isBuffer(new Buffer(2));
  24494. * // => true
  24495. *
  24496. * _.isBuffer(new Uint8Array(2));
  24497. * // => false
  24498. */
  24499. var isBuffer = nativeIsBuffer || stubFalse;
  24500. /**
  24501. * Checks if `value` is classified as a `Date` object.
  24502. *
  24503. * @static
  24504. * @memberOf _
  24505. * @since 0.1.0
  24506. * @category Lang
  24507. * @param {*} value The value to check.
  24508. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  24509. * @example
  24510. *
  24511. * _.isDate(new Date);
  24512. * // => true
  24513. *
  24514. * _.isDate('Mon April 23 2012');
  24515. * // => false
  24516. */
  24517. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  24518. /**
  24519. * Checks if `value` is likely a DOM element.
  24520. *
  24521. * @static
  24522. * @memberOf _
  24523. * @since 0.1.0
  24524. * @category Lang
  24525. * @param {*} value The value to check.
  24526. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  24527. * @example
  24528. *
  24529. * _.isElement(document.body);
  24530. * // => true
  24531. *
  24532. * _.isElement('<body>');
  24533. * // => false
  24534. */
  24535. function isElement(value) {
  24536. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  24537. }
  24538. /**
  24539. * Checks if `value` is an empty object, collection, map, or set.
  24540. *
  24541. * Objects are considered empty if they have no own enumerable string keyed
  24542. * properties.
  24543. *
  24544. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  24545. * jQuery-like collections are considered empty if they have a `length` of `0`.
  24546. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  24547. *
  24548. * @static
  24549. * @memberOf _
  24550. * @since 0.1.0
  24551. * @category Lang
  24552. * @param {*} value The value to check.
  24553. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  24554. * @example
  24555. *
  24556. * _.isEmpty(null);
  24557. * // => true
  24558. *
  24559. * _.isEmpty(true);
  24560. * // => true
  24561. *
  24562. * _.isEmpty(1);
  24563. * // => true
  24564. *
  24565. * _.isEmpty([1, 2, 3]);
  24566. * // => false
  24567. *
  24568. * _.isEmpty({ 'a': 1 });
  24569. * // => false
  24570. */
  24571. function isEmpty(value) {
  24572. if (value == null) {
  24573. return true;
  24574. }
  24575. if (isArrayLike(value) &&
  24576. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  24577. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  24578. return !value.length;
  24579. }
  24580. var tag = getTag(value);
  24581. if (tag == mapTag || tag == setTag) {
  24582. return !value.size;
  24583. }
  24584. if (isPrototype(value)) {
  24585. return !baseKeys(value).length;
  24586. }
  24587. for (var key in value) {
  24588. if (hasOwnProperty.call(value, key)) {
  24589. return false;
  24590. }
  24591. }
  24592. return true;
  24593. }
  24594. /**
  24595. * Performs a deep comparison between two values to determine if they are
  24596. * equivalent.
  24597. *
  24598. * **Note:** This method supports comparing arrays, array buffers, booleans,
  24599. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  24600. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  24601. * by their own, not inherited, enumerable properties. Functions and DOM
  24602. * nodes are compared by strict equality, i.e. `===`.
  24603. *
  24604. * @static
  24605. * @memberOf _
  24606. * @since 0.1.0
  24607. * @category Lang
  24608. * @param {*} value The value to compare.
  24609. * @param {*} other The other value to compare.
  24610. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24611. * @example
  24612. *
  24613. * var object = { 'a': 1 };
  24614. * var other = { 'a': 1 };
  24615. *
  24616. * _.isEqual(object, other);
  24617. * // => true
  24618. *
  24619. * object === other;
  24620. * // => false
  24621. */
  24622. function isEqual(value, other) {
  24623. return baseIsEqual(value, other);
  24624. }
  24625. /**
  24626. * This method is like `_.isEqual` except that it accepts `customizer` which
  24627. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24628. * are handled by the method instead. The `customizer` is invoked with up to
  24629. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  24630. *
  24631. * @static
  24632. * @memberOf _
  24633. * @since 4.0.0
  24634. * @category Lang
  24635. * @param {*} value The value to compare.
  24636. * @param {*} other The other value to compare.
  24637. * @param {Function} [customizer] The function to customize comparisons.
  24638. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24639. * @example
  24640. *
  24641. * function isGreeting(value) {
  24642. * return /^h(?:i|ello)$/.test(value);
  24643. * }
  24644. *
  24645. * function customizer(objValue, othValue) {
  24646. * if (isGreeting(objValue) && isGreeting(othValue)) {
  24647. * return true;
  24648. * }
  24649. * }
  24650. *
  24651. * var array = ['hello', 'goodbye'];
  24652. * var other = ['hi', 'goodbye'];
  24653. *
  24654. * _.isEqualWith(array, other, customizer);
  24655. * // => true
  24656. */
  24657. function isEqualWith(value, other, customizer) {
  24658. customizer = typeof customizer == 'function' ? customizer : undefined;
  24659. var result = customizer ? customizer(value, other) : undefined;
  24660. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  24661. }
  24662. /**
  24663. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  24664. * `SyntaxError`, `TypeError`, or `URIError` object.
  24665. *
  24666. * @static
  24667. * @memberOf _
  24668. * @since 3.0.0
  24669. * @category Lang
  24670. * @param {*} value The value to check.
  24671. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  24672. * @example
  24673. *
  24674. * _.isError(new Error);
  24675. * // => true
  24676. *
  24677. * _.isError(Error);
  24678. * // => false
  24679. */
  24680. function isError(value) {
  24681. if (!isObjectLike(value)) {
  24682. return false;
  24683. }
  24684. var tag = baseGetTag(value);
  24685. return tag == errorTag || tag == domExcTag ||
  24686. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  24687. }
  24688. /**
  24689. * Checks if `value` is a finite primitive number.
  24690. *
  24691. * **Note:** This method is based on
  24692. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  24693. *
  24694. * @static
  24695. * @memberOf _
  24696. * @since 0.1.0
  24697. * @category Lang
  24698. * @param {*} value The value to check.
  24699. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  24700. * @example
  24701. *
  24702. * _.isFinite(3);
  24703. * // => true
  24704. *
  24705. * _.isFinite(Number.MIN_VALUE);
  24706. * // => true
  24707. *
  24708. * _.isFinite(Infinity);
  24709. * // => false
  24710. *
  24711. * _.isFinite('3');
  24712. * // => false
  24713. */
  24714. function isFinite(value) {
  24715. return typeof value == 'number' && nativeIsFinite(value);
  24716. }
  24717. /**
  24718. * Checks if `value` is classified as a `Function` object.
  24719. *
  24720. * @static
  24721. * @memberOf _
  24722. * @since 0.1.0
  24723. * @category Lang
  24724. * @param {*} value The value to check.
  24725. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  24726. * @example
  24727. *
  24728. * _.isFunction(_);
  24729. * // => true
  24730. *
  24731. * _.isFunction(/abc/);
  24732. * // => false
  24733. */
  24734. function isFunction(value) {
  24735. if (!isObject(value)) {
  24736. return false;
  24737. }
  24738. // The use of `Object#toString` avoids issues with the `typeof` operator
  24739. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  24740. var tag = baseGetTag(value);
  24741. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  24742. }
  24743. /**
  24744. * Checks if `value` is an integer.
  24745. *
  24746. * **Note:** This method is based on
  24747. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  24748. *
  24749. * @static
  24750. * @memberOf _
  24751. * @since 4.0.0
  24752. * @category Lang
  24753. * @param {*} value The value to check.
  24754. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  24755. * @example
  24756. *
  24757. * _.isInteger(3);
  24758. * // => true
  24759. *
  24760. * _.isInteger(Number.MIN_VALUE);
  24761. * // => false
  24762. *
  24763. * _.isInteger(Infinity);
  24764. * // => false
  24765. *
  24766. * _.isInteger('3');
  24767. * // => false
  24768. */
  24769. function isInteger(value) {
  24770. return typeof value == 'number' && value == toInteger(value);
  24771. }
  24772. /**
  24773. * Checks if `value` is a valid array-like length.
  24774. *
  24775. * **Note:** This method is loosely based on
  24776. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  24777. *
  24778. * @static
  24779. * @memberOf _
  24780. * @since 4.0.0
  24781. * @category Lang
  24782. * @param {*} value The value to check.
  24783. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  24784. * @example
  24785. *
  24786. * _.isLength(3);
  24787. * // => true
  24788. *
  24789. * _.isLength(Number.MIN_VALUE);
  24790. * // => false
  24791. *
  24792. * _.isLength(Infinity);
  24793. * // => false
  24794. *
  24795. * _.isLength('3');
  24796. * // => false
  24797. */
  24798. function isLength(value) {
  24799. return typeof value == 'number' &&
  24800. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  24801. }
  24802. /**
  24803. * Checks if `value` is the
  24804. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  24805. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  24806. *
  24807. * @static
  24808. * @memberOf _
  24809. * @since 0.1.0
  24810. * @category Lang
  24811. * @param {*} value The value to check.
  24812. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  24813. * @example
  24814. *
  24815. * _.isObject({});
  24816. * // => true
  24817. *
  24818. * _.isObject([1, 2, 3]);
  24819. * // => true
  24820. *
  24821. * _.isObject(_.noop);
  24822. * // => true
  24823. *
  24824. * _.isObject(null);
  24825. * // => false
  24826. */
  24827. function isObject(value) {
  24828. var type = typeof value;
  24829. return value != null && (type == 'object' || type == 'function');
  24830. }
  24831. /**
  24832. * Checks if `value` is object-like. A value is object-like if it's not `null`
  24833. * and has a `typeof` result of "object".
  24834. *
  24835. * @static
  24836. * @memberOf _
  24837. * @since 4.0.0
  24838. * @category Lang
  24839. * @param {*} value The value to check.
  24840. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  24841. * @example
  24842. *
  24843. * _.isObjectLike({});
  24844. * // => true
  24845. *
  24846. * _.isObjectLike([1, 2, 3]);
  24847. * // => true
  24848. *
  24849. * _.isObjectLike(_.noop);
  24850. * // => false
  24851. *
  24852. * _.isObjectLike(null);
  24853. * // => false
  24854. */
  24855. function isObjectLike(value) {
  24856. return value != null && typeof value == 'object';
  24857. }
  24858. /**
  24859. * Checks if `value` is classified as a `Map` object.
  24860. *
  24861. * @static
  24862. * @memberOf _
  24863. * @since 4.3.0
  24864. * @category Lang
  24865. * @param {*} value The value to check.
  24866. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  24867. * @example
  24868. *
  24869. * _.isMap(new Map);
  24870. * // => true
  24871. *
  24872. * _.isMap(new WeakMap);
  24873. * // => false
  24874. */
  24875. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  24876. /**
  24877. * Performs a partial deep comparison between `object` and `source` to
  24878. * determine if `object` contains equivalent property values.
  24879. *
  24880. * **Note:** This method is equivalent to `_.matches` when `source` is
  24881. * partially applied.
  24882. *
  24883. * Partial comparisons will match empty array and empty object `source`
  24884. * values against any array or object value, respectively. See `_.isEqual`
  24885. * for a list of supported value comparisons.
  24886. *
  24887. * @static
  24888. * @memberOf _
  24889. * @since 3.0.0
  24890. * @category Lang
  24891. * @param {Object} object The object to inspect.
  24892. * @param {Object} source The object of property values to match.
  24893. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24894. * @example
  24895. *
  24896. * var object = { 'a': 1, 'b': 2 };
  24897. *
  24898. * _.isMatch(object, { 'b': 2 });
  24899. * // => true
  24900. *
  24901. * _.isMatch(object, { 'b': 1 });
  24902. * // => false
  24903. */
  24904. function isMatch(object, source) {
  24905. return object === source || baseIsMatch(object, source, getMatchData(source));
  24906. }
  24907. /**
  24908. * This method is like `_.isMatch` except that it accepts `customizer` which
  24909. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24910. * are handled by the method instead. The `customizer` is invoked with five
  24911. * arguments: (objValue, srcValue, index|key, object, source).
  24912. *
  24913. * @static
  24914. * @memberOf _
  24915. * @since 4.0.0
  24916. * @category Lang
  24917. * @param {Object} object The object to inspect.
  24918. * @param {Object} source The object of property values to match.
  24919. * @param {Function} [customizer] The function to customize comparisons.
  24920. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24921. * @example
  24922. *
  24923. * function isGreeting(value) {
  24924. * return /^h(?:i|ello)$/.test(value);
  24925. * }
  24926. *
  24927. * function customizer(objValue, srcValue) {
  24928. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  24929. * return true;
  24930. * }
  24931. * }
  24932. *
  24933. * var object = { 'greeting': 'hello' };
  24934. * var source = { 'greeting': 'hi' };
  24935. *
  24936. * _.isMatchWith(object, source, customizer);
  24937. * // => true
  24938. */
  24939. function isMatchWith(object, source, customizer) {
  24940. customizer = typeof customizer == 'function' ? customizer : undefined;
  24941. return baseIsMatch(object, source, getMatchData(source), customizer);
  24942. }
  24943. /**
  24944. * Checks if `value` is `NaN`.
  24945. *
  24946. * **Note:** This method is based on
  24947. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  24948. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  24949. * `undefined` and other non-number values.
  24950. *
  24951. * @static
  24952. * @memberOf _
  24953. * @since 0.1.0
  24954. * @category Lang
  24955. * @param {*} value The value to check.
  24956. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  24957. * @example
  24958. *
  24959. * _.isNaN(NaN);
  24960. * // => true
  24961. *
  24962. * _.isNaN(new Number(NaN));
  24963. * // => true
  24964. *
  24965. * isNaN(undefined);
  24966. * // => true
  24967. *
  24968. * _.isNaN(undefined);
  24969. * // => false
  24970. */
  24971. function isNaN(value) {
  24972. // An `NaN` primitive is the only value that is not equal to itself.
  24973. // Perform the `toStringTag` check first to avoid errors with some
  24974. // ActiveX objects in IE.
  24975. return isNumber(value) && value != +value;
  24976. }
  24977. /**
  24978. * Checks if `value` is a pristine native function.
  24979. *
  24980. * **Note:** This method can't reliably detect native functions in the presence
  24981. * of the core-js package because core-js circumvents this kind of detection.
  24982. * Despite multiple requests, the core-js maintainer has made it clear: any
  24983. * attempt to fix the detection will be obstructed. As a result, we're left
  24984. * with little choice but to throw an error. Unfortunately, this also affects
  24985. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  24986. * which rely on core-js.
  24987. *
  24988. * @static
  24989. * @memberOf _
  24990. * @since 3.0.0
  24991. * @category Lang
  24992. * @param {*} value The value to check.
  24993. * @returns {boolean} Returns `true` if `value` is a native function,
  24994. * else `false`.
  24995. * @example
  24996. *
  24997. * _.isNative(Array.prototype.push);
  24998. * // => true
  24999. *
  25000. * _.isNative(_);
  25001. * // => false
  25002. */
  25003. function isNative(value) {
  25004. if (isMaskable(value)) {
  25005. throw new Error(CORE_ERROR_TEXT);
  25006. }
  25007. return baseIsNative(value);
  25008. }
  25009. /**
  25010. * Checks if `value` is `null`.
  25011. *
  25012. * @static
  25013. * @memberOf _
  25014. * @since 0.1.0
  25015. * @category Lang
  25016. * @param {*} value The value to check.
  25017. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  25018. * @example
  25019. *
  25020. * _.isNull(null);
  25021. * // => true
  25022. *
  25023. * _.isNull(void 0);
  25024. * // => false
  25025. */
  25026. function isNull(value) {
  25027. return value === null;
  25028. }
  25029. /**
  25030. * Checks if `value` is `null` or `undefined`.
  25031. *
  25032. * @static
  25033. * @memberOf _
  25034. * @since 4.0.0
  25035. * @category Lang
  25036. * @param {*} value The value to check.
  25037. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  25038. * @example
  25039. *
  25040. * _.isNil(null);
  25041. * // => true
  25042. *
  25043. * _.isNil(void 0);
  25044. * // => true
  25045. *
  25046. * _.isNil(NaN);
  25047. * // => false
  25048. */
  25049. function isNil(value) {
  25050. return value == null;
  25051. }
  25052. /**
  25053. * Checks if `value` is classified as a `Number` primitive or object.
  25054. *
  25055. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  25056. * classified as numbers, use the `_.isFinite` method.
  25057. *
  25058. * @static
  25059. * @memberOf _
  25060. * @since 0.1.0
  25061. * @category Lang
  25062. * @param {*} value The value to check.
  25063. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  25064. * @example
  25065. *
  25066. * _.isNumber(3);
  25067. * // => true
  25068. *
  25069. * _.isNumber(Number.MIN_VALUE);
  25070. * // => true
  25071. *
  25072. * _.isNumber(Infinity);
  25073. * // => true
  25074. *
  25075. * _.isNumber('3');
  25076. * // => false
  25077. */
  25078. function isNumber(value) {
  25079. return typeof value == 'number' ||
  25080. (isObjectLike(value) && baseGetTag(value) == numberTag);
  25081. }
  25082. /**
  25083. * Checks if `value` is a plain object, that is, an object created by the
  25084. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  25085. *
  25086. * @static
  25087. * @memberOf _
  25088. * @since 0.8.0
  25089. * @category Lang
  25090. * @param {*} value The value to check.
  25091. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  25092. * @example
  25093. *
  25094. * function Foo() {
  25095. * this.a = 1;
  25096. * }
  25097. *
  25098. * _.isPlainObject(new Foo);
  25099. * // => false
  25100. *
  25101. * _.isPlainObject([1, 2, 3]);
  25102. * // => false
  25103. *
  25104. * _.isPlainObject({ 'x': 0, 'y': 0 });
  25105. * // => true
  25106. *
  25107. * _.isPlainObject(Object.create(null));
  25108. * // => true
  25109. */
  25110. function isPlainObject(value) {
  25111. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  25112. return false;
  25113. }
  25114. var proto = getPrototype(value);
  25115. if (proto === null) {
  25116. return true;
  25117. }
  25118. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  25119. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  25120. funcToString.call(Ctor) == objectCtorString;
  25121. }
  25122. /**
  25123. * Checks if `value` is classified as a `RegExp` object.
  25124. *
  25125. * @static
  25126. * @memberOf _
  25127. * @since 0.1.0
  25128. * @category Lang
  25129. * @param {*} value The value to check.
  25130. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  25131. * @example
  25132. *
  25133. * _.isRegExp(/abc/);
  25134. * // => true
  25135. *
  25136. * _.isRegExp('/abc/');
  25137. * // => false
  25138. */
  25139. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  25140. /**
  25141. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  25142. * double precision number which isn't the result of a rounded unsafe integer.
  25143. *
  25144. * **Note:** This method is based on
  25145. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  25146. *
  25147. * @static
  25148. * @memberOf _
  25149. * @since 4.0.0
  25150. * @category Lang
  25151. * @param {*} value The value to check.
  25152. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  25153. * @example
  25154. *
  25155. * _.isSafeInteger(3);
  25156. * // => true
  25157. *
  25158. * _.isSafeInteger(Number.MIN_VALUE);
  25159. * // => false
  25160. *
  25161. * _.isSafeInteger(Infinity);
  25162. * // => false
  25163. *
  25164. * _.isSafeInteger('3');
  25165. * // => false
  25166. */
  25167. function isSafeInteger(value) {
  25168. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  25169. }
  25170. /**
  25171. * Checks if `value` is classified as a `Set` object.
  25172. *
  25173. * @static
  25174. * @memberOf _
  25175. * @since 4.3.0
  25176. * @category Lang
  25177. * @param {*} value The value to check.
  25178. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  25179. * @example
  25180. *
  25181. * _.isSet(new Set);
  25182. * // => true
  25183. *
  25184. * _.isSet(new WeakSet);
  25185. * // => false
  25186. */
  25187. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  25188. /**
  25189. * Checks if `value` is classified as a `String` primitive or object.
  25190. *
  25191. * @static
  25192. * @since 0.1.0
  25193. * @memberOf _
  25194. * @category Lang
  25195. * @param {*} value The value to check.
  25196. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  25197. * @example
  25198. *
  25199. * _.isString('abc');
  25200. * // => true
  25201. *
  25202. * _.isString(1);
  25203. * // => false
  25204. */
  25205. function isString(value) {
  25206. return typeof value == 'string' ||
  25207. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  25208. }
  25209. /**
  25210. * Checks if `value` is classified as a `Symbol` primitive or object.
  25211. *
  25212. * @static
  25213. * @memberOf _
  25214. * @since 4.0.0
  25215. * @category Lang
  25216. * @param {*} value The value to check.
  25217. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  25218. * @example
  25219. *
  25220. * _.isSymbol(Symbol.iterator);
  25221. * // => true
  25222. *
  25223. * _.isSymbol('abc');
  25224. * // => false
  25225. */
  25226. function isSymbol(value) {
  25227. return typeof value == 'symbol' ||
  25228. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  25229. }
  25230. /**
  25231. * Checks if `value` is classified as a typed array.
  25232. *
  25233. * @static
  25234. * @memberOf _
  25235. * @since 3.0.0
  25236. * @category Lang
  25237. * @param {*} value The value to check.
  25238. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  25239. * @example
  25240. *
  25241. * _.isTypedArray(new Uint8Array);
  25242. * // => true
  25243. *
  25244. * _.isTypedArray([]);
  25245. * // => false
  25246. */
  25247. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  25248. /**
  25249. * Checks if `value` is `undefined`.
  25250. *
  25251. * @static
  25252. * @since 0.1.0
  25253. * @memberOf _
  25254. * @category Lang
  25255. * @param {*} value The value to check.
  25256. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  25257. * @example
  25258. *
  25259. * _.isUndefined(void 0);
  25260. * // => true
  25261. *
  25262. * _.isUndefined(null);
  25263. * // => false
  25264. */
  25265. function isUndefined(value) {
  25266. return value === undefined;
  25267. }
  25268. /**
  25269. * Checks if `value` is classified as a `WeakMap` object.
  25270. *
  25271. * @static
  25272. * @memberOf _
  25273. * @since 4.3.0
  25274. * @category Lang
  25275. * @param {*} value The value to check.
  25276. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  25277. * @example
  25278. *
  25279. * _.isWeakMap(new WeakMap);
  25280. * // => true
  25281. *
  25282. * _.isWeakMap(new Map);
  25283. * // => false
  25284. */
  25285. function isWeakMap(value) {
  25286. return isObjectLike(value) && getTag(value) == weakMapTag;
  25287. }
  25288. /**
  25289. * Checks if `value` is classified as a `WeakSet` object.
  25290. *
  25291. * @static
  25292. * @memberOf _
  25293. * @since 4.3.0
  25294. * @category Lang
  25295. * @param {*} value The value to check.
  25296. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  25297. * @example
  25298. *
  25299. * _.isWeakSet(new WeakSet);
  25300. * // => true
  25301. *
  25302. * _.isWeakSet(new Set);
  25303. * // => false
  25304. */
  25305. function isWeakSet(value) {
  25306. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  25307. }
  25308. /**
  25309. * Checks if `value` is less than `other`.
  25310. *
  25311. * @static
  25312. * @memberOf _
  25313. * @since 3.9.0
  25314. * @category Lang
  25315. * @param {*} value The value to compare.
  25316. * @param {*} other The other value to compare.
  25317. * @returns {boolean} Returns `true` if `value` is less than `other`,
  25318. * else `false`.
  25319. * @see _.gt
  25320. * @example
  25321. *
  25322. * _.lt(1, 3);
  25323. * // => true
  25324. *
  25325. * _.lt(3, 3);
  25326. * // => false
  25327. *
  25328. * _.lt(3, 1);
  25329. * // => false
  25330. */
  25331. var lt = createRelationalOperation(baseLt);
  25332. /**
  25333. * Checks if `value` is less than or equal to `other`.
  25334. *
  25335. * @static
  25336. * @memberOf _
  25337. * @since 3.9.0
  25338. * @category Lang
  25339. * @param {*} value The value to compare.
  25340. * @param {*} other The other value to compare.
  25341. * @returns {boolean} Returns `true` if `value` is less than or equal to
  25342. * `other`, else `false`.
  25343. * @see _.gte
  25344. * @example
  25345. *
  25346. * _.lte(1, 3);
  25347. * // => true
  25348. *
  25349. * _.lte(3, 3);
  25350. * // => true
  25351. *
  25352. * _.lte(3, 1);
  25353. * // => false
  25354. */
  25355. var lte = createRelationalOperation(function(value, other) {
  25356. return value <= other;
  25357. });
  25358. /**
  25359. * Converts `value` to an array.
  25360. *
  25361. * @static
  25362. * @since 0.1.0
  25363. * @memberOf _
  25364. * @category Lang
  25365. * @param {*} value The value to convert.
  25366. * @returns {Array} Returns the converted array.
  25367. * @example
  25368. *
  25369. * _.toArray({ 'a': 1, 'b': 2 });
  25370. * // => [1, 2]
  25371. *
  25372. * _.toArray('abc');
  25373. * // => ['a', 'b', 'c']
  25374. *
  25375. * _.toArray(1);
  25376. * // => []
  25377. *
  25378. * _.toArray(null);
  25379. * // => []
  25380. */
  25381. function toArray(value) {
  25382. if (!value) {
  25383. return [];
  25384. }
  25385. if (isArrayLike(value)) {
  25386. return isString(value) ? stringToArray(value) : copyArray(value);
  25387. }
  25388. if (symIterator && value[symIterator]) {
  25389. return iteratorToArray(value[symIterator]());
  25390. }
  25391. var tag = getTag(value),
  25392. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  25393. return func(value);
  25394. }
  25395. /**
  25396. * Converts `value` to a finite number.
  25397. *
  25398. * @static
  25399. * @memberOf _
  25400. * @since 4.12.0
  25401. * @category Lang
  25402. * @param {*} value The value to convert.
  25403. * @returns {number} Returns the converted number.
  25404. * @example
  25405. *
  25406. * _.toFinite(3.2);
  25407. * // => 3.2
  25408. *
  25409. * _.toFinite(Number.MIN_VALUE);
  25410. * // => 5e-324
  25411. *
  25412. * _.toFinite(Infinity);
  25413. * // => 1.7976931348623157e+308
  25414. *
  25415. * _.toFinite('3.2');
  25416. * // => 3.2
  25417. */
  25418. function toFinite(value) {
  25419. if (!value) {
  25420. return value === 0 ? value : 0;
  25421. }
  25422. value = toNumber(value);
  25423. if (value === INFINITY || value === -INFINITY) {
  25424. var sign = (value < 0 ? -1 : 1);
  25425. return sign * MAX_INTEGER;
  25426. }
  25427. return value === value ? value : 0;
  25428. }
  25429. /**
  25430. * Converts `value` to an integer.
  25431. *
  25432. * **Note:** This method is loosely based on
  25433. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  25434. *
  25435. * @static
  25436. * @memberOf _
  25437. * @since 4.0.0
  25438. * @category Lang
  25439. * @param {*} value The value to convert.
  25440. * @returns {number} Returns the converted integer.
  25441. * @example
  25442. *
  25443. * _.toInteger(3.2);
  25444. * // => 3
  25445. *
  25446. * _.toInteger(Number.MIN_VALUE);
  25447. * // => 0
  25448. *
  25449. * _.toInteger(Infinity);
  25450. * // => 1.7976931348623157e+308
  25451. *
  25452. * _.toInteger('3.2');
  25453. * // => 3
  25454. */
  25455. function toInteger(value) {
  25456. var result = toFinite(value),
  25457. remainder = result % 1;
  25458. return result === result ? (remainder ? result - remainder : result) : 0;
  25459. }
  25460. /**
  25461. * Converts `value` to an integer suitable for use as the length of an
  25462. * array-like object.
  25463. *
  25464. * **Note:** This method is based on
  25465. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  25466. *
  25467. * @static
  25468. * @memberOf _
  25469. * @since 4.0.0
  25470. * @category Lang
  25471. * @param {*} value The value to convert.
  25472. * @returns {number} Returns the converted integer.
  25473. * @example
  25474. *
  25475. * _.toLength(3.2);
  25476. * // => 3
  25477. *
  25478. * _.toLength(Number.MIN_VALUE);
  25479. * // => 0
  25480. *
  25481. * _.toLength(Infinity);
  25482. * // => 4294967295
  25483. *
  25484. * _.toLength('3.2');
  25485. * // => 3
  25486. */
  25487. function toLength(value) {
  25488. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  25489. }
  25490. /**
  25491. * Converts `value` to a number.
  25492. *
  25493. * @static
  25494. * @memberOf _
  25495. * @since 4.0.0
  25496. * @category Lang
  25497. * @param {*} value The value to process.
  25498. * @returns {number} Returns the number.
  25499. * @example
  25500. *
  25501. * _.toNumber(3.2);
  25502. * // => 3.2
  25503. *
  25504. * _.toNumber(Number.MIN_VALUE);
  25505. * // => 5e-324
  25506. *
  25507. * _.toNumber(Infinity);
  25508. * // => Infinity
  25509. *
  25510. * _.toNumber('3.2');
  25511. * // => 3.2
  25512. */
  25513. function toNumber(value) {
  25514. if (typeof value == 'number') {
  25515. return value;
  25516. }
  25517. if (isSymbol(value)) {
  25518. return NAN;
  25519. }
  25520. if (isObject(value)) {
  25521. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  25522. value = isObject(other) ? (other + '') : other;
  25523. }
  25524. if (typeof value != 'string') {
  25525. return value === 0 ? value : +value;
  25526. }
  25527. value = value.replace(reTrim, '');
  25528. var isBinary = reIsBinary.test(value);
  25529. return (isBinary || reIsOctal.test(value))
  25530. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  25531. : (reIsBadHex.test(value) ? NAN : +value);
  25532. }
  25533. /**
  25534. * Converts `value` to a plain object flattening inherited enumerable string
  25535. * keyed properties of `value` to own properties of the plain object.
  25536. *
  25537. * @static
  25538. * @memberOf _
  25539. * @since 3.0.0
  25540. * @category Lang
  25541. * @param {*} value The value to convert.
  25542. * @returns {Object} Returns the converted plain object.
  25543. * @example
  25544. *
  25545. * function Foo() {
  25546. * this.b = 2;
  25547. * }
  25548. *
  25549. * Foo.prototype.c = 3;
  25550. *
  25551. * _.assign({ 'a': 1 }, new Foo);
  25552. * // => { 'a': 1, 'b': 2 }
  25553. *
  25554. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  25555. * // => { 'a': 1, 'b': 2, 'c': 3 }
  25556. */
  25557. function toPlainObject(value) {
  25558. return copyObject(value, keysIn(value));
  25559. }
  25560. /**
  25561. * Converts `value` to a safe integer. A safe integer can be compared and
  25562. * represented correctly.
  25563. *
  25564. * @static
  25565. * @memberOf _
  25566. * @since 4.0.0
  25567. * @category Lang
  25568. * @param {*} value The value to convert.
  25569. * @returns {number} Returns the converted integer.
  25570. * @example
  25571. *
  25572. * _.toSafeInteger(3.2);
  25573. * // => 3
  25574. *
  25575. * _.toSafeInteger(Number.MIN_VALUE);
  25576. * // => 0
  25577. *
  25578. * _.toSafeInteger(Infinity);
  25579. * // => 9007199254740991
  25580. *
  25581. * _.toSafeInteger('3.2');
  25582. * // => 3
  25583. */
  25584. function toSafeInteger(value) {
  25585. return value
  25586. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  25587. : (value === 0 ? value : 0);
  25588. }
  25589. /**
  25590. * Converts `value` to a string. An empty string is returned for `null`
  25591. * and `undefined` values. The sign of `-0` is preserved.
  25592. *
  25593. * @static
  25594. * @memberOf _
  25595. * @since 4.0.0
  25596. * @category Lang
  25597. * @param {*} value The value to convert.
  25598. * @returns {string} Returns the converted string.
  25599. * @example
  25600. *
  25601. * _.toString(null);
  25602. * // => ''
  25603. *
  25604. * _.toString(-0);
  25605. * // => '-0'
  25606. *
  25607. * _.toString([1, 2, 3]);
  25608. * // => '1,2,3'
  25609. */
  25610. function toString(value) {
  25611. return value == null ? '' : baseToString(value);
  25612. }
  25613. /*------------------------------------------------------------------------*/
  25614. /**
  25615. * Assigns own enumerable string keyed properties of source objects to the
  25616. * destination object. Source objects are applied from left to right.
  25617. * Subsequent sources overwrite property assignments of previous sources.
  25618. *
  25619. * **Note:** This method mutates `object` and is loosely based on
  25620. * [`Object.assign`](https://mdn.io/Object/assign).
  25621. *
  25622. * @static
  25623. * @memberOf _
  25624. * @since 0.10.0
  25625. * @category Object
  25626. * @param {Object} object The destination object.
  25627. * @param {...Object} [sources] The source objects.
  25628. * @returns {Object} Returns `object`.
  25629. * @see _.assignIn
  25630. * @example
  25631. *
  25632. * function Foo() {
  25633. * this.a = 1;
  25634. * }
  25635. *
  25636. * function Bar() {
  25637. * this.c = 3;
  25638. * }
  25639. *
  25640. * Foo.prototype.b = 2;
  25641. * Bar.prototype.d = 4;
  25642. *
  25643. * _.assign({ 'a': 0 }, new Foo, new Bar);
  25644. * // => { 'a': 1, 'c': 3 }
  25645. */
  25646. var assign = createAssigner(function(object, source) {
  25647. if (isPrototype(source) || isArrayLike(source)) {
  25648. copyObject(source, keys(source), object);
  25649. return;
  25650. }
  25651. for (var key in source) {
  25652. if (hasOwnProperty.call(source, key)) {
  25653. assignValue(object, key, source[key]);
  25654. }
  25655. }
  25656. });
  25657. /**
  25658. * This method is like `_.assign` except that it iterates over own and
  25659. * inherited source properties.
  25660. *
  25661. * **Note:** This method mutates `object`.
  25662. *
  25663. * @static
  25664. * @memberOf _
  25665. * @since 4.0.0
  25666. * @alias extend
  25667. * @category Object
  25668. * @param {Object} object The destination object.
  25669. * @param {...Object} [sources] The source objects.
  25670. * @returns {Object} Returns `object`.
  25671. * @see _.assign
  25672. * @example
  25673. *
  25674. * function Foo() {
  25675. * this.a = 1;
  25676. * }
  25677. *
  25678. * function Bar() {
  25679. * this.c = 3;
  25680. * }
  25681. *
  25682. * Foo.prototype.b = 2;
  25683. * Bar.prototype.d = 4;
  25684. *
  25685. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  25686. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  25687. */
  25688. var assignIn = createAssigner(function(object, source) {
  25689. copyObject(source, keysIn(source), object);
  25690. });
  25691. /**
  25692. * This method is like `_.assignIn` except that it accepts `customizer`
  25693. * which is invoked to produce the assigned values. If `customizer` returns
  25694. * `undefined`, assignment is handled by the method instead. The `customizer`
  25695. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25696. *
  25697. * **Note:** This method mutates `object`.
  25698. *
  25699. * @static
  25700. * @memberOf _
  25701. * @since 4.0.0
  25702. * @alias extendWith
  25703. * @category Object
  25704. * @param {Object} object The destination object.
  25705. * @param {...Object} sources The source objects.
  25706. * @param {Function} [customizer] The function to customize assigned values.
  25707. * @returns {Object} Returns `object`.
  25708. * @see _.assignWith
  25709. * @example
  25710. *
  25711. * function customizer(objValue, srcValue) {
  25712. * return _.isUndefined(objValue) ? srcValue : objValue;
  25713. * }
  25714. *
  25715. * var defaults = _.partialRight(_.assignInWith, customizer);
  25716. *
  25717. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25718. * // => { 'a': 1, 'b': 2 }
  25719. */
  25720. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  25721. copyObject(source, keysIn(source), object, customizer);
  25722. });
  25723. /**
  25724. * This method is like `_.assign` except that it accepts `customizer`
  25725. * which is invoked to produce the assigned values. If `customizer` returns
  25726. * `undefined`, assignment is handled by the method instead. The `customizer`
  25727. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25728. *
  25729. * **Note:** This method mutates `object`.
  25730. *
  25731. * @static
  25732. * @memberOf _
  25733. * @since 4.0.0
  25734. * @category Object
  25735. * @param {Object} object The destination object.
  25736. * @param {...Object} sources The source objects.
  25737. * @param {Function} [customizer] The function to customize assigned values.
  25738. * @returns {Object} Returns `object`.
  25739. * @see _.assignInWith
  25740. * @example
  25741. *
  25742. * function customizer(objValue, srcValue) {
  25743. * return _.isUndefined(objValue) ? srcValue : objValue;
  25744. * }
  25745. *
  25746. * var defaults = _.partialRight(_.assignWith, customizer);
  25747. *
  25748. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25749. * // => { 'a': 1, 'b': 2 }
  25750. */
  25751. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  25752. copyObject(source, keys(source), object, customizer);
  25753. });
  25754. /**
  25755. * Creates an array of values corresponding to `paths` of `object`.
  25756. *
  25757. * @static
  25758. * @memberOf _
  25759. * @since 1.0.0
  25760. * @category Object
  25761. * @param {Object} object The object to iterate over.
  25762. * @param {...(string|string[])} [paths] The property paths to pick.
  25763. * @returns {Array} Returns the picked values.
  25764. * @example
  25765. *
  25766. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25767. *
  25768. * _.at(object, ['a[0].b.c', 'a[1]']);
  25769. * // => [3, 4]
  25770. */
  25771. var at = flatRest(baseAt);
  25772. /**
  25773. * Creates an object that inherits from the `prototype` object. If a
  25774. * `properties` object is given, its own enumerable string keyed properties
  25775. * are assigned to the created object.
  25776. *
  25777. * @static
  25778. * @memberOf _
  25779. * @since 2.3.0
  25780. * @category Object
  25781. * @param {Object} prototype The object to inherit from.
  25782. * @param {Object} [properties] The properties to assign to the object.
  25783. * @returns {Object} Returns the new object.
  25784. * @example
  25785. *
  25786. * function Shape() {
  25787. * this.x = 0;
  25788. * this.y = 0;
  25789. * }
  25790. *
  25791. * function Circle() {
  25792. * Shape.call(this);
  25793. * }
  25794. *
  25795. * Circle.prototype = _.create(Shape.prototype, {
  25796. * 'constructor': Circle
  25797. * });
  25798. *
  25799. * var circle = new Circle;
  25800. * circle instanceof Circle;
  25801. * // => true
  25802. *
  25803. * circle instanceof Shape;
  25804. * // => true
  25805. */
  25806. function create(prototype, properties) {
  25807. var result = baseCreate(prototype);
  25808. return properties == null ? result : baseAssign(result, properties);
  25809. }
  25810. /**
  25811. * Assigns own and inherited enumerable string keyed properties of source
  25812. * objects to the destination object for all destination properties that
  25813. * resolve to `undefined`. Source objects are applied from left to right.
  25814. * Once a property is set, additional values of the same property are ignored.
  25815. *
  25816. * **Note:** This method mutates `object`.
  25817. *
  25818. * @static
  25819. * @since 0.1.0
  25820. * @memberOf _
  25821. * @category Object
  25822. * @param {Object} object The destination object.
  25823. * @param {...Object} [sources] The source objects.
  25824. * @returns {Object} Returns `object`.
  25825. * @see _.defaultsDeep
  25826. * @example
  25827. *
  25828. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25829. * // => { 'a': 1, 'b': 2 }
  25830. */
  25831. var defaults = baseRest(function(object, sources) {
  25832. object = Object(object);
  25833. var index = -1;
  25834. var length = sources.length;
  25835. var guard = length > 2 ? sources[2] : undefined;
  25836. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  25837. length = 1;
  25838. }
  25839. while (++index < length) {
  25840. var source = sources[index];
  25841. var props = keysIn(source);
  25842. var propsIndex = -1;
  25843. var propsLength = props.length;
  25844. while (++propsIndex < propsLength) {
  25845. var key = props[propsIndex];
  25846. var value = object[key];
  25847. if (value === undefined ||
  25848. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  25849. object[key] = source[key];
  25850. }
  25851. }
  25852. }
  25853. return object;
  25854. });
  25855. /**
  25856. * This method is like `_.defaults` except that it recursively assigns
  25857. * default properties.
  25858. *
  25859. * **Note:** This method mutates `object`.
  25860. *
  25861. * @static
  25862. * @memberOf _
  25863. * @since 3.10.0
  25864. * @category Object
  25865. * @param {Object} object The destination object.
  25866. * @param {...Object} [sources] The source objects.
  25867. * @returns {Object} Returns `object`.
  25868. * @see _.defaults
  25869. * @example
  25870. *
  25871. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  25872. * // => { 'a': { 'b': 2, 'c': 3 } }
  25873. */
  25874. var defaultsDeep = baseRest(function(args) {
  25875. args.push(undefined, customDefaultsMerge);
  25876. return apply(mergeWith, undefined, args);
  25877. });
  25878. /**
  25879. * This method is like `_.find` except that it returns the key of the first
  25880. * element `predicate` returns truthy for instead of the element itself.
  25881. *
  25882. * @static
  25883. * @memberOf _
  25884. * @since 1.1.0
  25885. * @category Object
  25886. * @param {Object} object The object to inspect.
  25887. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25888. * @returns {string|undefined} Returns the key of the matched element,
  25889. * else `undefined`.
  25890. * @example
  25891. *
  25892. * var users = {
  25893. * 'barney': { 'age': 36, 'active': true },
  25894. * 'fred': { 'age': 40, 'active': false },
  25895. * 'pebbles': { 'age': 1, 'active': true }
  25896. * };
  25897. *
  25898. * _.findKey(users, function(o) { return o.age < 40; });
  25899. * // => 'barney' (iteration order is not guaranteed)
  25900. *
  25901. * // The `_.matches` iteratee shorthand.
  25902. * _.findKey(users, { 'age': 1, 'active': true });
  25903. * // => 'pebbles'
  25904. *
  25905. * // The `_.matchesProperty` iteratee shorthand.
  25906. * _.findKey(users, ['active', false]);
  25907. * // => 'fred'
  25908. *
  25909. * // The `_.property` iteratee shorthand.
  25910. * _.findKey(users, 'active');
  25911. * // => 'barney'
  25912. */
  25913. function findKey(object, predicate) {
  25914. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  25915. }
  25916. /**
  25917. * This method is like `_.findKey` except that it iterates over elements of
  25918. * a collection in the opposite order.
  25919. *
  25920. * @static
  25921. * @memberOf _
  25922. * @since 2.0.0
  25923. * @category Object
  25924. * @param {Object} object The object to inspect.
  25925. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25926. * @returns {string|undefined} Returns the key of the matched element,
  25927. * else `undefined`.
  25928. * @example
  25929. *
  25930. * var users = {
  25931. * 'barney': { 'age': 36, 'active': true },
  25932. * 'fred': { 'age': 40, 'active': false },
  25933. * 'pebbles': { 'age': 1, 'active': true }
  25934. * };
  25935. *
  25936. * _.findLastKey(users, function(o) { return o.age < 40; });
  25937. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  25938. *
  25939. * // The `_.matches` iteratee shorthand.
  25940. * _.findLastKey(users, { 'age': 36, 'active': true });
  25941. * // => 'barney'
  25942. *
  25943. * // The `_.matchesProperty` iteratee shorthand.
  25944. * _.findLastKey(users, ['active', false]);
  25945. * // => 'fred'
  25946. *
  25947. * // The `_.property` iteratee shorthand.
  25948. * _.findLastKey(users, 'active');
  25949. * // => 'pebbles'
  25950. */
  25951. function findLastKey(object, predicate) {
  25952. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  25953. }
  25954. /**
  25955. * Iterates over own and inherited enumerable string keyed properties of an
  25956. * object and invokes `iteratee` for each property. The iteratee is invoked
  25957. * with three arguments: (value, key, object). Iteratee functions may exit
  25958. * iteration early by explicitly returning `false`.
  25959. *
  25960. * @static
  25961. * @memberOf _
  25962. * @since 0.3.0
  25963. * @category Object
  25964. * @param {Object} object The object to iterate over.
  25965. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25966. * @returns {Object} Returns `object`.
  25967. * @see _.forInRight
  25968. * @example
  25969. *
  25970. * function Foo() {
  25971. * this.a = 1;
  25972. * this.b = 2;
  25973. * }
  25974. *
  25975. * Foo.prototype.c = 3;
  25976. *
  25977. * _.forIn(new Foo, function(value, key) {
  25978. * console.log(key);
  25979. * });
  25980. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  25981. */
  25982. function forIn(object, iteratee) {
  25983. return object == null
  25984. ? object
  25985. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  25986. }
  25987. /**
  25988. * This method is like `_.forIn` except that it iterates over properties of
  25989. * `object` in the opposite order.
  25990. *
  25991. * @static
  25992. * @memberOf _
  25993. * @since 2.0.0
  25994. * @category Object
  25995. * @param {Object} object The object to iterate over.
  25996. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25997. * @returns {Object} Returns `object`.
  25998. * @see _.forIn
  25999. * @example
  26000. *
  26001. * function Foo() {
  26002. * this.a = 1;
  26003. * this.b = 2;
  26004. * }
  26005. *
  26006. * Foo.prototype.c = 3;
  26007. *
  26008. * _.forInRight(new Foo, function(value, key) {
  26009. * console.log(key);
  26010. * });
  26011. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  26012. */
  26013. function forInRight(object, iteratee) {
  26014. return object == null
  26015. ? object
  26016. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  26017. }
  26018. /**
  26019. * Iterates over own enumerable string keyed properties of an object and
  26020. * invokes `iteratee` for each property. The iteratee is invoked with three
  26021. * arguments: (value, key, object). Iteratee functions may exit iteration
  26022. * early by explicitly returning `false`.
  26023. *
  26024. * @static
  26025. * @memberOf _
  26026. * @since 0.3.0
  26027. * @category Object
  26028. * @param {Object} object The object to iterate over.
  26029. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26030. * @returns {Object} Returns `object`.
  26031. * @see _.forOwnRight
  26032. * @example
  26033. *
  26034. * function Foo() {
  26035. * this.a = 1;
  26036. * this.b = 2;
  26037. * }
  26038. *
  26039. * Foo.prototype.c = 3;
  26040. *
  26041. * _.forOwn(new Foo, function(value, key) {
  26042. * console.log(key);
  26043. * });
  26044. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26045. */
  26046. function forOwn(object, iteratee) {
  26047. return object && baseForOwn(object, getIteratee(iteratee, 3));
  26048. }
  26049. /**
  26050. * This method is like `_.forOwn` except that it iterates over properties of
  26051. * `object` in the opposite order.
  26052. *
  26053. * @static
  26054. * @memberOf _
  26055. * @since 2.0.0
  26056. * @category Object
  26057. * @param {Object} object The object to iterate over.
  26058. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26059. * @returns {Object} Returns `object`.
  26060. * @see _.forOwn
  26061. * @example
  26062. *
  26063. * function Foo() {
  26064. * this.a = 1;
  26065. * this.b = 2;
  26066. * }
  26067. *
  26068. * Foo.prototype.c = 3;
  26069. *
  26070. * _.forOwnRight(new Foo, function(value, key) {
  26071. * console.log(key);
  26072. * });
  26073. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  26074. */
  26075. function forOwnRight(object, iteratee) {
  26076. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  26077. }
  26078. /**
  26079. * Creates an array of function property names from own enumerable properties
  26080. * of `object`.
  26081. *
  26082. * @static
  26083. * @since 0.1.0
  26084. * @memberOf _
  26085. * @category Object
  26086. * @param {Object} object The object to inspect.
  26087. * @returns {Array} Returns the function names.
  26088. * @see _.functionsIn
  26089. * @example
  26090. *
  26091. * function Foo() {
  26092. * this.a = _.constant('a');
  26093. * this.b = _.constant('b');
  26094. * }
  26095. *
  26096. * Foo.prototype.c = _.constant('c');
  26097. *
  26098. * _.functions(new Foo);
  26099. * // => ['a', 'b']
  26100. */
  26101. function functions(object) {
  26102. return object == null ? [] : baseFunctions(object, keys(object));
  26103. }
  26104. /**
  26105. * Creates an array of function property names from own and inherited
  26106. * enumerable properties of `object`.
  26107. *
  26108. * @static
  26109. * @memberOf _
  26110. * @since 4.0.0
  26111. * @category Object
  26112. * @param {Object} object The object to inspect.
  26113. * @returns {Array} Returns the function names.
  26114. * @see _.functions
  26115. * @example
  26116. *
  26117. * function Foo() {
  26118. * this.a = _.constant('a');
  26119. * this.b = _.constant('b');
  26120. * }
  26121. *
  26122. * Foo.prototype.c = _.constant('c');
  26123. *
  26124. * _.functionsIn(new Foo);
  26125. * // => ['a', 'b', 'c']
  26126. */
  26127. function functionsIn(object) {
  26128. return object == null ? [] : baseFunctions(object, keysIn(object));
  26129. }
  26130. /**
  26131. * Gets the value at `path` of `object`. If the resolved value is
  26132. * `undefined`, the `defaultValue` is returned in its place.
  26133. *
  26134. * @static
  26135. * @memberOf _
  26136. * @since 3.7.0
  26137. * @category Object
  26138. * @param {Object} object The object to query.
  26139. * @param {Array|string} path The path of the property to get.
  26140. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26141. * @returns {*} Returns the resolved value.
  26142. * @example
  26143. *
  26144. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26145. *
  26146. * _.get(object, 'a[0].b.c');
  26147. * // => 3
  26148. *
  26149. * _.get(object, ['a', '0', 'b', 'c']);
  26150. * // => 3
  26151. *
  26152. * _.get(object, 'a.b.c', 'default');
  26153. * // => 'default'
  26154. */
  26155. function get(object, path, defaultValue) {
  26156. var result = object == null ? undefined : baseGet(object, path);
  26157. return result === undefined ? defaultValue : result;
  26158. }
  26159. /**
  26160. * Checks if `path` is a direct property of `object`.
  26161. *
  26162. * @static
  26163. * @since 0.1.0
  26164. * @memberOf _
  26165. * @category Object
  26166. * @param {Object} object The object to query.
  26167. * @param {Array|string} path The path to check.
  26168. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26169. * @example
  26170. *
  26171. * var object = { 'a': { 'b': 2 } };
  26172. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  26173. *
  26174. * _.has(object, 'a');
  26175. * // => true
  26176. *
  26177. * _.has(object, 'a.b');
  26178. * // => true
  26179. *
  26180. * _.has(object, ['a', 'b']);
  26181. * // => true
  26182. *
  26183. * _.has(other, 'a');
  26184. * // => false
  26185. */
  26186. function has(object, path) {
  26187. return object != null && hasPath(object, path, baseHas);
  26188. }
  26189. /**
  26190. * Checks if `path` is a direct or inherited property of `object`.
  26191. *
  26192. * @static
  26193. * @memberOf _
  26194. * @since 4.0.0
  26195. * @category Object
  26196. * @param {Object} object The object to query.
  26197. * @param {Array|string} path The path to check.
  26198. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26199. * @example
  26200. *
  26201. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  26202. *
  26203. * _.hasIn(object, 'a');
  26204. * // => true
  26205. *
  26206. * _.hasIn(object, 'a.b');
  26207. * // => true
  26208. *
  26209. * _.hasIn(object, ['a', 'b']);
  26210. * // => true
  26211. *
  26212. * _.hasIn(object, 'b');
  26213. * // => false
  26214. */
  26215. function hasIn(object, path) {
  26216. return object != null && hasPath(object, path, baseHasIn);
  26217. }
  26218. /**
  26219. * Creates an object composed of the inverted keys and values of `object`.
  26220. * If `object` contains duplicate values, subsequent values overwrite
  26221. * property assignments of previous values.
  26222. *
  26223. * @static
  26224. * @memberOf _
  26225. * @since 0.7.0
  26226. * @category Object
  26227. * @param {Object} object The object to invert.
  26228. * @returns {Object} Returns the new inverted object.
  26229. * @example
  26230. *
  26231. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26232. *
  26233. * _.invert(object);
  26234. * // => { '1': 'c', '2': 'b' }
  26235. */
  26236. var invert = createInverter(function(result, value, key) {
  26237. if (value != null &&
  26238. typeof value.toString != 'function') {
  26239. value = nativeObjectToString.call(value);
  26240. }
  26241. result[value] = key;
  26242. }, constant(identity));
  26243. /**
  26244. * This method is like `_.invert` except that the inverted object is generated
  26245. * from the results of running each element of `object` thru `iteratee`. The
  26246. * corresponding inverted value of each inverted key is an array of keys
  26247. * responsible for generating the inverted value. The iteratee is invoked
  26248. * with one argument: (value).
  26249. *
  26250. * @static
  26251. * @memberOf _
  26252. * @since 4.1.0
  26253. * @category Object
  26254. * @param {Object} object The object to invert.
  26255. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  26256. * @returns {Object} Returns the new inverted object.
  26257. * @example
  26258. *
  26259. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26260. *
  26261. * _.invertBy(object);
  26262. * // => { '1': ['a', 'c'], '2': ['b'] }
  26263. *
  26264. * _.invertBy(object, function(value) {
  26265. * return 'group' + value;
  26266. * });
  26267. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  26268. */
  26269. var invertBy = createInverter(function(result, value, key) {
  26270. if (value != null &&
  26271. typeof value.toString != 'function') {
  26272. value = nativeObjectToString.call(value);
  26273. }
  26274. if (hasOwnProperty.call(result, value)) {
  26275. result[value].push(key);
  26276. } else {
  26277. result[value] = [key];
  26278. }
  26279. }, getIteratee);
  26280. /**
  26281. * Invokes the method at `path` of `object`.
  26282. *
  26283. * @static
  26284. * @memberOf _
  26285. * @since 4.0.0
  26286. * @category Object
  26287. * @param {Object} object The object to query.
  26288. * @param {Array|string} path The path of the method to invoke.
  26289. * @param {...*} [args] The arguments to invoke the method with.
  26290. * @returns {*} Returns the result of the invoked method.
  26291. * @example
  26292. *
  26293. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  26294. *
  26295. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  26296. * // => [2, 3]
  26297. */
  26298. var invoke = baseRest(baseInvoke);
  26299. /**
  26300. * Creates an array of the own enumerable property names of `object`.
  26301. *
  26302. * **Note:** Non-object values are coerced to objects. See the
  26303. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  26304. * for more details.
  26305. *
  26306. * @static
  26307. * @since 0.1.0
  26308. * @memberOf _
  26309. * @category Object
  26310. * @param {Object} object The object to query.
  26311. * @returns {Array} Returns the array of property names.
  26312. * @example
  26313. *
  26314. * function Foo() {
  26315. * this.a = 1;
  26316. * this.b = 2;
  26317. * }
  26318. *
  26319. * Foo.prototype.c = 3;
  26320. *
  26321. * _.keys(new Foo);
  26322. * // => ['a', 'b'] (iteration order is not guaranteed)
  26323. *
  26324. * _.keys('hi');
  26325. * // => ['0', '1']
  26326. */
  26327. function keys(object) {
  26328. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  26329. }
  26330. /**
  26331. * Creates an array of the own and inherited enumerable property names of `object`.
  26332. *
  26333. * **Note:** Non-object values are coerced to objects.
  26334. *
  26335. * @static
  26336. * @memberOf _
  26337. * @since 3.0.0
  26338. * @category Object
  26339. * @param {Object} object The object to query.
  26340. * @returns {Array} Returns the array of property names.
  26341. * @example
  26342. *
  26343. * function Foo() {
  26344. * this.a = 1;
  26345. * this.b = 2;
  26346. * }
  26347. *
  26348. * Foo.prototype.c = 3;
  26349. *
  26350. * _.keysIn(new Foo);
  26351. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  26352. */
  26353. function keysIn(object) {
  26354. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  26355. }
  26356. /**
  26357. * The opposite of `_.mapValues`; this method creates an object with the
  26358. * same values as `object` and keys generated by running each own enumerable
  26359. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  26360. * with three arguments: (value, key, object).
  26361. *
  26362. * @static
  26363. * @memberOf _
  26364. * @since 3.8.0
  26365. * @category Object
  26366. * @param {Object} object The object to iterate over.
  26367. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26368. * @returns {Object} Returns the new mapped object.
  26369. * @see _.mapValues
  26370. * @example
  26371. *
  26372. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  26373. * return key + value;
  26374. * });
  26375. * // => { 'a1': 1, 'b2': 2 }
  26376. */
  26377. function mapKeys(object, iteratee) {
  26378. var result = {};
  26379. iteratee = getIteratee(iteratee, 3);
  26380. baseForOwn(object, function(value, key, object) {
  26381. baseAssignValue(result, iteratee(value, key, object), value);
  26382. });
  26383. return result;
  26384. }
  26385. /**
  26386. * Creates an object with the same keys as `object` and values generated
  26387. * by running each own enumerable string keyed property of `object` thru
  26388. * `iteratee`. The iteratee is invoked with three arguments:
  26389. * (value, key, object).
  26390. *
  26391. * @static
  26392. * @memberOf _
  26393. * @since 2.4.0
  26394. * @category Object
  26395. * @param {Object} object The object to iterate over.
  26396. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26397. * @returns {Object} Returns the new mapped object.
  26398. * @see _.mapKeys
  26399. * @example
  26400. *
  26401. * var users = {
  26402. * 'fred': { 'user': 'fred', 'age': 40 },
  26403. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  26404. * };
  26405. *
  26406. * _.mapValues(users, function(o) { return o.age; });
  26407. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26408. *
  26409. * // The `_.property` iteratee shorthand.
  26410. * _.mapValues(users, 'age');
  26411. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26412. */
  26413. function mapValues(object, iteratee) {
  26414. var result = {};
  26415. iteratee = getIteratee(iteratee, 3);
  26416. baseForOwn(object, function(value, key, object) {
  26417. baseAssignValue(result, key, iteratee(value, key, object));
  26418. });
  26419. return result;
  26420. }
  26421. /**
  26422. * This method is like `_.assign` except that it recursively merges own and
  26423. * inherited enumerable string keyed properties of source objects into the
  26424. * destination object. Source properties that resolve to `undefined` are
  26425. * skipped if a destination value exists. Array and plain object properties
  26426. * are merged recursively. Other objects and value types are overridden by
  26427. * assignment. Source objects are applied from left to right. Subsequent
  26428. * sources overwrite property assignments of previous sources.
  26429. *
  26430. * **Note:** This method mutates `object`.
  26431. *
  26432. * @static
  26433. * @memberOf _
  26434. * @since 0.5.0
  26435. * @category Object
  26436. * @param {Object} object The destination object.
  26437. * @param {...Object} [sources] The source objects.
  26438. * @returns {Object} Returns `object`.
  26439. * @example
  26440. *
  26441. * var object = {
  26442. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  26443. * };
  26444. *
  26445. * var other = {
  26446. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  26447. * };
  26448. *
  26449. * _.merge(object, other);
  26450. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  26451. */
  26452. var merge = createAssigner(function(object, source, srcIndex) {
  26453. baseMerge(object, source, srcIndex);
  26454. });
  26455. /**
  26456. * This method is like `_.merge` except that it accepts `customizer` which
  26457. * is invoked to produce the merged values of the destination and source
  26458. * properties. If `customizer` returns `undefined`, merging is handled by the
  26459. * method instead. The `customizer` is invoked with six arguments:
  26460. * (objValue, srcValue, key, object, source, stack).
  26461. *
  26462. * **Note:** This method mutates `object`.
  26463. *
  26464. * @static
  26465. * @memberOf _
  26466. * @since 4.0.0
  26467. * @category Object
  26468. * @param {Object} object The destination object.
  26469. * @param {...Object} sources The source objects.
  26470. * @param {Function} customizer The function to customize assigned values.
  26471. * @returns {Object} Returns `object`.
  26472. * @example
  26473. *
  26474. * function customizer(objValue, srcValue) {
  26475. * if (_.isArray(objValue)) {
  26476. * return objValue.concat(srcValue);
  26477. * }
  26478. * }
  26479. *
  26480. * var object = { 'a': [1], 'b': [2] };
  26481. * var other = { 'a': [3], 'b': [4] };
  26482. *
  26483. * _.mergeWith(object, other, customizer);
  26484. * // => { 'a': [1, 3], 'b': [2, 4] }
  26485. */
  26486. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  26487. baseMerge(object, source, srcIndex, customizer);
  26488. });
  26489. /**
  26490. * The opposite of `_.pick`; this method creates an object composed of the
  26491. * own and inherited enumerable property paths of `object` that are not omitted.
  26492. *
  26493. * **Note:** This method is considerably slower than `_.pick`.
  26494. *
  26495. * @static
  26496. * @since 0.1.0
  26497. * @memberOf _
  26498. * @category Object
  26499. * @param {Object} object The source object.
  26500. * @param {...(string|string[])} [paths] The property paths to omit.
  26501. * @returns {Object} Returns the new object.
  26502. * @example
  26503. *
  26504. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26505. *
  26506. * _.omit(object, ['a', 'c']);
  26507. * // => { 'b': '2' }
  26508. */
  26509. var omit = flatRest(function(object, paths) {
  26510. var result = {};
  26511. if (object == null) {
  26512. return result;
  26513. }
  26514. var isDeep = false;
  26515. paths = arrayMap(paths, function(path) {
  26516. path = castPath(path, object);
  26517. isDeep || (isDeep = path.length > 1);
  26518. return path;
  26519. });
  26520. copyObject(object, getAllKeysIn(object), result);
  26521. if (isDeep) {
  26522. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  26523. }
  26524. var length = paths.length;
  26525. while (length--) {
  26526. baseUnset(result, paths[length]);
  26527. }
  26528. return result;
  26529. });
  26530. /**
  26531. * The opposite of `_.pickBy`; this method creates an object composed of
  26532. * the own and inherited enumerable string keyed properties of `object` that
  26533. * `predicate` doesn't return truthy for. The predicate is invoked with two
  26534. * arguments: (value, key).
  26535. *
  26536. * @static
  26537. * @memberOf _
  26538. * @since 4.0.0
  26539. * @category Object
  26540. * @param {Object} object The source object.
  26541. * @param {Function} [predicate=_.identity] The function invoked per property.
  26542. * @returns {Object} Returns the new object.
  26543. * @example
  26544. *
  26545. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26546. *
  26547. * _.omitBy(object, _.isNumber);
  26548. * // => { 'b': '2' }
  26549. */
  26550. function omitBy(object, predicate) {
  26551. return pickBy(object, negate(getIteratee(predicate)));
  26552. }
  26553. /**
  26554. * Creates an object composed of the picked `object` properties.
  26555. *
  26556. * @static
  26557. * @since 0.1.0
  26558. * @memberOf _
  26559. * @category Object
  26560. * @param {Object} object The source object.
  26561. * @param {...(string|string[])} [paths] The property paths to pick.
  26562. * @returns {Object} Returns the new object.
  26563. * @example
  26564. *
  26565. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26566. *
  26567. * _.pick(object, ['a', 'c']);
  26568. * // => { 'a': 1, 'c': 3 }
  26569. */
  26570. var pick = flatRest(function(object, paths) {
  26571. return object == null ? {} : basePick(object, paths);
  26572. });
  26573. /**
  26574. * Creates an object composed of the `object` properties `predicate` returns
  26575. * truthy for. The predicate is invoked with two arguments: (value, key).
  26576. *
  26577. * @static
  26578. * @memberOf _
  26579. * @since 4.0.0
  26580. * @category Object
  26581. * @param {Object} object The source object.
  26582. * @param {Function} [predicate=_.identity] The function invoked per property.
  26583. * @returns {Object} Returns the new object.
  26584. * @example
  26585. *
  26586. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26587. *
  26588. * _.pickBy(object, _.isNumber);
  26589. * // => { 'a': 1, 'c': 3 }
  26590. */
  26591. function pickBy(object, predicate) {
  26592. if (object == null) {
  26593. return {};
  26594. }
  26595. var props = arrayMap(getAllKeysIn(object), function(prop) {
  26596. return [prop];
  26597. });
  26598. predicate = getIteratee(predicate);
  26599. return basePickBy(object, props, function(value, path) {
  26600. return predicate(value, path[0]);
  26601. });
  26602. }
  26603. /**
  26604. * This method is like `_.get` except that if the resolved value is a
  26605. * function it's invoked with the `this` binding of its parent object and
  26606. * its result is returned.
  26607. *
  26608. * @static
  26609. * @since 0.1.0
  26610. * @memberOf _
  26611. * @category Object
  26612. * @param {Object} object The object to query.
  26613. * @param {Array|string} path The path of the property to resolve.
  26614. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26615. * @returns {*} Returns the resolved value.
  26616. * @example
  26617. *
  26618. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  26619. *
  26620. * _.result(object, 'a[0].b.c1');
  26621. * // => 3
  26622. *
  26623. * _.result(object, 'a[0].b.c2');
  26624. * // => 4
  26625. *
  26626. * _.result(object, 'a[0].b.c3', 'default');
  26627. * // => 'default'
  26628. *
  26629. * _.result(object, 'a[0].b.c3', _.constant('default'));
  26630. * // => 'default'
  26631. */
  26632. function result(object, path, defaultValue) {
  26633. path = castPath(path, object);
  26634. var index = -1,
  26635. length = path.length;
  26636. // Ensure the loop is entered when path is empty.
  26637. if (!length) {
  26638. length = 1;
  26639. object = undefined;
  26640. }
  26641. while (++index < length) {
  26642. var value = object == null ? undefined : object[toKey(path[index])];
  26643. if (value === undefined) {
  26644. index = length;
  26645. value = defaultValue;
  26646. }
  26647. object = isFunction(value) ? value.call(object) : value;
  26648. }
  26649. return object;
  26650. }
  26651. /**
  26652. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  26653. * it's created. Arrays are created for missing index properties while objects
  26654. * are created for all other missing properties. Use `_.setWith` to customize
  26655. * `path` creation.
  26656. *
  26657. * **Note:** This method mutates `object`.
  26658. *
  26659. * @static
  26660. * @memberOf _
  26661. * @since 3.7.0
  26662. * @category Object
  26663. * @param {Object} object The object to modify.
  26664. * @param {Array|string} path The path of the property to set.
  26665. * @param {*} value The value to set.
  26666. * @returns {Object} Returns `object`.
  26667. * @example
  26668. *
  26669. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26670. *
  26671. * _.set(object, 'a[0].b.c', 4);
  26672. * console.log(object.a[0].b.c);
  26673. * // => 4
  26674. *
  26675. * _.set(object, ['x', '0', 'y', 'z'], 5);
  26676. * console.log(object.x[0].y.z);
  26677. * // => 5
  26678. */
  26679. function set(object, path, value) {
  26680. return object == null ? object : baseSet(object, path, value);
  26681. }
  26682. /**
  26683. * This method is like `_.set` except that it accepts `customizer` which is
  26684. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26685. * path creation is handled by the method instead. The `customizer` is invoked
  26686. * with three arguments: (nsValue, key, nsObject).
  26687. *
  26688. * **Note:** This method mutates `object`.
  26689. *
  26690. * @static
  26691. * @memberOf _
  26692. * @since 4.0.0
  26693. * @category Object
  26694. * @param {Object} object The object to modify.
  26695. * @param {Array|string} path The path of the property to set.
  26696. * @param {*} value The value to set.
  26697. * @param {Function} [customizer] The function to customize assigned values.
  26698. * @returns {Object} Returns `object`.
  26699. * @example
  26700. *
  26701. * var object = {};
  26702. *
  26703. * _.setWith(object, '[0][1]', 'a', Object);
  26704. * // => { '0': { '1': 'a' } }
  26705. */
  26706. function setWith(object, path, value, customizer) {
  26707. customizer = typeof customizer == 'function' ? customizer : undefined;
  26708. return object == null ? object : baseSet(object, path, value, customizer);
  26709. }
  26710. /**
  26711. * Creates an array of own enumerable string keyed-value pairs for `object`
  26712. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  26713. * entries are returned.
  26714. *
  26715. * @static
  26716. * @memberOf _
  26717. * @since 4.0.0
  26718. * @alias entries
  26719. * @category Object
  26720. * @param {Object} object The object to query.
  26721. * @returns {Array} Returns the key-value pairs.
  26722. * @example
  26723. *
  26724. * function Foo() {
  26725. * this.a = 1;
  26726. * this.b = 2;
  26727. * }
  26728. *
  26729. * Foo.prototype.c = 3;
  26730. *
  26731. * _.toPairs(new Foo);
  26732. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  26733. */
  26734. var toPairs = createToPairs(keys);
  26735. /**
  26736. * Creates an array of own and inherited enumerable string keyed-value pairs
  26737. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  26738. * or set, its entries are returned.
  26739. *
  26740. * @static
  26741. * @memberOf _
  26742. * @since 4.0.0
  26743. * @alias entriesIn
  26744. * @category Object
  26745. * @param {Object} object The object to query.
  26746. * @returns {Array} Returns the key-value pairs.
  26747. * @example
  26748. *
  26749. * function Foo() {
  26750. * this.a = 1;
  26751. * this.b = 2;
  26752. * }
  26753. *
  26754. * Foo.prototype.c = 3;
  26755. *
  26756. * _.toPairsIn(new Foo);
  26757. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  26758. */
  26759. var toPairsIn = createToPairs(keysIn);
  26760. /**
  26761. * An alternative to `_.reduce`; this method transforms `object` to a new
  26762. * `accumulator` object which is the result of running each of its own
  26763. * enumerable string keyed properties thru `iteratee`, with each invocation
  26764. * potentially mutating the `accumulator` object. If `accumulator` is not
  26765. * provided, a new object with the same `[[Prototype]]` will be used. The
  26766. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  26767. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26768. *
  26769. * @static
  26770. * @memberOf _
  26771. * @since 1.3.0
  26772. * @category Object
  26773. * @param {Object} object The object to iterate over.
  26774. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26775. * @param {*} [accumulator] The custom accumulator value.
  26776. * @returns {*} Returns the accumulated value.
  26777. * @example
  26778. *
  26779. * _.transform([2, 3, 4], function(result, n) {
  26780. * result.push(n *= n);
  26781. * return n % 2 == 0;
  26782. * }, []);
  26783. * // => [4, 9]
  26784. *
  26785. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26786. * (result[value] || (result[value] = [])).push(key);
  26787. * }, {});
  26788. * // => { '1': ['a', 'c'], '2': ['b'] }
  26789. */
  26790. function transform(object, iteratee, accumulator) {
  26791. var isArr = isArray(object),
  26792. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  26793. iteratee = getIteratee(iteratee, 4);
  26794. if (accumulator == null) {
  26795. var Ctor = object && object.constructor;
  26796. if (isArrLike) {
  26797. accumulator = isArr ? new Ctor : [];
  26798. }
  26799. else if (isObject(object)) {
  26800. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  26801. }
  26802. else {
  26803. accumulator = {};
  26804. }
  26805. }
  26806. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  26807. return iteratee(accumulator, value, index, object);
  26808. });
  26809. return accumulator;
  26810. }
  26811. /**
  26812. * Removes the property at `path` of `object`.
  26813. *
  26814. * **Note:** This method mutates `object`.
  26815. *
  26816. * @static
  26817. * @memberOf _
  26818. * @since 4.0.0
  26819. * @category Object
  26820. * @param {Object} object The object to modify.
  26821. * @param {Array|string} path The path of the property to unset.
  26822. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  26823. * @example
  26824. *
  26825. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  26826. * _.unset(object, 'a[0].b.c');
  26827. * // => true
  26828. *
  26829. * console.log(object);
  26830. * // => { 'a': [{ 'b': {} }] };
  26831. *
  26832. * _.unset(object, ['a', '0', 'b', 'c']);
  26833. * // => true
  26834. *
  26835. * console.log(object);
  26836. * // => { 'a': [{ 'b': {} }] };
  26837. */
  26838. function unset(object, path) {
  26839. return object == null ? true : baseUnset(object, path);
  26840. }
  26841. /**
  26842. * This method is like `_.set` except that accepts `updater` to produce the
  26843. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  26844. * is invoked with one argument: (value).
  26845. *
  26846. * **Note:** This method mutates `object`.
  26847. *
  26848. * @static
  26849. * @memberOf _
  26850. * @since 4.6.0
  26851. * @category Object
  26852. * @param {Object} object The object to modify.
  26853. * @param {Array|string} path The path of the property to set.
  26854. * @param {Function} updater The function to produce the updated value.
  26855. * @returns {Object} Returns `object`.
  26856. * @example
  26857. *
  26858. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26859. *
  26860. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  26861. * console.log(object.a[0].b.c);
  26862. * // => 9
  26863. *
  26864. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  26865. * console.log(object.x[0].y.z);
  26866. * // => 0
  26867. */
  26868. function update(object, path, updater) {
  26869. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  26870. }
  26871. /**
  26872. * This method is like `_.update` except that it accepts `customizer` which is
  26873. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26874. * path creation is handled by the method instead. The `customizer` is invoked
  26875. * with three arguments: (nsValue, key, nsObject).
  26876. *
  26877. * **Note:** This method mutates `object`.
  26878. *
  26879. * @static
  26880. * @memberOf _
  26881. * @since 4.6.0
  26882. * @category Object
  26883. * @param {Object} object The object to modify.
  26884. * @param {Array|string} path The path of the property to set.
  26885. * @param {Function} updater The function to produce the updated value.
  26886. * @param {Function} [customizer] The function to customize assigned values.
  26887. * @returns {Object} Returns `object`.
  26888. * @example
  26889. *
  26890. * var object = {};
  26891. *
  26892. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  26893. * // => { '0': { '1': 'a' } }
  26894. */
  26895. function updateWith(object, path, updater, customizer) {
  26896. customizer = typeof customizer == 'function' ? customizer : undefined;
  26897. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  26898. }
  26899. /**
  26900. * Creates an array of the own enumerable string keyed property values of `object`.
  26901. *
  26902. * **Note:** Non-object values are coerced to objects.
  26903. *
  26904. * @static
  26905. * @since 0.1.0
  26906. * @memberOf _
  26907. * @category Object
  26908. * @param {Object} object The object to query.
  26909. * @returns {Array} Returns the array of property values.
  26910. * @example
  26911. *
  26912. * function Foo() {
  26913. * this.a = 1;
  26914. * this.b = 2;
  26915. * }
  26916. *
  26917. * Foo.prototype.c = 3;
  26918. *
  26919. * _.values(new Foo);
  26920. * // => [1, 2] (iteration order is not guaranteed)
  26921. *
  26922. * _.values('hi');
  26923. * // => ['h', 'i']
  26924. */
  26925. function values(object) {
  26926. return object == null ? [] : baseValues(object, keys(object));
  26927. }
  26928. /**
  26929. * Creates an array of the own and inherited enumerable string keyed property
  26930. * values of `object`.
  26931. *
  26932. * **Note:** Non-object values are coerced to objects.
  26933. *
  26934. * @static
  26935. * @memberOf _
  26936. * @since 3.0.0
  26937. * @category Object
  26938. * @param {Object} object The object to query.
  26939. * @returns {Array} Returns the array of property values.
  26940. * @example
  26941. *
  26942. * function Foo() {
  26943. * this.a = 1;
  26944. * this.b = 2;
  26945. * }
  26946. *
  26947. * Foo.prototype.c = 3;
  26948. *
  26949. * _.valuesIn(new Foo);
  26950. * // => [1, 2, 3] (iteration order is not guaranteed)
  26951. */
  26952. function valuesIn(object) {
  26953. return object == null ? [] : baseValues(object, keysIn(object));
  26954. }
  26955. /*------------------------------------------------------------------------*/
  26956. /**
  26957. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  26958. *
  26959. * @static
  26960. * @memberOf _
  26961. * @since 4.0.0
  26962. * @category Number
  26963. * @param {number} number The number to clamp.
  26964. * @param {number} [lower] The lower bound.
  26965. * @param {number} upper The upper bound.
  26966. * @returns {number} Returns the clamped number.
  26967. * @example
  26968. *
  26969. * _.clamp(-10, -5, 5);
  26970. * // => -5
  26971. *
  26972. * _.clamp(10, -5, 5);
  26973. * // => 5
  26974. */
  26975. function clamp(number, lower, upper) {
  26976. if (upper === undefined) {
  26977. upper = lower;
  26978. lower = undefined;
  26979. }
  26980. if (upper !== undefined) {
  26981. upper = toNumber(upper);
  26982. upper = upper === upper ? upper : 0;
  26983. }
  26984. if (lower !== undefined) {
  26985. lower = toNumber(lower);
  26986. lower = lower === lower ? lower : 0;
  26987. }
  26988. return baseClamp(toNumber(number), lower, upper);
  26989. }
  26990. /**
  26991. * Checks if `n` is between `start` and up to, but not including, `end`. If
  26992. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  26993. * If `start` is greater than `end` the params are swapped to support
  26994. * negative ranges.
  26995. *
  26996. * @static
  26997. * @memberOf _
  26998. * @since 3.3.0
  26999. * @category Number
  27000. * @param {number} number The number to check.
  27001. * @param {number} [start=0] The start of the range.
  27002. * @param {number} end The end of the range.
  27003. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  27004. * @see _.range, _.rangeRight
  27005. * @example
  27006. *
  27007. * _.inRange(3, 2, 4);
  27008. * // => true
  27009. *
  27010. * _.inRange(4, 8);
  27011. * // => true
  27012. *
  27013. * _.inRange(4, 2);
  27014. * // => false
  27015. *
  27016. * _.inRange(2, 2);
  27017. * // => false
  27018. *
  27019. * _.inRange(1.2, 2);
  27020. * // => true
  27021. *
  27022. * _.inRange(5.2, 4);
  27023. * // => false
  27024. *
  27025. * _.inRange(-3, -2, -6);
  27026. * // => true
  27027. */
  27028. function inRange(number, start, end) {
  27029. start = toFinite(start);
  27030. if (end === undefined) {
  27031. end = start;
  27032. start = 0;
  27033. } else {
  27034. end = toFinite(end);
  27035. }
  27036. number = toNumber(number);
  27037. return baseInRange(number, start, end);
  27038. }
  27039. /**
  27040. * Produces a random number between the inclusive `lower` and `upper` bounds.
  27041. * If only one argument is provided a number between `0` and the given number
  27042. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  27043. * floats, a floating-point number is returned instead of an integer.
  27044. *
  27045. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  27046. * floating-point values which can produce unexpected results.
  27047. *
  27048. * @static
  27049. * @memberOf _
  27050. * @since 0.7.0
  27051. * @category Number
  27052. * @param {number} [lower=0] The lower bound.
  27053. * @param {number} [upper=1] The upper bound.
  27054. * @param {boolean} [floating] Specify returning a floating-point number.
  27055. * @returns {number} Returns the random number.
  27056. * @example
  27057. *
  27058. * _.random(0, 5);
  27059. * // => an integer between 0 and 5
  27060. *
  27061. * _.random(5);
  27062. * // => also an integer between 0 and 5
  27063. *
  27064. * _.random(5, true);
  27065. * // => a floating-point number between 0 and 5
  27066. *
  27067. * _.random(1.2, 5.2);
  27068. * // => a floating-point number between 1.2 and 5.2
  27069. */
  27070. function random(lower, upper, floating) {
  27071. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  27072. upper = floating = undefined;
  27073. }
  27074. if (floating === undefined) {
  27075. if (typeof upper == 'boolean') {
  27076. floating = upper;
  27077. upper = undefined;
  27078. }
  27079. else if (typeof lower == 'boolean') {
  27080. floating = lower;
  27081. lower = undefined;
  27082. }
  27083. }
  27084. if (lower === undefined && upper === undefined) {
  27085. lower = 0;
  27086. upper = 1;
  27087. }
  27088. else {
  27089. lower = toFinite(lower);
  27090. if (upper === undefined) {
  27091. upper = lower;
  27092. lower = 0;
  27093. } else {
  27094. upper = toFinite(upper);
  27095. }
  27096. }
  27097. if (lower > upper) {
  27098. var temp = lower;
  27099. lower = upper;
  27100. upper = temp;
  27101. }
  27102. if (floating || lower % 1 || upper % 1) {
  27103. var rand = nativeRandom();
  27104. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  27105. }
  27106. return baseRandom(lower, upper);
  27107. }
  27108. /*------------------------------------------------------------------------*/
  27109. /**
  27110. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  27111. *
  27112. * @static
  27113. * @memberOf _
  27114. * @since 3.0.0
  27115. * @category String
  27116. * @param {string} [string=''] The string to convert.
  27117. * @returns {string} Returns the camel cased string.
  27118. * @example
  27119. *
  27120. * _.camelCase('Foo Bar');
  27121. * // => 'fooBar'
  27122. *
  27123. * _.camelCase('--foo-bar--');
  27124. * // => 'fooBar'
  27125. *
  27126. * _.camelCase('__FOO_BAR__');
  27127. * // => 'fooBar'
  27128. */
  27129. var camelCase = createCompounder(function(result, word, index) {
  27130. word = word.toLowerCase();
  27131. return result + (index ? capitalize(word) : word);
  27132. });
  27133. /**
  27134. * Converts the first character of `string` to upper case and the remaining
  27135. * to lower case.
  27136. *
  27137. * @static
  27138. * @memberOf _
  27139. * @since 3.0.0
  27140. * @category String
  27141. * @param {string} [string=''] The string to capitalize.
  27142. * @returns {string} Returns the capitalized string.
  27143. * @example
  27144. *
  27145. * _.capitalize('FRED');
  27146. * // => 'Fred'
  27147. */
  27148. function capitalize(string) {
  27149. return upperFirst(toString(string).toLowerCase());
  27150. }
  27151. /**
  27152. * Deburrs `string` by converting
  27153. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  27154. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  27155. * letters to basic Latin letters and removing
  27156. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  27157. *
  27158. * @static
  27159. * @memberOf _
  27160. * @since 3.0.0
  27161. * @category String
  27162. * @param {string} [string=''] The string to deburr.
  27163. * @returns {string} Returns the deburred string.
  27164. * @example
  27165. *
  27166. * _.deburr('déjà vu');
  27167. * // => 'deja vu'
  27168. */
  27169. function deburr(string) {
  27170. string = toString(string);
  27171. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  27172. }
  27173. /**
  27174. * Checks if `string` ends with the given target string.
  27175. *
  27176. * @static
  27177. * @memberOf _
  27178. * @since 3.0.0
  27179. * @category String
  27180. * @param {string} [string=''] The string to inspect.
  27181. * @param {string} [target] The string to search for.
  27182. * @param {number} [position=string.length] The position to search up to.
  27183. * @returns {boolean} Returns `true` if `string` ends with `target`,
  27184. * else `false`.
  27185. * @example
  27186. *
  27187. * _.endsWith('abc', 'c');
  27188. * // => true
  27189. *
  27190. * _.endsWith('abc', 'b');
  27191. * // => false
  27192. *
  27193. * _.endsWith('abc', 'b', 2);
  27194. * // => true
  27195. */
  27196. function endsWith(string, target, position) {
  27197. string = toString(string);
  27198. target = baseToString(target);
  27199. var length = string.length;
  27200. position = position === undefined
  27201. ? length
  27202. : baseClamp(toInteger(position), 0, length);
  27203. var end = position;
  27204. position -= target.length;
  27205. return position >= 0 && string.slice(position, end) == target;
  27206. }
  27207. /**
  27208. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  27209. * corresponding HTML entities.
  27210. *
  27211. * **Note:** No other characters are escaped. To escape additional
  27212. * characters use a third-party library like [_he_](https://mths.be/he).
  27213. *
  27214. * Though the ">" character is escaped for symmetry, characters like
  27215. * ">" and "/" don't need escaping in HTML and have no special meaning
  27216. * unless they're part of a tag or unquoted attribute value. See
  27217. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  27218. * (under "semi-related fun fact") for more details.
  27219. *
  27220. * When working with HTML you should always
  27221. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  27222. * XSS vectors.
  27223. *
  27224. * @static
  27225. * @since 0.1.0
  27226. * @memberOf _
  27227. * @category String
  27228. * @param {string} [string=''] The string to escape.
  27229. * @returns {string} Returns the escaped string.
  27230. * @example
  27231. *
  27232. * _.escape('fred, barney, & pebbles');
  27233. * // => 'fred, barney, &amp; pebbles'
  27234. */
  27235. function escape(string) {
  27236. string = toString(string);
  27237. return (string && reHasUnescapedHtml.test(string))
  27238. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  27239. : string;
  27240. }
  27241. /**
  27242. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  27243. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  27244. *
  27245. * @static
  27246. * @memberOf _
  27247. * @since 3.0.0
  27248. * @category String
  27249. * @param {string} [string=''] The string to escape.
  27250. * @returns {string} Returns the escaped string.
  27251. * @example
  27252. *
  27253. * _.escapeRegExp('[lodash](https://lodash.com/)');
  27254. * // => '\[lodash\]\(https://lodash\.com/\)'
  27255. */
  27256. function escapeRegExp(string) {
  27257. string = toString(string);
  27258. return (string && reHasRegExpChar.test(string))
  27259. ? string.replace(reRegExpChar, '\\$&')
  27260. : string;
  27261. }
  27262. /**
  27263. * Converts `string` to
  27264. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  27265. *
  27266. * @static
  27267. * @memberOf _
  27268. * @since 3.0.0
  27269. * @category String
  27270. * @param {string} [string=''] The string to convert.
  27271. * @returns {string} Returns the kebab cased string.
  27272. * @example
  27273. *
  27274. * _.kebabCase('Foo Bar');
  27275. * // => 'foo-bar'
  27276. *
  27277. * _.kebabCase('fooBar');
  27278. * // => 'foo-bar'
  27279. *
  27280. * _.kebabCase('__FOO_BAR__');
  27281. * // => 'foo-bar'
  27282. */
  27283. var kebabCase = createCompounder(function(result, word, index) {
  27284. return result + (index ? '-' : '') + word.toLowerCase();
  27285. });
  27286. /**
  27287. * Converts `string`, as space separated words, to lower case.
  27288. *
  27289. * @static
  27290. * @memberOf _
  27291. * @since 4.0.0
  27292. * @category String
  27293. * @param {string} [string=''] The string to convert.
  27294. * @returns {string} Returns the lower cased string.
  27295. * @example
  27296. *
  27297. * _.lowerCase('--Foo-Bar--');
  27298. * // => 'foo bar'
  27299. *
  27300. * _.lowerCase('fooBar');
  27301. * // => 'foo bar'
  27302. *
  27303. * _.lowerCase('__FOO_BAR__');
  27304. * // => 'foo bar'
  27305. */
  27306. var lowerCase = createCompounder(function(result, word, index) {
  27307. return result + (index ? ' ' : '') + word.toLowerCase();
  27308. });
  27309. /**
  27310. * Converts the first character of `string` to lower case.
  27311. *
  27312. * @static
  27313. * @memberOf _
  27314. * @since 4.0.0
  27315. * @category String
  27316. * @param {string} [string=''] The string to convert.
  27317. * @returns {string} Returns the converted string.
  27318. * @example
  27319. *
  27320. * _.lowerFirst('Fred');
  27321. * // => 'fred'
  27322. *
  27323. * _.lowerFirst('FRED');
  27324. * // => 'fRED'
  27325. */
  27326. var lowerFirst = createCaseFirst('toLowerCase');
  27327. /**
  27328. * Pads `string` on the left and right sides if it's shorter than `length`.
  27329. * Padding characters are truncated if they can't be evenly divided by `length`.
  27330. *
  27331. * @static
  27332. * @memberOf _
  27333. * @since 3.0.0
  27334. * @category String
  27335. * @param {string} [string=''] The string to pad.
  27336. * @param {number} [length=0] The padding length.
  27337. * @param {string} [chars=' '] The string used as padding.
  27338. * @returns {string} Returns the padded string.
  27339. * @example
  27340. *
  27341. * _.pad('abc', 8);
  27342. * // => ' abc '
  27343. *
  27344. * _.pad('abc', 8, '_-');
  27345. * // => '_-abc_-_'
  27346. *
  27347. * _.pad('abc', 3);
  27348. * // => 'abc'
  27349. */
  27350. function pad(string, length, chars) {
  27351. string = toString(string);
  27352. length = toInteger(length);
  27353. var strLength = length ? stringSize(string) : 0;
  27354. if (!length || strLength >= length) {
  27355. return string;
  27356. }
  27357. var mid = (length - strLength) / 2;
  27358. return (
  27359. createPadding(nativeFloor(mid), chars) +
  27360. string +
  27361. createPadding(nativeCeil(mid), chars)
  27362. );
  27363. }
  27364. /**
  27365. * Pads `string` on the right side if it's shorter than `length`. Padding
  27366. * characters are truncated if they exceed `length`.
  27367. *
  27368. * @static
  27369. * @memberOf _
  27370. * @since 4.0.0
  27371. * @category String
  27372. * @param {string} [string=''] The string to pad.
  27373. * @param {number} [length=0] The padding length.
  27374. * @param {string} [chars=' '] The string used as padding.
  27375. * @returns {string} Returns the padded string.
  27376. * @example
  27377. *
  27378. * _.padEnd('abc', 6);
  27379. * // => 'abc '
  27380. *
  27381. * _.padEnd('abc', 6, '_-');
  27382. * // => 'abc_-_'
  27383. *
  27384. * _.padEnd('abc', 3);
  27385. * // => 'abc'
  27386. */
  27387. function padEnd(string, length, chars) {
  27388. string = toString(string);
  27389. length = toInteger(length);
  27390. var strLength = length ? stringSize(string) : 0;
  27391. return (length && strLength < length)
  27392. ? (string + createPadding(length - strLength, chars))
  27393. : string;
  27394. }
  27395. /**
  27396. * Pads `string` on the left side if it's shorter than `length`. Padding
  27397. * characters are truncated if they exceed `length`.
  27398. *
  27399. * @static
  27400. * @memberOf _
  27401. * @since 4.0.0
  27402. * @category String
  27403. * @param {string} [string=''] The string to pad.
  27404. * @param {number} [length=0] The padding length.
  27405. * @param {string} [chars=' '] The string used as padding.
  27406. * @returns {string} Returns the padded string.
  27407. * @example
  27408. *
  27409. * _.padStart('abc', 6);
  27410. * // => ' abc'
  27411. *
  27412. * _.padStart('abc', 6, '_-');
  27413. * // => '_-_abc'
  27414. *
  27415. * _.padStart('abc', 3);
  27416. * // => 'abc'
  27417. */
  27418. function padStart(string, length, chars) {
  27419. string = toString(string);
  27420. length = toInteger(length);
  27421. var strLength = length ? stringSize(string) : 0;
  27422. return (length && strLength < length)
  27423. ? (createPadding(length - strLength, chars) + string)
  27424. : string;
  27425. }
  27426. /**
  27427. * Converts `string` to an integer of the specified radix. If `radix` is
  27428. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  27429. * hexadecimal, in which case a `radix` of `16` is used.
  27430. *
  27431. * **Note:** This method aligns with the
  27432. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  27433. *
  27434. * @static
  27435. * @memberOf _
  27436. * @since 1.1.0
  27437. * @category String
  27438. * @param {string} string The string to convert.
  27439. * @param {number} [radix=10] The radix to interpret `value` by.
  27440. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27441. * @returns {number} Returns the converted integer.
  27442. * @example
  27443. *
  27444. * _.parseInt('08');
  27445. * // => 8
  27446. *
  27447. * _.map(['6', '08', '10'], _.parseInt);
  27448. * // => [6, 8, 10]
  27449. */
  27450. function parseInt(string, radix, guard) {
  27451. if (guard || radix == null) {
  27452. radix = 0;
  27453. } else if (radix) {
  27454. radix = +radix;
  27455. }
  27456. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  27457. }
  27458. /**
  27459. * Repeats the given string `n` times.
  27460. *
  27461. * @static
  27462. * @memberOf _
  27463. * @since 3.0.0
  27464. * @category String
  27465. * @param {string} [string=''] The string to repeat.
  27466. * @param {number} [n=1] The number of times to repeat the string.
  27467. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27468. * @returns {string} Returns the repeated string.
  27469. * @example
  27470. *
  27471. * _.repeat('*', 3);
  27472. * // => '***'
  27473. *
  27474. * _.repeat('abc', 2);
  27475. * // => 'abcabc'
  27476. *
  27477. * _.repeat('abc', 0);
  27478. * // => ''
  27479. */
  27480. function repeat(string, n, guard) {
  27481. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  27482. n = 1;
  27483. } else {
  27484. n = toInteger(n);
  27485. }
  27486. return baseRepeat(toString(string), n);
  27487. }
  27488. /**
  27489. * Replaces matches for `pattern` in `string` with `replacement`.
  27490. *
  27491. * **Note:** This method is based on
  27492. * [`String#replace`](https://mdn.io/String/replace).
  27493. *
  27494. * @static
  27495. * @memberOf _
  27496. * @since 4.0.0
  27497. * @category String
  27498. * @param {string} [string=''] The string to modify.
  27499. * @param {RegExp|string} pattern The pattern to replace.
  27500. * @param {Function|string} replacement The match replacement.
  27501. * @returns {string} Returns the modified string.
  27502. * @example
  27503. *
  27504. * _.replace('Hi Fred', 'Fred', 'Barney');
  27505. * // => 'Hi Barney'
  27506. */
  27507. function replace() {
  27508. var args = arguments,
  27509. string = toString(args[0]);
  27510. return args.length < 3 ? string : string.replace(args[1], args[2]);
  27511. }
  27512. /**
  27513. * Converts `string` to
  27514. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  27515. *
  27516. * @static
  27517. * @memberOf _
  27518. * @since 3.0.0
  27519. * @category String
  27520. * @param {string} [string=''] The string to convert.
  27521. * @returns {string} Returns the snake cased string.
  27522. * @example
  27523. *
  27524. * _.snakeCase('Foo Bar');
  27525. * // => 'foo_bar'
  27526. *
  27527. * _.snakeCase('fooBar');
  27528. * // => 'foo_bar'
  27529. *
  27530. * _.snakeCase('--FOO-BAR--');
  27531. * // => 'foo_bar'
  27532. */
  27533. var snakeCase = createCompounder(function(result, word, index) {
  27534. return result + (index ? '_' : '') + word.toLowerCase();
  27535. });
  27536. /**
  27537. * Splits `string` by `separator`.
  27538. *
  27539. * **Note:** This method is based on
  27540. * [`String#split`](https://mdn.io/String/split).
  27541. *
  27542. * @static
  27543. * @memberOf _
  27544. * @since 4.0.0
  27545. * @category String
  27546. * @param {string} [string=''] The string to split.
  27547. * @param {RegExp|string} separator The separator pattern to split by.
  27548. * @param {number} [limit] The length to truncate results to.
  27549. * @returns {Array} Returns the string segments.
  27550. * @example
  27551. *
  27552. * _.split('a-b-c', '-', 2);
  27553. * // => ['a', 'b']
  27554. */
  27555. function split(string, separator, limit) {
  27556. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  27557. separator = limit = undefined;
  27558. }
  27559. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  27560. if (!limit) {
  27561. return [];
  27562. }
  27563. string = toString(string);
  27564. if (string && (
  27565. typeof separator == 'string' ||
  27566. (separator != null && !isRegExp(separator))
  27567. )) {
  27568. separator = baseToString(separator);
  27569. if (!separator && hasUnicode(string)) {
  27570. return castSlice(stringToArray(string), 0, limit);
  27571. }
  27572. }
  27573. return string.split(separator, limit);
  27574. }
  27575. /**
  27576. * Converts `string` to
  27577. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  27578. *
  27579. * @static
  27580. * @memberOf _
  27581. * @since 3.1.0
  27582. * @category String
  27583. * @param {string} [string=''] The string to convert.
  27584. * @returns {string} Returns the start cased string.
  27585. * @example
  27586. *
  27587. * _.startCase('--foo-bar--');
  27588. * // => 'Foo Bar'
  27589. *
  27590. * _.startCase('fooBar');
  27591. * // => 'Foo Bar'
  27592. *
  27593. * _.startCase('__FOO_BAR__');
  27594. * // => 'FOO BAR'
  27595. */
  27596. var startCase = createCompounder(function(result, word, index) {
  27597. return result + (index ? ' ' : '') + upperFirst(word);
  27598. });
  27599. /**
  27600. * Checks if `string` starts with the given target string.
  27601. *
  27602. * @static
  27603. * @memberOf _
  27604. * @since 3.0.0
  27605. * @category String
  27606. * @param {string} [string=''] The string to inspect.
  27607. * @param {string} [target] The string to search for.
  27608. * @param {number} [position=0] The position to search from.
  27609. * @returns {boolean} Returns `true` if `string` starts with `target`,
  27610. * else `false`.
  27611. * @example
  27612. *
  27613. * _.startsWith('abc', 'a');
  27614. * // => true
  27615. *
  27616. * _.startsWith('abc', 'b');
  27617. * // => false
  27618. *
  27619. * _.startsWith('abc', 'b', 1);
  27620. * // => true
  27621. */
  27622. function startsWith(string, target, position) {
  27623. string = toString(string);
  27624. position = position == null
  27625. ? 0
  27626. : baseClamp(toInteger(position), 0, string.length);
  27627. target = baseToString(target);
  27628. return string.slice(position, position + target.length) == target;
  27629. }
  27630. /**
  27631. * Creates a compiled template function that can interpolate data properties
  27632. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  27633. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  27634. * properties may be accessed as free variables in the template. If a setting
  27635. * object is given, it takes precedence over `_.templateSettings` values.
  27636. *
  27637. * **Note:** In the development build `_.template` utilizes
  27638. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  27639. * for easier debugging.
  27640. *
  27641. * For more information on precompiling templates see
  27642. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  27643. *
  27644. * For more information on Chrome extension sandboxes see
  27645. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  27646. *
  27647. * @static
  27648. * @since 0.1.0
  27649. * @memberOf _
  27650. * @category String
  27651. * @param {string} [string=''] The template string.
  27652. * @param {Object} [options={}] The options object.
  27653. * @param {RegExp} [options.escape=_.templateSettings.escape]
  27654. * The HTML "escape" delimiter.
  27655. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  27656. * The "evaluate" delimiter.
  27657. * @param {Object} [options.imports=_.templateSettings.imports]
  27658. * An object to import into the template as free variables.
  27659. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  27660. * The "interpolate" delimiter.
  27661. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  27662. * The sourceURL of the compiled template.
  27663. * @param {string} [options.variable='obj']
  27664. * The data object variable name.
  27665. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27666. * @returns {Function} Returns the compiled template function.
  27667. * @example
  27668. *
  27669. * // Use the "interpolate" delimiter to create a compiled template.
  27670. * var compiled = _.template('hello <%= user %>!');
  27671. * compiled({ 'user': 'fred' });
  27672. * // => 'hello fred!'
  27673. *
  27674. * // Use the HTML "escape" delimiter to escape data property values.
  27675. * var compiled = _.template('<b><%- value %></b>');
  27676. * compiled({ 'value': '<script>' });
  27677. * // => '<b>&lt;script&gt;</b>'
  27678. *
  27679. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  27680. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  27681. * compiled({ 'users': ['fred', 'barney'] });
  27682. * // => '<li>fred</li><li>barney</li>'
  27683. *
  27684. * // Use the internal `print` function in "evaluate" delimiters.
  27685. * var compiled = _.template('<% print("hello " + user); %>!');
  27686. * compiled({ 'user': 'barney' });
  27687. * // => 'hello barney!'
  27688. *
  27689. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  27690. * // Disable support by replacing the "interpolate" delimiter.
  27691. * var compiled = _.template('hello ${ user }!');
  27692. * compiled({ 'user': 'pebbles' });
  27693. * // => 'hello pebbles!'
  27694. *
  27695. * // Use backslashes to treat delimiters as plain text.
  27696. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  27697. * compiled({ 'value': 'ignored' });
  27698. * // => '<%- value %>'
  27699. *
  27700. * // Use the `imports` option to import `jQuery` as `jq`.
  27701. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  27702. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  27703. * compiled({ 'users': ['fred', 'barney'] });
  27704. * // => '<li>fred</li><li>barney</li>'
  27705. *
  27706. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  27707. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  27708. * compiled(data);
  27709. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  27710. *
  27711. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  27712. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  27713. * compiled.source;
  27714. * // => function(data) {
  27715. * // var __t, __p = '';
  27716. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  27717. * // return __p;
  27718. * // }
  27719. *
  27720. * // Use custom template delimiters.
  27721. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  27722. * var compiled = _.template('hello {{ user }}!');
  27723. * compiled({ 'user': 'mustache' });
  27724. * // => 'hello mustache!'
  27725. *
  27726. * // Use the `source` property to inline compiled templates for meaningful
  27727. * // line numbers in error messages and stack traces.
  27728. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  27729. * var JST = {\
  27730. * "main": ' + _.template(mainText).source + '\
  27731. * };\
  27732. * ');
  27733. */
  27734. function template(string, options, guard) {
  27735. // Based on John Resig's `tmpl` implementation
  27736. // (http://ejohn.org/blog/javascript-micro-templating/)
  27737. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  27738. var settings = lodash.templateSettings;
  27739. if (guard && isIterateeCall(string, options, guard)) {
  27740. options = undefined;
  27741. }
  27742. string = toString(string);
  27743. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  27744. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  27745. importsKeys = keys(imports),
  27746. importsValues = baseValues(imports, importsKeys);
  27747. var isEscaping,
  27748. isEvaluating,
  27749. index = 0,
  27750. interpolate = options.interpolate || reNoMatch,
  27751. source = "__p += '";
  27752. // Compile the regexp to match each delimiter.
  27753. var reDelimiters = RegExp(
  27754. (options.escape || reNoMatch).source + '|' +
  27755. interpolate.source + '|' +
  27756. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  27757. (options.evaluate || reNoMatch).source + '|$'
  27758. , 'g');
  27759. // Use a sourceURL for easier debugging.
  27760. // The sourceURL gets injected into the source that's eval-ed, so be careful
  27761. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  27762. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  27763. var sourceURL = '//# sourceURL=' +
  27764. (hasOwnProperty.call(options, 'sourceURL')
  27765. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  27766. : ('lodash.templateSources[' + (++templateCounter) + ']')
  27767. ) + '\n';
  27768. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  27769. interpolateValue || (interpolateValue = esTemplateValue);
  27770. // Escape characters that can't be included in string literals.
  27771. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  27772. // Replace delimiters with snippets.
  27773. if (escapeValue) {
  27774. isEscaping = true;
  27775. source += "' +\n__e(" + escapeValue + ") +\n'";
  27776. }
  27777. if (evaluateValue) {
  27778. isEvaluating = true;
  27779. source += "';\n" + evaluateValue + ";\n__p += '";
  27780. }
  27781. if (interpolateValue) {
  27782. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  27783. }
  27784. index = offset + match.length;
  27785. // The JS engine embedded in Adobe products needs `match` returned in
  27786. // order to produce the correct `offset` value.
  27787. return match;
  27788. });
  27789. source += "';\n";
  27790. // If `variable` is not specified wrap a with-statement around the generated
  27791. // code to add the data object to the top of the scope chain.
  27792. // Like with sourceURL, we take care to not check the option's prototype,
  27793. // as this configuration is a code injection vector.
  27794. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  27795. if (!variable) {
  27796. source = 'with (obj) {\n' + source + '\n}\n';
  27797. }
  27798. // Cleanup code by stripping empty strings.
  27799. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  27800. .replace(reEmptyStringMiddle, '$1')
  27801. .replace(reEmptyStringTrailing, '$1;');
  27802. // Frame code as the function body.
  27803. source = 'function(' + (variable || 'obj') + ') {\n' +
  27804. (variable
  27805. ? ''
  27806. : 'obj || (obj = {});\n'
  27807. ) +
  27808. "var __t, __p = ''" +
  27809. (isEscaping
  27810. ? ', __e = _.escape'
  27811. : ''
  27812. ) +
  27813. (isEvaluating
  27814. ? ', __j = Array.prototype.join;\n' +
  27815. "function print() { __p += __j.call(arguments, '') }\n"
  27816. : ';\n'
  27817. ) +
  27818. source +
  27819. 'return __p\n}';
  27820. var result = attempt(function() {
  27821. return Function(importsKeys, sourceURL + 'return ' + source)
  27822. .apply(undefined, importsValues);
  27823. });
  27824. // Provide the compiled function's source by its `toString` method or
  27825. // the `source` property as a convenience for inlining compiled templates.
  27826. result.source = source;
  27827. if (isError(result)) {
  27828. throw result;
  27829. }
  27830. return result;
  27831. }
  27832. /**
  27833. * Converts `string`, as a whole, to lower case just like
  27834. * [String#toLowerCase](https://mdn.io/toLowerCase).
  27835. *
  27836. * @static
  27837. * @memberOf _
  27838. * @since 4.0.0
  27839. * @category String
  27840. * @param {string} [string=''] The string to convert.
  27841. * @returns {string} Returns the lower cased string.
  27842. * @example
  27843. *
  27844. * _.toLower('--Foo-Bar--');
  27845. * // => '--foo-bar--'
  27846. *
  27847. * _.toLower('fooBar');
  27848. * // => 'foobar'
  27849. *
  27850. * _.toLower('__FOO_BAR__');
  27851. * // => '__foo_bar__'
  27852. */
  27853. function toLower(value) {
  27854. return toString(value).toLowerCase();
  27855. }
  27856. /**
  27857. * Converts `string`, as a whole, to upper case just like
  27858. * [String#toUpperCase](https://mdn.io/toUpperCase).
  27859. *
  27860. * @static
  27861. * @memberOf _
  27862. * @since 4.0.0
  27863. * @category String
  27864. * @param {string} [string=''] The string to convert.
  27865. * @returns {string} Returns the upper cased string.
  27866. * @example
  27867. *
  27868. * _.toUpper('--foo-bar--');
  27869. * // => '--FOO-BAR--'
  27870. *
  27871. * _.toUpper('fooBar');
  27872. * // => 'FOOBAR'
  27873. *
  27874. * _.toUpper('__foo_bar__');
  27875. * // => '__FOO_BAR__'
  27876. */
  27877. function toUpper(value) {
  27878. return toString(value).toUpperCase();
  27879. }
  27880. /**
  27881. * Removes leading and trailing whitespace or specified characters from `string`.
  27882. *
  27883. * @static
  27884. * @memberOf _
  27885. * @since 3.0.0
  27886. * @category String
  27887. * @param {string} [string=''] The string to trim.
  27888. * @param {string} [chars=whitespace] The characters to trim.
  27889. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27890. * @returns {string} Returns the trimmed string.
  27891. * @example
  27892. *
  27893. * _.trim(' abc ');
  27894. * // => 'abc'
  27895. *
  27896. * _.trim('-_-abc-_-', '_-');
  27897. * // => 'abc'
  27898. *
  27899. * _.map([' foo ', ' bar '], _.trim);
  27900. * // => ['foo', 'bar']
  27901. */
  27902. function trim(string, chars, guard) {
  27903. string = toString(string);
  27904. if (string && (guard || chars === undefined)) {
  27905. return string.replace(reTrim, '');
  27906. }
  27907. if (!string || !(chars = baseToString(chars))) {
  27908. return string;
  27909. }
  27910. var strSymbols = stringToArray(string),
  27911. chrSymbols = stringToArray(chars),
  27912. start = charsStartIndex(strSymbols, chrSymbols),
  27913. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  27914. return castSlice(strSymbols, start, end).join('');
  27915. }
  27916. /**
  27917. * Removes trailing whitespace or specified characters from `string`.
  27918. *
  27919. * @static
  27920. * @memberOf _
  27921. * @since 4.0.0
  27922. * @category String
  27923. * @param {string} [string=''] The string to trim.
  27924. * @param {string} [chars=whitespace] The characters to trim.
  27925. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27926. * @returns {string} Returns the trimmed string.
  27927. * @example
  27928. *
  27929. * _.trimEnd(' abc ');
  27930. * // => ' abc'
  27931. *
  27932. * _.trimEnd('-_-abc-_-', '_-');
  27933. * // => '-_-abc'
  27934. */
  27935. function trimEnd(string, chars, guard) {
  27936. string = toString(string);
  27937. if (string && (guard || chars === undefined)) {
  27938. return string.replace(reTrimEnd, '');
  27939. }
  27940. if (!string || !(chars = baseToString(chars))) {
  27941. return string;
  27942. }
  27943. var strSymbols = stringToArray(string),
  27944. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  27945. return castSlice(strSymbols, 0, end).join('');
  27946. }
  27947. /**
  27948. * Removes leading whitespace or specified characters from `string`.
  27949. *
  27950. * @static
  27951. * @memberOf _
  27952. * @since 4.0.0
  27953. * @category String
  27954. * @param {string} [string=''] The string to trim.
  27955. * @param {string} [chars=whitespace] The characters to trim.
  27956. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27957. * @returns {string} Returns the trimmed string.
  27958. * @example
  27959. *
  27960. * _.trimStart(' abc ');
  27961. * // => 'abc '
  27962. *
  27963. * _.trimStart('-_-abc-_-', '_-');
  27964. * // => 'abc-_-'
  27965. */
  27966. function trimStart(string, chars, guard) {
  27967. string = toString(string);
  27968. if (string && (guard || chars === undefined)) {
  27969. return string.replace(reTrimStart, '');
  27970. }
  27971. if (!string || !(chars = baseToString(chars))) {
  27972. return string;
  27973. }
  27974. var strSymbols = stringToArray(string),
  27975. start = charsStartIndex(strSymbols, stringToArray(chars));
  27976. return castSlice(strSymbols, start).join('');
  27977. }
  27978. /**
  27979. * Truncates `string` if it's longer than the given maximum string length.
  27980. * The last characters of the truncated string are replaced with the omission
  27981. * string which defaults to "...".
  27982. *
  27983. * @static
  27984. * @memberOf _
  27985. * @since 4.0.0
  27986. * @category String
  27987. * @param {string} [string=''] The string to truncate.
  27988. * @param {Object} [options={}] The options object.
  27989. * @param {number} [options.length=30] The maximum string length.
  27990. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  27991. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  27992. * @returns {string} Returns the truncated string.
  27993. * @example
  27994. *
  27995. * _.truncate('hi-diddly-ho there, neighborino');
  27996. * // => 'hi-diddly-ho there, neighbo...'
  27997. *
  27998. * _.truncate('hi-diddly-ho there, neighborino', {
  27999. * 'length': 24,
  28000. * 'separator': ' '
  28001. * });
  28002. * // => 'hi-diddly-ho there,...'
  28003. *
  28004. * _.truncate('hi-diddly-ho there, neighborino', {
  28005. * 'length': 24,
  28006. * 'separator': /,? +/
  28007. * });
  28008. * // => 'hi-diddly-ho there...'
  28009. *
  28010. * _.truncate('hi-diddly-ho there, neighborino', {
  28011. * 'omission': ' [...]'
  28012. * });
  28013. * // => 'hi-diddly-ho there, neig [...]'
  28014. */
  28015. function truncate(string, options) {
  28016. var length = DEFAULT_TRUNC_LENGTH,
  28017. omission = DEFAULT_TRUNC_OMISSION;
  28018. if (isObject(options)) {
  28019. var separator = 'separator' in options ? options.separator : separator;
  28020. length = 'length' in options ? toInteger(options.length) : length;
  28021. omission = 'omission' in options ? baseToString(options.omission) : omission;
  28022. }
  28023. string = toString(string);
  28024. var strLength = string.length;
  28025. if (hasUnicode(string)) {
  28026. var strSymbols = stringToArray(string);
  28027. strLength = strSymbols.length;
  28028. }
  28029. if (length >= strLength) {
  28030. return string;
  28031. }
  28032. var end = length - stringSize(omission);
  28033. if (end < 1) {
  28034. return omission;
  28035. }
  28036. var result = strSymbols
  28037. ? castSlice(strSymbols, 0, end).join('')
  28038. : string.slice(0, end);
  28039. if (separator === undefined) {
  28040. return result + omission;
  28041. }
  28042. if (strSymbols) {
  28043. end += (result.length - end);
  28044. }
  28045. if (isRegExp(separator)) {
  28046. if (string.slice(end).search(separator)) {
  28047. var match,
  28048. substring = result;
  28049. if (!separator.global) {
  28050. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  28051. }
  28052. separator.lastIndex = 0;
  28053. while ((match = separator.exec(substring))) {
  28054. var newEnd = match.index;
  28055. }
  28056. result = result.slice(0, newEnd === undefined ? end : newEnd);
  28057. }
  28058. } else if (string.indexOf(baseToString(separator), end) != end) {
  28059. var index = result.lastIndexOf(separator);
  28060. if (index > -1) {
  28061. result = result.slice(0, index);
  28062. }
  28063. }
  28064. return result + omission;
  28065. }
  28066. /**
  28067. * The inverse of `_.escape`; this method converts the HTML entities
  28068. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  28069. * their corresponding characters.
  28070. *
  28071. * **Note:** No other HTML entities are unescaped. To unescape additional
  28072. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  28073. *
  28074. * @static
  28075. * @memberOf _
  28076. * @since 0.6.0
  28077. * @category String
  28078. * @param {string} [string=''] The string to unescape.
  28079. * @returns {string} Returns the unescaped string.
  28080. * @example
  28081. *
  28082. * _.unescape('fred, barney, &amp; pebbles');
  28083. * // => 'fred, barney, & pebbles'
  28084. */
  28085. function unescape(string) {
  28086. string = toString(string);
  28087. return (string && reHasEscapedHtml.test(string))
  28088. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  28089. : string;
  28090. }
  28091. /**
  28092. * Converts `string`, as space separated words, to upper case.
  28093. *
  28094. * @static
  28095. * @memberOf _
  28096. * @since 4.0.0
  28097. * @category String
  28098. * @param {string} [string=''] The string to convert.
  28099. * @returns {string} Returns the upper cased string.
  28100. * @example
  28101. *
  28102. * _.upperCase('--foo-bar');
  28103. * // => 'FOO BAR'
  28104. *
  28105. * _.upperCase('fooBar');
  28106. * // => 'FOO BAR'
  28107. *
  28108. * _.upperCase('__foo_bar__');
  28109. * // => 'FOO BAR'
  28110. */
  28111. var upperCase = createCompounder(function(result, word, index) {
  28112. return result + (index ? ' ' : '') + word.toUpperCase();
  28113. });
  28114. /**
  28115. * Converts the first character of `string` to upper case.
  28116. *
  28117. * @static
  28118. * @memberOf _
  28119. * @since 4.0.0
  28120. * @category String
  28121. * @param {string} [string=''] The string to convert.
  28122. * @returns {string} Returns the converted string.
  28123. * @example
  28124. *
  28125. * _.upperFirst('fred');
  28126. * // => 'Fred'
  28127. *
  28128. * _.upperFirst('FRED');
  28129. * // => 'FRED'
  28130. */
  28131. var upperFirst = createCaseFirst('toUpperCase');
  28132. /**
  28133. * Splits `string` into an array of its words.
  28134. *
  28135. * @static
  28136. * @memberOf _
  28137. * @since 3.0.0
  28138. * @category String
  28139. * @param {string} [string=''] The string to inspect.
  28140. * @param {RegExp|string} [pattern] The pattern to match words.
  28141. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28142. * @returns {Array} Returns the words of `string`.
  28143. * @example
  28144. *
  28145. * _.words('fred, barney, & pebbles');
  28146. * // => ['fred', 'barney', 'pebbles']
  28147. *
  28148. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  28149. * // => ['fred', 'barney', '&', 'pebbles']
  28150. */
  28151. function words(string, pattern, guard) {
  28152. string = toString(string);
  28153. pattern = guard ? undefined : pattern;
  28154. if (pattern === undefined) {
  28155. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  28156. }
  28157. return string.match(pattern) || [];
  28158. }
  28159. /*------------------------------------------------------------------------*/
  28160. /**
  28161. * Attempts to invoke `func`, returning either the result or the caught error
  28162. * object. Any additional arguments are provided to `func` when it's invoked.
  28163. *
  28164. * @static
  28165. * @memberOf _
  28166. * @since 3.0.0
  28167. * @category Util
  28168. * @param {Function} func The function to attempt.
  28169. * @param {...*} [args] The arguments to invoke `func` with.
  28170. * @returns {*} Returns the `func` result or error object.
  28171. * @example
  28172. *
  28173. * // Avoid throwing errors for invalid selectors.
  28174. * var elements = _.attempt(function(selector) {
  28175. * return document.querySelectorAll(selector);
  28176. * }, '>_>');
  28177. *
  28178. * if (_.isError(elements)) {
  28179. * elements = [];
  28180. * }
  28181. */
  28182. var attempt = baseRest(function(func, args) {
  28183. try {
  28184. return apply(func, undefined, args);
  28185. } catch (e) {
  28186. return isError(e) ? e : new Error(e);
  28187. }
  28188. });
  28189. /**
  28190. * Binds methods of an object to the object itself, overwriting the existing
  28191. * method.
  28192. *
  28193. * **Note:** This method doesn't set the "length" property of bound functions.
  28194. *
  28195. * @static
  28196. * @since 0.1.0
  28197. * @memberOf _
  28198. * @category Util
  28199. * @param {Object} object The object to bind and assign the bound methods to.
  28200. * @param {...(string|string[])} methodNames The object method names to bind.
  28201. * @returns {Object} Returns `object`.
  28202. * @example
  28203. *
  28204. * var view = {
  28205. * 'label': 'docs',
  28206. * 'click': function() {
  28207. * console.log('clicked ' + this.label);
  28208. * }
  28209. * };
  28210. *
  28211. * _.bindAll(view, ['click']);
  28212. * jQuery(element).on('click', view.click);
  28213. * // => Logs 'clicked docs' when clicked.
  28214. */
  28215. var bindAll = flatRest(function(object, methodNames) {
  28216. arrayEach(methodNames, function(key) {
  28217. key = toKey(key);
  28218. baseAssignValue(object, key, bind(object[key], object));
  28219. });
  28220. return object;
  28221. });
  28222. /**
  28223. * Creates a function that iterates over `pairs` and invokes the corresponding
  28224. * function of the first predicate to return truthy. The predicate-function
  28225. * pairs are invoked with the `this` binding and arguments of the created
  28226. * function.
  28227. *
  28228. * @static
  28229. * @memberOf _
  28230. * @since 4.0.0
  28231. * @category Util
  28232. * @param {Array} pairs The predicate-function pairs.
  28233. * @returns {Function} Returns the new composite function.
  28234. * @example
  28235. *
  28236. * var func = _.cond([
  28237. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  28238. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  28239. * [_.stubTrue, _.constant('no match')]
  28240. * ]);
  28241. *
  28242. * func({ 'a': 1, 'b': 2 });
  28243. * // => 'matches A'
  28244. *
  28245. * func({ 'a': 0, 'b': 1 });
  28246. * // => 'matches B'
  28247. *
  28248. * func({ 'a': '1', 'b': '2' });
  28249. * // => 'no match'
  28250. */
  28251. function cond(pairs) {
  28252. var length = pairs == null ? 0 : pairs.length,
  28253. toIteratee = getIteratee();
  28254. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  28255. if (typeof pair[1] != 'function') {
  28256. throw new TypeError(FUNC_ERROR_TEXT);
  28257. }
  28258. return [toIteratee(pair[0]), pair[1]];
  28259. });
  28260. return baseRest(function(args) {
  28261. var index = -1;
  28262. while (++index < length) {
  28263. var pair = pairs[index];
  28264. if (apply(pair[0], this, args)) {
  28265. return apply(pair[1], this, args);
  28266. }
  28267. }
  28268. });
  28269. }
  28270. /**
  28271. * Creates a function that invokes the predicate properties of `source` with
  28272. * the corresponding property values of a given object, returning `true` if
  28273. * all predicates return truthy, else `false`.
  28274. *
  28275. * **Note:** The created function is equivalent to `_.conformsTo` with
  28276. * `source` partially applied.
  28277. *
  28278. * @static
  28279. * @memberOf _
  28280. * @since 4.0.0
  28281. * @category Util
  28282. * @param {Object} source The object of property predicates to conform to.
  28283. * @returns {Function} Returns the new spec function.
  28284. * @example
  28285. *
  28286. * var objects = [
  28287. * { 'a': 2, 'b': 1 },
  28288. * { 'a': 1, 'b': 2 }
  28289. * ];
  28290. *
  28291. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  28292. * // => [{ 'a': 1, 'b': 2 }]
  28293. */
  28294. function conforms(source) {
  28295. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  28296. }
  28297. /**
  28298. * Creates a function that returns `value`.
  28299. *
  28300. * @static
  28301. * @memberOf _
  28302. * @since 2.4.0
  28303. * @category Util
  28304. * @param {*} value The value to return from the new function.
  28305. * @returns {Function} Returns the new constant function.
  28306. * @example
  28307. *
  28308. * var objects = _.times(2, _.constant({ 'a': 1 }));
  28309. *
  28310. * console.log(objects);
  28311. * // => [{ 'a': 1 }, { 'a': 1 }]
  28312. *
  28313. * console.log(objects[0] === objects[1]);
  28314. * // => true
  28315. */
  28316. function constant(value) {
  28317. return function() {
  28318. return value;
  28319. };
  28320. }
  28321. /**
  28322. * Checks `value` to determine whether a default value should be returned in
  28323. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  28324. * or `undefined`.
  28325. *
  28326. * @static
  28327. * @memberOf _
  28328. * @since 4.14.0
  28329. * @category Util
  28330. * @param {*} value The value to check.
  28331. * @param {*} defaultValue The default value.
  28332. * @returns {*} Returns the resolved value.
  28333. * @example
  28334. *
  28335. * _.defaultTo(1, 10);
  28336. * // => 1
  28337. *
  28338. * _.defaultTo(undefined, 10);
  28339. * // => 10
  28340. */
  28341. function defaultTo(value, defaultValue) {
  28342. return (value == null || value !== value) ? defaultValue : value;
  28343. }
  28344. /**
  28345. * Creates a function that returns the result of invoking the given functions
  28346. * with the `this` binding of the created function, where each successive
  28347. * invocation is supplied the return value of the previous.
  28348. *
  28349. * @static
  28350. * @memberOf _
  28351. * @since 3.0.0
  28352. * @category Util
  28353. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28354. * @returns {Function} Returns the new composite function.
  28355. * @see _.flowRight
  28356. * @example
  28357. *
  28358. * function square(n) {
  28359. * return n * n;
  28360. * }
  28361. *
  28362. * var addSquare = _.flow([_.add, square]);
  28363. * addSquare(1, 2);
  28364. * // => 9
  28365. */
  28366. var flow = createFlow();
  28367. /**
  28368. * This method is like `_.flow` except that it creates a function that
  28369. * invokes the given functions from right to left.
  28370. *
  28371. * @static
  28372. * @since 3.0.0
  28373. * @memberOf _
  28374. * @category Util
  28375. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28376. * @returns {Function} Returns the new composite function.
  28377. * @see _.flow
  28378. * @example
  28379. *
  28380. * function square(n) {
  28381. * return n * n;
  28382. * }
  28383. *
  28384. * var addSquare = _.flowRight([square, _.add]);
  28385. * addSquare(1, 2);
  28386. * // => 9
  28387. */
  28388. var flowRight = createFlow(true);
  28389. /**
  28390. * This method returns the first argument it receives.
  28391. *
  28392. * @static
  28393. * @since 0.1.0
  28394. * @memberOf _
  28395. * @category Util
  28396. * @param {*} value Any value.
  28397. * @returns {*} Returns `value`.
  28398. * @example
  28399. *
  28400. * var object = { 'a': 1 };
  28401. *
  28402. * console.log(_.identity(object) === object);
  28403. * // => true
  28404. */
  28405. function identity(value) {
  28406. return value;
  28407. }
  28408. /**
  28409. * Creates a function that invokes `func` with the arguments of the created
  28410. * function. If `func` is a property name, the created function returns the
  28411. * property value for a given element. If `func` is an array or object, the
  28412. * created function returns `true` for elements that contain the equivalent
  28413. * source properties, otherwise it returns `false`.
  28414. *
  28415. * @static
  28416. * @since 4.0.0
  28417. * @memberOf _
  28418. * @category Util
  28419. * @param {*} [func=_.identity] The value to convert to a callback.
  28420. * @returns {Function} Returns the callback.
  28421. * @example
  28422. *
  28423. * var users = [
  28424. * { 'user': 'barney', 'age': 36, 'active': true },
  28425. * { 'user': 'fred', 'age': 40, 'active': false }
  28426. * ];
  28427. *
  28428. * // The `_.matches` iteratee shorthand.
  28429. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  28430. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  28431. *
  28432. * // The `_.matchesProperty` iteratee shorthand.
  28433. * _.filter(users, _.iteratee(['user', 'fred']));
  28434. * // => [{ 'user': 'fred', 'age': 40 }]
  28435. *
  28436. * // The `_.property` iteratee shorthand.
  28437. * _.map(users, _.iteratee('user'));
  28438. * // => ['barney', 'fred']
  28439. *
  28440. * // Create custom iteratee shorthands.
  28441. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  28442. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  28443. * return func.test(string);
  28444. * };
  28445. * });
  28446. *
  28447. * _.filter(['abc', 'def'], /ef/);
  28448. * // => ['def']
  28449. */
  28450. function iteratee(func) {
  28451. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  28452. }
  28453. /**
  28454. * Creates a function that performs a partial deep comparison between a given
  28455. * object and `source`, returning `true` if the given object has equivalent
  28456. * property values, else `false`.
  28457. *
  28458. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  28459. * partially applied.
  28460. *
  28461. * Partial comparisons will match empty array and empty object `source`
  28462. * values against any array or object value, respectively. See `_.isEqual`
  28463. * for a list of supported value comparisons.
  28464. *
  28465. * @static
  28466. * @memberOf _
  28467. * @since 3.0.0
  28468. * @category Util
  28469. * @param {Object} source The object of property values to match.
  28470. * @returns {Function} Returns the new spec function.
  28471. * @example
  28472. *
  28473. * var objects = [
  28474. * { 'a': 1, 'b': 2, 'c': 3 },
  28475. * { 'a': 4, 'b': 5, 'c': 6 }
  28476. * ];
  28477. *
  28478. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  28479. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  28480. */
  28481. function matches(source) {
  28482. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  28483. }
  28484. /**
  28485. * Creates a function that performs a partial deep comparison between the
  28486. * value at `path` of a given object to `srcValue`, returning `true` if the
  28487. * object value is equivalent, else `false`.
  28488. *
  28489. * **Note:** Partial comparisons will match empty array and empty object
  28490. * `srcValue` values against any array or object value, respectively. See
  28491. * `_.isEqual` for a list of supported value comparisons.
  28492. *
  28493. * @static
  28494. * @memberOf _
  28495. * @since 3.2.0
  28496. * @category Util
  28497. * @param {Array|string} path The path of the property to get.
  28498. * @param {*} srcValue The value to match.
  28499. * @returns {Function} Returns the new spec function.
  28500. * @example
  28501. *
  28502. * var objects = [
  28503. * { 'a': 1, 'b': 2, 'c': 3 },
  28504. * { 'a': 4, 'b': 5, 'c': 6 }
  28505. * ];
  28506. *
  28507. * _.find(objects, _.matchesProperty('a', 4));
  28508. * // => { 'a': 4, 'b': 5, 'c': 6 }
  28509. */
  28510. function matchesProperty(path, srcValue) {
  28511. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  28512. }
  28513. /**
  28514. * Creates a function that invokes the method at `path` of a given object.
  28515. * Any additional arguments are provided to the invoked method.
  28516. *
  28517. * @static
  28518. * @memberOf _
  28519. * @since 3.7.0
  28520. * @category Util
  28521. * @param {Array|string} path The path of the method to invoke.
  28522. * @param {...*} [args] The arguments to invoke the method with.
  28523. * @returns {Function} Returns the new invoker function.
  28524. * @example
  28525. *
  28526. * var objects = [
  28527. * { 'a': { 'b': _.constant(2) } },
  28528. * { 'a': { 'b': _.constant(1) } }
  28529. * ];
  28530. *
  28531. * _.map(objects, _.method('a.b'));
  28532. * // => [2, 1]
  28533. *
  28534. * _.map(objects, _.method(['a', 'b']));
  28535. * // => [2, 1]
  28536. */
  28537. var method = baseRest(function(path, args) {
  28538. return function(object) {
  28539. return baseInvoke(object, path, args);
  28540. };
  28541. });
  28542. /**
  28543. * The opposite of `_.method`; this method creates a function that invokes
  28544. * the method at a given path of `object`. Any additional arguments are
  28545. * provided to the invoked method.
  28546. *
  28547. * @static
  28548. * @memberOf _
  28549. * @since 3.7.0
  28550. * @category Util
  28551. * @param {Object} object The object to query.
  28552. * @param {...*} [args] The arguments to invoke the method with.
  28553. * @returns {Function} Returns the new invoker function.
  28554. * @example
  28555. *
  28556. * var array = _.times(3, _.constant),
  28557. * object = { 'a': array, 'b': array, 'c': array };
  28558. *
  28559. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  28560. * // => [2, 0]
  28561. *
  28562. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  28563. * // => [2, 0]
  28564. */
  28565. var methodOf = baseRest(function(object, args) {
  28566. return function(path) {
  28567. return baseInvoke(object, path, args);
  28568. };
  28569. });
  28570. /**
  28571. * Adds all own enumerable string keyed function properties of a source
  28572. * object to the destination object. If `object` is a function, then methods
  28573. * are added to its prototype as well.
  28574. *
  28575. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  28576. * avoid conflicts caused by modifying the original.
  28577. *
  28578. * @static
  28579. * @since 0.1.0
  28580. * @memberOf _
  28581. * @category Util
  28582. * @param {Function|Object} [object=lodash] The destination object.
  28583. * @param {Object} source The object of functions to add.
  28584. * @param {Object} [options={}] The options object.
  28585. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  28586. * @returns {Function|Object} Returns `object`.
  28587. * @example
  28588. *
  28589. * function vowels(string) {
  28590. * return _.filter(string, function(v) {
  28591. * return /[aeiou]/i.test(v);
  28592. * });
  28593. * }
  28594. *
  28595. * _.mixin({ 'vowels': vowels });
  28596. * _.vowels('fred');
  28597. * // => ['e']
  28598. *
  28599. * _('fred').vowels().value();
  28600. * // => ['e']
  28601. *
  28602. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  28603. * _('fred').vowels();
  28604. * // => ['e']
  28605. */
  28606. function mixin(object, source, options) {
  28607. var props = keys(source),
  28608. methodNames = baseFunctions(source, props);
  28609. if (options == null &&
  28610. !(isObject(source) && (methodNames.length || !props.length))) {
  28611. options = source;
  28612. source = object;
  28613. object = this;
  28614. methodNames = baseFunctions(source, keys(source));
  28615. }
  28616. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  28617. isFunc = isFunction(object);
  28618. arrayEach(methodNames, function(methodName) {
  28619. var func = source[methodName];
  28620. object[methodName] = func;
  28621. if (isFunc) {
  28622. object.prototype[methodName] = function() {
  28623. var chainAll = this.__chain__;
  28624. if (chain || chainAll) {
  28625. var result = object(this.__wrapped__),
  28626. actions = result.__actions__ = copyArray(this.__actions__);
  28627. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  28628. result.__chain__ = chainAll;
  28629. return result;
  28630. }
  28631. return func.apply(object, arrayPush([this.value()], arguments));
  28632. };
  28633. }
  28634. });
  28635. return object;
  28636. }
  28637. /**
  28638. * Reverts the `_` variable to its previous value and returns a reference to
  28639. * the `lodash` function.
  28640. *
  28641. * @static
  28642. * @since 0.1.0
  28643. * @memberOf _
  28644. * @category Util
  28645. * @returns {Function} Returns the `lodash` function.
  28646. * @example
  28647. *
  28648. * var lodash = _.noConflict();
  28649. */
  28650. function noConflict() {
  28651. if (root._ === this) {
  28652. root._ = oldDash;
  28653. }
  28654. return this;
  28655. }
  28656. /**
  28657. * This method returns `undefined`.
  28658. *
  28659. * @static
  28660. * @memberOf _
  28661. * @since 2.3.0
  28662. * @category Util
  28663. * @example
  28664. *
  28665. * _.times(2, _.noop);
  28666. * // => [undefined, undefined]
  28667. */
  28668. function noop() {
  28669. // No operation performed.
  28670. }
  28671. /**
  28672. * Creates a function that gets the argument at index `n`. If `n` is negative,
  28673. * the nth argument from the end is returned.
  28674. *
  28675. * @static
  28676. * @memberOf _
  28677. * @since 4.0.0
  28678. * @category Util
  28679. * @param {number} [n=0] The index of the argument to return.
  28680. * @returns {Function} Returns the new pass-thru function.
  28681. * @example
  28682. *
  28683. * var func = _.nthArg(1);
  28684. * func('a', 'b', 'c', 'd');
  28685. * // => 'b'
  28686. *
  28687. * var func = _.nthArg(-2);
  28688. * func('a', 'b', 'c', 'd');
  28689. * // => 'c'
  28690. */
  28691. function nthArg(n) {
  28692. n = toInteger(n);
  28693. return baseRest(function(args) {
  28694. return baseNth(args, n);
  28695. });
  28696. }
  28697. /**
  28698. * Creates a function that invokes `iteratees` with the arguments it receives
  28699. * and returns their results.
  28700. *
  28701. * @static
  28702. * @memberOf _
  28703. * @since 4.0.0
  28704. * @category Util
  28705. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  28706. * The iteratees to invoke.
  28707. * @returns {Function} Returns the new function.
  28708. * @example
  28709. *
  28710. * var func = _.over([Math.max, Math.min]);
  28711. *
  28712. * func(1, 2, 3, 4);
  28713. * // => [4, 1]
  28714. */
  28715. var over = createOver(arrayMap);
  28716. /**
  28717. * Creates a function that checks if **all** of the `predicates` return
  28718. * truthy when invoked with the arguments it receives.
  28719. *
  28720. * @static
  28721. * @memberOf _
  28722. * @since 4.0.0
  28723. * @category Util
  28724. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28725. * The predicates to check.
  28726. * @returns {Function} Returns the new function.
  28727. * @example
  28728. *
  28729. * var func = _.overEvery([Boolean, isFinite]);
  28730. *
  28731. * func('1');
  28732. * // => true
  28733. *
  28734. * func(null);
  28735. * // => false
  28736. *
  28737. * func(NaN);
  28738. * // => false
  28739. */
  28740. var overEvery = createOver(arrayEvery);
  28741. /**
  28742. * Creates a function that checks if **any** of the `predicates` return
  28743. * truthy when invoked with the arguments it receives.
  28744. *
  28745. * @static
  28746. * @memberOf _
  28747. * @since 4.0.0
  28748. * @category Util
  28749. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28750. * The predicates to check.
  28751. * @returns {Function} Returns the new function.
  28752. * @example
  28753. *
  28754. * var func = _.overSome([Boolean, isFinite]);
  28755. *
  28756. * func('1');
  28757. * // => true
  28758. *
  28759. * func(null);
  28760. * // => true
  28761. *
  28762. * func(NaN);
  28763. * // => false
  28764. */
  28765. var overSome = createOver(arraySome);
  28766. /**
  28767. * Creates a function that returns the value at `path` of a given object.
  28768. *
  28769. * @static
  28770. * @memberOf _
  28771. * @since 2.4.0
  28772. * @category Util
  28773. * @param {Array|string} path The path of the property to get.
  28774. * @returns {Function} Returns the new accessor function.
  28775. * @example
  28776. *
  28777. * var objects = [
  28778. * { 'a': { 'b': 2 } },
  28779. * { 'a': { 'b': 1 } }
  28780. * ];
  28781. *
  28782. * _.map(objects, _.property('a.b'));
  28783. * // => [2, 1]
  28784. *
  28785. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  28786. * // => [1, 2]
  28787. */
  28788. function property(path) {
  28789. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  28790. }
  28791. /**
  28792. * The opposite of `_.property`; this method creates a function that returns
  28793. * the value at a given path of `object`.
  28794. *
  28795. * @static
  28796. * @memberOf _
  28797. * @since 3.0.0
  28798. * @category Util
  28799. * @param {Object} object The object to query.
  28800. * @returns {Function} Returns the new accessor function.
  28801. * @example
  28802. *
  28803. * var array = [0, 1, 2],
  28804. * object = { 'a': array, 'b': array, 'c': array };
  28805. *
  28806. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  28807. * // => [2, 0]
  28808. *
  28809. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  28810. * // => [2, 0]
  28811. */
  28812. function propertyOf(object) {
  28813. return function(path) {
  28814. return object == null ? undefined : baseGet(object, path);
  28815. };
  28816. }
  28817. /**
  28818. * Creates an array of numbers (positive and/or negative) progressing from
  28819. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  28820. * `start` is specified without an `end` or `step`. If `end` is not specified,
  28821. * it's set to `start` with `start` then set to `0`.
  28822. *
  28823. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  28824. * floating-point values which can produce unexpected results.
  28825. *
  28826. * @static
  28827. * @since 0.1.0
  28828. * @memberOf _
  28829. * @category Util
  28830. * @param {number} [start=0] The start of the range.
  28831. * @param {number} end The end of the range.
  28832. * @param {number} [step=1] The value to increment or decrement by.
  28833. * @returns {Array} Returns the range of numbers.
  28834. * @see _.inRange, _.rangeRight
  28835. * @example
  28836. *
  28837. * _.range(4);
  28838. * // => [0, 1, 2, 3]
  28839. *
  28840. * _.range(-4);
  28841. * // => [0, -1, -2, -3]
  28842. *
  28843. * _.range(1, 5);
  28844. * // => [1, 2, 3, 4]
  28845. *
  28846. * _.range(0, 20, 5);
  28847. * // => [0, 5, 10, 15]
  28848. *
  28849. * _.range(0, -4, -1);
  28850. * // => [0, -1, -2, -3]
  28851. *
  28852. * _.range(1, 4, 0);
  28853. * // => [1, 1, 1]
  28854. *
  28855. * _.range(0);
  28856. * // => []
  28857. */
  28858. var range = createRange();
  28859. /**
  28860. * This method is like `_.range` except that it populates values in
  28861. * descending order.
  28862. *
  28863. * @static
  28864. * @memberOf _
  28865. * @since 4.0.0
  28866. * @category Util
  28867. * @param {number} [start=0] The start of the range.
  28868. * @param {number} end The end of the range.
  28869. * @param {number} [step=1] The value to increment or decrement by.
  28870. * @returns {Array} Returns the range of numbers.
  28871. * @see _.inRange, _.range
  28872. * @example
  28873. *
  28874. * _.rangeRight(4);
  28875. * // => [3, 2, 1, 0]
  28876. *
  28877. * _.rangeRight(-4);
  28878. * // => [-3, -2, -1, 0]
  28879. *
  28880. * _.rangeRight(1, 5);
  28881. * // => [4, 3, 2, 1]
  28882. *
  28883. * _.rangeRight(0, 20, 5);
  28884. * // => [15, 10, 5, 0]
  28885. *
  28886. * _.rangeRight(0, -4, -1);
  28887. * // => [-3, -2, -1, 0]
  28888. *
  28889. * _.rangeRight(1, 4, 0);
  28890. * // => [1, 1, 1]
  28891. *
  28892. * _.rangeRight(0);
  28893. * // => []
  28894. */
  28895. var rangeRight = createRange(true);
  28896. /**
  28897. * This method returns a new empty array.
  28898. *
  28899. * @static
  28900. * @memberOf _
  28901. * @since 4.13.0
  28902. * @category Util
  28903. * @returns {Array} Returns the new empty array.
  28904. * @example
  28905. *
  28906. * var arrays = _.times(2, _.stubArray);
  28907. *
  28908. * console.log(arrays);
  28909. * // => [[], []]
  28910. *
  28911. * console.log(arrays[0] === arrays[1]);
  28912. * // => false
  28913. */
  28914. function stubArray() {
  28915. return [];
  28916. }
  28917. /**
  28918. * This method returns `false`.
  28919. *
  28920. * @static
  28921. * @memberOf _
  28922. * @since 4.13.0
  28923. * @category Util
  28924. * @returns {boolean} Returns `false`.
  28925. * @example
  28926. *
  28927. * _.times(2, _.stubFalse);
  28928. * // => [false, false]
  28929. */
  28930. function stubFalse() {
  28931. return false;
  28932. }
  28933. /**
  28934. * This method returns a new empty object.
  28935. *
  28936. * @static
  28937. * @memberOf _
  28938. * @since 4.13.0
  28939. * @category Util
  28940. * @returns {Object} Returns the new empty object.
  28941. * @example
  28942. *
  28943. * var objects = _.times(2, _.stubObject);
  28944. *
  28945. * console.log(objects);
  28946. * // => [{}, {}]
  28947. *
  28948. * console.log(objects[0] === objects[1]);
  28949. * // => false
  28950. */
  28951. function stubObject() {
  28952. return {};
  28953. }
  28954. /**
  28955. * This method returns an empty string.
  28956. *
  28957. * @static
  28958. * @memberOf _
  28959. * @since 4.13.0
  28960. * @category Util
  28961. * @returns {string} Returns the empty string.
  28962. * @example
  28963. *
  28964. * _.times(2, _.stubString);
  28965. * // => ['', '']
  28966. */
  28967. function stubString() {
  28968. return '';
  28969. }
  28970. /**
  28971. * This method returns `true`.
  28972. *
  28973. * @static
  28974. * @memberOf _
  28975. * @since 4.13.0
  28976. * @category Util
  28977. * @returns {boolean} Returns `true`.
  28978. * @example
  28979. *
  28980. * _.times(2, _.stubTrue);
  28981. * // => [true, true]
  28982. */
  28983. function stubTrue() {
  28984. return true;
  28985. }
  28986. /**
  28987. * Invokes the iteratee `n` times, returning an array of the results of
  28988. * each invocation. The iteratee is invoked with one argument; (index).
  28989. *
  28990. * @static
  28991. * @since 0.1.0
  28992. * @memberOf _
  28993. * @category Util
  28994. * @param {number} n The number of times to invoke `iteratee`.
  28995. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28996. * @returns {Array} Returns the array of results.
  28997. * @example
  28998. *
  28999. * _.times(3, String);
  29000. * // => ['0', '1', '2']
  29001. *
  29002. * _.times(4, _.constant(0));
  29003. * // => [0, 0, 0, 0]
  29004. */
  29005. function times(n, iteratee) {
  29006. n = toInteger(n);
  29007. if (n < 1 || n > MAX_SAFE_INTEGER) {
  29008. return [];
  29009. }
  29010. var index = MAX_ARRAY_LENGTH,
  29011. length = nativeMin(n, MAX_ARRAY_LENGTH);
  29012. iteratee = getIteratee(iteratee);
  29013. n -= MAX_ARRAY_LENGTH;
  29014. var result = baseTimes(length, iteratee);
  29015. while (++index < n) {
  29016. iteratee(index);
  29017. }
  29018. return result;
  29019. }
  29020. /**
  29021. * Converts `value` to a property path array.
  29022. *
  29023. * @static
  29024. * @memberOf _
  29025. * @since 4.0.0
  29026. * @category Util
  29027. * @param {*} value The value to convert.
  29028. * @returns {Array} Returns the new property path array.
  29029. * @example
  29030. *
  29031. * _.toPath('a.b.c');
  29032. * // => ['a', 'b', 'c']
  29033. *
  29034. * _.toPath('a[0].b.c');
  29035. * // => ['a', '0', 'b', 'c']
  29036. */
  29037. function toPath(value) {
  29038. if (isArray(value)) {
  29039. return arrayMap(value, toKey);
  29040. }
  29041. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  29042. }
  29043. /**
  29044. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  29045. *
  29046. * @static
  29047. * @since 0.1.0
  29048. * @memberOf _
  29049. * @category Util
  29050. * @param {string} [prefix=''] The value to prefix the ID with.
  29051. * @returns {string} Returns the unique ID.
  29052. * @example
  29053. *
  29054. * _.uniqueId('contact_');
  29055. * // => 'contact_104'
  29056. *
  29057. * _.uniqueId();
  29058. * // => '105'
  29059. */
  29060. function uniqueId(prefix) {
  29061. var id = ++idCounter;
  29062. return toString(prefix) + id;
  29063. }
  29064. /*------------------------------------------------------------------------*/
  29065. /**
  29066. * Adds two numbers.
  29067. *
  29068. * @static
  29069. * @memberOf _
  29070. * @since 3.4.0
  29071. * @category Math
  29072. * @param {number} augend The first number in an addition.
  29073. * @param {number} addend The second number in an addition.
  29074. * @returns {number} Returns the total.
  29075. * @example
  29076. *
  29077. * _.add(6, 4);
  29078. * // => 10
  29079. */
  29080. var add = createMathOperation(function(augend, addend) {
  29081. return augend + addend;
  29082. }, 0);
  29083. /**
  29084. * Computes `number` rounded up to `precision`.
  29085. *
  29086. * @static
  29087. * @memberOf _
  29088. * @since 3.10.0
  29089. * @category Math
  29090. * @param {number} number The number to round up.
  29091. * @param {number} [precision=0] The precision to round up to.
  29092. * @returns {number} Returns the rounded up number.
  29093. * @example
  29094. *
  29095. * _.ceil(4.006);
  29096. * // => 5
  29097. *
  29098. * _.ceil(6.004, 2);
  29099. * // => 6.01
  29100. *
  29101. * _.ceil(6040, -2);
  29102. * // => 6100
  29103. */
  29104. var ceil = createRound('ceil');
  29105. /**
  29106. * Divide two numbers.
  29107. *
  29108. * @static
  29109. * @memberOf _
  29110. * @since 4.7.0
  29111. * @category Math
  29112. * @param {number} dividend The first number in a division.
  29113. * @param {number} divisor The second number in a division.
  29114. * @returns {number} Returns the quotient.
  29115. * @example
  29116. *
  29117. * _.divide(6, 4);
  29118. * // => 1.5
  29119. */
  29120. var divide = createMathOperation(function(dividend, divisor) {
  29121. return dividend / divisor;
  29122. }, 1);
  29123. /**
  29124. * Computes `number` rounded down to `precision`.
  29125. *
  29126. * @static
  29127. * @memberOf _
  29128. * @since 3.10.0
  29129. * @category Math
  29130. * @param {number} number The number to round down.
  29131. * @param {number} [precision=0] The precision to round down to.
  29132. * @returns {number} Returns the rounded down number.
  29133. * @example
  29134. *
  29135. * _.floor(4.006);
  29136. * // => 4
  29137. *
  29138. * _.floor(0.046, 2);
  29139. * // => 0.04
  29140. *
  29141. * _.floor(4060, -2);
  29142. * // => 4000
  29143. */
  29144. var floor = createRound('floor');
  29145. /**
  29146. * Computes the maximum value of `array`. If `array` is empty or falsey,
  29147. * `undefined` is returned.
  29148. *
  29149. * @static
  29150. * @since 0.1.0
  29151. * @memberOf _
  29152. * @category Math
  29153. * @param {Array} array The array to iterate over.
  29154. * @returns {*} Returns the maximum value.
  29155. * @example
  29156. *
  29157. * _.max([4, 2, 8, 6]);
  29158. * // => 8
  29159. *
  29160. * _.max([]);
  29161. * // => undefined
  29162. */
  29163. function max(array) {
  29164. return (array && array.length)
  29165. ? baseExtremum(array, identity, baseGt)
  29166. : undefined;
  29167. }
  29168. /**
  29169. * This method is like `_.max` except that it accepts `iteratee` which is
  29170. * invoked for each element in `array` to generate the criterion by which
  29171. * the value is ranked. The iteratee is invoked with one argument: (value).
  29172. *
  29173. * @static
  29174. * @memberOf _
  29175. * @since 4.0.0
  29176. * @category Math
  29177. * @param {Array} array The array to iterate over.
  29178. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29179. * @returns {*} Returns the maximum value.
  29180. * @example
  29181. *
  29182. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29183. *
  29184. * _.maxBy(objects, function(o) { return o.n; });
  29185. * // => { 'n': 2 }
  29186. *
  29187. * // The `_.property` iteratee shorthand.
  29188. * _.maxBy(objects, 'n');
  29189. * // => { 'n': 2 }
  29190. */
  29191. function maxBy(array, iteratee) {
  29192. return (array && array.length)
  29193. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  29194. : undefined;
  29195. }
  29196. /**
  29197. * Computes the mean of the values in `array`.
  29198. *
  29199. * @static
  29200. * @memberOf _
  29201. * @since 4.0.0
  29202. * @category Math
  29203. * @param {Array} array The array to iterate over.
  29204. * @returns {number} Returns the mean.
  29205. * @example
  29206. *
  29207. * _.mean([4, 2, 8, 6]);
  29208. * // => 5
  29209. */
  29210. function mean(array) {
  29211. return baseMean(array, identity);
  29212. }
  29213. /**
  29214. * This method is like `_.mean` except that it accepts `iteratee` which is
  29215. * invoked for each element in `array` to generate the value to be averaged.
  29216. * The iteratee is invoked with one argument: (value).
  29217. *
  29218. * @static
  29219. * @memberOf _
  29220. * @since 4.7.0
  29221. * @category Math
  29222. * @param {Array} array The array to iterate over.
  29223. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29224. * @returns {number} Returns the mean.
  29225. * @example
  29226. *
  29227. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29228. *
  29229. * _.meanBy(objects, function(o) { return o.n; });
  29230. * // => 5
  29231. *
  29232. * // The `_.property` iteratee shorthand.
  29233. * _.meanBy(objects, 'n');
  29234. * // => 5
  29235. */
  29236. function meanBy(array, iteratee) {
  29237. return baseMean(array, getIteratee(iteratee, 2));
  29238. }
  29239. /**
  29240. * Computes the minimum value of `array`. If `array` is empty or falsey,
  29241. * `undefined` is returned.
  29242. *
  29243. * @static
  29244. * @since 0.1.0
  29245. * @memberOf _
  29246. * @category Math
  29247. * @param {Array} array The array to iterate over.
  29248. * @returns {*} Returns the minimum value.
  29249. * @example
  29250. *
  29251. * _.min([4, 2, 8, 6]);
  29252. * // => 2
  29253. *
  29254. * _.min([]);
  29255. * // => undefined
  29256. */
  29257. function min(array) {
  29258. return (array && array.length)
  29259. ? baseExtremum(array, identity, baseLt)
  29260. : undefined;
  29261. }
  29262. /**
  29263. * This method is like `_.min` except that it accepts `iteratee` which is
  29264. * invoked for each element in `array` to generate the criterion by which
  29265. * the value is ranked. The iteratee is invoked with one argument: (value).
  29266. *
  29267. * @static
  29268. * @memberOf _
  29269. * @since 4.0.0
  29270. * @category Math
  29271. * @param {Array} array The array to iterate over.
  29272. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29273. * @returns {*} Returns the minimum value.
  29274. * @example
  29275. *
  29276. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29277. *
  29278. * _.minBy(objects, function(o) { return o.n; });
  29279. * // => { 'n': 1 }
  29280. *
  29281. * // The `_.property` iteratee shorthand.
  29282. * _.minBy(objects, 'n');
  29283. * // => { 'n': 1 }
  29284. */
  29285. function minBy(array, iteratee) {
  29286. return (array && array.length)
  29287. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  29288. : undefined;
  29289. }
  29290. /**
  29291. * Multiply two numbers.
  29292. *
  29293. * @static
  29294. * @memberOf _
  29295. * @since 4.7.0
  29296. * @category Math
  29297. * @param {number} multiplier The first number in a multiplication.
  29298. * @param {number} multiplicand The second number in a multiplication.
  29299. * @returns {number} Returns the product.
  29300. * @example
  29301. *
  29302. * _.multiply(6, 4);
  29303. * // => 24
  29304. */
  29305. var multiply = createMathOperation(function(multiplier, multiplicand) {
  29306. return multiplier * multiplicand;
  29307. }, 1);
  29308. /**
  29309. * Computes `number` rounded to `precision`.
  29310. *
  29311. * @static
  29312. * @memberOf _
  29313. * @since 3.10.0
  29314. * @category Math
  29315. * @param {number} number The number to round.
  29316. * @param {number} [precision=0] The precision to round to.
  29317. * @returns {number} Returns the rounded number.
  29318. * @example
  29319. *
  29320. * _.round(4.006);
  29321. * // => 4
  29322. *
  29323. * _.round(4.006, 2);
  29324. * // => 4.01
  29325. *
  29326. * _.round(4060, -2);
  29327. * // => 4100
  29328. */
  29329. var round = createRound('round');
  29330. /**
  29331. * Subtract two numbers.
  29332. *
  29333. * @static
  29334. * @memberOf _
  29335. * @since 4.0.0
  29336. * @category Math
  29337. * @param {number} minuend The first number in a subtraction.
  29338. * @param {number} subtrahend The second number in a subtraction.
  29339. * @returns {number} Returns the difference.
  29340. * @example
  29341. *
  29342. * _.subtract(6, 4);
  29343. * // => 2
  29344. */
  29345. var subtract = createMathOperation(function(minuend, subtrahend) {
  29346. return minuend - subtrahend;
  29347. }, 0);
  29348. /**
  29349. * Computes the sum of the values in `array`.
  29350. *
  29351. * @static
  29352. * @memberOf _
  29353. * @since 3.4.0
  29354. * @category Math
  29355. * @param {Array} array The array to iterate over.
  29356. * @returns {number} Returns the sum.
  29357. * @example
  29358. *
  29359. * _.sum([4, 2, 8, 6]);
  29360. * // => 20
  29361. */
  29362. function sum(array) {
  29363. return (array && array.length)
  29364. ? baseSum(array, identity)
  29365. : 0;
  29366. }
  29367. /**
  29368. * This method is like `_.sum` except that it accepts `iteratee` which is
  29369. * invoked for each element in `array` to generate the value to be summed.
  29370. * The iteratee is invoked with one argument: (value).
  29371. *
  29372. * @static
  29373. * @memberOf _
  29374. * @since 4.0.0
  29375. * @category Math
  29376. * @param {Array} array The array to iterate over.
  29377. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29378. * @returns {number} Returns the sum.
  29379. * @example
  29380. *
  29381. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29382. *
  29383. * _.sumBy(objects, function(o) { return o.n; });
  29384. * // => 20
  29385. *
  29386. * // The `_.property` iteratee shorthand.
  29387. * _.sumBy(objects, 'n');
  29388. * // => 20
  29389. */
  29390. function sumBy(array, iteratee) {
  29391. return (array && array.length)
  29392. ? baseSum(array, getIteratee(iteratee, 2))
  29393. : 0;
  29394. }
  29395. /*------------------------------------------------------------------------*/
  29396. // Add methods that return wrapped values in chain sequences.
  29397. lodash.after = after;
  29398. lodash.ary = ary;
  29399. lodash.assign = assign;
  29400. lodash.assignIn = assignIn;
  29401. lodash.assignInWith = assignInWith;
  29402. lodash.assignWith = assignWith;
  29403. lodash.at = at;
  29404. lodash.before = before;
  29405. lodash.bind = bind;
  29406. lodash.bindAll = bindAll;
  29407. lodash.bindKey = bindKey;
  29408. lodash.castArray = castArray;
  29409. lodash.chain = chain;
  29410. lodash.chunk = chunk;
  29411. lodash.compact = compact;
  29412. lodash.concat = concat;
  29413. lodash.cond = cond;
  29414. lodash.conforms = conforms;
  29415. lodash.constant = constant;
  29416. lodash.countBy = countBy;
  29417. lodash.create = create;
  29418. lodash.curry = curry;
  29419. lodash.curryRight = curryRight;
  29420. lodash.debounce = debounce;
  29421. lodash.defaults = defaults;
  29422. lodash.defaultsDeep = defaultsDeep;
  29423. lodash.defer = defer;
  29424. lodash.delay = delay;
  29425. lodash.difference = difference;
  29426. lodash.differenceBy = differenceBy;
  29427. lodash.differenceWith = differenceWith;
  29428. lodash.drop = drop;
  29429. lodash.dropRight = dropRight;
  29430. lodash.dropRightWhile = dropRightWhile;
  29431. lodash.dropWhile = dropWhile;
  29432. lodash.fill = fill;
  29433. lodash.filter = filter;
  29434. lodash.flatMap = flatMap;
  29435. lodash.flatMapDeep = flatMapDeep;
  29436. lodash.flatMapDepth = flatMapDepth;
  29437. lodash.flatten = flatten;
  29438. lodash.flattenDeep = flattenDeep;
  29439. lodash.flattenDepth = flattenDepth;
  29440. lodash.flip = flip;
  29441. lodash.flow = flow;
  29442. lodash.flowRight = flowRight;
  29443. lodash.fromPairs = fromPairs;
  29444. lodash.functions = functions;
  29445. lodash.functionsIn = functionsIn;
  29446. lodash.groupBy = groupBy;
  29447. lodash.initial = initial;
  29448. lodash.intersection = intersection;
  29449. lodash.intersectionBy = intersectionBy;
  29450. lodash.intersectionWith = intersectionWith;
  29451. lodash.invert = invert;
  29452. lodash.invertBy = invertBy;
  29453. lodash.invokeMap = invokeMap;
  29454. lodash.iteratee = iteratee;
  29455. lodash.keyBy = keyBy;
  29456. lodash.keys = keys;
  29457. lodash.keysIn = keysIn;
  29458. lodash.map = map;
  29459. lodash.mapKeys = mapKeys;
  29460. lodash.mapValues = mapValues;
  29461. lodash.matches = matches;
  29462. lodash.matchesProperty = matchesProperty;
  29463. lodash.memoize = memoize;
  29464. lodash.merge = merge;
  29465. lodash.mergeWith = mergeWith;
  29466. lodash.method = method;
  29467. lodash.methodOf = methodOf;
  29468. lodash.mixin = mixin;
  29469. lodash.negate = negate;
  29470. lodash.nthArg = nthArg;
  29471. lodash.omit = omit;
  29472. lodash.omitBy = omitBy;
  29473. lodash.once = once;
  29474. lodash.orderBy = orderBy;
  29475. lodash.over = over;
  29476. lodash.overArgs = overArgs;
  29477. lodash.overEvery = overEvery;
  29478. lodash.overSome = overSome;
  29479. lodash.partial = partial;
  29480. lodash.partialRight = partialRight;
  29481. lodash.partition = partition;
  29482. lodash.pick = pick;
  29483. lodash.pickBy = pickBy;
  29484. lodash.property = property;
  29485. lodash.propertyOf = propertyOf;
  29486. lodash.pull = pull;
  29487. lodash.pullAll = pullAll;
  29488. lodash.pullAllBy = pullAllBy;
  29489. lodash.pullAllWith = pullAllWith;
  29490. lodash.pullAt = pullAt;
  29491. lodash.range = range;
  29492. lodash.rangeRight = rangeRight;
  29493. lodash.rearg = rearg;
  29494. lodash.reject = reject;
  29495. lodash.remove = remove;
  29496. lodash.rest = rest;
  29497. lodash.reverse = reverse;
  29498. lodash.sampleSize = sampleSize;
  29499. lodash.set = set;
  29500. lodash.setWith = setWith;
  29501. lodash.shuffle = shuffle;
  29502. lodash.slice = slice;
  29503. lodash.sortBy = sortBy;
  29504. lodash.sortedUniq = sortedUniq;
  29505. lodash.sortedUniqBy = sortedUniqBy;
  29506. lodash.split = split;
  29507. lodash.spread = spread;
  29508. lodash.tail = tail;
  29509. lodash.take = take;
  29510. lodash.takeRight = takeRight;
  29511. lodash.takeRightWhile = takeRightWhile;
  29512. lodash.takeWhile = takeWhile;
  29513. lodash.tap = tap;
  29514. lodash.throttle = throttle;
  29515. lodash.thru = thru;
  29516. lodash.toArray = toArray;
  29517. lodash.toPairs = toPairs;
  29518. lodash.toPairsIn = toPairsIn;
  29519. lodash.toPath = toPath;
  29520. lodash.toPlainObject = toPlainObject;
  29521. lodash.transform = transform;
  29522. lodash.unary = unary;
  29523. lodash.union = union;
  29524. lodash.unionBy = unionBy;
  29525. lodash.unionWith = unionWith;
  29526. lodash.uniq = uniq;
  29527. lodash.uniqBy = uniqBy;
  29528. lodash.uniqWith = uniqWith;
  29529. lodash.unset = unset;
  29530. lodash.unzip = unzip;
  29531. lodash.unzipWith = unzipWith;
  29532. lodash.update = update;
  29533. lodash.updateWith = updateWith;
  29534. lodash.values = values;
  29535. lodash.valuesIn = valuesIn;
  29536. lodash.without = without;
  29537. lodash.words = words;
  29538. lodash.wrap = wrap;
  29539. lodash.xor = xor;
  29540. lodash.xorBy = xorBy;
  29541. lodash.xorWith = xorWith;
  29542. lodash.zip = zip;
  29543. lodash.zipObject = zipObject;
  29544. lodash.zipObjectDeep = zipObjectDeep;
  29545. lodash.zipWith = zipWith;
  29546. // Add aliases.
  29547. lodash.entries = toPairs;
  29548. lodash.entriesIn = toPairsIn;
  29549. lodash.extend = assignIn;
  29550. lodash.extendWith = assignInWith;
  29551. // Add methods to `lodash.prototype`.
  29552. mixin(lodash, lodash);
  29553. /*------------------------------------------------------------------------*/
  29554. // Add methods that return unwrapped values in chain sequences.
  29555. lodash.add = add;
  29556. lodash.attempt = attempt;
  29557. lodash.camelCase = camelCase;
  29558. lodash.capitalize = capitalize;
  29559. lodash.ceil = ceil;
  29560. lodash.clamp = clamp;
  29561. lodash.clone = clone;
  29562. lodash.cloneDeep = cloneDeep;
  29563. lodash.cloneDeepWith = cloneDeepWith;
  29564. lodash.cloneWith = cloneWith;
  29565. lodash.conformsTo = conformsTo;
  29566. lodash.deburr = deburr;
  29567. lodash.defaultTo = defaultTo;
  29568. lodash.divide = divide;
  29569. lodash.endsWith = endsWith;
  29570. lodash.eq = eq;
  29571. lodash.escape = escape;
  29572. lodash.escapeRegExp = escapeRegExp;
  29573. lodash.every = every;
  29574. lodash.find = find;
  29575. lodash.findIndex = findIndex;
  29576. lodash.findKey = findKey;
  29577. lodash.findLast = findLast;
  29578. lodash.findLastIndex = findLastIndex;
  29579. lodash.findLastKey = findLastKey;
  29580. lodash.floor = floor;
  29581. lodash.forEach = forEach;
  29582. lodash.forEachRight = forEachRight;
  29583. lodash.forIn = forIn;
  29584. lodash.forInRight = forInRight;
  29585. lodash.forOwn = forOwn;
  29586. lodash.forOwnRight = forOwnRight;
  29587. lodash.get = get;
  29588. lodash.gt = gt;
  29589. lodash.gte = gte;
  29590. lodash.has = has;
  29591. lodash.hasIn = hasIn;
  29592. lodash.head = head;
  29593. lodash.identity = identity;
  29594. lodash.includes = includes;
  29595. lodash.indexOf = indexOf;
  29596. lodash.inRange = inRange;
  29597. lodash.invoke = invoke;
  29598. lodash.isArguments = isArguments;
  29599. lodash.isArray = isArray;
  29600. lodash.isArrayBuffer = isArrayBuffer;
  29601. lodash.isArrayLike = isArrayLike;
  29602. lodash.isArrayLikeObject = isArrayLikeObject;
  29603. lodash.isBoolean = isBoolean;
  29604. lodash.isBuffer = isBuffer;
  29605. lodash.isDate = isDate;
  29606. lodash.isElement = isElement;
  29607. lodash.isEmpty = isEmpty;
  29608. lodash.isEqual = isEqual;
  29609. lodash.isEqualWith = isEqualWith;
  29610. lodash.isError = isError;
  29611. lodash.isFinite = isFinite;
  29612. lodash.isFunction = isFunction;
  29613. lodash.isInteger = isInteger;
  29614. lodash.isLength = isLength;
  29615. lodash.isMap = isMap;
  29616. lodash.isMatch = isMatch;
  29617. lodash.isMatchWith = isMatchWith;
  29618. lodash.isNaN = isNaN;
  29619. lodash.isNative = isNative;
  29620. lodash.isNil = isNil;
  29621. lodash.isNull = isNull;
  29622. lodash.isNumber = isNumber;
  29623. lodash.isObject = isObject;
  29624. lodash.isObjectLike = isObjectLike;
  29625. lodash.isPlainObject = isPlainObject;
  29626. lodash.isRegExp = isRegExp;
  29627. lodash.isSafeInteger = isSafeInteger;
  29628. lodash.isSet = isSet;
  29629. lodash.isString = isString;
  29630. lodash.isSymbol = isSymbol;
  29631. lodash.isTypedArray = isTypedArray;
  29632. lodash.isUndefined = isUndefined;
  29633. lodash.isWeakMap = isWeakMap;
  29634. lodash.isWeakSet = isWeakSet;
  29635. lodash.join = join;
  29636. lodash.kebabCase = kebabCase;
  29637. lodash.last = last;
  29638. lodash.lastIndexOf = lastIndexOf;
  29639. lodash.lowerCase = lowerCase;
  29640. lodash.lowerFirst = lowerFirst;
  29641. lodash.lt = lt;
  29642. lodash.lte = lte;
  29643. lodash.max = max;
  29644. lodash.maxBy = maxBy;
  29645. lodash.mean = mean;
  29646. lodash.meanBy = meanBy;
  29647. lodash.min = min;
  29648. lodash.minBy = minBy;
  29649. lodash.stubArray = stubArray;
  29650. lodash.stubFalse = stubFalse;
  29651. lodash.stubObject = stubObject;
  29652. lodash.stubString = stubString;
  29653. lodash.stubTrue = stubTrue;
  29654. lodash.multiply = multiply;
  29655. lodash.nth = nth;
  29656. lodash.noConflict = noConflict;
  29657. lodash.noop = noop;
  29658. lodash.now = now;
  29659. lodash.pad = pad;
  29660. lodash.padEnd = padEnd;
  29661. lodash.padStart = padStart;
  29662. lodash.parseInt = parseInt;
  29663. lodash.random = random;
  29664. lodash.reduce = reduce;
  29665. lodash.reduceRight = reduceRight;
  29666. lodash.repeat = repeat;
  29667. lodash.replace = replace;
  29668. lodash.result = result;
  29669. lodash.round = round;
  29670. lodash.runInContext = runInContext;
  29671. lodash.sample = sample;
  29672. lodash.size = size;
  29673. lodash.snakeCase = snakeCase;
  29674. lodash.some = some;
  29675. lodash.sortedIndex = sortedIndex;
  29676. lodash.sortedIndexBy = sortedIndexBy;
  29677. lodash.sortedIndexOf = sortedIndexOf;
  29678. lodash.sortedLastIndex = sortedLastIndex;
  29679. lodash.sortedLastIndexBy = sortedLastIndexBy;
  29680. lodash.sortedLastIndexOf = sortedLastIndexOf;
  29681. lodash.startCase = startCase;
  29682. lodash.startsWith = startsWith;
  29683. lodash.subtract = subtract;
  29684. lodash.sum = sum;
  29685. lodash.sumBy = sumBy;
  29686. lodash.template = template;
  29687. lodash.times = times;
  29688. lodash.toFinite = toFinite;
  29689. lodash.toInteger = toInteger;
  29690. lodash.toLength = toLength;
  29691. lodash.toLower = toLower;
  29692. lodash.toNumber = toNumber;
  29693. lodash.toSafeInteger = toSafeInteger;
  29694. lodash.toString = toString;
  29695. lodash.toUpper = toUpper;
  29696. lodash.trim = trim;
  29697. lodash.trimEnd = trimEnd;
  29698. lodash.trimStart = trimStart;
  29699. lodash.truncate = truncate;
  29700. lodash.unescape = unescape;
  29701. lodash.uniqueId = uniqueId;
  29702. lodash.upperCase = upperCase;
  29703. lodash.upperFirst = upperFirst;
  29704. // Add aliases.
  29705. lodash.each = forEach;
  29706. lodash.eachRight = forEachRight;
  29707. lodash.first = head;
  29708. mixin(lodash, (function() {
  29709. var source = {};
  29710. baseForOwn(lodash, function(func, methodName) {
  29711. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  29712. source[methodName] = func;
  29713. }
  29714. });
  29715. return source;
  29716. }()), { 'chain': false });
  29717. /*------------------------------------------------------------------------*/
  29718. /**
  29719. * The semantic version number.
  29720. *
  29721. * @static
  29722. * @memberOf _
  29723. * @type {string}
  29724. */
  29725. lodash.VERSION = VERSION;
  29726. // Assign default placeholders.
  29727. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  29728. lodash[methodName].placeholder = lodash;
  29729. });
  29730. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  29731. arrayEach(['drop', 'take'], function(methodName, index) {
  29732. LazyWrapper.prototype[methodName] = function(n) {
  29733. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  29734. var result = (this.__filtered__ && !index)
  29735. ? new LazyWrapper(this)
  29736. : this.clone();
  29737. if (result.__filtered__) {
  29738. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  29739. } else {
  29740. result.__views__.push({
  29741. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  29742. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  29743. });
  29744. }
  29745. return result;
  29746. };
  29747. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  29748. return this.reverse()[methodName](n).reverse();
  29749. };
  29750. });
  29751. // Add `LazyWrapper` methods that accept an `iteratee` value.
  29752. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  29753. var type = index + 1,
  29754. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  29755. LazyWrapper.prototype[methodName] = function(iteratee) {
  29756. var result = this.clone();
  29757. result.__iteratees__.push({
  29758. 'iteratee': getIteratee(iteratee, 3),
  29759. 'type': type
  29760. });
  29761. result.__filtered__ = result.__filtered__ || isFilter;
  29762. return result;
  29763. };
  29764. });
  29765. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  29766. arrayEach(['head', 'last'], function(methodName, index) {
  29767. var takeName = 'take' + (index ? 'Right' : '');
  29768. LazyWrapper.prototype[methodName] = function() {
  29769. return this[takeName](1).value()[0];
  29770. };
  29771. });
  29772. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  29773. arrayEach(['initial', 'tail'], function(methodName, index) {
  29774. var dropName = 'drop' + (index ? '' : 'Right');
  29775. LazyWrapper.prototype[methodName] = function() {
  29776. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  29777. };
  29778. });
  29779. LazyWrapper.prototype.compact = function() {
  29780. return this.filter(identity);
  29781. };
  29782. LazyWrapper.prototype.find = function(predicate) {
  29783. return this.filter(predicate).head();
  29784. };
  29785. LazyWrapper.prototype.findLast = function(predicate) {
  29786. return this.reverse().find(predicate);
  29787. };
  29788. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  29789. if (typeof path == 'function') {
  29790. return new LazyWrapper(this);
  29791. }
  29792. return this.map(function(value) {
  29793. return baseInvoke(value, path, args);
  29794. });
  29795. });
  29796. LazyWrapper.prototype.reject = function(predicate) {
  29797. return this.filter(negate(getIteratee(predicate)));
  29798. };
  29799. LazyWrapper.prototype.slice = function(start, end) {
  29800. start = toInteger(start);
  29801. var result = this;
  29802. if (result.__filtered__ && (start > 0 || end < 0)) {
  29803. return new LazyWrapper(result);
  29804. }
  29805. if (start < 0) {
  29806. result = result.takeRight(-start);
  29807. } else if (start) {
  29808. result = result.drop(start);
  29809. }
  29810. if (end !== undefined) {
  29811. end = toInteger(end);
  29812. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  29813. }
  29814. return result;
  29815. };
  29816. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  29817. return this.reverse().takeWhile(predicate).reverse();
  29818. };
  29819. LazyWrapper.prototype.toArray = function() {
  29820. return this.take(MAX_ARRAY_LENGTH);
  29821. };
  29822. // Add `LazyWrapper` methods to `lodash.prototype`.
  29823. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29824. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  29825. isTaker = /^(?:head|last)$/.test(methodName),
  29826. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  29827. retUnwrapped = isTaker || /^find/.test(methodName);
  29828. if (!lodashFunc) {
  29829. return;
  29830. }
  29831. lodash.prototype[methodName] = function() {
  29832. var value = this.__wrapped__,
  29833. args = isTaker ? [1] : arguments,
  29834. isLazy = value instanceof LazyWrapper,
  29835. iteratee = args[0],
  29836. useLazy = isLazy || isArray(value);
  29837. var interceptor = function(value) {
  29838. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  29839. return (isTaker && chainAll) ? result[0] : result;
  29840. };
  29841. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  29842. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  29843. isLazy = useLazy = false;
  29844. }
  29845. var chainAll = this.__chain__,
  29846. isHybrid = !!this.__actions__.length,
  29847. isUnwrapped = retUnwrapped && !chainAll,
  29848. onlyLazy = isLazy && !isHybrid;
  29849. if (!retUnwrapped && useLazy) {
  29850. value = onlyLazy ? value : new LazyWrapper(this);
  29851. var result = func.apply(value, args);
  29852. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  29853. return new LodashWrapper(result, chainAll);
  29854. }
  29855. if (isUnwrapped && onlyLazy) {
  29856. return func.apply(this, args);
  29857. }
  29858. result = this.thru(interceptor);
  29859. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  29860. };
  29861. });
  29862. // Add `Array` methods to `lodash.prototype`.
  29863. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  29864. var func = arrayProto[methodName],
  29865. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  29866. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  29867. lodash.prototype[methodName] = function() {
  29868. var args = arguments;
  29869. if (retUnwrapped && !this.__chain__) {
  29870. var value = this.value();
  29871. return func.apply(isArray(value) ? value : [], args);
  29872. }
  29873. return this[chainName](function(value) {
  29874. return func.apply(isArray(value) ? value : [], args);
  29875. });
  29876. };
  29877. });
  29878. // Map minified method names to their real names.
  29879. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29880. var lodashFunc = lodash[methodName];
  29881. if (lodashFunc) {
  29882. var key = lodashFunc.name + '';
  29883. if (!hasOwnProperty.call(realNames, key)) {
  29884. realNames[key] = [];
  29885. }
  29886. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  29887. }
  29888. });
  29889. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  29890. 'name': 'wrapper',
  29891. 'func': undefined
  29892. }];
  29893. // Add methods to `LazyWrapper`.
  29894. LazyWrapper.prototype.clone = lazyClone;
  29895. LazyWrapper.prototype.reverse = lazyReverse;
  29896. LazyWrapper.prototype.value = lazyValue;
  29897. // Add chain sequence methods to the `lodash` wrapper.
  29898. lodash.prototype.at = wrapperAt;
  29899. lodash.prototype.chain = wrapperChain;
  29900. lodash.prototype.commit = wrapperCommit;
  29901. lodash.prototype.next = wrapperNext;
  29902. lodash.prototype.plant = wrapperPlant;
  29903. lodash.prototype.reverse = wrapperReverse;
  29904. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  29905. // Add lazy aliases.
  29906. lodash.prototype.first = lodash.prototype.head;
  29907. if (symIterator) {
  29908. lodash.prototype[symIterator] = wrapperToIterator;
  29909. }
  29910. return lodash;
  29911. });
  29912. /*--------------------------------------------------------------------------*/
  29913. // Export lodash.
  29914. var _ = runInContext();
  29915. // Some AMD build optimizers, like r.js, check for condition patterns like:
  29916. if (true) {
  29917. // Expose Lodash on the global object to prevent errors when Lodash is
  29918. // loaded by a script tag in the presence of an AMD loader.
  29919. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  29920. // Use `_.noConflict` to remove Lodash from the global object.
  29921. root._ = _;
  29922. // Define as an anonymous module so, through path mapping, it can be
  29923. // referenced as the "underscore" module.
  29924. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  29925. return _;
  29926. }).call(exports, __webpack_require__, exports, module),
  29927. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  29928. }
  29929. // Check for `exports` after `define` in case a build optimizer adds it.
  29930. else {}
  29931. }.call(this));
  29932. /* 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)))
  29933. /***/ }),
  29934. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  29935. /*!***************************************************!*\
  29936. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  29937. \***************************************************/
  29938. /*! exports provided: default */
  29939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  29940. "use strict";
  29941. __webpack_require__.r(__webpack_exports__);
  29942. /* WEBPACK VAR INJECTION */(function(global) {/**!
  29943. * @fileOverview Kickass library to create and place poppers near their reference elements.
  29944. * @version 1.16.1
  29945. * @license
  29946. * Copyright (c) 2016 Federico Zivolo and contributors
  29947. *
  29948. * Permission is hereby granted, free of charge, to any person obtaining a copy
  29949. * of this software and associated documentation files (the "Software"), to deal
  29950. * in the Software without restriction, including without limitation the rights
  29951. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  29952. * copies of the Software, and to permit persons to whom the Software is
  29953. * furnished to do so, subject to the following conditions:
  29954. *
  29955. * The above copyright notice and this permission notice shall be included in all
  29956. * copies or substantial portions of the Software.
  29957. *
  29958. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29959. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  29960. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  29961. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29962. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29963. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29964. * SOFTWARE.
  29965. */
  29966. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  29967. var timeoutDuration = function () {
  29968. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  29969. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  29970. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  29971. return 1;
  29972. }
  29973. }
  29974. return 0;
  29975. }();
  29976. function microtaskDebounce(fn) {
  29977. var called = false;
  29978. return function () {
  29979. if (called) {
  29980. return;
  29981. }
  29982. called = true;
  29983. window.Promise.resolve().then(function () {
  29984. called = false;
  29985. fn();
  29986. });
  29987. };
  29988. }
  29989. function taskDebounce(fn) {
  29990. var scheduled = false;
  29991. return function () {
  29992. if (!scheduled) {
  29993. scheduled = true;
  29994. setTimeout(function () {
  29995. scheduled = false;
  29996. fn();
  29997. }, timeoutDuration);
  29998. }
  29999. };
  30000. }
  30001. var supportsMicroTasks = isBrowser && window.Promise;
  30002. /**
  30003. * Create a debounced version of a method, that's asynchronously deferred
  30004. * but called in the minimum time possible.
  30005. *
  30006. * @method
  30007. * @memberof Popper.Utils
  30008. * @argument {Function} fn
  30009. * @returns {Function}
  30010. */
  30011. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  30012. /**
  30013. * Check if the given variable is a function
  30014. * @method
  30015. * @memberof Popper.Utils
  30016. * @argument {Any} functionToCheck - variable to check
  30017. * @returns {Boolean} answer to: is a function?
  30018. */
  30019. function isFunction(functionToCheck) {
  30020. var getType = {};
  30021. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  30022. }
  30023. /**
  30024. * Get CSS computed property of the given element
  30025. * @method
  30026. * @memberof Popper.Utils
  30027. * @argument {Eement} element
  30028. * @argument {String} property
  30029. */
  30030. function getStyleComputedProperty(element, property) {
  30031. if (element.nodeType !== 1) {
  30032. return [];
  30033. }
  30034. // NOTE: 1 DOM access here
  30035. var window = element.ownerDocument.defaultView;
  30036. var css = window.getComputedStyle(element, null);
  30037. return property ? css[property] : css;
  30038. }
  30039. /**
  30040. * Returns the parentNode or the host of the element
  30041. * @method
  30042. * @memberof Popper.Utils
  30043. * @argument {Element} element
  30044. * @returns {Element} parent
  30045. */
  30046. function getParentNode(element) {
  30047. if (element.nodeName === 'HTML') {
  30048. return element;
  30049. }
  30050. return element.parentNode || element.host;
  30051. }
  30052. /**
  30053. * Returns the scrolling parent of the given element
  30054. * @method
  30055. * @memberof Popper.Utils
  30056. * @argument {Element} element
  30057. * @returns {Element} scroll parent
  30058. */
  30059. function getScrollParent(element) {
  30060. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  30061. if (!element) {
  30062. return document.body;
  30063. }
  30064. switch (element.nodeName) {
  30065. case 'HTML':
  30066. case 'BODY':
  30067. return element.ownerDocument.body;
  30068. case '#document':
  30069. return element.body;
  30070. }
  30071. // Firefox want us to check `-x` and `-y` variations as well
  30072. var _getStyleComputedProp = getStyleComputedProperty(element),
  30073. overflow = _getStyleComputedProp.overflow,
  30074. overflowX = _getStyleComputedProp.overflowX,
  30075. overflowY = _getStyleComputedProp.overflowY;
  30076. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  30077. return element;
  30078. }
  30079. return getScrollParent(getParentNode(element));
  30080. }
  30081. /**
  30082. * Returns the reference node of the reference object, or the reference object itself.
  30083. * @method
  30084. * @memberof Popper.Utils
  30085. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  30086. * @returns {Element} parent
  30087. */
  30088. function getReferenceNode(reference) {
  30089. return reference && reference.referenceNode ? reference.referenceNode : reference;
  30090. }
  30091. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  30092. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  30093. /**
  30094. * Determines if the browser is Internet Explorer
  30095. * @method
  30096. * @memberof Popper.Utils
  30097. * @param {Number} version to check
  30098. * @returns {Boolean} isIE
  30099. */
  30100. function isIE(version) {
  30101. if (version === 11) {
  30102. return isIE11;
  30103. }
  30104. if (version === 10) {
  30105. return isIE10;
  30106. }
  30107. return isIE11 || isIE10;
  30108. }
  30109. /**
  30110. * Returns the offset parent of the given element
  30111. * @method
  30112. * @memberof Popper.Utils
  30113. * @argument {Element} element
  30114. * @returns {Element} offset parent
  30115. */
  30116. function getOffsetParent(element) {
  30117. if (!element) {
  30118. return document.documentElement;
  30119. }
  30120. var noOffsetParent = isIE(10) ? document.body : null;
  30121. // NOTE: 1 DOM access here
  30122. var offsetParent = element.offsetParent || null;
  30123. // Skip hidden elements which don't have an offsetParent
  30124. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  30125. offsetParent = (element = element.nextElementSibling).offsetParent;
  30126. }
  30127. var nodeName = offsetParent && offsetParent.nodeName;
  30128. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  30129. return element ? element.ownerDocument.documentElement : document.documentElement;
  30130. }
  30131. // .offsetParent will return the closest TH, TD or TABLE in case
  30132. // no offsetParent is present, I hate this job...
  30133. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  30134. return getOffsetParent(offsetParent);
  30135. }
  30136. return offsetParent;
  30137. }
  30138. function isOffsetContainer(element) {
  30139. var nodeName = element.nodeName;
  30140. if (nodeName === 'BODY') {
  30141. return false;
  30142. }
  30143. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  30144. }
  30145. /**
  30146. * Finds the root node (document, shadowDOM root) of the given element
  30147. * @method
  30148. * @memberof Popper.Utils
  30149. * @argument {Element} node
  30150. * @returns {Element} root node
  30151. */
  30152. function getRoot(node) {
  30153. if (node.parentNode !== null) {
  30154. return getRoot(node.parentNode);
  30155. }
  30156. return node;
  30157. }
  30158. /**
  30159. * Finds the offset parent common to the two provided nodes
  30160. * @method
  30161. * @memberof Popper.Utils
  30162. * @argument {Element} element1
  30163. * @argument {Element} element2
  30164. * @returns {Element} common offset parent
  30165. */
  30166. function findCommonOffsetParent(element1, element2) {
  30167. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30168. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  30169. return document.documentElement;
  30170. }
  30171. // Here we make sure to give as "start" the element that comes first in the DOM
  30172. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  30173. var start = order ? element1 : element2;
  30174. var end = order ? element2 : element1;
  30175. // Get common ancestor container
  30176. var range = document.createRange();
  30177. range.setStart(start, 0);
  30178. range.setEnd(end, 0);
  30179. var commonAncestorContainer = range.commonAncestorContainer;
  30180. // Both nodes are inside #document
  30181. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  30182. if (isOffsetContainer(commonAncestorContainer)) {
  30183. return commonAncestorContainer;
  30184. }
  30185. return getOffsetParent(commonAncestorContainer);
  30186. }
  30187. // one of the nodes is inside shadowDOM, find which one
  30188. var element1root = getRoot(element1);
  30189. if (element1root.host) {
  30190. return findCommonOffsetParent(element1root.host, element2);
  30191. } else {
  30192. return findCommonOffsetParent(element1, getRoot(element2).host);
  30193. }
  30194. }
  30195. /**
  30196. * Gets the scroll value of the given element in the given side (top and left)
  30197. * @method
  30198. * @memberof Popper.Utils
  30199. * @argument {Element} element
  30200. * @argument {String} side `top` or `left`
  30201. * @returns {number} amount of scrolled pixels
  30202. */
  30203. function getScroll(element) {
  30204. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  30205. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  30206. var nodeName = element.nodeName;
  30207. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30208. var html = element.ownerDocument.documentElement;
  30209. var scrollingElement = element.ownerDocument.scrollingElement || html;
  30210. return scrollingElement[upperSide];
  30211. }
  30212. return element[upperSide];
  30213. }
  30214. /*
  30215. * Sum or subtract the element scroll values (left and top) from a given rect object
  30216. * @method
  30217. * @memberof Popper.Utils
  30218. * @param {Object} rect - Rect object you want to change
  30219. * @param {HTMLElement} element - The element from the function reads the scroll values
  30220. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  30221. * @return {Object} rect - The modifier rect object
  30222. */
  30223. function includeScroll(rect, element) {
  30224. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30225. var scrollTop = getScroll(element, 'top');
  30226. var scrollLeft = getScroll(element, 'left');
  30227. var modifier = subtract ? -1 : 1;
  30228. rect.top += scrollTop * modifier;
  30229. rect.bottom += scrollTop * modifier;
  30230. rect.left += scrollLeft * modifier;
  30231. rect.right += scrollLeft * modifier;
  30232. return rect;
  30233. }
  30234. /*
  30235. * Helper to detect borders of a given element
  30236. * @method
  30237. * @memberof Popper.Utils
  30238. * @param {CSSStyleDeclaration} styles
  30239. * Result of `getStyleComputedProperty` on the given element
  30240. * @param {String} axis - `x` or `y`
  30241. * @return {number} borders - The borders size of the given axis
  30242. */
  30243. function getBordersSize(styles, axis) {
  30244. var sideA = axis === 'x' ? 'Left' : 'Top';
  30245. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  30246. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  30247. }
  30248. function getSize(axis, body, html, computedStyle) {
  30249. 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);
  30250. }
  30251. function getWindowSizes(document) {
  30252. var body = document.body;
  30253. var html = document.documentElement;
  30254. var computedStyle = isIE(10) && getComputedStyle(html);
  30255. return {
  30256. height: getSize('Height', body, html, computedStyle),
  30257. width: getSize('Width', body, html, computedStyle)
  30258. };
  30259. }
  30260. var classCallCheck = function (instance, Constructor) {
  30261. if (!(instance instanceof Constructor)) {
  30262. throw new TypeError("Cannot call a class as a function");
  30263. }
  30264. };
  30265. var createClass = function () {
  30266. function defineProperties(target, props) {
  30267. for (var i = 0; i < props.length; i++) {
  30268. var descriptor = props[i];
  30269. descriptor.enumerable = descriptor.enumerable || false;
  30270. descriptor.configurable = true;
  30271. if ("value" in descriptor) descriptor.writable = true;
  30272. Object.defineProperty(target, descriptor.key, descriptor);
  30273. }
  30274. }
  30275. return function (Constructor, protoProps, staticProps) {
  30276. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  30277. if (staticProps) defineProperties(Constructor, staticProps);
  30278. return Constructor;
  30279. };
  30280. }();
  30281. var defineProperty = function (obj, key, value) {
  30282. if (key in obj) {
  30283. Object.defineProperty(obj, key, {
  30284. value: value,
  30285. enumerable: true,
  30286. configurable: true,
  30287. writable: true
  30288. });
  30289. } else {
  30290. obj[key] = value;
  30291. }
  30292. return obj;
  30293. };
  30294. var _extends = Object.assign || function (target) {
  30295. for (var i = 1; i < arguments.length; i++) {
  30296. var source = arguments[i];
  30297. for (var key in source) {
  30298. if (Object.prototype.hasOwnProperty.call(source, key)) {
  30299. target[key] = source[key];
  30300. }
  30301. }
  30302. }
  30303. return target;
  30304. };
  30305. /**
  30306. * Given element offsets, generate an output similar to getBoundingClientRect
  30307. * @method
  30308. * @memberof Popper.Utils
  30309. * @argument {Object} offsets
  30310. * @returns {Object} ClientRect like output
  30311. */
  30312. function getClientRect(offsets) {
  30313. return _extends({}, offsets, {
  30314. right: offsets.left + offsets.width,
  30315. bottom: offsets.top + offsets.height
  30316. });
  30317. }
  30318. /**
  30319. * Get bounding client rect of given element
  30320. * @method
  30321. * @memberof Popper.Utils
  30322. * @param {HTMLElement} element
  30323. * @return {Object} client rect
  30324. */
  30325. function getBoundingClientRect(element) {
  30326. var rect = {};
  30327. // IE10 10 FIX: Please, don't ask, the element isn't
  30328. // considered in DOM in some circumstances...
  30329. // This isn't reproducible in IE10 compatibility mode of IE11
  30330. try {
  30331. if (isIE(10)) {
  30332. rect = element.getBoundingClientRect();
  30333. var scrollTop = getScroll(element, 'top');
  30334. var scrollLeft = getScroll(element, 'left');
  30335. rect.top += scrollTop;
  30336. rect.left += scrollLeft;
  30337. rect.bottom += scrollTop;
  30338. rect.right += scrollLeft;
  30339. } else {
  30340. rect = element.getBoundingClientRect();
  30341. }
  30342. } catch (e) {}
  30343. var result = {
  30344. left: rect.left,
  30345. top: rect.top,
  30346. width: rect.right - rect.left,
  30347. height: rect.bottom - rect.top
  30348. };
  30349. // subtract scrollbar size from sizes
  30350. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  30351. var width = sizes.width || element.clientWidth || result.width;
  30352. var height = sizes.height || element.clientHeight || result.height;
  30353. var horizScrollbar = element.offsetWidth - width;
  30354. var vertScrollbar = element.offsetHeight - height;
  30355. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  30356. // we make this check conditional for performance reasons
  30357. if (horizScrollbar || vertScrollbar) {
  30358. var styles = getStyleComputedProperty(element);
  30359. horizScrollbar -= getBordersSize(styles, 'x');
  30360. vertScrollbar -= getBordersSize(styles, 'y');
  30361. result.width -= horizScrollbar;
  30362. result.height -= vertScrollbar;
  30363. }
  30364. return getClientRect(result);
  30365. }
  30366. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  30367. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30368. var isIE10 = isIE(10);
  30369. var isHTML = parent.nodeName === 'HTML';
  30370. var childrenRect = getBoundingClientRect(children);
  30371. var parentRect = getBoundingClientRect(parent);
  30372. var scrollParent = getScrollParent(children);
  30373. var styles = getStyleComputedProperty(parent);
  30374. var borderTopWidth = parseFloat(styles.borderTopWidth);
  30375. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  30376. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  30377. if (fixedPosition && isHTML) {
  30378. parentRect.top = Math.max(parentRect.top, 0);
  30379. parentRect.left = Math.max(parentRect.left, 0);
  30380. }
  30381. var offsets = getClientRect({
  30382. top: childrenRect.top - parentRect.top - borderTopWidth,
  30383. left: childrenRect.left - parentRect.left - borderLeftWidth,
  30384. width: childrenRect.width,
  30385. height: childrenRect.height
  30386. });
  30387. offsets.marginTop = 0;
  30388. offsets.marginLeft = 0;
  30389. // Subtract margins of documentElement in case it's being used as parent
  30390. // we do this only on HTML because it's the only element that behaves
  30391. // differently when margins are applied to it. The margins are included in
  30392. // the box of the documentElement, in the other cases not.
  30393. if (!isIE10 && isHTML) {
  30394. var marginTop = parseFloat(styles.marginTop);
  30395. var marginLeft = parseFloat(styles.marginLeft);
  30396. offsets.top -= borderTopWidth - marginTop;
  30397. offsets.bottom -= borderTopWidth - marginTop;
  30398. offsets.left -= borderLeftWidth - marginLeft;
  30399. offsets.right -= borderLeftWidth - marginLeft;
  30400. // Attach marginTop and marginLeft because in some circumstances we may need them
  30401. offsets.marginTop = marginTop;
  30402. offsets.marginLeft = marginLeft;
  30403. }
  30404. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  30405. offsets = includeScroll(offsets, parent);
  30406. }
  30407. return offsets;
  30408. }
  30409. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  30410. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  30411. var html = element.ownerDocument.documentElement;
  30412. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  30413. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  30414. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  30415. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  30416. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  30417. var offset = {
  30418. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  30419. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  30420. width: width,
  30421. height: height
  30422. };
  30423. return getClientRect(offset);
  30424. }
  30425. /**
  30426. * Check if the given element is fixed or is inside a fixed parent
  30427. * @method
  30428. * @memberof Popper.Utils
  30429. * @argument {Element} element
  30430. * @argument {Element} customContainer
  30431. * @returns {Boolean} answer to "isFixed?"
  30432. */
  30433. function isFixed(element) {
  30434. var nodeName = element.nodeName;
  30435. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30436. return false;
  30437. }
  30438. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  30439. return true;
  30440. }
  30441. var parentNode = getParentNode(element);
  30442. if (!parentNode) {
  30443. return false;
  30444. }
  30445. return isFixed(parentNode);
  30446. }
  30447. /**
  30448. * Finds the first parent of an element that has a transformed property defined
  30449. * @method
  30450. * @memberof Popper.Utils
  30451. * @argument {Element} element
  30452. * @returns {Element} first transformed parent or documentElement
  30453. */
  30454. function getFixedPositionOffsetParent(element) {
  30455. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30456. if (!element || !element.parentElement || isIE()) {
  30457. return document.documentElement;
  30458. }
  30459. var el = element.parentElement;
  30460. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  30461. el = el.parentElement;
  30462. }
  30463. return el || document.documentElement;
  30464. }
  30465. /**
  30466. * Computed the boundaries limits and return them
  30467. * @method
  30468. * @memberof Popper.Utils
  30469. * @param {HTMLElement} popper
  30470. * @param {HTMLElement} reference
  30471. * @param {number} padding
  30472. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  30473. * @param {Boolean} fixedPosition - Is in fixed position mode
  30474. * @returns {Object} Coordinates of the boundaries
  30475. */
  30476. function getBoundaries(popper, reference, padding, boundariesElement) {
  30477. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  30478. // NOTE: 1 DOM access here
  30479. var boundaries = { top: 0, left: 0 };
  30480. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30481. // Handle viewport case
  30482. if (boundariesElement === 'viewport') {
  30483. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  30484. } else {
  30485. // Handle other cases based on DOM element used as boundaries
  30486. var boundariesNode = void 0;
  30487. if (boundariesElement === 'scrollParent') {
  30488. boundariesNode = getScrollParent(getParentNode(reference));
  30489. if (boundariesNode.nodeName === 'BODY') {
  30490. boundariesNode = popper.ownerDocument.documentElement;
  30491. }
  30492. } else if (boundariesElement === 'window') {
  30493. boundariesNode = popper.ownerDocument.documentElement;
  30494. } else {
  30495. boundariesNode = boundariesElement;
  30496. }
  30497. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  30498. // In case of HTML, we need a different computation
  30499. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  30500. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  30501. height = _getWindowSizes.height,
  30502. width = _getWindowSizes.width;
  30503. boundaries.top += offsets.top - offsets.marginTop;
  30504. boundaries.bottom = height + offsets.top;
  30505. boundaries.left += offsets.left - offsets.marginLeft;
  30506. boundaries.right = width + offsets.left;
  30507. } else {
  30508. // for all the other DOM elements, this one is good
  30509. boundaries = offsets;
  30510. }
  30511. }
  30512. // Add paddings
  30513. padding = padding || 0;
  30514. var isPaddingNumber = typeof padding === 'number';
  30515. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  30516. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  30517. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  30518. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  30519. return boundaries;
  30520. }
  30521. function getArea(_ref) {
  30522. var width = _ref.width,
  30523. height = _ref.height;
  30524. return width * height;
  30525. }
  30526. /**
  30527. * Utility used to transform the `auto` placement to the placement with more
  30528. * available space.
  30529. * @method
  30530. * @memberof Popper.Utils
  30531. * @argument {Object} data - The data object generated by update method
  30532. * @argument {Object} options - Modifiers configuration and options
  30533. * @returns {Object} The data object, properly modified
  30534. */
  30535. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  30536. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  30537. if (placement.indexOf('auto') === -1) {
  30538. return placement;
  30539. }
  30540. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  30541. var rects = {
  30542. top: {
  30543. width: boundaries.width,
  30544. height: refRect.top - boundaries.top
  30545. },
  30546. right: {
  30547. width: boundaries.right - refRect.right,
  30548. height: boundaries.height
  30549. },
  30550. bottom: {
  30551. width: boundaries.width,
  30552. height: boundaries.bottom - refRect.bottom
  30553. },
  30554. left: {
  30555. width: refRect.left - boundaries.left,
  30556. height: boundaries.height
  30557. }
  30558. };
  30559. var sortedAreas = Object.keys(rects).map(function (key) {
  30560. return _extends({
  30561. key: key
  30562. }, rects[key], {
  30563. area: getArea(rects[key])
  30564. });
  30565. }).sort(function (a, b) {
  30566. return b.area - a.area;
  30567. });
  30568. var filteredAreas = sortedAreas.filter(function (_ref2) {
  30569. var width = _ref2.width,
  30570. height = _ref2.height;
  30571. return width >= popper.clientWidth && height >= popper.clientHeight;
  30572. });
  30573. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  30574. var variation = placement.split('-')[1];
  30575. return computedPlacement + (variation ? '-' + variation : '');
  30576. }
  30577. /**
  30578. * Get offsets to the reference element
  30579. * @method
  30580. * @memberof Popper.Utils
  30581. * @param {Object} state
  30582. * @param {Element} popper - the popper element
  30583. * @param {Element} reference - the reference element (the popper will be relative to this)
  30584. * @param {Element} fixedPosition - is in fixed position mode
  30585. * @returns {Object} An object containing the offsets which will be applied to the popper
  30586. */
  30587. function getReferenceOffsets(state, popper, reference) {
  30588. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  30589. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30590. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  30591. }
  30592. /**
  30593. * Get the outer sizes of the given element (offset size + margins)
  30594. * @method
  30595. * @memberof Popper.Utils
  30596. * @argument {Element} element
  30597. * @returns {Object} object containing width and height properties
  30598. */
  30599. function getOuterSizes(element) {
  30600. var window = element.ownerDocument.defaultView;
  30601. var styles = window.getComputedStyle(element);
  30602. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  30603. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  30604. var result = {
  30605. width: element.offsetWidth + y,
  30606. height: element.offsetHeight + x
  30607. };
  30608. return result;
  30609. }
  30610. /**
  30611. * Get the opposite placement of the given one
  30612. * @method
  30613. * @memberof Popper.Utils
  30614. * @argument {String} placement
  30615. * @returns {String} flipped placement
  30616. */
  30617. function getOppositePlacement(placement) {
  30618. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  30619. return placement.replace(/left|right|bottom|top/g, function (matched) {
  30620. return hash[matched];
  30621. });
  30622. }
  30623. /**
  30624. * Get offsets to the popper
  30625. * @method
  30626. * @memberof Popper.Utils
  30627. * @param {Object} position - CSS position the Popper will get applied
  30628. * @param {HTMLElement} popper - the popper element
  30629. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  30630. * @param {String} placement - one of the valid placement options
  30631. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  30632. */
  30633. function getPopperOffsets(popper, referenceOffsets, placement) {
  30634. placement = placement.split('-')[0];
  30635. // Get popper node sizes
  30636. var popperRect = getOuterSizes(popper);
  30637. // Add position, width and height to our offsets object
  30638. var popperOffsets = {
  30639. width: popperRect.width,
  30640. height: popperRect.height
  30641. };
  30642. // depending by the popper placement we have to compute its offsets slightly differently
  30643. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  30644. var mainSide = isHoriz ? 'top' : 'left';
  30645. var secondarySide = isHoriz ? 'left' : 'top';
  30646. var measurement = isHoriz ? 'height' : 'width';
  30647. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  30648. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  30649. if (placement === secondarySide) {
  30650. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  30651. } else {
  30652. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  30653. }
  30654. return popperOffsets;
  30655. }
  30656. /**
  30657. * Mimics the `find` method of Array
  30658. * @method
  30659. * @memberof Popper.Utils
  30660. * @argument {Array} arr
  30661. * @argument prop
  30662. * @argument value
  30663. * @returns index or -1
  30664. */
  30665. function find(arr, check) {
  30666. // use native find if supported
  30667. if (Array.prototype.find) {
  30668. return arr.find(check);
  30669. }
  30670. // use `filter` to obtain the same behavior of `find`
  30671. return arr.filter(check)[0];
  30672. }
  30673. /**
  30674. * Return the index of the matching object
  30675. * @method
  30676. * @memberof Popper.Utils
  30677. * @argument {Array} arr
  30678. * @argument prop
  30679. * @argument value
  30680. * @returns index or -1
  30681. */
  30682. function findIndex(arr, prop, value) {
  30683. // use native findIndex if supported
  30684. if (Array.prototype.findIndex) {
  30685. return arr.findIndex(function (cur) {
  30686. return cur[prop] === value;
  30687. });
  30688. }
  30689. // use `find` + `indexOf` if `findIndex` isn't supported
  30690. var match = find(arr, function (obj) {
  30691. return obj[prop] === value;
  30692. });
  30693. return arr.indexOf(match);
  30694. }
  30695. /**
  30696. * Loop trough the list of modifiers and run them in order,
  30697. * each of them will then edit the data object.
  30698. * @method
  30699. * @memberof Popper.Utils
  30700. * @param {dataObject} data
  30701. * @param {Array} modifiers
  30702. * @param {String} ends - Optional modifier name used as stopper
  30703. * @returns {dataObject}
  30704. */
  30705. function runModifiers(modifiers, data, ends) {
  30706. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  30707. modifiersToRun.forEach(function (modifier) {
  30708. if (modifier['function']) {
  30709. // eslint-disable-line dot-notation
  30710. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  30711. }
  30712. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  30713. if (modifier.enabled && isFunction(fn)) {
  30714. // Add properties to offsets to make them a complete clientRect object
  30715. // we do this before each modifier to make sure the previous one doesn't
  30716. // mess with these values
  30717. data.offsets.popper = getClientRect(data.offsets.popper);
  30718. data.offsets.reference = getClientRect(data.offsets.reference);
  30719. data = fn(data, modifier);
  30720. }
  30721. });
  30722. return data;
  30723. }
  30724. /**
  30725. * Updates the position of the popper, computing the new offsets and applying
  30726. * the new style.<br />
  30727. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  30728. * @method
  30729. * @memberof Popper
  30730. */
  30731. function update() {
  30732. // if popper is destroyed, don't perform any further update
  30733. if (this.state.isDestroyed) {
  30734. return;
  30735. }
  30736. var data = {
  30737. instance: this,
  30738. styles: {},
  30739. arrowStyles: {},
  30740. attributes: {},
  30741. flipped: false,
  30742. offsets: {}
  30743. };
  30744. // compute reference element offsets
  30745. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  30746. // compute auto placement, store placement inside the data object,
  30747. // modifiers will be able to edit `placement` if needed
  30748. // and refer to originalPlacement to know the original value
  30749. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  30750. // store the computed placement inside `originalPlacement`
  30751. data.originalPlacement = data.placement;
  30752. data.positionFixed = this.options.positionFixed;
  30753. // compute the popper offsets
  30754. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  30755. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  30756. // run the modifiers
  30757. data = runModifiers(this.modifiers, data);
  30758. // the first `update` will call `onCreate` callback
  30759. // the other ones will call `onUpdate` callback
  30760. if (!this.state.isCreated) {
  30761. this.state.isCreated = true;
  30762. this.options.onCreate(data);
  30763. } else {
  30764. this.options.onUpdate(data);
  30765. }
  30766. }
  30767. /**
  30768. * Helper used to know if the given modifier is enabled.
  30769. * @method
  30770. * @memberof Popper.Utils
  30771. * @returns {Boolean}
  30772. */
  30773. function isModifierEnabled(modifiers, modifierName) {
  30774. return modifiers.some(function (_ref) {
  30775. var name = _ref.name,
  30776. enabled = _ref.enabled;
  30777. return enabled && name === modifierName;
  30778. });
  30779. }
  30780. /**
  30781. * Get the prefixed supported property name
  30782. * @method
  30783. * @memberof Popper.Utils
  30784. * @argument {String} property (camelCase)
  30785. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  30786. */
  30787. function getSupportedPropertyName(property) {
  30788. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  30789. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  30790. for (var i = 0; i < prefixes.length; i++) {
  30791. var prefix = prefixes[i];
  30792. var toCheck = prefix ? '' + prefix + upperProp : property;
  30793. if (typeof document.body.style[toCheck] !== 'undefined') {
  30794. return toCheck;
  30795. }
  30796. }
  30797. return null;
  30798. }
  30799. /**
  30800. * Destroys the popper.
  30801. * @method
  30802. * @memberof Popper
  30803. */
  30804. function destroy() {
  30805. this.state.isDestroyed = true;
  30806. // touch DOM only if `applyStyle` modifier is enabled
  30807. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  30808. this.popper.removeAttribute('x-placement');
  30809. this.popper.style.position = '';
  30810. this.popper.style.top = '';
  30811. this.popper.style.left = '';
  30812. this.popper.style.right = '';
  30813. this.popper.style.bottom = '';
  30814. this.popper.style.willChange = '';
  30815. this.popper.style[getSupportedPropertyName('transform')] = '';
  30816. }
  30817. this.disableEventListeners();
  30818. // remove the popper if user explicitly asked for the deletion on destroy
  30819. // do not use `remove` because IE11 doesn't support it
  30820. if (this.options.removeOnDestroy) {
  30821. this.popper.parentNode.removeChild(this.popper);
  30822. }
  30823. return this;
  30824. }
  30825. /**
  30826. * Get the window associated with the element
  30827. * @argument {Element} element
  30828. * @returns {Window}
  30829. */
  30830. function getWindow(element) {
  30831. var ownerDocument = element.ownerDocument;
  30832. return ownerDocument ? ownerDocument.defaultView : window;
  30833. }
  30834. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  30835. var isBody = scrollParent.nodeName === 'BODY';
  30836. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  30837. target.addEventListener(event, callback, { passive: true });
  30838. if (!isBody) {
  30839. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  30840. }
  30841. scrollParents.push(target);
  30842. }
  30843. /**
  30844. * Setup needed event listeners used to update the popper position
  30845. * @method
  30846. * @memberof Popper.Utils
  30847. * @private
  30848. */
  30849. function setupEventListeners(reference, options, state, updateBound) {
  30850. // Resize event listener on window
  30851. state.updateBound = updateBound;
  30852. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  30853. // Scroll event listener on scroll parents
  30854. var scrollElement = getScrollParent(reference);
  30855. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  30856. state.scrollElement = scrollElement;
  30857. state.eventsEnabled = true;
  30858. return state;
  30859. }
  30860. /**
  30861. * It will add resize/scroll events and start recalculating
  30862. * position of the popper element when they are triggered.
  30863. * @method
  30864. * @memberof Popper
  30865. */
  30866. function enableEventListeners() {
  30867. if (!this.state.eventsEnabled) {
  30868. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  30869. }
  30870. }
  30871. /**
  30872. * Remove event listeners used to update the popper position
  30873. * @method
  30874. * @memberof Popper.Utils
  30875. * @private
  30876. */
  30877. function removeEventListeners(reference, state) {
  30878. // Remove resize event listener on window
  30879. getWindow(reference).removeEventListener('resize', state.updateBound);
  30880. // Remove scroll event listener on scroll parents
  30881. state.scrollParents.forEach(function (target) {
  30882. target.removeEventListener('scroll', state.updateBound);
  30883. });
  30884. // Reset state
  30885. state.updateBound = null;
  30886. state.scrollParents = [];
  30887. state.scrollElement = null;
  30888. state.eventsEnabled = false;
  30889. return state;
  30890. }
  30891. /**
  30892. * It will remove resize/scroll events and won't recalculate popper position
  30893. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  30894. * unless you call `update` method manually.
  30895. * @method
  30896. * @memberof Popper
  30897. */
  30898. function disableEventListeners() {
  30899. if (this.state.eventsEnabled) {
  30900. cancelAnimationFrame(this.scheduleUpdate);
  30901. this.state = removeEventListeners(this.reference, this.state);
  30902. }
  30903. }
  30904. /**
  30905. * Tells if a given input is a number
  30906. * @method
  30907. * @memberof Popper.Utils
  30908. * @param {*} input to check
  30909. * @return {Boolean}
  30910. */
  30911. function isNumeric(n) {
  30912. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  30913. }
  30914. /**
  30915. * Set the style to the given popper
  30916. * @method
  30917. * @memberof Popper.Utils
  30918. * @argument {Element} element - Element to apply the style to
  30919. * @argument {Object} styles
  30920. * Object with a list of properties and values which will be applied to the element
  30921. */
  30922. function setStyles(element, styles) {
  30923. Object.keys(styles).forEach(function (prop) {
  30924. var unit = '';
  30925. // add unit if the value is numeric and is one of the following
  30926. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  30927. unit = 'px';
  30928. }
  30929. element.style[prop] = styles[prop] + unit;
  30930. });
  30931. }
  30932. /**
  30933. * Set the attributes to the given popper
  30934. * @method
  30935. * @memberof Popper.Utils
  30936. * @argument {Element} element - Element to apply the attributes to
  30937. * @argument {Object} styles
  30938. * Object with a list of properties and values which will be applied to the element
  30939. */
  30940. function setAttributes(element, attributes) {
  30941. Object.keys(attributes).forEach(function (prop) {
  30942. var value = attributes[prop];
  30943. if (value !== false) {
  30944. element.setAttribute(prop, attributes[prop]);
  30945. } else {
  30946. element.removeAttribute(prop);
  30947. }
  30948. });
  30949. }
  30950. /**
  30951. * @function
  30952. * @memberof Modifiers
  30953. * @argument {Object} data - The data object generated by `update` method
  30954. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  30955. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  30956. * @argument {Object} options - Modifiers configuration and options
  30957. * @returns {Object} The same data object
  30958. */
  30959. function applyStyle(data) {
  30960. // any property present in `data.styles` will be applied to the popper,
  30961. // in this way we can make the 3rd party modifiers add custom styles to it
  30962. // Be aware, modifiers could override the properties defined in the previous
  30963. // lines of this modifier!
  30964. setStyles(data.instance.popper, data.styles);
  30965. // any property present in `data.attributes` will be applied to the popper,
  30966. // they will be set as HTML attributes of the element
  30967. setAttributes(data.instance.popper, data.attributes);
  30968. // if arrowElement is defined and arrowStyles has some properties
  30969. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  30970. setStyles(data.arrowElement, data.arrowStyles);
  30971. }
  30972. return data;
  30973. }
  30974. /**
  30975. * Set the x-placement attribute before everything else because it could be used
  30976. * to add margins to the popper margins needs to be calculated to get the
  30977. * correct popper offsets.
  30978. * @method
  30979. * @memberof Popper.modifiers
  30980. * @param {HTMLElement} reference - The reference element used to position the popper
  30981. * @param {HTMLElement} popper - The HTML element used as popper
  30982. * @param {Object} options - Popper.js options
  30983. */
  30984. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  30985. // compute reference element offsets
  30986. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  30987. // compute auto placement, store placement inside the data object,
  30988. // modifiers will be able to edit `placement` if needed
  30989. // and refer to originalPlacement to know the original value
  30990. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  30991. popper.setAttribute('x-placement', placement);
  30992. // Apply `position` to popper before anything else because
  30993. // without the position applied we can't guarantee correct computations
  30994. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  30995. return options;
  30996. }
  30997. /**
  30998. * @function
  30999. * @memberof Popper.Utils
  31000. * @argument {Object} data - The data object generated by `update` method
  31001. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  31002. * @returns {Object} The popper's position offsets rounded
  31003. *
  31004. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  31005. * good as it can be within reason.
  31006. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  31007. *
  31008. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  31009. * as well on High DPI screens).
  31010. *
  31011. * Firefox prefers no rounding for positioning and does not have blurriness on
  31012. * high DPI screens.
  31013. *
  31014. * Only horizontal placement and left/right values need to be considered.
  31015. */
  31016. function getRoundedOffsets(data, shouldRound) {
  31017. var _data$offsets = data.offsets,
  31018. popper = _data$offsets.popper,
  31019. reference = _data$offsets.reference;
  31020. var round = Math.round,
  31021. floor = Math.floor;
  31022. var noRound = function noRound(v) {
  31023. return v;
  31024. };
  31025. var referenceWidth = round(reference.width);
  31026. var popperWidth = round(popper.width);
  31027. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  31028. var isVariation = data.placement.indexOf('-') !== -1;
  31029. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  31030. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  31031. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  31032. var verticalToInteger = !shouldRound ? noRound : round;
  31033. return {
  31034. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  31035. top: verticalToInteger(popper.top),
  31036. bottom: verticalToInteger(popper.bottom),
  31037. right: horizontalToInteger(popper.right)
  31038. };
  31039. }
  31040. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  31041. /**
  31042. * @function
  31043. * @memberof Modifiers
  31044. * @argument {Object} data - The data object generated by `update` method
  31045. * @argument {Object} options - Modifiers configuration and options
  31046. * @returns {Object} The data object, properly modified
  31047. */
  31048. function computeStyle(data, options) {
  31049. var x = options.x,
  31050. y = options.y;
  31051. var popper = data.offsets.popper;
  31052. // Remove this legacy support in Popper.js v2
  31053. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  31054. return modifier.name === 'applyStyle';
  31055. }).gpuAcceleration;
  31056. if (legacyGpuAccelerationOption !== undefined) {
  31057. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  31058. }
  31059. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  31060. var offsetParent = getOffsetParent(data.instance.popper);
  31061. var offsetParentRect = getBoundingClientRect(offsetParent);
  31062. // Styles
  31063. var styles = {
  31064. position: popper.position
  31065. };
  31066. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  31067. var sideA = x === 'bottom' ? 'top' : 'bottom';
  31068. var sideB = y === 'right' ? 'left' : 'right';
  31069. // if gpuAcceleration is set to `true` and transform is supported,
  31070. // we use `translate3d` to apply the position to the popper we
  31071. // automatically use the supported prefixed version if needed
  31072. var prefixedProperty = getSupportedPropertyName('transform');
  31073. // now, let's make a step back and look at this code closely (wtf?)
  31074. // If the content of the popper grows once it's been positioned, it
  31075. // may happen that the popper gets misplaced because of the new content
  31076. // overflowing its reference element
  31077. // To avoid this problem, we provide two options (x and y), which allow
  31078. // the consumer to define the offset origin.
  31079. // If we position a popper on top of a reference element, we can set
  31080. // `x` to `top` to make the popper grow towards its top instead of
  31081. // its bottom.
  31082. var left = void 0,
  31083. top = void 0;
  31084. if (sideA === 'bottom') {
  31085. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  31086. // and not the bottom of the html element
  31087. if (offsetParent.nodeName === 'HTML') {
  31088. top = -offsetParent.clientHeight + offsets.bottom;
  31089. } else {
  31090. top = -offsetParentRect.height + offsets.bottom;
  31091. }
  31092. } else {
  31093. top = offsets.top;
  31094. }
  31095. if (sideB === 'right') {
  31096. if (offsetParent.nodeName === 'HTML') {
  31097. left = -offsetParent.clientWidth + offsets.right;
  31098. } else {
  31099. left = -offsetParentRect.width + offsets.right;
  31100. }
  31101. } else {
  31102. left = offsets.left;
  31103. }
  31104. if (gpuAcceleration && prefixedProperty) {
  31105. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  31106. styles[sideA] = 0;
  31107. styles[sideB] = 0;
  31108. styles.willChange = 'transform';
  31109. } else {
  31110. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  31111. var invertTop = sideA === 'bottom' ? -1 : 1;
  31112. var invertLeft = sideB === 'right' ? -1 : 1;
  31113. styles[sideA] = top * invertTop;
  31114. styles[sideB] = left * invertLeft;
  31115. styles.willChange = sideA + ', ' + sideB;
  31116. }
  31117. // Attributes
  31118. var attributes = {
  31119. 'x-placement': data.placement
  31120. };
  31121. // Update `data` attributes, styles and arrowStyles
  31122. data.attributes = _extends({}, attributes, data.attributes);
  31123. data.styles = _extends({}, styles, data.styles);
  31124. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  31125. return data;
  31126. }
  31127. /**
  31128. * Helper used to know if the given modifier depends from another one.<br />
  31129. * It checks if the needed modifier is listed and enabled.
  31130. * @method
  31131. * @memberof Popper.Utils
  31132. * @param {Array} modifiers - list of modifiers
  31133. * @param {String} requestingName - name of requesting modifier
  31134. * @param {String} requestedName - name of requested modifier
  31135. * @returns {Boolean}
  31136. */
  31137. function isModifierRequired(modifiers, requestingName, requestedName) {
  31138. var requesting = find(modifiers, function (_ref) {
  31139. var name = _ref.name;
  31140. return name === requestingName;
  31141. });
  31142. var isRequired = !!requesting && modifiers.some(function (modifier) {
  31143. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  31144. });
  31145. if (!isRequired) {
  31146. var _requesting = '`' + requestingName + '`';
  31147. var requested = '`' + requestedName + '`';
  31148. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  31149. }
  31150. return isRequired;
  31151. }
  31152. /**
  31153. * @function
  31154. * @memberof Modifiers
  31155. * @argument {Object} data - The data object generated by update method
  31156. * @argument {Object} options - Modifiers configuration and options
  31157. * @returns {Object} The data object, properly modified
  31158. */
  31159. function arrow(data, options) {
  31160. var _data$offsets$arrow;
  31161. // arrow depends on keepTogether in order to work
  31162. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  31163. return data;
  31164. }
  31165. var arrowElement = options.element;
  31166. // if arrowElement is a string, suppose it's a CSS selector
  31167. if (typeof arrowElement === 'string') {
  31168. arrowElement = data.instance.popper.querySelector(arrowElement);
  31169. // if arrowElement is not found, don't run the modifier
  31170. if (!arrowElement) {
  31171. return data;
  31172. }
  31173. } else {
  31174. // if the arrowElement isn't a query selector we must check that the
  31175. // provided DOM node is child of its popper node
  31176. if (!data.instance.popper.contains(arrowElement)) {
  31177. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  31178. return data;
  31179. }
  31180. }
  31181. var placement = data.placement.split('-')[0];
  31182. var _data$offsets = data.offsets,
  31183. popper = _data$offsets.popper,
  31184. reference = _data$offsets.reference;
  31185. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  31186. var len = isVertical ? 'height' : 'width';
  31187. var sideCapitalized = isVertical ? 'Top' : 'Left';
  31188. var side = sideCapitalized.toLowerCase();
  31189. var altSide = isVertical ? 'left' : 'top';
  31190. var opSide = isVertical ? 'bottom' : 'right';
  31191. var arrowElementSize = getOuterSizes(arrowElement)[len];
  31192. //
  31193. // extends keepTogether behavior making sure the popper and its
  31194. // reference have enough pixels in conjunction
  31195. //
  31196. // top/left side
  31197. if (reference[opSide] - arrowElementSize < popper[side]) {
  31198. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  31199. }
  31200. // bottom/right side
  31201. if (reference[side] + arrowElementSize > popper[opSide]) {
  31202. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  31203. }
  31204. data.offsets.popper = getClientRect(data.offsets.popper);
  31205. // compute center of the popper
  31206. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  31207. // Compute the sideValue using the updated popper offsets
  31208. // take popper margin in account because we don't have this info available
  31209. var css = getStyleComputedProperty(data.instance.popper);
  31210. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  31211. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  31212. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  31213. // prevent arrowElement from being placed not contiguously to its popper
  31214. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  31215. data.arrowElement = arrowElement;
  31216. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  31217. return data;
  31218. }
  31219. /**
  31220. * Get the opposite placement variation of the given one
  31221. * @method
  31222. * @memberof Popper.Utils
  31223. * @argument {String} placement variation
  31224. * @returns {String} flipped placement variation
  31225. */
  31226. function getOppositeVariation(variation) {
  31227. if (variation === 'end') {
  31228. return 'start';
  31229. } else if (variation === 'start') {
  31230. return 'end';
  31231. }
  31232. return variation;
  31233. }
  31234. /**
  31235. * List of accepted placements to use as values of the `placement` option.<br />
  31236. * Valid placements are:
  31237. * - `auto`
  31238. * - `top`
  31239. * - `right`
  31240. * - `bottom`
  31241. * - `left`
  31242. *
  31243. * Each placement can have a variation from this list:
  31244. * - `-start`
  31245. * - `-end`
  31246. *
  31247. * Variations are interpreted easily if you think of them as the left to right
  31248. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  31249. * is right.<br />
  31250. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  31251. *
  31252. * Some valid examples are:
  31253. * - `top-end` (on top of reference, right aligned)
  31254. * - `right-start` (on right of reference, top aligned)
  31255. * - `bottom` (on bottom, centered)
  31256. * - `auto-end` (on the side with more space available, alignment depends by placement)
  31257. *
  31258. * @static
  31259. * @type {Array}
  31260. * @enum {String}
  31261. * @readonly
  31262. * @method placements
  31263. * @memberof Popper
  31264. */
  31265. 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'];
  31266. // Get rid of `auto` `auto-start` and `auto-end`
  31267. var validPlacements = placements.slice(3);
  31268. /**
  31269. * Given an initial placement, returns all the subsequent placements
  31270. * clockwise (or counter-clockwise).
  31271. *
  31272. * @method
  31273. * @memberof Popper.Utils
  31274. * @argument {String} placement - A valid placement (it accepts variations)
  31275. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  31276. * @returns {Array} placements including their variations
  31277. */
  31278. function clockwise(placement) {
  31279. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  31280. var index = validPlacements.indexOf(placement);
  31281. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  31282. return counter ? arr.reverse() : arr;
  31283. }
  31284. var BEHAVIORS = {
  31285. FLIP: 'flip',
  31286. CLOCKWISE: 'clockwise',
  31287. COUNTERCLOCKWISE: 'counterclockwise'
  31288. };
  31289. /**
  31290. * @function
  31291. * @memberof Modifiers
  31292. * @argument {Object} data - The data object generated by update method
  31293. * @argument {Object} options - Modifiers configuration and options
  31294. * @returns {Object} The data object, properly modified
  31295. */
  31296. function flip(data, options) {
  31297. // if `inner` modifier is enabled, we can't use the `flip` modifier
  31298. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  31299. return data;
  31300. }
  31301. if (data.flipped && data.placement === data.originalPlacement) {
  31302. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  31303. return data;
  31304. }
  31305. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  31306. var placement = data.placement.split('-')[0];
  31307. var placementOpposite = getOppositePlacement(placement);
  31308. var variation = data.placement.split('-')[1] || '';
  31309. var flipOrder = [];
  31310. switch (options.behavior) {
  31311. case BEHAVIORS.FLIP:
  31312. flipOrder = [placement, placementOpposite];
  31313. break;
  31314. case BEHAVIORS.CLOCKWISE:
  31315. flipOrder = clockwise(placement);
  31316. break;
  31317. case BEHAVIORS.COUNTERCLOCKWISE:
  31318. flipOrder = clockwise(placement, true);
  31319. break;
  31320. default:
  31321. flipOrder = options.behavior;
  31322. }
  31323. flipOrder.forEach(function (step, index) {
  31324. if (placement !== step || flipOrder.length === index + 1) {
  31325. return data;
  31326. }
  31327. placement = data.placement.split('-')[0];
  31328. placementOpposite = getOppositePlacement(placement);
  31329. var popperOffsets = data.offsets.popper;
  31330. var refOffsets = data.offsets.reference;
  31331. // using floor because the reference offsets may contain decimals we are not going to consider here
  31332. var floor = Math.floor;
  31333. 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);
  31334. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  31335. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  31336. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  31337. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  31338. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  31339. // flip the variation if required
  31340. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31341. // flips variation if reference element overflows boundaries
  31342. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  31343. // flips variation if popper content overflows boundaries
  31344. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  31345. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  31346. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  31347. // this boolean to detect any flip loop
  31348. data.flipped = true;
  31349. if (overlapsRef || overflowsBoundaries) {
  31350. placement = flipOrder[index + 1];
  31351. }
  31352. if (flippedVariation) {
  31353. variation = getOppositeVariation(variation);
  31354. }
  31355. data.placement = placement + (variation ? '-' + variation : '');
  31356. // this object contains `position`, we want to preserve it along with
  31357. // any additional property we may add in the future
  31358. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  31359. data = runModifiers(data.instance.modifiers, data, 'flip');
  31360. }
  31361. });
  31362. return data;
  31363. }
  31364. /**
  31365. * @function
  31366. * @memberof Modifiers
  31367. * @argument {Object} data - The data object generated by update method
  31368. * @argument {Object} options - Modifiers configuration and options
  31369. * @returns {Object} The data object, properly modified
  31370. */
  31371. function keepTogether(data) {
  31372. var _data$offsets = data.offsets,
  31373. popper = _data$offsets.popper,
  31374. reference = _data$offsets.reference;
  31375. var placement = data.placement.split('-')[0];
  31376. var floor = Math.floor;
  31377. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31378. var side = isVertical ? 'right' : 'bottom';
  31379. var opSide = isVertical ? 'left' : 'top';
  31380. var measurement = isVertical ? 'width' : 'height';
  31381. if (popper[side] < floor(reference[opSide])) {
  31382. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  31383. }
  31384. if (popper[opSide] > floor(reference[side])) {
  31385. data.offsets.popper[opSide] = floor(reference[side]);
  31386. }
  31387. return data;
  31388. }
  31389. /**
  31390. * Converts a string containing value + unit into a px value number
  31391. * @function
  31392. * @memberof {modifiers~offset}
  31393. * @private
  31394. * @argument {String} str - Value + unit string
  31395. * @argument {String} measurement - `height` or `width`
  31396. * @argument {Object} popperOffsets
  31397. * @argument {Object} referenceOffsets
  31398. * @returns {Number|String}
  31399. * Value in pixels, or original string if no values were extracted
  31400. */
  31401. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  31402. // separate value from unit
  31403. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  31404. var value = +split[1];
  31405. var unit = split[2];
  31406. // If it's not a number it's an operator, I guess
  31407. if (!value) {
  31408. return str;
  31409. }
  31410. if (unit.indexOf('%') === 0) {
  31411. var element = void 0;
  31412. switch (unit) {
  31413. case '%p':
  31414. element = popperOffsets;
  31415. break;
  31416. case '%':
  31417. case '%r':
  31418. default:
  31419. element = referenceOffsets;
  31420. }
  31421. var rect = getClientRect(element);
  31422. return rect[measurement] / 100 * value;
  31423. } else if (unit === 'vh' || unit === 'vw') {
  31424. // if is a vh or vw, we calculate the size based on the viewport
  31425. var size = void 0;
  31426. if (unit === 'vh') {
  31427. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  31428. } else {
  31429. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  31430. }
  31431. return size / 100 * value;
  31432. } else {
  31433. // if is an explicit pixel unit, we get rid of the unit and keep the value
  31434. // if is an implicit unit, it's px, and we return just the value
  31435. return value;
  31436. }
  31437. }
  31438. /**
  31439. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  31440. * @function
  31441. * @memberof {modifiers~offset}
  31442. * @private
  31443. * @argument {String} offset
  31444. * @argument {Object} popperOffsets
  31445. * @argument {Object} referenceOffsets
  31446. * @argument {String} basePlacement
  31447. * @returns {Array} a two cells array with x and y offsets in numbers
  31448. */
  31449. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  31450. var offsets = [0, 0];
  31451. // Use height if placement is left or right and index is 0 otherwise use width
  31452. // in this way the first offset will use an axis and the second one
  31453. // will use the other one
  31454. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  31455. // Split the offset string to obtain a list of values and operands
  31456. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  31457. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  31458. return frag.trim();
  31459. });
  31460. // Detect if the offset string contains a pair of values or a single one
  31461. // they could be separated by comma or space
  31462. var divider = fragments.indexOf(find(fragments, function (frag) {
  31463. return frag.search(/,|\s/) !== -1;
  31464. }));
  31465. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  31466. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  31467. }
  31468. // If divider is found, we divide the list of values and operands to divide
  31469. // them by ofset X and Y.
  31470. var splitRegex = /\s*,\s*|\s+/;
  31471. 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];
  31472. // Convert the values with units to absolute pixels to allow our computations
  31473. ops = ops.map(function (op, index) {
  31474. // Most of the units rely on the orientation of the popper
  31475. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  31476. var mergeWithPrevious = false;
  31477. return op
  31478. // This aggregates any `+` or `-` sign that aren't considered operators
  31479. // e.g.: 10 + +5 => [10, +, +5]
  31480. .reduce(function (a, b) {
  31481. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  31482. a[a.length - 1] = b;
  31483. mergeWithPrevious = true;
  31484. return a;
  31485. } else if (mergeWithPrevious) {
  31486. a[a.length - 1] += b;
  31487. mergeWithPrevious = false;
  31488. return a;
  31489. } else {
  31490. return a.concat(b);
  31491. }
  31492. }, [])
  31493. // Here we convert the string values into number values (in px)
  31494. .map(function (str) {
  31495. return toValue(str, measurement, popperOffsets, referenceOffsets);
  31496. });
  31497. });
  31498. // Loop trough the offsets arrays and execute the operations
  31499. ops.forEach(function (op, index) {
  31500. op.forEach(function (frag, index2) {
  31501. if (isNumeric(frag)) {
  31502. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  31503. }
  31504. });
  31505. });
  31506. return offsets;
  31507. }
  31508. /**
  31509. * @function
  31510. * @memberof Modifiers
  31511. * @argument {Object} data - The data object generated by update method
  31512. * @argument {Object} options - Modifiers configuration and options
  31513. * @argument {Number|String} options.offset=0
  31514. * The offset value as described in the modifier description
  31515. * @returns {Object} The data object, properly modified
  31516. */
  31517. function offset(data, _ref) {
  31518. var offset = _ref.offset;
  31519. var placement = data.placement,
  31520. _data$offsets = data.offsets,
  31521. popper = _data$offsets.popper,
  31522. reference = _data$offsets.reference;
  31523. var basePlacement = placement.split('-')[0];
  31524. var offsets = void 0;
  31525. if (isNumeric(+offset)) {
  31526. offsets = [+offset, 0];
  31527. } else {
  31528. offsets = parseOffset(offset, popper, reference, basePlacement);
  31529. }
  31530. if (basePlacement === 'left') {
  31531. popper.top += offsets[0];
  31532. popper.left -= offsets[1];
  31533. } else if (basePlacement === 'right') {
  31534. popper.top += offsets[0];
  31535. popper.left += offsets[1];
  31536. } else if (basePlacement === 'top') {
  31537. popper.left += offsets[0];
  31538. popper.top -= offsets[1];
  31539. } else if (basePlacement === 'bottom') {
  31540. popper.left += offsets[0];
  31541. popper.top += offsets[1];
  31542. }
  31543. data.popper = popper;
  31544. return data;
  31545. }
  31546. /**
  31547. * @function
  31548. * @memberof Modifiers
  31549. * @argument {Object} data - The data object generated by `update` method
  31550. * @argument {Object} options - Modifiers configuration and options
  31551. * @returns {Object} The data object, properly modified
  31552. */
  31553. function preventOverflow(data, options) {
  31554. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  31555. // If offsetParent is the reference element, we really want to
  31556. // go one step up and use the next offsetParent as reference to
  31557. // avoid to make this modifier completely useless and look like broken
  31558. if (data.instance.reference === boundariesElement) {
  31559. boundariesElement = getOffsetParent(boundariesElement);
  31560. }
  31561. // NOTE: DOM access here
  31562. // resets the popper's position so that the document size can be calculated excluding
  31563. // the size of the popper element itself
  31564. var transformProp = getSupportedPropertyName('transform');
  31565. var popperStyles = data.instance.popper.style; // assignment to help minification
  31566. var top = popperStyles.top,
  31567. left = popperStyles.left,
  31568. transform = popperStyles[transformProp];
  31569. popperStyles.top = '';
  31570. popperStyles.left = '';
  31571. popperStyles[transformProp] = '';
  31572. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  31573. // NOTE: DOM access here
  31574. // restores the original style properties after the offsets have been computed
  31575. popperStyles.top = top;
  31576. popperStyles.left = left;
  31577. popperStyles[transformProp] = transform;
  31578. options.boundaries = boundaries;
  31579. var order = options.priority;
  31580. var popper = data.offsets.popper;
  31581. var check = {
  31582. primary: function primary(placement) {
  31583. var value = popper[placement];
  31584. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  31585. value = Math.max(popper[placement], boundaries[placement]);
  31586. }
  31587. return defineProperty({}, placement, value);
  31588. },
  31589. secondary: function secondary(placement) {
  31590. var mainSide = placement === 'right' ? 'left' : 'top';
  31591. var value = popper[mainSide];
  31592. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  31593. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  31594. }
  31595. return defineProperty({}, mainSide, value);
  31596. }
  31597. };
  31598. order.forEach(function (placement) {
  31599. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  31600. popper = _extends({}, popper, check[side](placement));
  31601. });
  31602. data.offsets.popper = popper;
  31603. return data;
  31604. }
  31605. /**
  31606. * @function
  31607. * @memberof Modifiers
  31608. * @argument {Object} data - The data object generated by `update` method
  31609. * @argument {Object} options - Modifiers configuration and options
  31610. * @returns {Object} The data object, properly modified
  31611. */
  31612. function shift(data) {
  31613. var placement = data.placement;
  31614. var basePlacement = placement.split('-')[0];
  31615. var shiftvariation = placement.split('-')[1];
  31616. // if shift shiftvariation is specified, run the modifier
  31617. if (shiftvariation) {
  31618. var _data$offsets = data.offsets,
  31619. reference = _data$offsets.reference,
  31620. popper = _data$offsets.popper;
  31621. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  31622. var side = isVertical ? 'left' : 'top';
  31623. var measurement = isVertical ? 'width' : 'height';
  31624. var shiftOffsets = {
  31625. start: defineProperty({}, side, reference[side]),
  31626. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  31627. };
  31628. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  31629. }
  31630. return data;
  31631. }
  31632. /**
  31633. * @function
  31634. * @memberof Modifiers
  31635. * @argument {Object} data - The data object generated by update method
  31636. * @argument {Object} options - Modifiers configuration and options
  31637. * @returns {Object} The data object, properly modified
  31638. */
  31639. function hide(data) {
  31640. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  31641. return data;
  31642. }
  31643. var refRect = data.offsets.reference;
  31644. var bound = find(data.instance.modifiers, function (modifier) {
  31645. return modifier.name === 'preventOverflow';
  31646. }).boundaries;
  31647. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  31648. // Avoid unnecessary DOM access if visibility hasn't changed
  31649. if (data.hide === true) {
  31650. return data;
  31651. }
  31652. data.hide = true;
  31653. data.attributes['x-out-of-boundaries'] = '';
  31654. } else {
  31655. // Avoid unnecessary DOM access if visibility hasn't changed
  31656. if (data.hide === false) {
  31657. return data;
  31658. }
  31659. data.hide = false;
  31660. data.attributes['x-out-of-boundaries'] = false;
  31661. }
  31662. return data;
  31663. }
  31664. /**
  31665. * @function
  31666. * @memberof Modifiers
  31667. * @argument {Object} data - The data object generated by `update` method
  31668. * @argument {Object} options - Modifiers configuration and options
  31669. * @returns {Object} The data object, properly modified
  31670. */
  31671. function inner(data) {
  31672. var placement = data.placement;
  31673. var basePlacement = placement.split('-')[0];
  31674. var _data$offsets = data.offsets,
  31675. popper = _data$offsets.popper,
  31676. reference = _data$offsets.reference;
  31677. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  31678. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  31679. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  31680. data.placement = getOppositePlacement(placement);
  31681. data.offsets.popper = getClientRect(popper);
  31682. return data;
  31683. }
  31684. /**
  31685. * Modifier function, each modifier can have a function of this type assigned
  31686. * to its `fn` property.<br />
  31687. * These functions will be called on each update, this means that you must
  31688. * make sure they are performant enough to avoid performance bottlenecks.
  31689. *
  31690. * @function ModifierFn
  31691. * @argument {dataObject} data - The data object generated by `update` method
  31692. * @argument {Object} options - Modifiers configuration and options
  31693. * @returns {dataObject} The data object, properly modified
  31694. */
  31695. /**
  31696. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  31697. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  31698. * needed by the library.
  31699. *
  31700. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  31701. * All the other properties are configurations that could be tweaked.
  31702. * @namespace modifiers
  31703. */
  31704. var modifiers = {
  31705. /**
  31706. * Modifier used to shift the popper on the start or end of its reference
  31707. * element.<br />
  31708. * It will read the variation of the `placement` property.<br />
  31709. * It can be one either `-end` or `-start`.
  31710. * @memberof modifiers
  31711. * @inner
  31712. */
  31713. shift: {
  31714. /** @prop {number} order=100 - Index used to define the order of execution */
  31715. order: 100,
  31716. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31717. enabled: true,
  31718. /** @prop {ModifierFn} */
  31719. fn: shift
  31720. },
  31721. /**
  31722. * The `offset` modifier can shift your popper on both its axis.
  31723. *
  31724. * It accepts the following units:
  31725. * - `px` or unit-less, interpreted as pixels
  31726. * - `%` or `%r`, percentage relative to the length of the reference element
  31727. * - `%p`, percentage relative to the length of the popper element
  31728. * - `vw`, CSS viewport width unit
  31729. * - `vh`, CSS viewport height unit
  31730. *
  31731. * For length is intended the main axis relative to the placement of the popper.<br />
  31732. * This means that if the placement is `top` or `bottom`, the length will be the
  31733. * `width`. In case of `left` or `right`, it will be the `height`.
  31734. *
  31735. * You can provide a single value (as `Number` or `String`), or a pair of values
  31736. * as `String` divided by a comma or one (or more) white spaces.<br />
  31737. * The latter is a deprecated method because it leads to confusion and will be
  31738. * removed in v2.<br />
  31739. * Additionally, it accepts additions and subtractions between different units.
  31740. * Note that multiplications and divisions aren't supported.
  31741. *
  31742. * Valid examples are:
  31743. * ```
  31744. * 10
  31745. * '10%'
  31746. * '10, 10'
  31747. * '10%, 10'
  31748. * '10 + 10%'
  31749. * '10 - 5vh + 3%'
  31750. * '-10px + 5vh, 5px - 6%'
  31751. * ```
  31752. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  31753. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  31754. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  31755. *
  31756. * @memberof modifiers
  31757. * @inner
  31758. */
  31759. offset: {
  31760. /** @prop {number} order=200 - Index used to define the order of execution */
  31761. order: 200,
  31762. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31763. enabled: true,
  31764. /** @prop {ModifierFn} */
  31765. fn: offset,
  31766. /** @prop {Number|String} offset=0
  31767. * The offset value as described in the modifier description
  31768. */
  31769. offset: 0
  31770. },
  31771. /**
  31772. * Modifier used to prevent the popper from being positioned outside the boundary.
  31773. *
  31774. * A scenario exists where the reference itself is not within the boundaries.<br />
  31775. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  31776. * In this case we need to decide whether the popper should either:
  31777. *
  31778. * - detach from the reference and remain "trapped" in the boundaries, or
  31779. * - if it should ignore the boundary and "escape with its reference"
  31780. *
  31781. * When `escapeWithReference` is set to`true` and reference is completely
  31782. * outside its boundaries, the popper will overflow (or completely leave)
  31783. * the boundaries in order to remain attached to the edge of the reference.
  31784. *
  31785. * @memberof modifiers
  31786. * @inner
  31787. */
  31788. preventOverflow: {
  31789. /** @prop {number} order=300 - Index used to define the order of execution */
  31790. order: 300,
  31791. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31792. enabled: true,
  31793. /** @prop {ModifierFn} */
  31794. fn: preventOverflow,
  31795. /**
  31796. * @prop {Array} [priority=['left','right','top','bottom']]
  31797. * Popper will try to prevent overflow following these priorities by default,
  31798. * then, it could overflow on the left and on top of the `boundariesElement`
  31799. */
  31800. priority: ['left', 'right', 'top', 'bottom'],
  31801. /**
  31802. * @prop {number} padding=5
  31803. * Amount of pixel used to define a minimum distance between the boundaries
  31804. * and the popper. This makes sure the popper always has a little padding
  31805. * between the edges of its container
  31806. */
  31807. padding: 5,
  31808. /**
  31809. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  31810. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  31811. * `viewport` or any DOM element.
  31812. */
  31813. boundariesElement: 'scrollParent'
  31814. },
  31815. /**
  31816. * Modifier used to make sure the reference and its popper stay near each other
  31817. * without leaving any gap between the two. Especially useful when the arrow is
  31818. * enabled and you want to ensure that it points to its reference element.
  31819. * It cares only about the first axis. You can still have poppers with margin
  31820. * between the popper and its reference element.
  31821. * @memberof modifiers
  31822. * @inner
  31823. */
  31824. keepTogether: {
  31825. /** @prop {number} order=400 - Index used to define the order of execution */
  31826. order: 400,
  31827. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31828. enabled: true,
  31829. /** @prop {ModifierFn} */
  31830. fn: keepTogether
  31831. },
  31832. /**
  31833. * This modifier is used to move the `arrowElement` of the popper to make
  31834. * sure it is positioned between the reference element and its popper element.
  31835. * It will read the outer size of the `arrowElement` node to detect how many
  31836. * pixels of conjunction are needed.
  31837. *
  31838. * It has no effect if no `arrowElement` is provided.
  31839. * @memberof modifiers
  31840. * @inner
  31841. */
  31842. arrow: {
  31843. /** @prop {number} order=500 - Index used to define the order of execution */
  31844. order: 500,
  31845. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31846. enabled: true,
  31847. /** @prop {ModifierFn} */
  31848. fn: arrow,
  31849. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  31850. element: '[x-arrow]'
  31851. },
  31852. /**
  31853. * Modifier used to flip the popper's placement when it starts to overlap its
  31854. * reference element.
  31855. *
  31856. * Requires the `preventOverflow` modifier before it in order to work.
  31857. *
  31858. * **NOTE:** this modifier will interrupt the current update cycle and will
  31859. * restart it if it detects the need to flip the placement.
  31860. * @memberof modifiers
  31861. * @inner
  31862. */
  31863. flip: {
  31864. /** @prop {number} order=600 - Index used to define the order of execution */
  31865. order: 600,
  31866. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31867. enabled: true,
  31868. /** @prop {ModifierFn} */
  31869. fn: flip,
  31870. /**
  31871. * @prop {String|Array} behavior='flip'
  31872. * The behavior used to change the popper's placement. It can be one of
  31873. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  31874. * placements (with optional variations)
  31875. */
  31876. behavior: 'flip',
  31877. /**
  31878. * @prop {number} padding=5
  31879. * The popper will flip if it hits the edges of the `boundariesElement`
  31880. */
  31881. padding: 5,
  31882. /**
  31883. * @prop {String|HTMLElement} boundariesElement='viewport'
  31884. * The element which will define the boundaries of the popper position.
  31885. * The popper will never be placed outside of the defined boundaries
  31886. * (except if `keepTogether` is enabled)
  31887. */
  31888. boundariesElement: 'viewport',
  31889. /**
  31890. * @prop {Boolean} flipVariations=false
  31891. * The popper will switch placement variation between `-start` and `-end` when
  31892. * the reference element overlaps its boundaries.
  31893. *
  31894. * The original placement should have a set variation.
  31895. */
  31896. flipVariations: false,
  31897. /**
  31898. * @prop {Boolean} flipVariationsByContent=false
  31899. * The popper will switch placement variation between `-start` and `-end` when
  31900. * the popper element overlaps its reference boundaries.
  31901. *
  31902. * The original placement should have a set variation.
  31903. */
  31904. flipVariationsByContent: false
  31905. },
  31906. /**
  31907. * Modifier used to make the popper flow toward the inner of the reference element.
  31908. * By default, when this modifier is disabled, the popper will be placed outside
  31909. * the reference element.
  31910. * @memberof modifiers
  31911. * @inner
  31912. */
  31913. inner: {
  31914. /** @prop {number} order=700 - Index used to define the order of execution */
  31915. order: 700,
  31916. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  31917. enabled: false,
  31918. /** @prop {ModifierFn} */
  31919. fn: inner
  31920. },
  31921. /**
  31922. * Modifier used to hide the popper when its reference element is outside of the
  31923. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  31924. * be used to hide with a CSS selector the popper when its reference is
  31925. * out of boundaries.
  31926. *
  31927. * Requires the `preventOverflow` modifier before it in order to work.
  31928. * @memberof modifiers
  31929. * @inner
  31930. */
  31931. hide: {
  31932. /** @prop {number} order=800 - Index used to define the order of execution */
  31933. order: 800,
  31934. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31935. enabled: true,
  31936. /** @prop {ModifierFn} */
  31937. fn: hide
  31938. },
  31939. /**
  31940. * Computes the style that will be applied to the popper element to gets
  31941. * properly positioned.
  31942. *
  31943. * Note that this modifier will not touch the DOM, it just prepares the styles
  31944. * so that `applyStyle` modifier can apply it. This separation is useful
  31945. * in case you need to replace `applyStyle` with a custom implementation.
  31946. *
  31947. * This modifier has `850` as `order` value to maintain backward compatibility
  31948. * with previous versions of Popper.js. Expect the modifiers ordering method
  31949. * to change in future major versions of the library.
  31950. *
  31951. * @memberof modifiers
  31952. * @inner
  31953. */
  31954. computeStyle: {
  31955. /** @prop {number} order=850 - Index used to define the order of execution */
  31956. order: 850,
  31957. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31958. enabled: true,
  31959. /** @prop {ModifierFn} */
  31960. fn: computeStyle,
  31961. /**
  31962. * @prop {Boolean} gpuAcceleration=true
  31963. * If true, it uses the CSS 3D transformation to position the popper.
  31964. * Otherwise, it will use the `top` and `left` properties
  31965. */
  31966. gpuAcceleration: true,
  31967. /**
  31968. * @prop {string} [x='bottom']
  31969. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  31970. * Change this if your popper should grow in a direction different from `bottom`
  31971. */
  31972. x: 'bottom',
  31973. /**
  31974. * @prop {string} [x='left']
  31975. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  31976. * Change this if your popper should grow in a direction different from `right`
  31977. */
  31978. y: 'right'
  31979. },
  31980. /**
  31981. * Applies the computed styles to the popper element.
  31982. *
  31983. * All the DOM manipulations are limited to this modifier. This is useful in case
  31984. * you want to integrate Popper.js inside a framework or view library and you
  31985. * want to delegate all the DOM manipulations to it.
  31986. *
  31987. * Note that if you disable this modifier, you must make sure the popper element
  31988. * has its position set to `absolute` before Popper.js can do its work!
  31989. *
  31990. * Just disable this modifier and define your own to achieve the desired effect.
  31991. *
  31992. * @memberof modifiers
  31993. * @inner
  31994. */
  31995. applyStyle: {
  31996. /** @prop {number} order=900 - Index used to define the order of execution */
  31997. order: 900,
  31998. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31999. enabled: true,
  32000. /** @prop {ModifierFn} */
  32001. fn: applyStyle,
  32002. /** @prop {Function} */
  32003. onLoad: applyStyleOnLoad,
  32004. /**
  32005. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  32006. * @prop {Boolean} gpuAcceleration=true
  32007. * If true, it uses the CSS 3D transformation to position the popper.
  32008. * Otherwise, it will use the `top` and `left` properties
  32009. */
  32010. gpuAcceleration: undefined
  32011. }
  32012. };
  32013. /**
  32014. * The `dataObject` is an object containing all the information used by Popper.js.
  32015. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  32016. * @name dataObject
  32017. * @property {Object} data.instance The Popper.js instance
  32018. * @property {String} data.placement Placement applied to popper
  32019. * @property {String} data.originalPlacement Placement originally defined on init
  32020. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  32021. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  32022. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  32023. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32024. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32025. * @property {Object} data.boundaries Offsets of the popper boundaries
  32026. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  32027. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  32028. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  32029. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  32030. */
  32031. /**
  32032. * Default options provided to Popper.js constructor.<br />
  32033. * These can be overridden using the `options` argument of Popper.js.<br />
  32034. * To override an option, simply pass an object with the same
  32035. * structure of the `options` object, as the 3rd argument. For example:
  32036. * ```
  32037. * new Popper(ref, pop, {
  32038. * modifiers: {
  32039. * preventOverflow: { enabled: false }
  32040. * }
  32041. * })
  32042. * ```
  32043. * @type {Object}
  32044. * @static
  32045. * @memberof Popper
  32046. */
  32047. var Defaults = {
  32048. /**
  32049. * Popper's placement.
  32050. * @prop {Popper.placements} placement='bottom'
  32051. */
  32052. placement: 'bottom',
  32053. /**
  32054. * Set this to true if you want popper to position it self in 'fixed' mode
  32055. * @prop {Boolean} positionFixed=false
  32056. */
  32057. positionFixed: false,
  32058. /**
  32059. * Whether events (resize, scroll) are initially enabled.
  32060. * @prop {Boolean} eventsEnabled=true
  32061. */
  32062. eventsEnabled: true,
  32063. /**
  32064. * Set to true if you want to automatically remove the popper when
  32065. * you call the `destroy` method.
  32066. * @prop {Boolean} removeOnDestroy=false
  32067. */
  32068. removeOnDestroy: false,
  32069. /**
  32070. * Callback called when the popper is created.<br />
  32071. * By default, it is set to no-op.<br />
  32072. * Access Popper.js instance with `data.instance`.
  32073. * @prop {onCreate}
  32074. */
  32075. onCreate: function onCreate() {},
  32076. /**
  32077. * Callback called when the popper is updated. This callback is not called
  32078. * on the initialization/creation of the popper, but only on subsequent
  32079. * updates.<br />
  32080. * By default, it is set to no-op.<br />
  32081. * Access Popper.js instance with `data.instance`.
  32082. * @prop {onUpdate}
  32083. */
  32084. onUpdate: function onUpdate() {},
  32085. /**
  32086. * List of modifiers used to modify the offsets before they are applied to the popper.
  32087. * They provide most of the functionalities of Popper.js.
  32088. * @prop {modifiers}
  32089. */
  32090. modifiers: modifiers
  32091. };
  32092. /**
  32093. * @callback onCreate
  32094. * @param {dataObject} data
  32095. */
  32096. /**
  32097. * @callback onUpdate
  32098. * @param {dataObject} data
  32099. */
  32100. // Utils
  32101. // Methods
  32102. var Popper = function () {
  32103. /**
  32104. * Creates a new Popper.js instance.
  32105. * @class Popper
  32106. * @param {Element|referenceObject} reference - The reference element used to position the popper
  32107. * @param {Element} popper - The HTML / XML element used as the popper
  32108. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  32109. * @return {Object} instance - The generated Popper.js instance
  32110. */
  32111. function Popper(reference, popper) {
  32112. var _this = this;
  32113. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  32114. classCallCheck(this, Popper);
  32115. this.scheduleUpdate = function () {
  32116. return requestAnimationFrame(_this.update);
  32117. };
  32118. // make update() debounced, so that it only runs at most once-per-tick
  32119. this.update = debounce(this.update.bind(this));
  32120. // with {} we create a new object with the options inside it
  32121. this.options = _extends({}, Popper.Defaults, options);
  32122. // init state
  32123. this.state = {
  32124. isDestroyed: false,
  32125. isCreated: false,
  32126. scrollParents: []
  32127. };
  32128. // get reference and popper elements (allow jQuery wrappers)
  32129. this.reference = reference && reference.jquery ? reference[0] : reference;
  32130. this.popper = popper && popper.jquery ? popper[0] : popper;
  32131. // Deep merge modifiers options
  32132. this.options.modifiers = {};
  32133. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  32134. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  32135. });
  32136. // Refactoring modifiers' list (Object => Array)
  32137. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  32138. return _extends({
  32139. name: name
  32140. }, _this.options.modifiers[name]);
  32141. })
  32142. // sort the modifiers by order
  32143. .sort(function (a, b) {
  32144. return a.order - b.order;
  32145. });
  32146. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  32147. // such code is executed in the same order of its modifier
  32148. // they could add new properties to their options configuration
  32149. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  32150. this.modifiers.forEach(function (modifierOptions) {
  32151. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  32152. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  32153. }
  32154. });
  32155. // fire the first update to position the popper in the right place
  32156. this.update();
  32157. var eventsEnabled = this.options.eventsEnabled;
  32158. if (eventsEnabled) {
  32159. // setup event listeners, they will take care of update the position in specific situations
  32160. this.enableEventListeners();
  32161. }
  32162. this.state.eventsEnabled = eventsEnabled;
  32163. }
  32164. // We can't use class properties because they don't get listed in the
  32165. // class prototype and break stuff like Sinon stubs
  32166. createClass(Popper, [{
  32167. key: 'update',
  32168. value: function update$$1() {
  32169. return update.call(this);
  32170. }
  32171. }, {
  32172. key: 'destroy',
  32173. value: function destroy$$1() {
  32174. return destroy.call(this);
  32175. }
  32176. }, {
  32177. key: 'enableEventListeners',
  32178. value: function enableEventListeners$$1() {
  32179. return enableEventListeners.call(this);
  32180. }
  32181. }, {
  32182. key: 'disableEventListeners',
  32183. value: function disableEventListeners$$1() {
  32184. return disableEventListeners.call(this);
  32185. }
  32186. /**
  32187. * Schedules an update. It will run on the next UI update available.
  32188. * @method scheduleUpdate
  32189. * @memberof Popper
  32190. */
  32191. /**
  32192. * Collection of utilities useful when writing custom modifiers.
  32193. * Starting from version 1.7, this method is available only if you
  32194. * include `popper-utils.js` before `popper.js`.
  32195. *
  32196. * **DEPRECATION**: This way to access PopperUtils is deprecated
  32197. * and will be removed in v2! Use the PopperUtils module directly instead.
  32198. * Due to the high instability of the methods contained in Utils, we can't
  32199. * guarantee them to follow semver. Use them at your own risk!
  32200. * @static
  32201. * @private
  32202. * @type {Object}
  32203. * @deprecated since version 1.8
  32204. * @member Utils
  32205. * @memberof Popper
  32206. */
  32207. }]);
  32208. return Popper;
  32209. }();
  32210. /**
  32211. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  32212. * and lets you use it as replacement of a real DOM node.<br />
  32213. * You can use this method to position a popper relatively to a set of coordinates
  32214. * in case you don't have a DOM node to use as reference.
  32215. *
  32216. * ```
  32217. * new Popper(referenceObject, popperNode);
  32218. * ```
  32219. *
  32220. * NB: This feature isn't supported in Internet Explorer 10.
  32221. * @name referenceObject
  32222. * @property {Function} data.getBoundingClientRect
  32223. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  32224. * @property {number} data.clientWidth
  32225. * An ES6 getter that will return the width of the virtual reference element.
  32226. * @property {number} data.clientHeight
  32227. * An ES6 getter that will return the height of the virtual reference element.
  32228. */
  32229. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  32230. Popper.placements = placements;
  32231. Popper.Defaults = Defaults;
  32232. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  32233. //# sourceMappingURL=popper.js.map
  32234. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  32235. /***/ }),
  32236. /***/ "./node_modules/process/browser.js":
  32237. /*!*****************************************!*\
  32238. !*** ./node_modules/process/browser.js ***!
  32239. \*****************************************/
  32240. /*! no static exports found */
  32241. /***/ (function(module, exports) {
  32242. // shim for using process in browser
  32243. var process = module.exports = {};
  32244. // cached from whatever global is present so that test runners that stub it
  32245. // don't break things. But we need to wrap it in a try catch in case it is
  32246. // wrapped in strict mode code which doesn't define any globals. It's inside a
  32247. // function because try/catches deoptimize in certain engines.
  32248. var cachedSetTimeout;
  32249. var cachedClearTimeout;
  32250. function defaultSetTimout() {
  32251. throw new Error('setTimeout has not been defined');
  32252. }
  32253. function defaultClearTimeout () {
  32254. throw new Error('clearTimeout has not been defined');
  32255. }
  32256. (function () {
  32257. try {
  32258. if (typeof setTimeout === 'function') {
  32259. cachedSetTimeout = setTimeout;
  32260. } else {
  32261. cachedSetTimeout = defaultSetTimout;
  32262. }
  32263. } catch (e) {
  32264. cachedSetTimeout = defaultSetTimout;
  32265. }
  32266. try {
  32267. if (typeof clearTimeout === 'function') {
  32268. cachedClearTimeout = clearTimeout;
  32269. } else {
  32270. cachedClearTimeout = defaultClearTimeout;
  32271. }
  32272. } catch (e) {
  32273. cachedClearTimeout = defaultClearTimeout;
  32274. }
  32275. } ())
  32276. function runTimeout(fun) {
  32277. if (cachedSetTimeout === setTimeout) {
  32278. //normal enviroments in sane situations
  32279. return setTimeout(fun, 0);
  32280. }
  32281. // if setTimeout wasn't available but was latter defined
  32282. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  32283. cachedSetTimeout = setTimeout;
  32284. return setTimeout(fun, 0);
  32285. }
  32286. try {
  32287. // when when somebody has screwed with setTimeout but no I.E. maddness
  32288. return cachedSetTimeout(fun, 0);
  32289. } catch(e){
  32290. try {
  32291. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32292. return cachedSetTimeout.call(null, fun, 0);
  32293. } catch(e){
  32294. // 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
  32295. return cachedSetTimeout.call(this, fun, 0);
  32296. }
  32297. }
  32298. }
  32299. function runClearTimeout(marker) {
  32300. if (cachedClearTimeout === clearTimeout) {
  32301. //normal enviroments in sane situations
  32302. return clearTimeout(marker);
  32303. }
  32304. // if clearTimeout wasn't available but was latter defined
  32305. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  32306. cachedClearTimeout = clearTimeout;
  32307. return clearTimeout(marker);
  32308. }
  32309. try {
  32310. // when when somebody has screwed with setTimeout but no I.E. maddness
  32311. return cachedClearTimeout(marker);
  32312. } catch (e){
  32313. try {
  32314. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32315. return cachedClearTimeout.call(null, marker);
  32316. } catch (e){
  32317. // 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.
  32318. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  32319. return cachedClearTimeout.call(this, marker);
  32320. }
  32321. }
  32322. }
  32323. var queue = [];
  32324. var draining = false;
  32325. var currentQueue;
  32326. var queueIndex = -1;
  32327. function cleanUpNextTick() {
  32328. if (!draining || !currentQueue) {
  32329. return;
  32330. }
  32331. draining = false;
  32332. if (currentQueue.length) {
  32333. queue = currentQueue.concat(queue);
  32334. } else {
  32335. queueIndex = -1;
  32336. }
  32337. if (queue.length) {
  32338. drainQueue();
  32339. }
  32340. }
  32341. function drainQueue() {
  32342. if (draining) {
  32343. return;
  32344. }
  32345. var timeout = runTimeout(cleanUpNextTick);
  32346. draining = true;
  32347. var len = queue.length;
  32348. while(len) {
  32349. currentQueue = queue;
  32350. queue = [];
  32351. while (++queueIndex < len) {
  32352. if (currentQueue) {
  32353. currentQueue[queueIndex].run();
  32354. }
  32355. }
  32356. queueIndex = -1;
  32357. len = queue.length;
  32358. }
  32359. currentQueue = null;
  32360. draining = false;
  32361. runClearTimeout(timeout);
  32362. }
  32363. process.nextTick = function (fun) {
  32364. var args = new Array(arguments.length - 1);
  32365. if (arguments.length > 1) {
  32366. for (var i = 1; i < arguments.length; i++) {
  32367. args[i - 1] = arguments[i];
  32368. }
  32369. }
  32370. queue.push(new Item(fun, args));
  32371. if (queue.length === 1 && !draining) {
  32372. runTimeout(drainQueue);
  32373. }
  32374. };
  32375. // v8 likes predictible objects
  32376. function Item(fun, array) {
  32377. this.fun = fun;
  32378. this.array = array;
  32379. }
  32380. Item.prototype.run = function () {
  32381. this.fun.apply(null, this.array);
  32382. };
  32383. process.title = 'browser';
  32384. process.browser = true;
  32385. process.env = {};
  32386. process.argv = [];
  32387. process.version = ''; // empty string to avoid regexp issues
  32388. process.versions = {};
  32389. function noop() {}
  32390. process.on = noop;
  32391. process.addListener = noop;
  32392. process.once = noop;
  32393. process.off = noop;
  32394. process.removeListener = noop;
  32395. process.removeAllListeners = noop;
  32396. process.emit = noop;
  32397. process.prependListener = noop;
  32398. process.prependOnceListener = noop;
  32399. process.listeners = function (name) { return [] }
  32400. process.binding = function (name) {
  32401. throw new Error('process.binding is not supported');
  32402. };
  32403. process.cwd = function () { return '/' };
  32404. process.chdir = function (dir) {
  32405. throw new Error('process.chdir is not supported');
  32406. };
  32407. process.umask = function() { return 0; };
  32408. /***/ }),
  32409. /***/ "./node_modules/webpack/buildin/global.js":
  32410. /*!***********************************!*\
  32411. !*** (webpack)/buildin/global.js ***!
  32412. \***********************************/
  32413. /*! no static exports found */
  32414. /***/ (function(module, exports) {
  32415. var g;
  32416. // This works in non-strict mode
  32417. g = (function() {
  32418. return this;
  32419. })();
  32420. try {
  32421. // This works if eval is allowed (see CSP)
  32422. g = g || new Function("return this")();
  32423. } catch (e) {
  32424. // This works if the window reference is available
  32425. if (typeof window === "object") g = window;
  32426. }
  32427. // g can still be undefined, but nothing to do about it...
  32428. // We return undefined, instead of nothing here, so it's
  32429. // easier to handle this case. if(!global) { ...}
  32430. module.exports = g;
  32431. /***/ }),
  32432. /***/ "./node_modules/webpack/buildin/module.js":
  32433. /*!***********************************!*\
  32434. !*** (webpack)/buildin/module.js ***!
  32435. \***********************************/
  32436. /*! no static exports found */
  32437. /***/ (function(module, exports) {
  32438. module.exports = function(module) {
  32439. if (!module.webpackPolyfill) {
  32440. module.deprecate = function() {};
  32441. module.paths = [];
  32442. // module.parent = undefined by default
  32443. if (!module.children) module.children = [];
  32444. Object.defineProperty(module, "loaded", {
  32445. enumerable: true,
  32446. get: function() {
  32447. return module.l;
  32448. }
  32449. });
  32450. Object.defineProperty(module, "id", {
  32451. enumerable: true,
  32452. get: function() {
  32453. return module.i;
  32454. }
  32455. });
  32456. module.webpackPolyfill = 1;
  32457. }
  32458. return module;
  32459. };
  32460. /***/ }),
  32461. /***/ "./resources/js/app.js":
  32462. /*!*****************************!*\
  32463. !*** ./resources/js/app.js ***!
  32464. \*****************************/
  32465. /*! no static exports found */
  32466. /***/ (function(module, exports, __webpack_require__) {
  32467. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  32468. /***/ }),
  32469. /***/ "./resources/js/bootstrap.js":
  32470. /*!***********************************!*\
  32471. !*** ./resources/js/bootstrap.js ***!
  32472. \***********************************/
  32473. /*! no static exports found */
  32474. /***/ (function(module, exports, __webpack_require__) {
  32475. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  32476. /**
  32477. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  32478. * for JavaScript based Bootstrap features such as modals and tabs. This
  32479. * code may be modified to fit the specific needs of your application.
  32480. */
  32481. try {
  32482. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  32483. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  32484. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  32485. } catch (e) {}
  32486. /**
  32487. * We'll load the axios HTTP library which allows us to easily issue requests
  32488. * to our Laravel back-end. This library automatically handles sending the
  32489. * CSRF token as a header based on the value of the "XSRF" token cookie.
  32490. */
  32491. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  32492. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  32493. /**
  32494. * Echo exposes an expressive API for subscribing to channels and listening
  32495. * for events that are broadcast by Laravel. Echo and event broadcasting
  32496. * allows your team to easily build robust real-time web applications.
  32497. */
  32498. // import Echo from 'laravel-echo';
  32499. // window.Pusher = require('pusher-js');
  32500. // window.Echo = new Echo({
  32501. // broadcaster: 'pusher',
  32502. // key: process.env.MIX_PUSHER_APP_KEY,
  32503. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  32504. // encrypted: true
  32505. // });
  32506. /***/ }),
  32507. /***/ "./resources/sass/app.scss":
  32508. /*!*********************************!*\
  32509. !*** ./resources/sass/app.scss ***!
  32510. \*********************************/
  32511. /*! no static exports found */
  32512. /***/ (function(module, exports) {
  32513. // removed by extract-text-webpack-plugin
  32514. /***/ }),
  32515. /***/ 0:
  32516. /*!*************************************************************!*\
  32517. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  32518. \*************************************************************/
  32519. /*! no static exports found */
  32520. /***/ (function(module, exports, __webpack_require__) {
  32521. __webpack_require__(/*! C:\Works\Development\spasPortal\resources\js\app.js */"./resources/js/app.js");
  32522. module.exports = __webpack_require__(/*! C:\Works\Development\spasPortal\resources\sass\app.scss */"./resources/sass/app.scss");
  32523. /***/ })
  32524. /******/ });