app.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483
  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.5.0
  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: 2020-04-10T15:07Z
  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 getProto = Object.getPrototypeOf;
  5300. var slice = arr.slice;
  5301. var flat = arr.flat ? function( array ) {
  5302. return arr.flat.call( array );
  5303. } : function( array ) {
  5304. return arr.concat.apply( [], array );
  5305. };
  5306. var push = arr.push;
  5307. var indexOf = arr.indexOf;
  5308. var class2type = {};
  5309. var toString = class2type.toString;
  5310. var hasOwn = class2type.hasOwnProperty;
  5311. var fnToString = hasOwn.toString;
  5312. var ObjectFunctionString = fnToString.call( Object );
  5313. var support = {};
  5314. var isFunction = function isFunction( obj ) {
  5315. // Support: Chrome <=57, Firefox <=52
  5316. // In some browsers, typeof returns "function" for HTML <object> elements
  5317. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  5318. // We don't want to classify *any* DOM node as a function.
  5319. return typeof obj === "function" && typeof obj.nodeType !== "number";
  5320. };
  5321. var isWindow = function isWindow( obj ) {
  5322. return obj != null && obj === obj.window;
  5323. };
  5324. var document = window.document;
  5325. var preservedScriptAttributes = {
  5326. type: true,
  5327. src: true,
  5328. nonce: true,
  5329. noModule: true
  5330. };
  5331. function DOMEval( code, node, doc ) {
  5332. doc = doc || document;
  5333. var i, val,
  5334. script = doc.createElement( "script" );
  5335. script.text = code;
  5336. if ( node ) {
  5337. for ( i in preservedScriptAttributes ) {
  5338. // Support: Firefox 64+, Edge 18+
  5339. // Some browsers don't support the "nonce" property on scripts.
  5340. // On the other hand, just using `getAttribute` is not enough as
  5341. // the `nonce` attribute is reset to an empty string whenever it
  5342. // becomes browsing-context connected.
  5343. // See https://github.com/whatwg/html/issues/2369
  5344. // See https://html.spec.whatwg.org/#nonce-attributes
  5345. // The `node.getAttribute` check was added for the sake of
  5346. // `jQuery.globalEval` so that it can fake a nonce-containing node
  5347. // via an object.
  5348. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  5349. if ( val ) {
  5350. script.setAttribute( i, val );
  5351. }
  5352. }
  5353. }
  5354. doc.head.appendChild( script ).parentNode.removeChild( script );
  5355. }
  5356. function toType( obj ) {
  5357. if ( obj == null ) {
  5358. return obj + "";
  5359. }
  5360. // Support: Android <=2.3 only (functionish RegExp)
  5361. return typeof obj === "object" || typeof obj === "function" ?
  5362. class2type[ toString.call( obj ) ] || "object" :
  5363. typeof obj;
  5364. }
  5365. /* global Symbol */
  5366. // Defining this global in .eslintrc.json would create a danger of using the global
  5367. // unguarded in another place, it seems safer to define global only for this module
  5368. var
  5369. version = "3.5.0",
  5370. // Define a local copy of jQuery
  5371. jQuery = function( selector, context ) {
  5372. // The jQuery object is actually just the init constructor 'enhanced'
  5373. // Need init if jQuery is called (just allow error to be thrown if not included)
  5374. return new jQuery.fn.init( selector, context );
  5375. };
  5376. jQuery.fn = jQuery.prototype = {
  5377. // The current version of jQuery being used
  5378. jquery: version,
  5379. constructor: jQuery,
  5380. // The default length of a jQuery object is 0
  5381. length: 0,
  5382. toArray: function() {
  5383. return slice.call( this );
  5384. },
  5385. // Get the Nth element in the matched element set OR
  5386. // Get the whole matched element set as a clean array
  5387. get: function( num ) {
  5388. // Return all the elements in a clean array
  5389. if ( num == null ) {
  5390. return slice.call( this );
  5391. }
  5392. // Return just the one element from the set
  5393. return num < 0 ? this[ num + this.length ] : this[ num ];
  5394. },
  5395. // Take an array of elements and push it onto the stack
  5396. // (returning the new matched element set)
  5397. pushStack: function( elems ) {
  5398. // Build a new jQuery matched element set
  5399. var ret = jQuery.merge( this.constructor(), elems );
  5400. // Add the old object onto the stack (as a reference)
  5401. ret.prevObject = this;
  5402. // Return the newly-formed element set
  5403. return ret;
  5404. },
  5405. // Execute a callback for every element in the matched set.
  5406. each: function( callback ) {
  5407. return jQuery.each( this, callback );
  5408. },
  5409. map: function( callback ) {
  5410. return this.pushStack( jQuery.map( this, function( elem, i ) {
  5411. return callback.call( elem, i, elem );
  5412. } ) );
  5413. },
  5414. slice: function() {
  5415. return this.pushStack( slice.apply( this, arguments ) );
  5416. },
  5417. first: function() {
  5418. return this.eq( 0 );
  5419. },
  5420. last: function() {
  5421. return this.eq( -1 );
  5422. },
  5423. even: function() {
  5424. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  5425. return ( i + 1 ) % 2;
  5426. } ) );
  5427. },
  5428. odd: function() {
  5429. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  5430. return i % 2;
  5431. } ) );
  5432. },
  5433. eq: function( i ) {
  5434. var len = this.length,
  5435. j = +i + ( i < 0 ? len : 0 );
  5436. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  5437. },
  5438. end: function() {
  5439. return this.prevObject || this.constructor();
  5440. },
  5441. // For internal use only.
  5442. // Behaves like an Array's method, not like a jQuery method.
  5443. push: push,
  5444. sort: arr.sort,
  5445. splice: arr.splice
  5446. };
  5447. jQuery.extend = jQuery.fn.extend = function() {
  5448. var options, name, src, copy, copyIsArray, clone,
  5449. target = arguments[ 0 ] || {},
  5450. i = 1,
  5451. length = arguments.length,
  5452. deep = false;
  5453. // Handle a deep copy situation
  5454. if ( typeof target === "boolean" ) {
  5455. deep = target;
  5456. // Skip the boolean and the target
  5457. target = arguments[ i ] || {};
  5458. i++;
  5459. }
  5460. // Handle case when target is a string or something (possible in deep copy)
  5461. if ( typeof target !== "object" && !isFunction( target ) ) {
  5462. target = {};
  5463. }
  5464. // Extend jQuery itself if only one argument is passed
  5465. if ( i === length ) {
  5466. target = this;
  5467. i--;
  5468. }
  5469. for ( ; i < length; i++ ) {
  5470. // Only deal with non-null/undefined values
  5471. if ( ( options = arguments[ i ] ) != null ) {
  5472. // Extend the base object
  5473. for ( name in options ) {
  5474. copy = options[ name ];
  5475. // Prevent Object.prototype pollution
  5476. // Prevent never-ending loop
  5477. if ( name === "__proto__" || target === copy ) {
  5478. continue;
  5479. }
  5480. // Recurse if we're merging plain objects or arrays
  5481. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  5482. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  5483. src = target[ name ];
  5484. // Ensure proper type for the source value
  5485. if ( copyIsArray && !Array.isArray( src ) ) {
  5486. clone = [];
  5487. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  5488. clone = {};
  5489. } else {
  5490. clone = src;
  5491. }
  5492. copyIsArray = false;
  5493. // Never move original objects, clone them
  5494. target[ name ] = jQuery.extend( deep, clone, copy );
  5495. // Don't bring in undefined values
  5496. } else if ( copy !== undefined ) {
  5497. target[ name ] = copy;
  5498. }
  5499. }
  5500. }
  5501. }
  5502. // Return the modified object
  5503. return target;
  5504. };
  5505. jQuery.extend( {
  5506. // Unique for each copy of jQuery on the page
  5507. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  5508. // Assume jQuery is ready without the ready module
  5509. isReady: true,
  5510. error: function( msg ) {
  5511. throw new Error( msg );
  5512. },
  5513. noop: function() {},
  5514. isPlainObject: function( obj ) {
  5515. var proto, Ctor;
  5516. // Detect obvious negatives
  5517. // Use toString instead of jQuery.type to catch host objects
  5518. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  5519. return false;
  5520. }
  5521. proto = getProto( obj );
  5522. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  5523. if ( !proto ) {
  5524. return true;
  5525. }
  5526. // Objects with prototype are plain iff they were constructed by a global Object function
  5527. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  5528. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  5529. },
  5530. isEmptyObject: function( obj ) {
  5531. var name;
  5532. for ( name in obj ) {
  5533. return false;
  5534. }
  5535. return true;
  5536. },
  5537. // Evaluates a script in a provided context; falls back to the global one
  5538. // if not specified.
  5539. globalEval: function( code, options, doc ) {
  5540. DOMEval( code, { nonce: options && options.nonce }, doc );
  5541. },
  5542. each: function( obj, callback ) {
  5543. var length, i = 0;
  5544. if ( isArrayLike( obj ) ) {
  5545. length = obj.length;
  5546. for ( ; i < length; i++ ) {
  5547. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5548. break;
  5549. }
  5550. }
  5551. } else {
  5552. for ( i in obj ) {
  5553. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5554. break;
  5555. }
  5556. }
  5557. }
  5558. return obj;
  5559. },
  5560. // results is for internal usage only
  5561. makeArray: function( arr, results ) {
  5562. var ret = results || [];
  5563. if ( arr != null ) {
  5564. if ( isArrayLike( Object( arr ) ) ) {
  5565. jQuery.merge( ret,
  5566. typeof arr === "string" ?
  5567. [ arr ] : arr
  5568. );
  5569. } else {
  5570. push.call( ret, arr );
  5571. }
  5572. }
  5573. return ret;
  5574. },
  5575. inArray: function( elem, arr, i ) {
  5576. return arr == null ? -1 : indexOf.call( arr, elem, i );
  5577. },
  5578. // Support: Android <=4.0 only, PhantomJS 1 only
  5579. // push.apply(_, arraylike) throws on ancient WebKit
  5580. merge: function( first, second ) {
  5581. var len = +second.length,
  5582. j = 0,
  5583. i = first.length;
  5584. for ( ; j < len; j++ ) {
  5585. first[ i++ ] = second[ j ];
  5586. }
  5587. first.length = i;
  5588. return first;
  5589. },
  5590. grep: function( elems, callback, invert ) {
  5591. var callbackInverse,
  5592. matches = [],
  5593. i = 0,
  5594. length = elems.length,
  5595. callbackExpect = !invert;
  5596. // Go through the array, only saving the items
  5597. // that pass the validator function
  5598. for ( ; i < length; i++ ) {
  5599. callbackInverse = !callback( elems[ i ], i );
  5600. if ( callbackInverse !== callbackExpect ) {
  5601. matches.push( elems[ i ] );
  5602. }
  5603. }
  5604. return matches;
  5605. },
  5606. // arg is for internal usage only
  5607. map: function( elems, callback, arg ) {
  5608. var length, value,
  5609. i = 0,
  5610. ret = [];
  5611. // Go through the array, translating each of the items to their new values
  5612. if ( isArrayLike( elems ) ) {
  5613. length = elems.length;
  5614. for ( ; i < length; i++ ) {
  5615. value = callback( elems[ i ], i, arg );
  5616. if ( value != null ) {
  5617. ret.push( value );
  5618. }
  5619. }
  5620. // Go through every key on the object,
  5621. } else {
  5622. for ( i in elems ) {
  5623. value = callback( elems[ i ], i, arg );
  5624. if ( value != null ) {
  5625. ret.push( value );
  5626. }
  5627. }
  5628. }
  5629. // Flatten any nested arrays
  5630. return flat( ret );
  5631. },
  5632. // A global GUID counter for objects
  5633. guid: 1,
  5634. // jQuery.support is not used in Core but other projects attach their
  5635. // properties to it so it needs to exist.
  5636. support: support
  5637. } );
  5638. if ( typeof Symbol === "function" ) {
  5639. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  5640. }
  5641. // Populate the class2type map
  5642. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  5643. function( _i, name ) {
  5644. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  5645. } );
  5646. function isArrayLike( obj ) {
  5647. // Support: real iOS 8.2 only (not reproducible in simulator)
  5648. // `in` check used to prevent JIT error (gh-2145)
  5649. // hasOwn isn't used here due to false negatives
  5650. // regarding Nodelist length in IE
  5651. var length = !!obj && "length" in obj && obj.length,
  5652. type = toType( obj );
  5653. if ( isFunction( obj ) || isWindow( obj ) ) {
  5654. return false;
  5655. }
  5656. return type === "array" || length === 0 ||
  5657. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  5658. }
  5659. var Sizzle =
  5660. /*!
  5661. * Sizzle CSS Selector Engine v2.3.5
  5662. * https://sizzlejs.com/
  5663. *
  5664. * Copyright JS Foundation and other contributors
  5665. * Released under the MIT license
  5666. * https://js.foundation/
  5667. *
  5668. * Date: 2020-03-14
  5669. */
  5670. ( function( window ) {
  5671. var i,
  5672. support,
  5673. Expr,
  5674. getText,
  5675. isXML,
  5676. tokenize,
  5677. compile,
  5678. select,
  5679. outermostContext,
  5680. sortInput,
  5681. hasDuplicate,
  5682. // Local document vars
  5683. setDocument,
  5684. document,
  5685. docElem,
  5686. documentIsHTML,
  5687. rbuggyQSA,
  5688. rbuggyMatches,
  5689. matches,
  5690. contains,
  5691. // Instance-specific data
  5692. expando = "sizzle" + 1 * new Date(),
  5693. preferredDoc = window.document,
  5694. dirruns = 0,
  5695. done = 0,
  5696. classCache = createCache(),
  5697. tokenCache = createCache(),
  5698. compilerCache = createCache(),
  5699. nonnativeSelectorCache = createCache(),
  5700. sortOrder = function( a, b ) {
  5701. if ( a === b ) {
  5702. hasDuplicate = true;
  5703. }
  5704. return 0;
  5705. },
  5706. // Instance methods
  5707. hasOwn = ( {} ).hasOwnProperty,
  5708. arr = [],
  5709. pop = arr.pop,
  5710. pushNative = arr.push,
  5711. push = arr.push,
  5712. slice = arr.slice,
  5713. // Use a stripped-down indexOf as it's faster than native
  5714. // https://jsperf.com/thor-indexof-vs-for/5
  5715. indexOf = function( list, elem ) {
  5716. var i = 0,
  5717. len = list.length;
  5718. for ( ; i < len; i++ ) {
  5719. if ( list[ i ] === elem ) {
  5720. return i;
  5721. }
  5722. }
  5723. return -1;
  5724. },
  5725. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
  5726. "ismap|loop|multiple|open|readonly|required|scoped",
  5727. // Regular expressions
  5728. // http://www.w3.org/TR/css3-selectors/#whitespace
  5729. whitespace = "[\\x20\\t\\r\\n\\f]",
  5730. // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
  5731. identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
  5732. "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
  5733. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  5734. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  5735. // Operator (capture 2)
  5736. "*([*^$|!~]?=)" + whitespace +
  5737. // "Attribute values must be CSS identifiers [capture 5]
  5738. // or strings [capture 3 or capture 4]"
  5739. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
  5740. whitespace + "*\\]",
  5741. pseudos = ":(" + identifier + ")(?:\\((" +
  5742. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  5743. // 1. quoted (capture 3; capture 4 or capture 5)
  5744. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  5745. // 2. simple (capture 6)
  5746. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  5747. // 3. anything else (capture 2)
  5748. ".*" +
  5749. ")\\)|)",
  5750. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  5751. rwhitespace = new RegExp( whitespace + "+", "g" ),
  5752. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
  5753. whitespace + "+$", "g" ),
  5754. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  5755. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
  5756. "*" ),
  5757. rdescend = new RegExp( whitespace + "|>" ),
  5758. rpseudo = new RegExp( pseudos ),
  5759. ridentifier = new RegExp( "^" + identifier + "$" ),
  5760. matchExpr = {
  5761. "ID": new RegExp( "^#(" + identifier + ")" ),
  5762. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  5763. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  5764. "ATTR": new RegExp( "^" + attributes ),
  5765. "PSEUDO": new RegExp( "^" + pseudos ),
  5766. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
  5767. whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
  5768. whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  5769. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  5770. // For use in libraries implementing .is()
  5771. // We use this for POS matching in `select`
  5772. "needsContext": new RegExp( "^" + whitespace +
  5773. "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  5774. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  5775. },
  5776. rhtml = /HTML$/i,
  5777. rinputs = /^(?:input|select|textarea|button)$/i,
  5778. rheader = /^h\d$/i,
  5779. rnative = /^[^{]+\{\s*\[native \w/,
  5780. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  5781. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  5782. rsibling = /[+~]/,
  5783. // CSS escapes
  5784. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  5785. runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
  5786. funescape = function( escape, nonHex ) {
  5787. var high = "0x" + escape.slice( 1 ) - 0x10000;
  5788. return nonHex ?
  5789. // Strip the backslash prefix from a non-hex escape sequence
  5790. nonHex :
  5791. // Replace a hexadecimal escape sequence with the encoded Unicode code point
  5792. // Support: IE <=11+
  5793. // For values outside the Basic Multilingual Plane (BMP), manually construct a
  5794. // surrogate pair
  5795. high < 0 ?
  5796. String.fromCharCode( high + 0x10000 ) :
  5797. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  5798. },
  5799. // CSS string/identifier serialization
  5800. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  5801. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  5802. fcssescape = function( ch, asCodePoint ) {
  5803. if ( asCodePoint ) {
  5804. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  5805. if ( ch === "\0" ) {
  5806. return "\uFFFD";
  5807. }
  5808. // Control characters and (dependent upon position) numbers get escaped as code points
  5809. return ch.slice( 0, -1 ) + "\\" +
  5810. ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  5811. }
  5812. // Other potentially-special ASCII characters get backslash-escaped
  5813. return "\\" + ch;
  5814. },
  5815. // Used for iframes
  5816. // See setDocument()
  5817. // Removing the function wrapper causes a "Permission Denied"
  5818. // error in IE
  5819. unloadHandler = function() {
  5820. setDocument();
  5821. },
  5822. inDisabledFieldset = addCombinator(
  5823. function( elem ) {
  5824. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  5825. },
  5826. { dir: "parentNode", next: "legend" }
  5827. );
  5828. // Optimize for push.apply( _, NodeList )
  5829. try {
  5830. push.apply(
  5831. ( arr = slice.call( preferredDoc.childNodes ) ),
  5832. preferredDoc.childNodes
  5833. );
  5834. // Support: Android<4.0
  5835. // Detect silently failing push.apply
  5836. // eslint-disable-next-line no-unused-expressions
  5837. arr[ preferredDoc.childNodes.length ].nodeType;
  5838. } catch ( e ) {
  5839. push = { apply: arr.length ?
  5840. // Leverage slice if possible
  5841. function( target, els ) {
  5842. pushNative.apply( target, slice.call( els ) );
  5843. } :
  5844. // Support: IE<9
  5845. // Otherwise append directly
  5846. function( target, els ) {
  5847. var j = target.length,
  5848. i = 0;
  5849. // Can't trust NodeList.length
  5850. while ( ( target[ j++ ] = els[ i++ ] ) ) {}
  5851. target.length = j - 1;
  5852. }
  5853. };
  5854. }
  5855. function Sizzle( selector, context, results, seed ) {
  5856. var m, i, elem, nid, match, groups, newSelector,
  5857. newContext = context && context.ownerDocument,
  5858. // nodeType defaults to 9, since context defaults to document
  5859. nodeType = context ? context.nodeType : 9;
  5860. results = results || [];
  5861. // Return early from calls with invalid selector or context
  5862. if ( typeof selector !== "string" || !selector ||
  5863. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  5864. return results;
  5865. }
  5866. // Try to shortcut find operations (as opposed to filters) in HTML documents
  5867. if ( !seed ) {
  5868. setDocument( context );
  5869. context = context || document;
  5870. if ( documentIsHTML ) {
  5871. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  5872. // (excepting DocumentFragment context, where the methods don't exist)
  5873. if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
  5874. // ID selector
  5875. if ( ( m = match[ 1 ] ) ) {
  5876. // Document context
  5877. if ( nodeType === 9 ) {
  5878. if ( ( elem = context.getElementById( m ) ) ) {
  5879. // Support: IE, Opera, Webkit
  5880. // TODO: identify versions
  5881. // getElementById can match elements by name instead of ID
  5882. if ( elem.id === m ) {
  5883. results.push( elem );
  5884. return results;
  5885. }
  5886. } else {
  5887. return results;
  5888. }
  5889. // Element context
  5890. } else {
  5891. // Support: IE, Opera, Webkit
  5892. // TODO: identify versions
  5893. // getElementById can match elements by name instead of ID
  5894. if ( newContext && ( elem = newContext.getElementById( m ) ) &&
  5895. contains( context, elem ) &&
  5896. elem.id === m ) {
  5897. results.push( elem );
  5898. return results;
  5899. }
  5900. }
  5901. // Type selector
  5902. } else if ( match[ 2 ] ) {
  5903. push.apply( results, context.getElementsByTagName( selector ) );
  5904. return results;
  5905. // Class selector
  5906. } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
  5907. context.getElementsByClassName ) {
  5908. push.apply( results, context.getElementsByClassName( m ) );
  5909. return results;
  5910. }
  5911. }
  5912. // Take advantage of querySelectorAll
  5913. if ( support.qsa &&
  5914. !nonnativeSelectorCache[ selector + " " ] &&
  5915. ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
  5916. // Support: IE 8 only
  5917. // Exclude object elements
  5918. ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
  5919. newSelector = selector;
  5920. newContext = context;
  5921. // qSA considers elements outside a scoping root when evaluating child or
  5922. // descendant combinators, which is not what we want.
  5923. // In such cases, we work around the behavior by prefixing every selector in the
  5924. // list with an ID selector referencing the scope context.
  5925. // The technique has to be used as well when a leading combinator is used
  5926. // as such selectors are not recognized by querySelectorAll.
  5927. // Thanks to Andrew Dupont for this technique.
  5928. if ( nodeType === 1 &&
  5929. ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
  5930. // Expand context for sibling selectors
  5931. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  5932. context;
  5933. // We can use :scope instead of the ID hack if the browser
  5934. // supports it & if we're not changing the context.
  5935. if ( newContext !== context || !support.scope ) {
  5936. // Capture the context ID, setting it first if necessary
  5937. if ( ( nid = context.getAttribute( "id" ) ) ) {
  5938. nid = nid.replace( rcssescape, fcssescape );
  5939. } else {
  5940. context.setAttribute( "id", ( nid = expando ) );
  5941. }
  5942. }
  5943. // Prefix every selector in the list
  5944. groups = tokenize( selector );
  5945. i = groups.length;
  5946. while ( i-- ) {
  5947. groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
  5948. toSelector( groups[ i ] );
  5949. }
  5950. newSelector = groups.join( "," );
  5951. }
  5952. try {
  5953. push.apply( results,
  5954. newContext.querySelectorAll( newSelector )
  5955. );
  5956. return results;
  5957. } catch ( qsaError ) {
  5958. nonnativeSelectorCache( selector, true );
  5959. } finally {
  5960. if ( nid === expando ) {
  5961. context.removeAttribute( "id" );
  5962. }
  5963. }
  5964. }
  5965. }
  5966. }
  5967. // All others
  5968. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  5969. }
  5970. /**
  5971. * Create key-value caches of limited size
  5972. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  5973. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  5974. * deleting the oldest entry
  5975. */
  5976. function createCache() {
  5977. var keys = [];
  5978. function cache( key, value ) {
  5979. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  5980. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  5981. // Only keep the most recent entries
  5982. delete cache[ keys.shift() ];
  5983. }
  5984. return ( cache[ key + " " ] = value );
  5985. }
  5986. return cache;
  5987. }
  5988. /**
  5989. * Mark a function for special use by Sizzle
  5990. * @param {Function} fn The function to mark
  5991. */
  5992. function markFunction( fn ) {
  5993. fn[ expando ] = true;
  5994. return fn;
  5995. }
  5996. /**
  5997. * Support testing using an element
  5998. * @param {Function} fn Passed the created element and returns a boolean result
  5999. */
  6000. function assert( fn ) {
  6001. var el = document.createElement( "fieldset" );
  6002. try {
  6003. return !!fn( el );
  6004. } catch ( e ) {
  6005. return false;
  6006. } finally {
  6007. // Remove from its parent by default
  6008. if ( el.parentNode ) {
  6009. el.parentNode.removeChild( el );
  6010. }
  6011. // release memory in IE
  6012. el = null;
  6013. }
  6014. }
  6015. /**
  6016. * Adds the same handler for all of the specified attrs
  6017. * @param {String} attrs Pipe-separated list of attributes
  6018. * @param {Function} handler The method that will be applied
  6019. */
  6020. function addHandle( attrs, handler ) {
  6021. var arr = attrs.split( "|" ),
  6022. i = arr.length;
  6023. while ( i-- ) {
  6024. Expr.attrHandle[ arr[ i ] ] = handler;
  6025. }
  6026. }
  6027. /**
  6028. * Checks document order of two siblings
  6029. * @param {Element} a
  6030. * @param {Element} b
  6031. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  6032. */
  6033. function siblingCheck( a, b ) {
  6034. var cur = b && a,
  6035. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  6036. a.sourceIndex - b.sourceIndex;
  6037. // Use IE sourceIndex if available on both nodes
  6038. if ( diff ) {
  6039. return diff;
  6040. }
  6041. // Check if b follows a
  6042. if ( cur ) {
  6043. while ( ( cur = cur.nextSibling ) ) {
  6044. if ( cur === b ) {
  6045. return -1;
  6046. }
  6047. }
  6048. }
  6049. return a ? 1 : -1;
  6050. }
  6051. /**
  6052. * Returns a function to use in pseudos for input types
  6053. * @param {String} type
  6054. */
  6055. function createInputPseudo( type ) {
  6056. return function( elem ) {
  6057. var name = elem.nodeName.toLowerCase();
  6058. return name === "input" && elem.type === type;
  6059. };
  6060. }
  6061. /**
  6062. * Returns a function to use in pseudos for buttons
  6063. * @param {String} type
  6064. */
  6065. function createButtonPseudo( type ) {
  6066. return function( elem ) {
  6067. var name = elem.nodeName.toLowerCase();
  6068. return ( name === "input" || name === "button" ) && elem.type === type;
  6069. };
  6070. }
  6071. /**
  6072. * Returns a function to use in pseudos for :enabled/:disabled
  6073. * @param {Boolean} disabled true for :disabled; false for :enabled
  6074. */
  6075. function createDisabledPseudo( disabled ) {
  6076. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  6077. return function( elem ) {
  6078. // Only certain elements can match :enabled or :disabled
  6079. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  6080. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  6081. if ( "form" in elem ) {
  6082. // Check for inherited disabledness on relevant non-disabled elements:
  6083. // * listed form-associated elements in a disabled fieldset
  6084. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  6085. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  6086. // * option elements in a disabled optgroup
  6087. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  6088. // All such elements have a "form" property.
  6089. if ( elem.parentNode && elem.disabled === false ) {
  6090. // Option elements defer to a parent optgroup if present
  6091. if ( "label" in elem ) {
  6092. if ( "label" in elem.parentNode ) {
  6093. return elem.parentNode.disabled === disabled;
  6094. } else {
  6095. return elem.disabled === disabled;
  6096. }
  6097. }
  6098. // Support: IE 6 - 11
  6099. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  6100. return elem.isDisabled === disabled ||
  6101. // Where there is no isDisabled, check manually
  6102. /* jshint -W018 */
  6103. elem.isDisabled !== !disabled &&
  6104. inDisabledFieldset( elem ) === disabled;
  6105. }
  6106. return elem.disabled === disabled;
  6107. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  6108. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  6109. // even exist on them, let alone have a boolean value.
  6110. } else if ( "label" in elem ) {
  6111. return elem.disabled === disabled;
  6112. }
  6113. // Remaining elements are neither :enabled nor :disabled
  6114. return false;
  6115. };
  6116. }
  6117. /**
  6118. * Returns a function to use in pseudos for positionals
  6119. * @param {Function} fn
  6120. */
  6121. function createPositionalPseudo( fn ) {
  6122. return markFunction( function( argument ) {
  6123. argument = +argument;
  6124. return markFunction( function( seed, matches ) {
  6125. var j,
  6126. matchIndexes = fn( [], seed.length, argument ),
  6127. i = matchIndexes.length;
  6128. // Match elements found at the specified indexes
  6129. while ( i-- ) {
  6130. if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
  6131. seed[ j ] = !( matches[ j ] = seed[ j ] );
  6132. }
  6133. }
  6134. } );
  6135. } );
  6136. }
  6137. /**
  6138. * Checks a node for validity as a Sizzle context
  6139. * @param {Element|Object=} context
  6140. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  6141. */
  6142. function testContext( context ) {
  6143. return context && typeof context.getElementsByTagName !== "undefined" && context;
  6144. }
  6145. // Expose support vars for convenience
  6146. support = Sizzle.support = {};
  6147. /**
  6148. * Detects XML nodes
  6149. * @param {Element|Object} elem An element or a document
  6150. * @returns {Boolean} True iff elem is a non-HTML XML node
  6151. */
  6152. isXML = Sizzle.isXML = function( elem ) {
  6153. var namespace = elem.namespaceURI,
  6154. docElem = ( elem.ownerDocument || elem ).documentElement;
  6155. // Support: IE <=8
  6156. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  6157. // https://bugs.jquery.com/ticket/4833
  6158. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  6159. };
  6160. /**
  6161. * Sets document-related variables once based on the current document
  6162. * @param {Element|Object} [doc] An element or document object to use to set the document
  6163. * @returns {Object} Returns the current document
  6164. */
  6165. setDocument = Sizzle.setDocument = function( node ) {
  6166. var hasCompare, subWindow,
  6167. doc = node ? node.ownerDocument || node : preferredDoc;
  6168. // Return early if doc is invalid or already selected
  6169. // Support: IE 11+, Edge 17 - 18+
  6170. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6171. // two documents; shallow comparisons work.
  6172. // eslint-disable-next-line eqeqeq
  6173. if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
  6174. return document;
  6175. }
  6176. // Update global variables
  6177. document = doc;
  6178. docElem = document.documentElement;
  6179. documentIsHTML = !isXML( document );
  6180. // Support: IE 9 - 11+, Edge 12 - 18+
  6181. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  6182. // Support: IE 11+, Edge 17 - 18+
  6183. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6184. // two documents; shallow comparisons work.
  6185. // eslint-disable-next-line eqeqeq
  6186. if ( preferredDoc != document &&
  6187. ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
  6188. // Support: IE 11, Edge
  6189. if ( subWindow.addEventListener ) {
  6190. subWindow.addEventListener( "unload", unloadHandler, false );
  6191. // Support: IE 9 - 10 only
  6192. } else if ( subWindow.attachEvent ) {
  6193. subWindow.attachEvent( "onunload", unloadHandler );
  6194. }
  6195. }
  6196. // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
  6197. // Safari 4 - 5 only, Opera <=11.6 - 12.x only
  6198. // IE/Edge & older browsers don't support the :scope pseudo-class.
  6199. // Support: Safari 6.0 only
  6200. // Safari 6.0 supports :scope but it's an alias of :root there.
  6201. support.scope = assert( function( el ) {
  6202. docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
  6203. return typeof el.querySelectorAll !== "undefined" &&
  6204. !el.querySelectorAll( ":scope fieldset div" ).length;
  6205. } );
  6206. /* Attributes
  6207. ---------------------------------------------------------------------- */
  6208. // Support: IE<8
  6209. // Verify that getAttribute really returns attributes and not properties
  6210. // (excepting IE8 booleans)
  6211. support.attributes = assert( function( el ) {
  6212. el.className = "i";
  6213. return !el.getAttribute( "className" );
  6214. } );
  6215. /* getElement(s)By*
  6216. ---------------------------------------------------------------------- */
  6217. // Check if getElementsByTagName("*") returns only elements
  6218. support.getElementsByTagName = assert( function( el ) {
  6219. el.appendChild( document.createComment( "" ) );
  6220. return !el.getElementsByTagName( "*" ).length;
  6221. } );
  6222. // Support: IE<9
  6223. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  6224. // Support: IE<10
  6225. // Check if getElementById returns elements by name
  6226. // The broken getElementById methods don't pick up programmatically-set names,
  6227. // so use a roundabout getElementsByName test
  6228. support.getById = assert( function( el ) {
  6229. docElem.appendChild( el ).id = expando;
  6230. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  6231. } );
  6232. // ID filter and find
  6233. if ( support.getById ) {
  6234. Expr.filter[ "ID" ] = function( id ) {
  6235. var attrId = id.replace( runescape, funescape );
  6236. return function( elem ) {
  6237. return elem.getAttribute( "id" ) === attrId;
  6238. };
  6239. };
  6240. Expr.find[ "ID" ] = function( id, context ) {
  6241. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6242. var elem = context.getElementById( id );
  6243. return elem ? [ elem ] : [];
  6244. }
  6245. };
  6246. } else {
  6247. Expr.filter[ "ID" ] = function( id ) {
  6248. var attrId = id.replace( runescape, funescape );
  6249. return function( elem ) {
  6250. var node = typeof elem.getAttributeNode !== "undefined" &&
  6251. elem.getAttributeNode( "id" );
  6252. return node && node.value === attrId;
  6253. };
  6254. };
  6255. // Support: IE 6 - 7 only
  6256. // getElementById is not reliable as a find shortcut
  6257. Expr.find[ "ID" ] = function( id, context ) {
  6258. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6259. var node, i, elems,
  6260. elem = context.getElementById( id );
  6261. if ( elem ) {
  6262. // Verify the id attribute
  6263. node = elem.getAttributeNode( "id" );
  6264. if ( node && node.value === id ) {
  6265. return [ elem ];
  6266. }
  6267. // Fall back on getElementsByName
  6268. elems = context.getElementsByName( id );
  6269. i = 0;
  6270. while ( ( elem = elems[ i++ ] ) ) {
  6271. node = elem.getAttributeNode( "id" );
  6272. if ( node && node.value === id ) {
  6273. return [ elem ];
  6274. }
  6275. }
  6276. }
  6277. return [];
  6278. }
  6279. };
  6280. }
  6281. // Tag
  6282. Expr.find[ "TAG" ] = support.getElementsByTagName ?
  6283. function( tag, context ) {
  6284. if ( typeof context.getElementsByTagName !== "undefined" ) {
  6285. return context.getElementsByTagName( tag );
  6286. // DocumentFragment nodes don't have gEBTN
  6287. } else if ( support.qsa ) {
  6288. return context.querySelectorAll( tag );
  6289. }
  6290. } :
  6291. function( tag, context ) {
  6292. var elem,
  6293. tmp = [],
  6294. i = 0,
  6295. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  6296. results = context.getElementsByTagName( tag );
  6297. // Filter out possible comments
  6298. if ( tag === "*" ) {
  6299. while ( ( elem = results[ i++ ] ) ) {
  6300. if ( elem.nodeType === 1 ) {
  6301. tmp.push( elem );
  6302. }
  6303. }
  6304. return tmp;
  6305. }
  6306. return results;
  6307. };
  6308. // Class
  6309. Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
  6310. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  6311. return context.getElementsByClassName( className );
  6312. }
  6313. };
  6314. /* QSA/matchesSelector
  6315. ---------------------------------------------------------------------- */
  6316. // QSA and matchesSelector support
  6317. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  6318. rbuggyMatches = [];
  6319. // qSa(:focus) reports false when true (Chrome 21)
  6320. // We allow this because of a bug in IE8/9 that throws an error
  6321. // whenever `document.activeElement` is accessed on an iframe
  6322. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  6323. // See https://bugs.jquery.com/ticket/13378
  6324. rbuggyQSA = [];
  6325. if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
  6326. // Build QSA regex
  6327. // Regex strategy adopted from Diego Perini
  6328. assert( function( el ) {
  6329. var input;
  6330. // Select is set to empty string on purpose
  6331. // This is to test IE's treatment of not explicitly
  6332. // setting a boolean content attribute,
  6333. // since its presence should be enough
  6334. // https://bugs.jquery.com/ticket/12359
  6335. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  6336. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  6337. "<option selected=''></option></select>";
  6338. // Support: IE8, Opera 11-12.16
  6339. // Nothing should be selected when empty strings follow ^= or $= or *=
  6340. // The test attribute must be unknown in Opera but "safe" for WinRT
  6341. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  6342. if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
  6343. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  6344. }
  6345. // Support: IE8
  6346. // Boolean attributes and "value" are not treated correctly
  6347. if ( !el.querySelectorAll( "[selected]" ).length ) {
  6348. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  6349. }
  6350. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  6351. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  6352. rbuggyQSA.push( "~=" );
  6353. }
  6354. // Support: IE 11+, Edge 15 - 18+
  6355. // IE 11/Edge don't find elements on a `[name='']` query in some cases.
  6356. // Adding a temporary attribute to the document before the selection works
  6357. // around the issue.
  6358. // Interestingly, IE 10 & older don't seem to have the issue.
  6359. input = document.createElement( "input" );
  6360. input.setAttribute( "name", "" );
  6361. el.appendChild( input );
  6362. if ( !el.querySelectorAll( "[name='']" ).length ) {
  6363. rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
  6364. whitespace + "*(?:''|\"\")" );
  6365. }
  6366. // Webkit/Opera - :checked should return selected option elements
  6367. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6368. // IE8 throws error here and will not see later tests
  6369. if ( !el.querySelectorAll( ":checked" ).length ) {
  6370. rbuggyQSA.push( ":checked" );
  6371. }
  6372. // Support: Safari 8+, iOS 8+
  6373. // https://bugs.webkit.org/show_bug.cgi?id=136851
  6374. // In-page `selector#id sibling-combinator selector` fails
  6375. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  6376. rbuggyQSA.push( ".#.+[+~]" );
  6377. }
  6378. // Support: Firefox <=3.6 - 5 only
  6379. // Old Firefox doesn't throw on a badly-escaped identifier.
  6380. el.querySelectorAll( "\\\f" );
  6381. rbuggyQSA.push( "[\\r\\n\\f]" );
  6382. } );
  6383. assert( function( el ) {
  6384. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  6385. "<select disabled='disabled'><option/></select>";
  6386. // Support: Windows 8 Native Apps
  6387. // The type and name attributes are restricted during .innerHTML assignment
  6388. var input = document.createElement( "input" );
  6389. input.setAttribute( "type", "hidden" );
  6390. el.appendChild( input ).setAttribute( "name", "D" );
  6391. // Support: IE8
  6392. // Enforce case-sensitivity of name attribute
  6393. if ( el.querySelectorAll( "[name=d]" ).length ) {
  6394. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  6395. }
  6396. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  6397. // IE8 throws error here and will not see later tests
  6398. if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
  6399. rbuggyQSA.push( ":enabled", ":disabled" );
  6400. }
  6401. // Support: IE9-11+
  6402. // IE's :disabled selector does not pick up the children of disabled fieldsets
  6403. docElem.appendChild( el ).disabled = true;
  6404. if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
  6405. rbuggyQSA.push( ":enabled", ":disabled" );
  6406. }
  6407. // Support: Opera 10 - 11 only
  6408. // Opera 10-11 does not throw on post-comma invalid pseudos
  6409. el.querySelectorAll( "*,:x" );
  6410. rbuggyQSA.push( ",.*:" );
  6411. } );
  6412. }
  6413. if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
  6414. docElem.webkitMatchesSelector ||
  6415. docElem.mozMatchesSelector ||
  6416. docElem.oMatchesSelector ||
  6417. docElem.msMatchesSelector ) ) ) ) {
  6418. assert( function( el ) {
  6419. // Check to see if it's possible to do matchesSelector
  6420. // on a disconnected node (IE 9)
  6421. support.disconnectedMatch = matches.call( el, "*" );
  6422. // This should fail with an exception
  6423. // Gecko does not error, returns false instead
  6424. matches.call( el, "[s!='']:x" );
  6425. rbuggyMatches.push( "!=", pseudos );
  6426. } );
  6427. }
  6428. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
  6429. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
  6430. /* Contains
  6431. ---------------------------------------------------------------------- */
  6432. hasCompare = rnative.test( docElem.compareDocumentPosition );
  6433. // Element contains another
  6434. // Purposefully self-exclusive
  6435. // As in, an element does not contain itself
  6436. contains = hasCompare || rnative.test( docElem.contains ) ?
  6437. function( a, b ) {
  6438. var adown = a.nodeType === 9 ? a.documentElement : a,
  6439. bup = b && b.parentNode;
  6440. return a === bup || !!( bup && bup.nodeType === 1 && (
  6441. adown.contains ?
  6442. adown.contains( bup ) :
  6443. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  6444. ) );
  6445. } :
  6446. function( a, b ) {
  6447. if ( b ) {
  6448. while ( ( b = b.parentNode ) ) {
  6449. if ( b === a ) {
  6450. return true;
  6451. }
  6452. }
  6453. }
  6454. return false;
  6455. };
  6456. /* Sorting
  6457. ---------------------------------------------------------------------- */
  6458. // Document order sorting
  6459. sortOrder = hasCompare ?
  6460. function( a, b ) {
  6461. // Flag for duplicate removal
  6462. if ( a === b ) {
  6463. hasDuplicate = true;
  6464. return 0;
  6465. }
  6466. // Sort on method existence if only one input has compareDocumentPosition
  6467. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  6468. if ( compare ) {
  6469. return compare;
  6470. }
  6471. // Calculate position if both inputs belong to the same document
  6472. // Support: IE 11+, Edge 17 - 18+
  6473. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6474. // two documents; shallow comparisons work.
  6475. // eslint-disable-next-line eqeqeq
  6476. compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
  6477. a.compareDocumentPosition( b ) :
  6478. // Otherwise we know they are disconnected
  6479. 1;
  6480. // Disconnected nodes
  6481. if ( compare & 1 ||
  6482. ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
  6483. // Choose the first element that is related to our preferred document
  6484. // Support: IE 11+, Edge 17 - 18+
  6485. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6486. // two documents; shallow comparisons work.
  6487. // eslint-disable-next-line eqeqeq
  6488. if ( a == document || a.ownerDocument == preferredDoc &&
  6489. contains( preferredDoc, a ) ) {
  6490. return -1;
  6491. }
  6492. // Support: IE 11+, Edge 17 - 18+
  6493. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6494. // two documents; shallow comparisons work.
  6495. // eslint-disable-next-line eqeqeq
  6496. if ( b == document || b.ownerDocument == preferredDoc &&
  6497. contains( preferredDoc, b ) ) {
  6498. return 1;
  6499. }
  6500. // Maintain original order
  6501. return sortInput ?
  6502. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6503. 0;
  6504. }
  6505. return compare & 4 ? -1 : 1;
  6506. } :
  6507. function( a, b ) {
  6508. // Exit early if the nodes are identical
  6509. if ( a === b ) {
  6510. hasDuplicate = true;
  6511. return 0;
  6512. }
  6513. var cur,
  6514. i = 0,
  6515. aup = a.parentNode,
  6516. bup = b.parentNode,
  6517. ap = [ a ],
  6518. bp = [ b ];
  6519. // Parentless nodes are either documents or disconnected
  6520. if ( !aup || !bup ) {
  6521. // Support: IE 11+, Edge 17 - 18+
  6522. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6523. // two documents; shallow comparisons work.
  6524. /* eslint-disable eqeqeq */
  6525. return a == document ? -1 :
  6526. b == document ? 1 :
  6527. /* eslint-enable eqeqeq */
  6528. aup ? -1 :
  6529. bup ? 1 :
  6530. sortInput ?
  6531. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6532. 0;
  6533. // If the nodes are siblings, we can do a quick check
  6534. } else if ( aup === bup ) {
  6535. return siblingCheck( a, b );
  6536. }
  6537. // Otherwise we need full lists of their ancestors for comparison
  6538. cur = a;
  6539. while ( ( cur = cur.parentNode ) ) {
  6540. ap.unshift( cur );
  6541. }
  6542. cur = b;
  6543. while ( ( cur = cur.parentNode ) ) {
  6544. bp.unshift( cur );
  6545. }
  6546. // Walk down the tree looking for a discrepancy
  6547. while ( ap[ i ] === bp[ i ] ) {
  6548. i++;
  6549. }
  6550. return i ?
  6551. // Do a sibling check if the nodes have a common ancestor
  6552. siblingCheck( ap[ i ], bp[ i ] ) :
  6553. // Otherwise nodes in our document sort first
  6554. // Support: IE 11+, Edge 17 - 18+
  6555. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6556. // two documents; shallow comparisons work.
  6557. /* eslint-disable eqeqeq */
  6558. ap[ i ] == preferredDoc ? -1 :
  6559. bp[ i ] == preferredDoc ? 1 :
  6560. /* eslint-enable eqeqeq */
  6561. 0;
  6562. };
  6563. return document;
  6564. };
  6565. Sizzle.matches = function( expr, elements ) {
  6566. return Sizzle( expr, null, null, elements );
  6567. };
  6568. Sizzle.matchesSelector = function( elem, expr ) {
  6569. setDocument( elem );
  6570. if ( support.matchesSelector && documentIsHTML &&
  6571. !nonnativeSelectorCache[ expr + " " ] &&
  6572. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  6573. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  6574. try {
  6575. var ret = matches.call( elem, expr );
  6576. // IE 9's matchesSelector returns false on disconnected nodes
  6577. if ( ret || support.disconnectedMatch ||
  6578. // As well, disconnected nodes are said to be in a document
  6579. // fragment in IE 9
  6580. elem.document && elem.document.nodeType !== 11 ) {
  6581. return ret;
  6582. }
  6583. } catch ( e ) {
  6584. nonnativeSelectorCache( expr, true );
  6585. }
  6586. }
  6587. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  6588. };
  6589. Sizzle.contains = function( context, elem ) {
  6590. // Set document vars if needed
  6591. // Support: IE 11+, Edge 17 - 18+
  6592. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6593. // two documents; shallow comparisons work.
  6594. // eslint-disable-next-line eqeqeq
  6595. if ( ( context.ownerDocument || context ) != document ) {
  6596. setDocument( context );
  6597. }
  6598. return contains( context, elem );
  6599. };
  6600. Sizzle.attr = function( elem, name ) {
  6601. // Set document vars if needed
  6602. // Support: IE 11+, Edge 17 - 18+
  6603. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6604. // two documents; shallow comparisons work.
  6605. // eslint-disable-next-line eqeqeq
  6606. if ( ( elem.ownerDocument || elem ) != document ) {
  6607. setDocument( elem );
  6608. }
  6609. var fn = Expr.attrHandle[ name.toLowerCase() ],
  6610. // Don't get fooled by Object.prototype properties (jQuery #13807)
  6611. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  6612. fn( elem, name, !documentIsHTML ) :
  6613. undefined;
  6614. return val !== undefined ?
  6615. val :
  6616. support.attributes || !documentIsHTML ?
  6617. elem.getAttribute( name ) :
  6618. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  6619. val.value :
  6620. null;
  6621. };
  6622. Sizzle.escape = function( sel ) {
  6623. return ( sel + "" ).replace( rcssescape, fcssescape );
  6624. };
  6625. Sizzle.error = function( msg ) {
  6626. throw new Error( "Syntax error, unrecognized expression: " + msg );
  6627. };
  6628. /**
  6629. * Document sorting and removing duplicates
  6630. * @param {ArrayLike} results
  6631. */
  6632. Sizzle.uniqueSort = function( results ) {
  6633. var elem,
  6634. duplicates = [],
  6635. j = 0,
  6636. i = 0;
  6637. // Unless we *know* we can detect duplicates, assume their presence
  6638. hasDuplicate = !support.detectDuplicates;
  6639. sortInput = !support.sortStable && results.slice( 0 );
  6640. results.sort( sortOrder );
  6641. if ( hasDuplicate ) {
  6642. while ( ( elem = results[ i++ ] ) ) {
  6643. if ( elem === results[ i ] ) {
  6644. j = duplicates.push( i );
  6645. }
  6646. }
  6647. while ( j-- ) {
  6648. results.splice( duplicates[ j ], 1 );
  6649. }
  6650. }
  6651. // Clear input after sorting to release objects
  6652. // See https://github.com/jquery/sizzle/pull/225
  6653. sortInput = null;
  6654. return results;
  6655. };
  6656. /**
  6657. * Utility function for retrieving the text value of an array of DOM nodes
  6658. * @param {Array|Element} elem
  6659. */
  6660. getText = Sizzle.getText = function( elem ) {
  6661. var node,
  6662. ret = "",
  6663. i = 0,
  6664. nodeType = elem.nodeType;
  6665. if ( !nodeType ) {
  6666. // If no nodeType, this is expected to be an array
  6667. while ( ( node = elem[ i++ ] ) ) {
  6668. // Do not traverse comment nodes
  6669. ret += getText( node );
  6670. }
  6671. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  6672. // Use textContent for elements
  6673. // innerText usage removed for consistency of new lines (jQuery #11153)
  6674. if ( typeof elem.textContent === "string" ) {
  6675. return elem.textContent;
  6676. } else {
  6677. // Traverse its children
  6678. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6679. ret += getText( elem );
  6680. }
  6681. }
  6682. } else if ( nodeType === 3 || nodeType === 4 ) {
  6683. return elem.nodeValue;
  6684. }
  6685. // Do not include comment or processing instruction nodes
  6686. return ret;
  6687. };
  6688. Expr = Sizzle.selectors = {
  6689. // Can be adjusted by the user
  6690. cacheLength: 50,
  6691. createPseudo: markFunction,
  6692. match: matchExpr,
  6693. attrHandle: {},
  6694. find: {},
  6695. relative: {
  6696. ">": { dir: "parentNode", first: true },
  6697. " ": { dir: "parentNode" },
  6698. "+": { dir: "previousSibling", first: true },
  6699. "~": { dir: "previousSibling" }
  6700. },
  6701. preFilter: {
  6702. "ATTR": function( match ) {
  6703. match[ 1 ] = match[ 1 ].replace( runescape, funescape );
  6704. // Move the given value to match[3] whether quoted or unquoted
  6705. match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
  6706. match[ 5 ] || "" ).replace( runescape, funescape );
  6707. if ( match[ 2 ] === "~=" ) {
  6708. match[ 3 ] = " " + match[ 3 ] + " ";
  6709. }
  6710. return match.slice( 0, 4 );
  6711. },
  6712. "CHILD": function( match ) {
  6713. /* matches from matchExpr["CHILD"]
  6714. 1 type (only|nth|...)
  6715. 2 what (child|of-type)
  6716. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  6717. 4 xn-component of xn+y argument ([+-]?\d*n|)
  6718. 5 sign of xn-component
  6719. 6 x of xn-component
  6720. 7 sign of y-component
  6721. 8 y of y-component
  6722. */
  6723. match[ 1 ] = match[ 1 ].toLowerCase();
  6724. if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
  6725. // nth-* requires argument
  6726. if ( !match[ 3 ] ) {
  6727. Sizzle.error( match[ 0 ] );
  6728. }
  6729. // numeric x and y parameters for Expr.filter.CHILD
  6730. // remember that false/true cast respectively to 0/1
  6731. match[ 4 ] = +( match[ 4 ] ?
  6732. match[ 5 ] + ( match[ 6 ] || 1 ) :
  6733. 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
  6734. match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
  6735. // other types prohibit arguments
  6736. } else if ( match[ 3 ] ) {
  6737. Sizzle.error( match[ 0 ] );
  6738. }
  6739. return match;
  6740. },
  6741. "PSEUDO": function( match ) {
  6742. var excess,
  6743. unquoted = !match[ 6 ] && match[ 2 ];
  6744. if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
  6745. return null;
  6746. }
  6747. // Accept quoted arguments as-is
  6748. if ( match[ 3 ] ) {
  6749. match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
  6750. // Strip excess characters from unquoted arguments
  6751. } else if ( unquoted && rpseudo.test( unquoted ) &&
  6752. // Get excess from tokenize (recursively)
  6753. ( excess = tokenize( unquoted, true ) ) &&
  6754. // advance to the next closing parenthesis
  6755. ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
  6756. // excess is a negative index
  6757. match[ 0 ] = match[ 0 ].slice( 0, excess );
  6758. match[ 2 ] = unquoted.slice( 0, excess );
  6759. }
  6760. // Return only captures needed by the pseudo filter method (type and argument)
  6761. return match.slice( 0, 3 );
  6762. }
  6763. },
  6764. filter: {
  6765. "TAG": function( nodeNameSelector ) {
  6766. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  6767. return nodeNameSelector === "*" ?
  6768. function() {
  6769. return true;
  6770. } :
  6771. function( elem ) {
  6772. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  6773. };
  6774. },
  6775. "CLASS": function( className ) {
  6776. var pattern = classCache[ className + " " ];
  6777. return pattern ||
  6778. ( pattern = new RegExp( "(^|" + whitespace +
  6779. ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
  6780. className, function( elem ) {
  6781. return pattern.test(
  6782. typeof elem.className === "string" && elem.className ||
  6783. typeof elem.getAttribute !== "undefined" &&
  6784. elem.getAttribute( "class" ) ||
  6785. ""
  6786. );
  6787. } );
  6788. },
  6789. "ATTR": function( name, operator, check ) {
  6790. return function( elem ) {
  6791. var result = Sizzle.attr( elem, name );
  6792. if ( result == null ) {
  6793. return operator === "!=";
  6794. }
  6795. if ( !operator ) {
  6796. return true;
  6797. }
  6798. result += "";
  6799. /* eslint-disable max-len */
  6800. return operator === "=" ? result === check :
  6801. operator === "!=" ? result !== check :
  6802. operator === "^=" ? check && result.indexOf( check ) === 0 :
  6803. operator === "*=" ? check && result.indexOf( check ) > -1 :
  6804. operator === "$=" ? check && result.slice( -check.length ) === check :
  6805. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  6806. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  6807. false;
  6808. /* eslint-enable max-len */
  6809. };
  6810. },
  6811. "CHILD": function( type, what, _argument, first, last ) {
  6812. var simple = type.slice( 0, 3 ) !== "nth",
  6813. forward = type.slice( -4 ) !== "last",
  6814. ofType = what === "of-type";
  6815. return first === 1 && last === 0 ?
  6816. // Shortcut for :nth-*(n)
  6817. function( elem ) {
  6818. return !!elem.parentNode;
  6819. } :
  6820. function( elem, _context, xml ) {
  6821. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  6822. dir = simple !== forward ? "nextSibling" : "previousSibling",
  6823. parent = elem.parentNode,
  6824. name = ofType && elem.nodeName.toLowerCase(),
  6825. useCache = !xml && !ofType,
  6826. diff = false;
  6827. if ( parent ) {
  6828. // :(first|last|only)-(child|of-type)
  6829. if ( simple ) {
  6830. while ( dir ) {
  6831. node = elem;
  6832. while ( ( node = node[ dir ] ) ) {
  6833. if ( ofType ?
  6834. node.nodeName.toLowerCase() === name :
  6835. node.nodeType === 1 ) {
  6836. return false;
  6837. }
  6838. }
  6839. // Reverse direction for :only-* (if we haven't yet done so)
  6840. start = dir = type === "only" && !start && "nextSibling";
  6841. }
  6842. return true;
  6843. }
  6844. start = [ forward ? parent.firstChild : parent.lastChild ];
  6845. // non-xml :nth-child(...) stores cache data on `parent`
  6846. if ( forward && useCache ) {
  6847. // Seek `elem` from a previously-cached index
  6848. // ...in a gzip-friendly way
  6849. node = parent;
  6850. outerCache = node[ expando ] || ( node[ expando ] = {} );
  6851. // Support: IE <9 only
  6852. // Defend against cloned attroperties (jQuery gh-1709)
  6853. uniqueCache = outerCache[ node.uniqueID ] ||
  6854. ( outerCache[ node.uniqueID ] = {} );
  6855. cache = uniqueCache[ type ] || [];
  6856. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6857. diff = nodeIndex && cache[ 2 ];
  6858. node = nodeIndex && parent.childNodes[ nodeIndex ];
  6859. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  6860. // Fallback to seeking `elem` from the start
  6861. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  6862. // When found, cache indexes on `parent` and break
  6863. if ( node.nodeType === 1 && ++diff && node === elem ) {
  6864. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  6865. break;
  6866. }
  6867. }
  6868. } else {
  6869. // Use previously-cached element index if available
  6870. if ( useCache ) {
  6871. // ...in a gzip-friendly way
  6872. node = elem;
  6873. outerCache = node[ expando ] || ( node[ expando ] = {} );
  6874. // Support: IE <9 only
  6875. // Defend against cloned attroperties (jQuery gh-1709)
  6876. uniqueCache = outerCache[ node.uniqueID ] ||
  6877. ( outerCache[ node.uniqueID ] = {} );
  6878. cache = uniqueCache[ type ] || [];
  6879. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6880. diff = nodeIndex;
  6881. }
  6882. // xml :nth-child(...)
  6883. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  6884. if ( diff === false ) {
  6885. // Use the same loop as above to seek `elem` from the start
  6886. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  6887. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  6888. if ( ( ofType ?
  6889. node.nodeName.toLowerCase() === name :
  6890. node.nodeType === 1 ) &&
  6891. ++diff ) {
  6892. // Cache the index of each encountered element
  6893. if ( useCache ) {
  6894. outerCache = node[ expando ] ||
  6895. ( node[ expando ] = {} );
  6896. // Support: IE <9 only
  6897. // Defend against cloned attroperties (jQuery gh-1709)
  6898. uniqueCache = outerCache[ node.uniqueID ] ||
  6899. ( outerCache[ node.uniqueID ] = {} );
  6900. uniqueCache[ type ] = [ dirruns, diff ];
  6901. }
  6902. if ( node === elem ) {
  6903. break;
  6904. }
  6905. }
  6906. }
  6907. }
  6908. }
  6909. // Incorporate the offset, then check against cycle size
  6910. diff -= last;
  6911. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  6912. }
  6913. };
  6914. },
  6915. "PSEUDO": function( pseudo, argument ) {
  6916. // pseudo-class names are case-insensitive
  6917. // http://www.w3.org/TR/selectors/#pseudo-classes
  6918. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  6919. // Remember that setFilters inherits from pseudos
  6920. var args,
  6921. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  6922. Sizzle.error( "unsupported pseudo: " + pseudo );
  6923. // The user may use createPseudo to indicate that
  6924. // arguments are needed to create the filter function
  6925. // just as Sizzle does
  6926. if ( fn[ expando ] ) {
  6927. return fn( argument );
  6928. }
  6929. // But maintain support for old signatures
  6930. if ( fn.length > 1 ) {
  6931. args = [ pseudo, pseudo, "", argument ];
  6932. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  6933. markFunction( function( seed, matches ) {
  6934. var idx,
  6935. matched = fn( seed, argument ),
  6936. i = matched.length;
  6937. while ( i-- ) {
  6938. idx = indexOf( seed, matched[ i ] );
  6939. seed[ idx ] = !( matches[ idx ] = matched[ i ] );
  6940. }
  6941. } ) :
  6942. function( elem ) {
  6943. return fn( elem, 0, args );
  6944. };
  6945. }
  6946. return fn;
  6947. }
  6948. },
  6949. pseudos: {
  6950. // Potentially complex pseudos
  6951. "not": markFunction( function( selector ) {
  6952. // Trim the selector passed to compile
  6953. // to avoid treating leading and trailing
  6954. // spaces as combinators
  6955. var input = [],
  6956. results = [],
  6957. matcher = compile( selector.replace( rtrim, "$1" ) );
  6958. return matcher[ expando ] ?
  6959. markFunction( function( seed, matches, _context, xml ) {
  6960. var elem,
  6961. unmatched = matcher( seed, null, xml, [] ),
  6962. i = seed.length;
  6963. // Match elements unmatched by `matcher`
  6964. while ( i-- ) {
  6965. if ( ( elem = unmatched[ i ] ) ) {
  6966. seed[ i ] = !( matches[ i ] = elem );
  6967. }
  6968. }
  6969. } ) :
  6970. function( elem, _context, xml ) {
  6971. input[ 0 ] = elem;
  6972. matcher( input, null, xml, results );
  6973. // Don't keep the element (issue #299)
  6974. input[ 0 ] = null;
  6975. return !results.pop();
  6976. };
  6977. } ),
  6978. "has": markFunction( function( selector ) {
  6979. return function( elem ) {
  6980. return Sizzle( selector, elem ).length > 0;
  6981. };
  6982. } ),
  6983. "contains": markFunction( function( text ) {
  6984. text = text.replace( runescape, funescape );
  6985. return function( elem ) {
  6986. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  6987. };
  6988. } ),
  6989. // "Whether an element is represented by a :lang() selector
  6990. // is based solely on the element's language value
  6991. // being equal to the identifier C,
  6992. // or beginning with the identifier C immediately followed by "-".
  6993. // The matching of C against the element's language value is performed case-insensitively.
  6994. // The identifier C does not have to be a valid language name."
  6995. // http://www.w3.org/TR/selectors/#lang-pseudo
  6996. "lang": markFunction( function( lang ) {
  6997. // lang value must be a valid identifier
  6998. if ( !ridentifier.test( lang || "" ) ) {
  6999. Sizzle.error( "unsupported lang: " + lang );
  7000. }
  7001. lang = lang.replace( runescape, funescape ).toLowerCase();
  7002. return function( elem ) {
  7003. var elemLang;
  7004. do {
  7005. if ( ( elemLang = documentIsHTML ?
  7006. elem.lang :
  7007. elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
  7008. elemLang = elemLang.toLowerCase();
  7009. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  7010. }
  7011. } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
  7012. return false;
  7013. };
  7014. } ),
  7015. // Miscellaneous
  7016. "target": function( elem ) {
  7017. var hash = window.location && window.location.hash;
  7018. return hash && hash.slice( 1 ) === elem.id;
  7019. },
  7020. "root": function( elem ) {
  7021. return elem === docElem;
  7022. },
  7023. "focus": function( elem ) {
  7024. return elem === document.activeElement &&
  7025. ( !document.hasFocus || document.hasFocus() ) &&
  7026. !!( elem.type || elem.href || ~elem.tabIndex );
  7027. },
  7028. // Boolean properties
  7029. "enabled": createDisabledPseudo( false ),
  7030. "disabled": createDisabledPseudo( true ),
  7031. "checked": function( elem ) {
  7032. // In CSS3, :checked should return both checked and selected elements
  7033. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  7034. var nodeName = elem.nodeName.toLowerCase();
  7035. return ( nodeName === "input" && !!elem.checked ) ||
  7036. ( nodeName === "option" && !!elem.selected );
  7037. },
  7038. "selected": function( elem ) {
  7039. // Accessing this property makes selected-by-default
  7040. // options in Safari work properly
  7041. if ( elem.parentNode ) {
  7042. // eslint-disable-next-line no-unused-expressions
  7043. elem.parentNode.selectedIndex;
  7044. }
  7045. return elem.selected === true;
  7046. },
  7047. // Contents
  7048. "empty": function( elem ) {
  7049. // http://www.w3.org/TR/selectors/#empty-pseudo
  7050. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  7051. // but not by others (comment: 8; processing instruction: 7; etc.)
  7052. // nodeType < 6 works because attributes (2) do not appear as children
  7053. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  7054. if ( elem.nodeType < 6 ) {
  7055. return false;
  7056. }
  7057. }
  7058. return true;
  7059. },
  7060. "parent": function( elem ) {
  7061. return !Expr.pseudos[ "empty" ]( elem );
  7062. },
  7063. // Element/input types
  7064. "header": function( elem ) {
  7065. return rheader.test( elem.nodeName );
  7066. },
  7067. "input": function( elem ) {
  7068. return rinputs.test( elem.nodeName );
  7069. },
  7070. "button": function( elem ) {
  7071. var name = elem.nodeName.toLowerCase();
  7072. return name === "input" && elem.type === "button" || name === "button";
  7073. },
  7074. "text": function( elem ) {
  7075. var attr;
  7076. return elem.nodeName.toLowerCase() === "input" &&
  7077. elem.type === "text" &&
  7078. // Support: IE<8
  7079. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  7080. ( ( attr = elem.getAttribute( "type" ) ) == null ||
  7081. attr.toLowerCase() === "text" );
  7082. },
  7083. // Position-in-collection
  7084. "first": createPositionalPseudo( function() {
  7085. return [ 0 ];
  7086. } ),
  7087. "last": createPositionalPseudo( function( _matchIndexes, length ) {
  7088. return [ length - 1 ];
  7089. } ),
  7090. "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
  7091. return [ argument < 0 ? argument + length : argument ];
  7092. } ),
  7093. "even": createPositionalPseudo( function( matchIndexes, length ) {
  7094. var i = 0;
  7095. for ( ; i < length; i += 2 ) {
  7096. matchIndexes.push( i );
  7097. }
  7098. return matchIndexes;
  7099. } ),
  7100. "odd": createPositionalPseudo( function( matchIndexes, length ) {
  7101. var i = 1;
  7102. for ( ; i < length; i += 2 ) {
  7103. matchIndexes.push( i );
  7104. }
  7105. return matchIndexes;
  7106. } ),
  7107. "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  7108. var i = argument < 0 ?
  7109. argument + length :
  7110. argument > length ?
  7111. length :
  7112. argument;
  7113. for ( ; --i >= 0; ) {
  7114. matchIndexes.push( i );
  7115. }
  7116. return matchIndexes;
  7117. } ),
  7118. "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  7119. var i = argument < 0 ? argument + length : argument;
  7120. for ( ; ++i < length; ) {
  7121. matchIndexes.push( i );
  7122. }
  7123. return matchIndexes;
  7124. } )
  7125. }
  7126. };
  7127. Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
  7128. // Add button/input type pseudos
  7129. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  7130. Expr.pseudos[ i ] = createInputPseudo( i );
  7131. }
  7132. for ( i in { submit: true, reset: true } ) {
  7133. Expr.pseudos[ i ] = createButtonPseudo( i );
  7134. }
  7135. // Easy API for creating new setFilters
  7136. function setFilters() {}
  7137. setFilters.prototype = Expr.filters = Expr.pseudos;
  7138. Expr.setFilters = new setFilters();
  7139. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  7140. var matched, match, tokens, type,
  7141. soFar, groups, preFilters,
  7142. cached = tokenCache[ selector + " " ];
  7143. if ( cached ) {
  7144. return parseOnly ? 0 : cached.slice( 0 );
  7145. }
  7146. soFar = selector;
  7147. groups = [];
  7148. preFilters = Expr.preFilter;
  7149. while ( soFar ) {
  7150. // Comma and first run
  7151. if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
  7152. if ( match ) {
  7153. // Don't consume trailing commas as valid
  7154. soFar = soFar.slice( match[ 0 ].length ) || soFar;
  7155. }
  7156. groups.push( ( tokens = [] ) );
  7157. }
  7158. matched = false;
  7159. // Combinators
  7160. if ( ( match = rcombinators.exec( soFar ) ) ) {
  7161. matched = match.shift();
  7162. tokens.push( {
  7163. value: matched,
  7164. // Cast descendant combinators to space
  7165. type: match[ 0 ].replace( rtrim, " " )
  7166. } );
  7167. soFar = soFar.slice( matched.length );
  7168. }
  7169. // Filters
  7170. for ( type in Expr.filter ) {
  7171. if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
  7172. ( match = preFilters[ type ]( match ) ) ) ) {
  7173. matched = match.shift();
  7174. tokens.push( {
  7175. value: matched,
  7176. type: type,
  7177. matches: match
  7178. } );
  7179. soFar = soFar.slice( matched.length );
  7180. }
  7181. }
  7182. if ( !matched ) {
  7183. break;
  7184. }
  7185. }
  7186. // Return the length of the invalid excess
  7187. // if we're just parsing
  7188. // Otherwise, throw an error or return tokens
  7189. return parseOnly ?
  7190. soFar.length :
  7191. soFar ?
  7192. Sizzle.error( selector ) :
  7193. // Cache the tokens
  7194. tokenCache( selector, groups ).slice( 0 );
  7195. };
  7196. function toSelector( tokens ) {
  7197. var i = 0,
  7198. len = tokens.length,
  7199. selector = "";
  7200. for ( ; i < len; i++ ) {
  7201. selector += tokens[ i ].value;
  7202. }
  7203. return selector;
  7204. }
  7205. function addCombinator( matcher, combinator, base ) {
  7206. var dir = combinator.dir,
  7207. skip = combinator.next,
  7208. key = skip || dir,
  7209. checkNonElements = base && key === "parentNode",
  7210. doneName = done++;
  7211. return combinator.first ?
  7212. // Check against closest ancestor/preceding element
  7213. function( elem, context, xml ) {
  7214. while ( ( elem = elem[ dir ] ) ) {
  7215. if ( elem.nodeType === 1 || checkNonElements ) {
  7216. return matcher( elem, context, xml );
  7217. }
  7218. }
  7219. return false;
  7220. } :
  7221. // Check against all ancestor/preceding elements
  7222. function( elem, context, xml ) {
  7223. var oldCache, uniqueCache, outerCache,
  7224. newCache = [ dirruns, doneName ];
  7225. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  7226. if ( xml ) {
  7227. while ( ( elem = elem[ dir ] ) ) {
  7228. if ( elem.nodeType === 1 || checkNonElements ) {
  7229. if ( matcher( elem, context, xml ) ) {
  7230. return true;
  7231. }
  7232. }
  7233. }
  7234. } else {
  7235. while ( ( elem = elem[ dir ] ) ) {
  7236. if ( elem.nodeType === 1 || checkNonElements ) {
  7237. outerCache = elem[ expando ] || ( elem[ expando ] = {} );
  7238. // Support: IE <9 only
  7239. // Defend against cloned attroperties (jQuery gh-1709)
  7240. uniqueCache = outerCache[ elem.uniqueID ] ||
  7241. ( outerCache[ elem.uniqueID ] = {} );
  7242. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  7243. elem = elem[ dir ] || elem;
  7244. } else if ( ( oldCache = uniqueCache[ key ] ) &&
  7245. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  7246. // Assign to newCache so results back-propagate to previous elements
  7247. return ( newCache[ 2 ] = oldCache[ 2 ] );
  7248. } else {
  7249. // Reuse newcache so results back-propagate to previous elements
  7250. uniqueCache[ key ] = newCache;
  7251. // A match means we're done; a fail means we have to keep checking
  7252. if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
  7253. return true;
  7254. }
  7255. }
  7256. }
  7257. }
  7258. }
  7259. return false;
  7260. };
  7261. }
  7262. function elementMatcher( matchers ) {
  7263. return matchers.length > 1 ?
  7264. function( elem, context, xml ) {
  7265. var i = matchers.length;
  7266. while ( i-- ) {
  7267. if ( !matchers[ i ]( elem, context, xml ) ) {
  7268. return false;
  7269. }
  7270. }
  7271. return true;
  7272. } :
  7273. matchers[ 0 ];
  7274. }
  7275. function multipleContexts( selector, contexts, results ) {
  7276. var i = 0,
  7277. len = contexts.length;
  7278. for ( ; i < len; i++ ) {
  7279. Sizzle( selector, contexts[ i ], results );
  7280. }
  7281. return results;
  7282. }
  7283. function condense( unmatched, map, filter, context, xml ) {
  7284. var elem,
  7285. newUnmatched = [],
  7286. i = 0,
  7287. len = unmatched.length,
  7288. mapped = map != null;
  7289. for ( ; i < len; i++ ) {
  7290. if ( ( elem = unmatched[ i ] ) ) {
  7291. if ( !filter || filter( elem, context, xml ) ) {
  7292. newUnmatched.push( elem );
  7293. if ( mapped ) {
  7294. map.push( i );
  7295. }
  7296. }
  7297. }
  7298. }
  7299. return newUnmatched;
  7300. }
  7301. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  7302. if ( postFilter && !postFilter[ expando ] ) {
  7303. postFilter = setMatcher( postFilter );
  7304. }
  7305. if ( postFinder && !postFinder[ expando ] ) {
  7306. postFinder = setMatcher( postFinder, postSelector );
  7307. }
  7308. return markFunction( function( seed, results, context, xml ) {
  7309. var temp, i, elem,
  7310. preMap = [],
  7311. postMap = [],
  7312. preexisting = results.length,
  7313. // Get initial elements from seed or context
  7314. elems = seed || multipleContexts(
  7315. selector || "*",
  7316. context.nodeType ? [ context ] : context,
  7317. []
  7318. ),
  7319. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  7320. matcherIn = preFilter && ( seed || !selector ) ?
  7321. condense( elems, preMap, preFilter, context, xml ) :
  7322. elems,
  7323. matcherOut = matcher ?
  7324. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  7325. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  7326. // ...intermediate processing is necessary
  7327. [] :
  7328. // ...otherwise use results directly
  7329. results :
  7330. matcherIn;
  7331. // Find primary matches
  7332. if ( matcher ) {
  7333. matcher( matcherIn, matcherOut, context, xml );
  7334. }
  7335. // Apply postFilter
  7336. if ( postFilter ) {
  7337. temp = condense( matcherOut, postMap );
  7338. postFilter( temp, [], context, xml );
  7339. // Un-match failing elements by moving them back to matcherIn
  7340. i = temp.length;
  7341. while ( i-- ) {
  7342. if ( ( elem = temp[ i ] ) ) {
  7343. matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
  7344. }
  7345. }
  7346. }
  7347. if ( seed ) {
  7348. if ( postFinder || preFilter ) {
  7349. if ( postFinder ) {
  7350. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  7351. temp = [];
  7352. i = matcherOut.length;
  7353. while ( i-- ) {
  7354. if ( ( elem = matcherOut[ i ] ) ) {
  7355. // Restore matcherIn since elem is not yet a final match
  7356. temp.push( ( matcherIn[ i ] = elem ) );
  7357. }
  7358. }
  7359. postFinder( null, ( matcherOut = [] ), temp, xml );
  7360. }
  7361. // Move matched elements from seed to results to keep them synchronized
  7362. i = matcherOut.length;
  7363. while ( i-- ) {
  7364. if ( ( elem = matcherOut[ i ] ) &&
  7365. ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
  7366. seed[ temp ] = !( results[ temp ] = elem );
  7367. }
  7368. }
  7369. }
  7370. // Add elements to results, through postFinder if defined
  7371. } else {
  7372. matcherOut = condense(
  7373. matcherOut === results ?
  7374. matcherOut.splice( preexisting, matcherOut.length ) :
  7375. matcherOut
  7376. );
  7377. if ( postFinder ) {
  7378. postFinder( null, results, matcherOut, xml );
  7379. } else {
  7380. push.apply( results, matcherOut );
  7381. }
  7382. }
  7383. } );
  7384. }
  7385. function matcherFromTokens( tokens ) {
  7386. var checkContext, matcher, j,
  7387. len = tokens.length,
  7388. leadingRelative = Expr.relative[ tokens[ 0 ].type ],
  7389. implicitRelative = leadingRelative || Expr.relative[ " " ],
  7390. i = leadingRelative ? 1 : 0,
  7391. // The foundational matcher ensures that elements are reachable from top-level context(s)
  7392. matchContext = addCombinator( function( elem ) {
  7393. return elem === checkContext;
  7394. }, implicitRelative, true ),
  7395. matchAnyContext = addCombinator( function( elem ) {
  7396. return indexOf( checkContext, elem ) > -1;
  7397. }, implicitRelative, true ),
  7398. matchers = [ function( elem, context, xml ) {
  7399. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  7400. ( checkContext = context ).nodeType ?
  7401. matchContext( elem, context, xml ) :
  7402. matchAnyContext( elem, context, xml ) );
  7403. // Avoid hanging onto element (issue #299)
  7404. checkContext = null;
  7405. return ret;
  7406. } ];
  7407. for ( ; i < len; i++ ) {
  7408. if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
  7409. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  7410. } else {
  7411. matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
  7412. // Return special upon seeing a positional matcher
  7413. if ( matcher[ expando ] ) {
  7414. // Find the next relative operator (if any) for proper handling
  7415. j = ++i;
  7416. for ( ; j < len; j++ ) {
  7417. if ( Expr.relative[ tokens[ j ].type ] ) {
  7418. break;
  7419. }
  7420. }
  7421. return setMatcher(
  7422. i > 1 && elementMatcher( matchers ),
  7423. i > 1 && toSelector(
  7424. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  7425. tokens
  7426. .slice( 0, i - 1 )
  7427. .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
  7428. ).replace( rtrim, "$1" ),
  7429. matcher,
  7430. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  7431. j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
  7432. j < len && toSelector( tokens )
  7433. );
  7434. }
  7435. matchers.push( matcher );
  7436. }
  7437. }
  7438. return elementMatcher( matchers );
  7439. }
  7440. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  7441. var bySet = setMatchers.length > 0,
  7442. byElement = elementMatchers.length > 0,
  7443. superMatcher = function( seed, context, xml, results, outermost ) {
  7444. var elem, j, matcher,
  7445. matchedCount = 0,
  7446. i = "0",
  7447. unmatched = seed && [],
  7448. setMatched = [],
  7449. contextBackup = outermostContext,
  7450. // We must always have either seed elements or outermost context
  7451. elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
  7452. // Use integer dirruns iff this is the outermost matcher
  7453. dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
  7454. len = elems.length;
  7455. if ( outermost ) {
  7456. // Support: IE 11+, Edge 17 - 18+
  7457. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  7458. // two documents; shallow comparisons work.
  7459. // eslint-disable-next-line eqeqeq
  7460. outermostContext = context == document || context || outermost;
  7461. }
  7462. // Add elements passing elementMatchers directly to results
  7463. // Support: IE<9, Safari
  7464. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  7465. for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
  7466. if ( byElement && elem ) {
  7467. j = 0;
  7468. // Support: IE 11+, Edge 17 - 18+
  7469. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  7470. // two documents; shallow comparisons work.
  7471. // eslint-disable-next-line eqeqeq
  7472. if ( !context && elem.ownerDocument != document ) {
  7473. setDocument( elem );
  7474. xml = !documentIsHTML;
  7475. }
  7476. while ( ( matcher = elementMatchers[ j++ ] ) ) {
  7477. if ( matcher( elem, context || document, xml ) ) {
  7478. results.push( elem );
  7479. break;
  7480. }
  7481. }
  7482. if ( outermost ) {
  7483. dirruns = dirrunsUnique;
  7484. }
  7485. }
  7486. // Track unmatched elements for set filters
  7487. if ( bySet ) {
  7488. // They will have gone through all possible matchers
  7489. if ( ( elem = !matcher && elem ) ) {
  7490. matchedCount--;
  7491. }
  7492. // Lengthen the array for every element, matched or not
  7493. if ( seed ) {
  7494. unmatched.push( elem );
  7495. }
  7496. }
  7497. }
  7498. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  7499. // makes the latter nonnegative.
  7500. matchedCount += i;
  7501. // Apply set filters to unmatched elements
  7502. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  7503. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  7504. // no element matchers and no seed.
  7505. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  7506. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  7507. // numerically zero.
  7508. if ( bySet && i !== matchedCount ) {
  7509. j = 0;
  7510. while ( ( matcher = setMatchers[ j++ ] ) ) {
  7511. matcher( unmatched, setMatched, context, xml );
  7512. }
  7513. if ( seed ) {
  7514. // Reintegrate element matches to eliminate the need for sorting
  7515. if ( matchedCount > 0 ) {
  7516. while ( i-- ) {
  7517. if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
  7518. setMatched[ i ] = pop.call( results );
  7519. }
  7520. }
  7521. }
  7522. // Discard index placeholder values to get only actual matches
  7523. setMatched = condense( setMatched );
  7524. }
  7525. // Add matches to results
  7526. push.apply( results, setMatched );
  7527. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  7528. if ( outermost && !seed && setMatched.length > 0 &&
  7529. ( matchedCount + setMatchers.length ) > 1 ) {
  7530. Sizzle.uniqueSort( results );
  7531. }
  7532. }
  7533. // Override manipulation of globals by nested matchers
  7534. if ( outermost ) {
  7535. dirruns = dirrunsUnique;
  7536. outermostContext = contextBackup;
  7537. }
  7538. return unmatched;
  7539. };
  7540. return bySet ?
  7541. markFunction( superMatcher ) :
  7542. superMatcher;
  7543. }
  7544. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  7545. var i,
  7546. setMatchers = [],
  7547. elementMatchers = [],
  7548. cached = compilerCache[ selector + " " ];
  7549. if ( !cached ) {
  7550. // Generate a function of recursive functions that can be used to check each element
  7551. if ( !match ) {
  7552. match = tokenize( selector );
  7553. }
  7554. i = match.length;
  7555. while ( i-- ) {
  7556. cached = matcherFromTokens( match[ i ] );
  7557. if ( cached[ expando ] ) {
  7558. setMatchers.push( cached );
  7559. } else {
  7560. elementMatchers.push( cached );
  7561. }
  7562. }
  7563. // Cache the compiled function
  7564. cached = compilerCache(
  7565. selector,
  7566. matcherFromGroupMatchers( elementMatchers, setMatchers )
  7567. );
  7568. // Save selector and tokenization
  7569. cached.selector = selector;
  7570. }
  7571. return cached;
  7572. };
  7573. /**
  7574. * A low-level selection function that works with Sizzle's compiled
  7575. * selector functions
  7576. * @param {String|Function} selector A selector or a pre-compiled
  7577. * selector function built with Sizzle.compile
  7578. * @param {Element} context
  7579. * @param {Array} [results]
  7580. * @param {Array} [seed] A set of elements to match against
  7581. */
  7582. select = Sizzle.select = function( selector, context, results, seed ) {
  7583. var i, tokens, token, type, find,
  7584. compiled = typeof selector === "function" && selector,
  7585. match = !seed && tokenize( ( selector = compiled.selector || selector ) );
  7586. results = results || [];
  7587. // Try to minimize operations if there is only one selector in the list and no seed
  7588. // (the latter of which guarantees us context)
  7589. if ( match.length === 1 ) {
  7590. // Reduce context if the leading compound selector is an ID
  7591. tokens = match[ 0 ] = match[ 0 ].slice( 0 );
  7592. if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
  7593. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
  7594. context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
  7595. .replace( runescape, funescape ), context ) || [] )[ 0 ];
  7596. if ( !context ) {
  7597. return results;
  7598. // Precompiled matchers will still verify ancestry, so step up a level
  7599. } else if ( compiled ) {
  7600. context = context.parentNode;
  7601. }
  7602. selector = selector.slice( tokens.shift().value.length );
  7603. }
  7604. // Fetch a seed set for right-to-left matching
  7605. i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
  7606. while ( i-- ) {
  7607. token = tokens[ i ];
  7608. // Abort if we hit a combinator
  7609. if ( Expr.relative[ ( type = token.type ) ] ) {
  7610. break;
  7611. }
  7612. if ( ( find = Expr.find[ type ] ) ) {
  7613. // Search, expanding context for leading sibling combinators
  7614. if ( ( seed = find(
  7615. token.matches[ 0 ].replace( runescape, funescape ),
  7616. rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
  7617. context
  7618. ) ) ) {
  7619. // If seed is empty or no tokens remain, we can return early
  7620. tokens.splice( i, 1 );
  7621. selector = seed.length && toSelector( tokens );
  7622. if ( !selector ) {
  7623. push.apply( results, seed );
  7624. return results;
  7625. }
  7626. break;
  7627. }
  7628. }
  7629. }
  7630. }
  7631. // Compile and execute a filtering function if one is not provided
  7632. // Provide `match` to avoid retokenization if we modified the selector above
  7633. ( compiled || compile( selector, match ) )(
  7634. seed,
  7635. context,
  7636. !documentIsHTML,
  7637. results,
  7638. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  7639. );
  7640. return results;
  7641. };
  7642. // One-time assignments
  7643. // Sort stability
  7644. support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
  7645. // Support: Chrome 14-35+
  7646. // Always assume duplicates if they aren't passed to the comparison function
  7647. support.detectDuplicates = !!hasDuplicate;
  7648. // Initialize against the default document
  7649. setDocument();
  7650. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  7651. // Detached nodes confoundingly follow *each other*
  7652. support.sortDetached = assert( function( el ) {
  7653. // Should return 1, but returns 4 (following)
  7654. return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
  7655. } );
  7656. // Support: IE<8
  7657. // Prevent attribute/property "interpolation"
  7658. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  7659. if ( !assert( function( el ) {
  7660. el.innerHTML = "<a href='#'></a>";
  7661. return el.firstChild.getAttribute( "href" ) === "#";
  7662. } ) ) {
  7663. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  7664. if ( !isXML ) {
  7665. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  7666. }
  7667. } );
  7668. }
  7669. // Support: IE<9
  7670. // Use defaultValue in place of getAttribute("value")
  7671. if ( !support.attributes || !assert( function( el ) {
  7672. el.innerHTML = "<input/>";
  7673. el.firstChild.setAttribute( "value", "" );
  7674. return el.firstChild.getAttribute( "value" ) === "";
  7675. } ) ) {
  7676. addHandle( "value", function( elem, _name, isXML ) {
  7677. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  7678. return elem.defaultValue;
  7679. }
  7680. } );
  7681. }
  7682. // Support: IE<9
  7683. // Use getAttributeNode to fetch booleans when getAttribute lies
  7684. if ( !assert( function( el ) {
  7685. return el.getAttribute( "disabled" ) == null;
  7686. } ) ) {
  7687. addHandle( booleans, function( elem, name, isXML ) {
  7688. var val;
  7689. if ( !isXML ) {
  7690. return elem[ name ] === true ? name.toLowerCase() :
  7691. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  7692. val.value :
  7693. null;
  7694. }
  7695. } );
  7696. }
  7697. return Sizzle;
  7698. } )( window );
  7699. jQuery.find = Sizzle;
  7700. jQuery.expr = Sizzle.selectors;
  7701. // Deprecated
  7702. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  7703. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  7704. jQuery.text = Sizzle.getText;
  7705. jQuery.isXMLDoc = Sizzle.isXML;
  7706. jQuery.contains = Sizzle.contains;
  7707. jQuery.escapeSelector = Sizzle.escape;
  7708. var dir = function( elem, dir, until ) {
  7709. var matched = [],
  7710. truncate = until !== undefined;
  7711. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  7712. if ( elem.nodeType === 1 ) {
  7713. if ( truncate && jQuery( elem ).is( until ) ) {
  7714. break;
  7715. }
  7716. matched.push( elem );
  7717. }
  7718. }
  7719. return matched;
  7720. };
  7721. var siblings = function( n, elem ) {
  7722. var matched = [];
  7723. for ( ; n; n = n.nextSibling ) {
  7724. if ( n.nodeType === 1 && n !== elem ) {
  7725. matched.push( n );
  7726. }
  7727. }
  7728. return matched;
  7729. };
  7730. var rneedsContext = jQuery.expr.match.needsContext;
  7731. function nodeName( elem, name ) {
  7732. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  7733. };
  7734. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  7735. // Implement the identical functionality for filter and not
  7736. function winnow( elements, qualifier, not ) {
  7737. if ( isFunction( qualifier ) ) {
  7738. return jQuery.grep( elements, function( elem, i ) {
  7739. return !!qualifier.call( elem, i, elem ) !== not;
  7740. } );
  7741. }
  7742. // Single element
  7743. if ( qualifier.nodeType ) {
  7744. return jQuery.grep( elements, function( elem ) {
  7745. return ( elem === qualifier ) !== not;
  7746. } );
  7747. }
  7748. // Arraylike of elements (jQuery, arguments, Array)
  7749. if ( typeof qualifier !== "string" ) {
  7750. return jQuery.grep( elements, function( elem ) {
  7751. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  7752. } );
  7753. }
  7754. // Filtered directly for both simple and complex selectors
  7755. return jQuery.filter( qualifier, elements, not );
  7756. }
  7757. jQuery.filter = function( expr, elems, not ) {
  7758. var elem = elems[ 0 ];
  7759. if ( not ) {
  7760. expr = ":not(" + expr + ")";
  7761. }
  7762. if ( elems.length === 1 && elem.nodeType === 1 ) {
  7763. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  7764. }
  7765. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  7766. return elem.nodeType === 1;
  7767. } ) );
  7768. };
  7769. jQuery.fn.extend( {
  7770. find: function( selector ) {
  7771. var i, ret,
  7772. len = this.length,
  7773. self = this;
  7774. if ( typeof selector !== "string" ) {
  7775. return this.pushStack( jQuery( selector ).filter( function() {
  7776. for ( i = 0; i < len; i++ ) {
  7777. if ( jQuery.contains( self[ i ], this ) ) {
  7778. return true;
  7779. }
  7780. }
  7781. } ) );
  7782. }
  7783. ret = this.pushStack( [] );
  7784. for ( i = 0; i < len; i++ ) {
  7785. jQuery.find( selector, self[ i ], ret );
  7786. }
  7787. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  7788. },
  7789. filter: function( selector ) {
  7790. return this.pushStack( winnow( this, selector || [], false ) );
  7791. },
  7792. not: function( selector ) {
  7793. return this.pushStack( winnow( this, selector || [], true ) );
  7794. },
  7795. is: function( selector ) {
  7796. return !!winnow(
  7797. this,
  7798. // If this is a positional/relative selector, check membership in the returned set
  7799. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  7800. typeof selector === "string" && rneedsContext.test( selector ) ?
  7801. jQuery( selector ) :
  7802. selector || [],
  7803. false
  7804. ).length;
  7805. }
  7806. } );
  7807. // Initialize a jQuery object
  7808. // A central reference to the root jQuery(document)
  7809. var rootjQuery,
  7810. // A simple way to check for HTML strings
  7811. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  7812. // Strict HTML recognition (#11290: must start with <)
  7813. // Shortcut simple #id case for speed
  7814. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  7815. init = jQuery.fn.init = function( selector, context, root ) {
  7816. var match, elem;
  7817. // HANDLE: $(""), $(null), $(undefined), $(false)
  7818. if ( !selector ) {
  7819. return this;
  7820. }
  7821. // Method init() accepts an alternate rootjQuery
  7822. // so migrate can support jQuery.sub (gh-2101)
  7823. root = root || rootjQuery;
  7824. // Handle HTML strings
  7825. if ( typeof selector === "string" ) {
  7826. if ( selector[ 0 ] === "<" &&
  7827. selector[ selector.length - 1 ] === ">" &&
  7828. selector.length >= 3 ) {
  7829. // Assume that strings that start and end with <> are HTML and skip the regex check
  7830. match = [ null, selector, null ];
  7831. } else {
  7832. match = rquickExpr.exec( selector );
  7833. }
  7834. // Match html or make sure no context is specified for #id
  7835. if ( match && ( match[ 1 ] || !context ) ) {
  7836. // HANDLE: $(html) -> $(array)
  7837. if ( match[ 1 ] ) {
  7838. context = context instanceof jQuery ? context[ 0 ] : context;
  7839. // Option to run scripts is true for back-compat
  7840. // Intentionally let the error be thrown if parseHTML is not present
  7841. jQuery.merge( this, jQuery.parseHTML(
  7842. match[ 1 ],
  7843. context && context.nodeType ? context.ownerDocument || context : document,
  7844. true
  7845. ) );
  7846. // HANDLE: $(html, props)
  7847. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  7848. for ( match in context ) {
  7849. // Properties of context are called as methods if possible
  7850. if ( isFunction( this[ match ] ) ) {
  7851. this[ match ]( context[ match ] );
  7852. // ...and otherwise set as attributes
  7853. } else {
  7854. this.attr( match, context[ match ] );
  7855. }
  7856. }
  7857. }
  7858. return this;
  7859. // HANDLE: $(#id)
  7860. } else {
  7861. elem = document.getElementById( match[ 2 ] );
  7862. if ( elem ) {
  7863. // Inject the element directly into the jQuery object
  7864. this[ 0 ] = elem;
  7865. this.length = 1;
  7866. }
  7867. return this;
  7868. }
  7869. // HANDLE: $(expr, $(...))
  7870. } else if ( !context || context.jquery ) {
  7871. return ( context || root ).find( selector );
  7872. // HANDLE: $(expr, context)
  7873. // (which is just equivalent to: $(context).find(expr)
  7874. } else {
  7875. return this.constructor( context ).find( selector );
  7876. }
  7877. // HANDLE: $(DOMElement)
  7878. } else if ( selector.nodeType ) {
  7879. this[ 0 ] = selector;
  7880. this.length = 1;
  7881. return this;
  7882. // HANDLE: $(function)
  7883. // Shortcut for document ready
  7884. } else if ( isFunction( selector ) ) {
  7885. return root.ready !== undefined ?
  7886. root.ready( selector ) :
  7887. // Execute immediately if ready is not present
  7888. selector( jQuery );
  7889. }
  7890. return jQuery.makeArray( selector, this );
  7891. };
  7892. // Give the init function the jQuery prototype for later instantiation
  7893. init.prototype = jQuery.fn;
  7894. // Initialize central reference
  7895. rootjQuery = jQuery( document );
  7896. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  7897. // Methods guaranteed to produce a unique set when starting from a unique set
  7898. guaranteedUnique = {
  7899. children: true,
  7900. contents: true,
  7901. next: true,
  7902. prev: true
  7903. };
  7904. jQuery.fn.extend( {
  7905. has: function( target ) {
  7906. var targets = jQuery( target, this ),
  7907. l = targets.length;
  7908. return this.filter( function() {
  7909. var i = 0;
  7910. for ( ; i < l; i++ ) {
  7911. if ( jQuery.contains( this, targets[ i ] ) ) {
  7912. return true;
  7913. }
  7914. }
  7915. } );
  7916. },
  7917. closest: function( selectors, context ) {
  7918. var cur,
  7919. i = 0,
  7920. l = this.length,
  7921. matched = [],
  7922. targets = typeof selectors !== "string" && jQuery( selectors );
  7923. // Positional selectors never match, since there's no _selection_ context
  7924. if ( !rneedsContext.test( selectors ) ) {
  7925. for ( ; i < l; i++ ) {
  7926. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  7927. // Always skip document fragments
  7928. if ( cur.nodeType < 11 && ( targets ?
  7929. targets.index( cur ) > -1 :
  7930. // Don't pass non-elements to Sizzle
  7931. cur.nodeType === 1 &&
  7932. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  7933. matched.push( cur );
  7934. break;
  7935. }
  7936. }
  7937. }
  7938. }
  7939. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  7940. },
  7941. // Determine the position of an element within the set
  7942. index: function( elem ) {
  7943. // No argument, return index in parent
  7944. if ( !elem ) {
  7945. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  7946. }
  7947. // Index in selector
  7948. if ( typeof elem === "string" ) {
  7949. return indexOf.call( jQuery( elem ), this[ 0 ] );
  7950. }
  7951. // Locate the position of the desired element
  7952. return indexOf.call( this,
  7953. // If it receives a jQuery object, the first element is used
  7954. elem.jquery ? elem[ 0 ] : elem
  7955. );
  7956. },
  7957. add: function( selector, context ) {
  7958. return this.pushStack(
  7959. jQuery.uniqueSort(
  7960. jQuery.merge( this.get(), jQuery( selector, context ) )
  7961. )
  7962. );
  7963. },
  7964. addBack: function( selector ) {
  7965. return this.add( selector == null ?
  7966. this.prevObject : this.prevObject.filter( selector )
  7967. );
  7968. }
  7969. } );
  7970. function sibling( cur, dir ) {
  7971. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  7972. return cur;
  7973. }
  7974. jQuery.each( {
  7975. parent: function( elem ) {
  7976. var parent = elem.parentNode;
  7977. return parent && parent.nodeType !== 11 ? parent : null;
  7978. },
  7979. parents: function( elem ) {
  7980. return dir( elem, "parentNode" );
  7981. },
  7982. parentsUntil: function( elem, _i, until ) {
  7983. return dir( elem, "parentNode", until );
  7984. },
  7985. next: function( elem ) {
  7986. return sibling( elem, "nextSibling" );
  7987. },
  7988. prev: function( elem ) {
  7989. return sibling( elem, "previousSibling" );
  7990. },
  7991. nextAll: function( elem ) {
  7992. return dir( elem, "nextSibling" );
  7993. },
  7994. prevAll: function( elem ) {
  7995. return dir( elem, "previousSibling" );
  7996. },
  7997. nextUntil: function( elem, _i, until ) {
  7998. return dir( elem, "nextSibling", until );
  7999. },
  8000. prevUntil: function( elem, _i, until ) {
  8001. return dir( elem, "previousSibling", until );
  8002. },
  8003. siblings: function( elem ) {
  8004. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  8005. },
  8006. children: function( elem ) {
  8007. return siblings( elem.firstChild );
  8008. },
  8009. contents: function( elem ) {
  8010. if ( elem.contentDocument != null &&
  8011. // Support: IE 11+
  8012. // <object> elements with no `data` attribute has an object
  8013. // `contentDocument` with a `null` prototype.
  8014. getProto( elem.contentDocument ) ) {
  8015. return elem.contentDocument;
  8016. }
  8017. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  8018. // Treat the template element as a regular one in browsers that
  8019. // don't support it.
  8020. if ( nodeName( elem, "template" ) ) {
  8021. elem = elem.content || elem;
  8022. }
  8023. return jQuery.merge( [], elem.childNodes );
  8024. }
  8025. }, function( name, fn ) {
  8026. jQuery.fn[ name ] = function( until, selector ) {
  8027. var matched = jQuery.map( this, fn, until );
  8028. if ( name.slice( -5 ) !== "Until" ) {
  8029. selector = until;
  8030. }
  8031. if ( selector && typeof selector === "string" ) {
  8032. matched = jQuery.filter( selector, matched );
  8033. }
  8034. if ( this.length > 1 ) {
  8035. // Remove duplicates
  8036. if ( !guaranteedUnique[ name ] ) {
  8037. jQuery.uniqueSort( matched );
  8038. }
  8039. // Reverse order for parents* and prev-derivatives
  8040. if ( rparentsprev.test( name ) ) {
  8041. matched.reverse();
  8042. }
  8043. }
  8044. return this.pushStack( matched );
  8045. };
  8046. } );
  8047. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  8048. // Convert String-formatted options into Object-formatted ones
  8049. function createOptions( options ) {
  8050. var object = {};
  8051. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  8052. object[ flag ] = true;
  8053. } );
  8054. return object;
  8055. }
  8056. /*
  8057. * Create a callback list using the following parameters:
  8058. *
  8059. * options: an optional list of space-separated options that will change how
  8060. * the callback list behaves or a more traditional option object
  8061. *
  8062. * By default a callback list will act like an event callback list and can be
  8063. * "fired" multiple times.
  8064. *
  8065. * Possible options:
  8066. *
  8067. * once: will ensure the callback list can only be fired once (like a Deferred)
  8068. *
  8069. * memory: will keep track of previous values and will call any callback added
  8070. * after the list has been fired right away with the latest "memorized"
  8071. * values (like a Deferred)
  8072. *
  8073. * unique: will ensure a callback can only be added once (no duplicate in the list)
  8074. *
  8075. * stopOnFalse: interrupt callings when a callback returns false
  8076. *
  8077. */
  8078. jQuery.Callbacks = function( options ) {
  8079. // Convert options from String-formatted to Object-formatted if needed
  8080. // (we check in cache first)
  8081. options = typeof options === "string" ?
  8082. createOptions( options ) :
  8083. jQuery.extend( {}, options );
  8084. var // Flag to know if list is currently firing
  8085. firing,
  8086. // Last fire value for non-forgettable lists
  8087. memory,
  8088. // Flag to know if list was already fired
  8089. fired,
  8090. // Flag to prevent firing
  8091. locked,
  8092. // Actual callback list
  8093. list = [],
  8094. // Queue of execution data for repeatable lists
  8095. queue = [],
  8096. // Index of currently firing callback (modified by add/remove as needed)
  8097. firingIndex = -1,
  8098. // Fire callbacks
  8099. fire = function() {
  8100. // Enforce single-firing
  8101. locked = locked || options.once;
  8102. // Execute callbacks for all pending executions,
  8103. // respecting firingIndex overrides and runtime changes
  8104. fired = firing = true;
  8105. for ( ; queue.length; firingIndex = -1 ) {
  8106. memory = queue.shift();
  8107. while ( ++firingIndex < list.length ) {
  8108. // Run callback and check for early termination
  8109. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  8110. options.stopOnFalse ) {
  8111. // Jump to end and forget the data so .add doesn't re-fire
  8112. firingIndex = list.length;
  8113. memory = false;
  8114. }
  8115. }
  8116. }
  8117. // Forget the data if we're done with it
  8118. if ( !options.memory ) {
  8119. memory = false;
  8120. }
  8121. firing = false;
  8122. // Clean up if we're done firing for good
  8123. if ( locked ) {
  8124. // Keep an empty list if we have data for future add calls
  8125. if ( memory ) {
  8126. list = [];
  8127. // Otherwise, this object is spent
  8128. } else {
  8129. list = "";
  8130. }
  8131. }
  8132. },
  8133. // Actual Callbacks object
  8134. self = {
  8135. // Add a callback or a collection of callbacks to the list
  8136. add: function() {
  8137. if ( list ) {
  8138. // If we have memory from a past run, we should fire after adding
  8139. if ( memory && !firing ) {
  8140. firingIndex = list.length - 1;
  8141. queue.push( memory );
  8142. }
  8143. ( function add( args ) {
  8144. jQuery.each( args, function( _, arg ) {
  8145. if ( isFunction( arg ) ) {
  8146. if ( !options.unique || !self.has( arg ) ) {
  8147. list.push( arg );
  8148. }
  8149. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  8150. // Inspect recursively
  8151. add( arg );
  8152. }
  8153. } );
  8154. } )( arguments );
  8155. if ( memory && !firing ) {
  8156. fire();
  8157. }
  8158. }
  8159. return this;
  8160. },
  8161. // Remove a callback from the list
  8162. remove: function() {
  8163. jQuery.each( arguments, function( _, arg ) {
  8164. var index;
  8165. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  8166. list.splice( index, 1 );
  8167. // Handle firing indexes
  8168. if ( index <= firingIndex ) {
  8169. firingIndex--;
  8170. }
  8171. }
  8172. } );
  8173. return this;
  8174. },
  8175. // Check if a given callback is in the list.
  8176. // If no argument is given, return whether or not list has callbacks attached.
  8177. has: function( fn ) {
  8178. return fn ?
  8179. jQuery.inArray( fn, list ) > -1 :
  8180. list.length > 0;
  8181. },
  8182. // Remove all callbacks from the list
  8183. empty: function() {
  8184. if ( list ) {
  8185. list = [];
  8186. }
  8187. return this;
  8188. },
  8189. // Disable .fire and .add
  8190. // Abort any current/pending executions
  8191. // Clear all callbacks and values
  8192. disable: function() {
  8193. locked = queue = [];
  8194. list = memory = "";
  8195. return this;
  8196. },
  8197. disabled: function() {
  8198. return !list;
  8199. },
  8200. // Disable .fire
  8201. // Also disable .add unless we have memory (since it would have no effect)
  8202. // Abort any pending executions
  8203. lock: function() {
  8204. locked = queue = [];
  8205. if ( !memory && !firing ) {
  8206. list = memory = "";
  8207. }
  8208. return this;
  8209. },
  8210. locked: function() {
  8211. return !!locked;
  8212. },
  8213. // Call all callbacks with the given context and arguments
  8214. fireWith: function( context, args ) {
  8215. if ( !locked ) {
  8216. args = args || [];
  8217. args = [ context, args.slice ? args.slice() : args ];
  8218. queue.push( args );
  8219. if ( !firing ) {
  8220. fire();
  8221. }
  8222. }
  8223. return this;
  8224. },
  8225. // Call all the callbacks with the given arguments
  8226. fire: function() {
  8227. self.fireWith( this, arguments );
  8228. return this;
  8229. },
  8230. // To know if the callbacks have already been called at least once
  8231. fired: function() {
  8232. return !!fired;
  8233. }
  8234. };
  8235. return self;
  8236. };
  8237. function Identity( v ) {
  8238. return v;
  8239. }
  8240. function Thrower( ex ) {
  8241. throw ex;
  8242. }
  8243. function adoptValue( value, resolve, reject, noValue ) {
  8244. var method;
  8245. try {
  8246. // Check for promise aspect first to privilege synchronous behavior
  8247. if ( value && isFunction( ( method = value.promise ) ) ) {
  8248. method.call( value ).done( resolve ).fail( reject );
  8249. // Other thenables
  8250. } else if ( value && isFunction( ( method = value.then ) ) ) {
  8251. method.call( value, resolve, reject );
  8252. // Other non-thenables
  8253. } else {
  8254. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  8255. // * false: [ value ].slice( 0 ) => resolve( value )
  8256. // * true: [ value ].slice( 1 ) => resolve()
  8257. resolve.apply( undefined, [ value ].slice( noValue ) );
  8258. }
  8259. // For Promises/A+, convert exceptions into rejections
  8260. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  8261. // Deferred#then to conditionally suppress rejection.
  8262. } catch ( value ) {
  8263. // Support: Android 4.0 only
  8264. // Strict mode functions invoked without .call/.apply get global-object context
  8265. reject.apply( undefined, [ value ] );
  8266. }
  8267. }
  8268. jQuery.extend( {
  8269. Deferred: function( func ) {
  8270. var tuples = [
  8271. // action, add listener, callbacks,
  8272. // ... .then handlers, argument index, [final state]
  8273. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  8274. jQuery.Callbacks( "memory" ), 2 ],
  8275. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  8276. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  8277. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  8278. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  8279. ],
  8280. state = "pending",
  8281. promise = {
  8282. state: function() {
  8283. return state;
  8284. },
  8285. always: function() {
  8286. deferred.done( arguments ).fail( arguments );
  8287. return this;
  8288. },
  8289. "catch": function( fn ) {
  8290. return promise.then( null, fn );
  8291. },
  8292. // Keep pipe for back-compat
  8293. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  8294. var fns = arguments;
  8295. return jQuery.Deferred( function( newDefer ) {
  8296. jQuery.each( tuples, function( _i, tuple ) {
  8297. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  8298. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  8299. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  8300. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  8301. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  8302. deferred[ tuple[ 1 ] ]( function() {
  8303. var returned = fn && fn.apply( this, arguments );
  8304. if ( returned && isFunction( returned.promise ) ) {
  8305. returned.promise()
  8306. .progress( newDefer.notify )
  8307. .done( newDefer.resolve )
  8308. .fail( newDefer.reject );
  8309. } else {
  8310. newDefer[ tuple[ 0 ] + "With" ](
  8311. this,
  8312. fn ? [ returned ] : arguments
  8313. );
  8314. }
  8315. } );
  8316. } );
  8317. fns = null;
  8318. } ).promise();
  8319. },
  8320. then: function( onFulfilled, onRejected, onProgress ) {
  8321. var maxDepth = 0;
  8322. function resolve( depth, deferred, handler, special ) {
  8323. return function() {
  8324. var that = this,
  8325. args = arguments,
  8326. mightThrow = function() {
  8327. var returned, then;
  8328. // Support: Promises/A+ section 2.3.3.3.3
  8329. // https://promisesaplus.com/#point-59
  8330. // Ignore double-resolution attempts
  8331. if ( depth < maxDepth ) {
  8332. return;
  8333. }
  8334. returned = handler.apply( that, args );
  8335. // Support: Promises/A+ section 2.3.1
  8336. // https://promisesaplus.com/#point-48
  8337. if ( returned === deferred.promise() ) {
  8338. throw new TypeError( "Thenable self-resolution" );
  8339. }
  8340. // Support: Promises/A+ sections 2.3.3.1, 3.5
  8341. // https://promisesaplus.com/#point-54
  8342. // https://promisesaplus.com/#point-75
  8343. // Retrieve `then` only once
  8344. then = returned &&
  8345. // Support: Promises/A+ section 2.3.4
  8346. // https://promisesaplus.com/#point-64
  8347. // Only check objects and functions for thenability
  8348. ( typeof returned === "object" ||
  8349. typeof returned === "function" ) &&
  8350. returned.then;
  8351. // Handle a returned thenable
  8352. if ( isFunction( then ) ) {
  8353. // Special processors (notify) just wait for resolution
  8354. if ( special ) {
  8355. then.call(
  8356. returned,
  8357. resolve( maxDepth, deferred, Identity, special ),
  8358. resolve( maxDepth, deferred, Thrower, special )
  8359. );
  8360. // Normal processors (resolve) also hook into progress
  8361. } else {
  8362. // ...and disregard older resolution values
  8363. maxDepth++;
  8364. then.call(
  8365. returned,
  8366. resolve( maxDepth, deferred, Identity, special ),
  8367. resolve( maxDepth, deferred, Thrower, special ),
  8368. resolve( maxDepth, deferred, Identity,
  8369. deferred.notifyWith )
  8370. );
  8371. }
  8372. // Handle all other returned values
  8373. } else {
  8374. // Only substitute handlers pass on context
  8375. // and multiple values (non-spec behavior)
  8376. if ( handler !== Identity ) {
  8377. that = undefined;
  8378. args = [ returned ];
  8379. }
  8380. // Process the value(s)
  8381. // Default process is resolve
  8382. ( special || deferred.resolveWith )( that, args );
  8383. }
  8384. },
  8385. // Only normal processors (resolve) catch and reject exceptions
  8386. process = special ?
  8387. mightThrow :
  8388. function() {
  8389. try {
  8390. mightThrow();
  8391. } catch ( e ) {
  8392. if ( jQuery.Deferred.exceptionHook ) {
  8393. jQuery.Deferred.exceptionHook( e,
  8394. process.stackTrace );
  8395. }
  8396. // Support: Promises/A+ section 2.3.3.3.4.1
  8397. // https://promisesaplus.com/#point-61
  8398. // Ignore post-resolution exceptions
  8399. if ( depth + 1 >= maxDepth ) {
  8400. // Only substitute handlers pass on context
  8401. // and multiple values (non-spec behavior)
  8402. if ( handler !== Thrower ) {
  8403. that = undefined;
  8404. args = [ e ];
  8405. }
  8406. deferred.rejectWith( that, args );
  8407. }
  8408. }
  8409. };
  8410. // Support: Promises/A+ section 2.3.3.3.1
  8411. // https://promisesaplus.com/#point-57
  8412. // Re-resolve promises immediately to dodge false rejection from
  8413. // subsequent errors
  8414. if ( depth ) {
  8415. process();
  8416. } else {
  8417. // Call an optional hook to record the stack, in case of exception
  8418. // since it's otherwise lost when execution goes async
  8419. if ( jQuery.Deferred.getStackHook ) {
  8420. process.stackTrace = jQuery.Deferred.getStackHook();
  8421. }
  8422. window.setTimeout( process );
  8423. }
  8424. };
  8425. }
  8426. return jQuery.Deferred( function( newDefer ) {
  8427. // progress_handlers.add( ... )
  8428. tuples[ 0 ][ 3 ].add(
  8429. resolve(
  8430. 0,
  8431. newDefer,
  8432. isFunction( onProgress ) ?
  8433. onProgress :
  8434. Identity,
  8435. newDefer.notifyWith
  8436. )
  8437. );
  8438. // fulfilled_handlers.add( ... )
  8439. tuples[ 1 ][ 3 ].add(
  8440. resolve(
  8441. 0,
  8442. newDefer,
  8443. isFunction( onFulfilled ) ?
  8444. onFulfilled :
  8445. Identity
  8446. )
  8447. );
  8448. // rejected_handlers.add( ... )
  8449. tuples[ 2 ][ 3 ].add(
  8450. resolve(
  8451. 0,
  8452. newDefer,
  8453. isFunction( onRejected ) ?
  8454. onRejected :
  8455. Thrower
  8456. )
  8457. );
  8458. } ).promise();
  8459. },
  8460. // Get a promise for this deferred
  8461. // If obj is provided, the promise aspect is added to the object
  8462. promise: function( obj ) {
  8463. return obj != null ? jQuery.extend( obj, promise ) : promise;
  8464. }
  8465. },
  8466. deferred = {};
  8467. // Add list-specific methods
  8468. jQuery.each( tuples, function( i, tuple ) {
  8469. var list = tuple[ 2 ],
  8470. stateString = tuple[ 5 ];
  8471. // promise.progress = list.add
  8472. // promise.done = list.add
  8473. // promise.fail = list.add
  8474. promise[ tuple[ 1 ] ] = list.add;
  8475. // Handle state
  8476. if ( stateString ) {
  8477. list.add(
  8478. function() {
  8479. // state = "resolved" (i.e., fulfilled)
  8480. // state = "rejected"
  8481. state = stateString;
  8482. },
  8483. // rejected_callbacks.disable
  8484. // fulfilled_callbacks.disable
  8485. tuples[ 3 - i ][ 2 ].disable,
  8486. // rejected_handlers.disable
  8487. // fulfilled_handlers.disable
  8488. tuples[ 3 - i ][ 3 ].disable,
  8489. // progress_callbacks.lock
  8490. tuples[ 0 ][ 2 ].lock,
  8491. // progress_handlers.lock
  8492. tuples[ 0 ][ 3 ].lock
  8493. );
  8494. }
  8495. // progress_handlers.fire
  8496. // fulfilled_handlers.fire
  8497. // rejected_handlers.fire
  8498. list.add( tuple[ 3 ].fire );
  8499. // deferred.notify = function() { deferred.notifyWith(...) }
  8500. // deferred.resolve = function() { deferred.resolveWith(...) }
  8501. // deferred.reject = function() { deferred.rejectWith(...) }
  8502. deferred[ tuple[ 0 ] ] = function() {
  8503. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  8504. return this;
  8505. };
  8506. // deferred.notifyWith = list.fireWith
  8507. // deferred.resolveWith = list.fireWith
  8508. // deferred.rejectWith = list.fireWith
  8509. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  8510. } );
  8511. // Make the deferred a promise
  8512. promise.promise( deferred );
  8513. // Call given func if any
  8514. if ( func ) {
  8515. func.call( deferred, deferred );
  8516. }
  8517. // All done!
  8518. return deferred;
  8519. },
  8520. // Deferred helper
  8521. when: function( singleValue ) {
  8522. var
  8523. // count of uncompleted subordinates
  8524. remaining = arguments.length,
  8525. // count of unprocessed arguments
  8526. i = remaining,
  8527. // subordinate fulfillment data
  8528. resolveContexts = Array( i ),
  8529. resolveValues = slice.call( arguments ),
  8530. // the master Deferred
  8531. master = jQuery.Deferred(),
  8532. // subordinate callback factory
  8533. updateFunc = function( i ) {
  8534. return function( value ) {
  8535. resolveContexts[ i ] = this;
  8536. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  8537. if ( !( --remaining ) ) {
  8538. master.resolveWith( resolveContexts, resolveValues );
  8539. }
  8540. };
  8541. };
  8542. // Single- and empty arguments are adopted like Promise.resolve
  8543. if ( remaining <= 1 ) {
  8544. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  8545. !remaining );
  8546. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  8547. if ( master.state() === "pending" ||
  8548. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  8549. return master.then();
  8550. }
  8551. }
  8552. // Multiple arguments are aggregated like Promise.all array elements
  8553. while ( i-- ) {
  8554. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  8555. }
  8556. return master.promise();
  8557. }
  8558. } );
  8559. // These usually indicate a programmer mistake during development,
  8560. // warn about them ASAP rather than swallowing them by default.
  8561. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  8562. jQuery.Deferred.exceptionHook = function( error, stack ) {
  8563. // Support: IE 8 - 9 only
  8564. // Console exists when dev tools are open, which can happen at any time
  8565. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  8566. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  8567. }
  8568. };
  8569. jQuery.readyException = function( error ) {
  8570. window.setTimeout( function() {
  8571. throw error;
  8572. } );
  8573. };
  8574. // The deferred used on DOM ready
  8575. var readyList = jQuery.Deferred();
  8576. jQuery.fn.ready = function( fn ) {
  8577. readyList
  8578. .then( fn )
  8579. // Wrap jQuery.readyException in a function so that the lookup
  8580. // happens at the time of error handling instead of callback
  8581. // registration.
  8582. .catch( function( error ) {
  8583. jQuery.readyException( error );
  8584. } );
  8585. return this;
  8586. };
  8587. jQuery.extend( {
  8588. // Is the DOM ready to be used? Set to true once it occurs.
  8589. isReady: false,
  8590. // A counter to track how many items to wait for before
  8591. // the ready event fires. See #6781
  8592. readyWait: 1,
  8593. // Handle when the DOM is ready
  8594. ready: function( wait ) {
  8595. // Abort if there are pending holds or we're already ready
  8596. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  8597. return;
  8598. }
  8599. // Remember that the DOM is ready
  8600. jQuery.isReady = true;
  8601. // If a normal DOM Ready event fired, decrement, and wait if need be
  8602. if ( wait !== true && --jQuery.readyWait > 0 ) {
  8603. return;
  8604. }
  8605. // If there are functions bound, to execute
  8606. readyList.resolveWith( document, [ jQuery ] );
  8607. }
  8608. } );
  8609. jQuery.ready.then = readyList.then;
  8610. // The ready event handler and self cleanup method
  8611. function completed() {
  8612. document.removeEventListener( "DOMContentLoaded", completed );
  8613. window.removeEventListener( "load", completed );
  8614. jQuery.ready();
  8615. }
  8616. // Catch cases where $(document).ready() is called
  8617. // after the browser event has already occurred.
  8618. // Support: IE <=9 - 10 only
  8619. // Older IE sometimes signals "interactive" too soon
  8620. if ( document.readyState === "complete" ||
  8621. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  8622. // Handle it asynchronously to allow scripts the opportunity to delay ready
  8623. window.setTimeout( jQuery.ready );
  8624. } else {
  8625. // Use the handy event callback
  8626. document.addEventListener( "DOMContentLoaded", completed );
  8627. // A fallback to window.onload, that will always work
  8628. window.addEventListener( "load", completed );
  8629. }
  8630. // Multifunctional method to get and set values of a collection
  8631. // The value/s can optionally be executed if it's a function
  8632. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  8633. var i = 0,
  8634. len = elems.length,
  8635. bulk = key == null;
  8636. // Sets many values
  8637. if ( toType( key ) === "object" ) {
  8638. chainable = true;
  8639. for ( i in key ) {
  8640. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  8641. }
  8642. // Sets one value
  8643. } else if ( value !== undefined ) {
  8644. chainable = true;
  8645. if ( !isFunction( value ) ) {
  8646. raw = true;
  8647. }
  8648. if ( bulk ) {
  8649. // Bulk operations run against the entire set
  8650. if ( raw ) {
  8651. fn.call( elems, value );
  8652. fn = null;
  8653. // ...except when executing function values
  8654. } else {
  8655. bulk = fn;
  8656. fn = function( elem, _key, value ) {
  8657. return bulk.call( jQuery( elem ), value );
  8658. };
  8659. }
  8660. }
  8661. if ( fn ) {
  8662. for ( ; i < len; i++ ) {
  8663. fn(
  8664. elems[ i ], key, raw ?
  8665. value :
  8666. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  8667. );
  8668. }
  8669. }
  8670. }
  8671. if ( chainable ) {
  8672. return elems;
  8673. }
  8674. // Gets
  8675. if ( bulk ) {
  8676. return fn.call( elems );
  8677. }
  8678. return len ? fn( elems[ 0 ], key ) : emptyGet;
  8679. };
  8680. // Matches dashed string for camelizing
  8681. var rmsPrefix = /^-ms-/,
  8682. rdashAlpha = /-([a-z])/g;
  8683. // Used by camelCase as callback to replace()
  8684. function fcamelCase( _all, letter ) {
  8685. return letter.toUpperCase();
  8686. }
  8687. // Convert dashed to camelCase; used by the css and data modules
  8688. // Support: IE <=9 - 11, Edge 12 - 15
  8689. // Microsoft forgot to hump their vendor prefix (#9572)
  8690. function camelCase( string ) {
  8691. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  8692. }
  8693. var acceptData = function( owner ) {
  8694. // Accepts only:
  8695. // - Node
  8696. // - Node.ELEMENT_NODE
  8697. // - Node.DOCUMENT_NODE
  8698. // - Object
  8699. // - Any
  8700. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  8701. };
  8702. function Data() {
  8703. this.expando = jQuery.expando + Data.uid++;
  8704. }
  8705. Data.uid = 1;
  8706. Data.prototype = {
  8707. cache: function( owner ) {
  8708. // Check if the owner object already has a cache
  8709. var value = owner[ this.expando ];
  8710. // If not, create one
  8711. if ( !value ) {
  8712. value = Object.create( null );
  8713. // We can accept data for non-element nodes in modern browsers,
  8714. // but we should not, see #8335.
  8715. // Always return an empty object.
  8716. if ( acceptData( owner ) ) {
  8717. // If it is a node unlikely to be stringify-ed or looped over
  8718. // use plain assignment
  8719. if ( owner.nodeType ) {
  8720. owner[ this.expando ] = value;
  8721. // Otherwise secure it in a non-enumerable property
  8722. // configurable must be true to allow the property to be
  8723. // deleted when data is removed
  8724. } else {
  8725. Object.defineProperty( owner, this.expando, {
  8726. value: value,
  8727. configurable: true
  8728. } );
  8729. }
  8730. }
  8731. }
  8732. return value;
  8733. },
  8734. set: function( owner, data, value ) {
  8735. var prop,
  8736. cache = this.cache( owner );
  8737. // Handle: [ owner, key, value ] args
  8738. // Always use camelCase key (gh-2257)
  8739. if ( typeof data === "string" ) {
  8740. cache[ camelCase( data ) ] = value;
  8741. // Handle: [ owner, { properties } ] args
  8742. } else {
  8743. // Copy the properties one-by-one to the cache object
  8744. for ( prop in data ) {
  8745. cache[ camelCase( prop ) ] = data[ prop ];
  8746. }
  8747. }
  8748. return cache;
  8749. },
  8750. get: function( owner, key ) {
  8751. return key === undefined ?
  8752. this.cache( owner ) :
  8753. // Always use camelCase key (gh-2257)
  8754. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  8755. },
  8756. access: function( owner, key, value ) {
  8757. // In cases where either:
  8758. //
  8759. // 1. No key was specified
  8760. // 2. A string key was specified, but no value provided
  8761. //
  8762. // Take the "read" path and allow the get method to determine
  8763. // which value to return, respectively either:
  8764. //
  8765. // 1. The entire cache object
  8766. // 2. The data stored at the key
  8767. //
  8768. if ( key === undefined ||
  8769. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  8770. return this.get( owner, key );
  8771. }
  8772. // When the key is not a string, or both a key and value
  8773. // are specified, set or extend (existing objects) with either:
  8774. //
  8775. // 1. An object of properties
  8776. // 2. A key and value
  8777. //
  8778. this.set( owner, key, value );
  8779. // Since the "set" path can have two possible entry points
  8780. // return the expected data based on which path was taken[*]
  8781. return value !== undefined ? value : key;
  8782. },
  8783. remove: function( owner, key ) {
  8784. var i,
  8785. cache = owner[ this.expando ];
  8786. if ( cache === undefined ) {
  8787. return;
  8788. }
  8789. if ( key !== undefined ) {
  8790. // Support array or space separated string of keys
  8791. if ( Array.isArray( key ) ) {
  8792. // If key is an array of keys...
  8793. // We always set camelCase keys, so remove that.
  8794. key = key.map( camelCase );
  8795. } else {
  8796. key = camelCase( key );
  8797. // If a key with the spaces exists, use it.
  8798. // Otherwise, create an array by matching non-whitespace
  8799. key = key in cache ?
  8800. [ key ] :
  8801. ( key.match( rnothtmlwhite ) || [] );
  8802. }
  8803. i = key.length;
  8804. while ( i-- ) {
  8805. delete cache[ key[ i ] ];
  8806. }
  8807. }
  8808. // Remove the expando if there's no more data
  8809. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  8810. // Support: Chrome <=35 - 45
  8811. // Webkit & Blink performance suffers when deleting properties
  8812. // from DOM nodes, so set to undefined instead
  8813. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  8814. if ( owner.nodeType ) {
  8815. owner[ this.expando ] = undefined;
  8816. } else {
  8817. delete owner[ this.expando ];
  8818. }
  8819. }
  8820. },
  8821. hasData: function( owner ) {
  8822. var cache = owner[ this.expando ];
  8823. return cache !== undefined && !jQuery.isEmptyObject( cache );
  8824. }
  8825. };
  8826. var dataPriv = new Data();
  8827. var dataUser = new Data();
  8828. // Implementation Summary
  8829. //
  8830. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  8831. // 2. Improve the module's maintainability by reducing the storage
  8832. // paths to a single mechanism.
  8833. // 3. Use the same single mechanism to support "private" and "user" data.
  8834. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  8835. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  8836. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  8837. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  8838. rmultiDash = /[A-Z]/g;
  8839. function getData( data ) {
  8840. if ( data === "true" ) {
  8841. return true;
  8842. }
  8843. if ( data === "false" ) {
  8844. return false;
  8845. }
  8846. if ( data === "null" ) {
  8847. return null;
  8848. }
  8849. // Only convert to a number if it doesn't change the string
  8850. if ( data === +data + "" ) {
  8851. return +data;
  8852. }
  8853. if ( rbrace.test( data ) ) {
  8854. return JSON.parse( data );
  8855. }
  8856. return data;
  8857. }
  8858. function dataAttr( elem, key, data ) {
  8859. var name;
  8860. // If nothing was found internally, try to fetch any
  8861. // data from the HTML5 data-* attribute
  8862. if ( data === undefined && elem.nodeType === 1 ) {
  8863. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  8864. data = elem.getAttribute( name );
  8865. if ( typeof data === "string" ) {
  8866. try {
  8867. data = getData( data );
  8868. } catch ( e ) {}
  8869. // Make sure we set the data so it isn't changed later
  8870. dataUser.set( elem, key, data );
  8871. } else {
  8872. data = undefined;
  8873. }
  8874. }
  8875. return data;
  8876. }
  8877. jQuery.extend( {
  8878. hasData: function( elem ) {
  8879. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  8880. },
  8881. data: function( elem, name, data ) {
  8882. return dataUser.access( elem, name, data );
  8883. },
  8884. removeData: function( elem, name ) {
  8885. dataUser.remove( elem, name );
  8886. },
  8887. // TODO: Now that all calls to _data and _removeData have been replaced
  8888. // with direct calls to dataPriv methods, these can be deprecated.
  8889. _data: function( elem, name, data ) {
  8890. return dataPriv.access( elem, name, data );
  8891. },
  8892. _removeData: function( elem, name ) {
  8893. dataPriv.remove( elem, name );
  8894. }
  8895. } );
  8896. jQuery.fn.extend( {
  8897. data: function( key, value ) {
  8898. var i, name, data,
  8899. elem = this[ 0 ],
  8900. attrs = elem && elem.attributes;
  8901. // Gets all values
  8902. if ( key === undefined ) {
  8903. if ( this.length ) {
  8904. data = dataUser.get( elem );
  8905. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  8906. i = attrs.length;
  8907. while ( i-- ) {
  8908. // Support: IE 11 only
  8909. // The attrs elements can be null (#14894)
  8910. if ( attrs[ i ] ) {
  8911. name = attrs[ i ].name;
  8912. if ( name.indexOf( "data-" ) === 0 ) {
  8913. name = camelCase( name.slice( 5 ) );
  8914. dataAttr( elem, name, data[ name ] );
  8915. }
  8916. }
  8917. }
  8918. dataPriv.set( elem, "hasDataAttrs", true );
  8919. }
  8920. }
  8921. return data;
  8922. }
  8923. // Sets multiple values
  8924. if ( typeof key === "object" ) {
  8925. return this.each( function() {
  8926. dataUser.set( this, key );
  8927. } );
  8928. }
  8929. return access( this, function( value ) {
  8930. var data;
  8931. // The calling jQuery object (element matches) is not empty
  8932. // (and therefore has an element appears at this[ 0 ]) and the
  8933. // `value` parameter was not undefined. An empty jQuery object
  8934. // will result in `undefined` for elem = this[ 0 ] which will
  8935. // throw an exception if an attempt to read a data cache is made.
  8936. if ( elem && value === undefined ) {
  8937. // Attempt to get data from the cache
  8938. // The key will always be camelCased in Data
  8939. data = dataUser.get( elem, key );
  8940. if ( data !== undefined ) {
  8941. return data;
  8942. }
  8943. // Attempt to "discover" the data in
  8944. // HTML5 custom data-* attrs
  8945. data = dataAttr( elem, key );
  8946. if ( data !== undefined ) {
  8947. return data;
  8948. }
  8949. // We tried really hard, but the data doesn't exist.
  8950. return;
  8951. }
  8952. // Set the data...
  8953. this.each( function() {
  8954. // We always store the camelCased key
  8955. dataUser.set( this, key, value );
  8956. } );
  8957. }, null, value, arguments.length > 1, null, true );
  8958. },
  8959. removeData: function( key ) {
  8960. return this.each( function() {
  8961. dataUser.remove( this, key );
  8962. } );
  8963. }
  8964. } );
  8965. jQuery.extend( {
  8966. queue: function( elem, type, data ) {
  8967. var queue;
  8968. if ( elem ) {
  8969. type = ( type || "fx" ) + "queue";
  8970. queue = dataPriv.get( elem, type );
  8971. // Speed up dequeue by getting out quickly if this is just a lookup
  8972. if ( data ) {
  8973. if ( !queue || Array.isArray( data ) ) {
  8974. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  8975. } else {
  8976. queue.push( data );
  8977. }
  8978. }
  8979. return queue || [];
  8980. }
  8981. },
  8982. dequeue: function( elem, type ) {
  8983. type = type || "fx";
  8984. var queue = jQuery.queue( elem, type ),
  8985. startLength = queue.length,
  8986. fn = queue.shift(),
  8987. hooks = jQuery._queueHooks( elem, type ),
  8988. next = function() {
  8989. jQuery.dequeue( elem, type );
  8990. };
  8991. // If the fx queue is dequeued, always remove the progress sentinel
  8992. if ( fn === "inprogress" ) {
  8993. fn = queue.shift();
  8994. startLength--;
  8995. }
  8996. if ( fn ) {
  8997. // Add a progress sentinel to prevent the fx queue from being
  8998. // automatically dequeued
  8999. if ( type === "fx" ) {
  9000. queue.unshift( "inprogress" );
  9001. }
  9002. // Clear up the last queue stop function
  9003. delete hooks.stop;
  9004. fn.call( elem, next, hooks );
  9005. }
  9006. if ( !startLength && hooks ) {
  9007. hooks.empty.fire();
  9008. }
  9009. },
  9010. // Not public - generate a queueHooks object, or return the current one
  9011. _queueHooks: function( elem, type ) {
  9012. var key = type + "queueHooks";
  9013. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  9014. empty: jQuery.Callbacks( "once memory" ).add( function() {
  9015. dataPriv.remove( elem, [ type + "queue", key ] );
  9016. } )
  9017. } );
  9018. }
  9019. } );
  9020. jQuery.fn.extend( {
  9021. queue: function( type, data ) {
  9022. var setter = 2;
  9023. if ( typeof type !== "string" ) {
  9024. data = type;
  9025. type = "fx";
  9026. setter--;
  9027. }
  9028. if ( arguments.length < setter ) {
  9029. return jQuery.queue( this[ 0 ], type );
  9030. }
  9031. return data === undefined ?
  9032. this :
  9033. this.each( function() {
  9034. var queue = jQuery.queue( this, type, data );
  9035. // Ensure a hooks for this queue
  9036. jQuery._queueHooks( this, type );
  9037. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  9038. jQuery.dequeue( this, type );
  9039. }
  9040. } );
  9041. },
  9042. dequeue: function( type ) {
  9043. return this.each( function() {
  9044. jQuery.dequeue( this, type );
  9045. } );
  9046. },
  9047. clearQueue: function( type ) {
  9048. return this.queue( type || "fx", [] );
  9049. },
  9050. // Get a promise resolved when queues of a certain type
  9051. // are emptied (fx is the type by default)
  9052. promise: function( type, obj ) {
  9053. var tmp,
  9054. count = 1,
  9055. defer = jQuery.Deferred(),
  9056. elements = this,
  9057. i = this.length,
  9058. resolve = function() {
  9059. if ( !( --count ) ) {
  9060. defer.resolveWith( elements, [ elements ] );
  9061. }
  9062. };
  9063. if ( typeof type !== "string" ) {
  9064. obj = type;
  9065. type = undefined;
  9066. }
  9067. type = type || "fx";
  9068. while ( i-- ) {
  9069. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  9070. if ( tmp && tmp.empty ) {
  9071. count++;
  9072. tmp.empty.add( resolve );
  9073. }
  9074. }
  9075. resolve();
  9076. return defer.promise( obj );
  9077. }
  9078. } );
  9079. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  9080. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  9081. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  9082. var documentElement = document.documentElement;
  9083. var isAttached = function( elem ) {
  9084. return jQuery.contains( elem.ownerDocument, elem );
  9085. },
  9086. composed = { composed: true };
  9087. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  9088. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  9089. // Support: iOS 10.0-10.2 only
  9090. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  9091. // leading to errors. We need to check for `getRootNode`.
  9092. if ( documentElement.getRootNode ) {
  9093. isAttached = function( elem ) {
  9094. return jQuery.contains( elem.ownerDocument, elem ) ||
  9095. elem.getRootNode( composed ) === elem.ownerDocument;
  9096. };
  9097. }
  9098. var isHiddenWithinTree = function( elem, el ) {
  9099. // isHiddenWithinTree might be called from jQuery#filter function;
  9100. // in that case, element will be second argument
  9101. elem = el || elem;
  9102. // Inline style trumps all
  9103. return elem.style.display === "none" ||
  9104. elem.style.display === "" &&
  9105. // Otherwise, check computed style
  9106. // Support: Firefox <=43 - 45
  9107. // Disconnected elements can have computed display: none, so first confirm that elem is
  9108. // in the document.
  9109. isAttached( elem ) &&
  9110. jQuery.css( elem, "display" ) === "none";
  9111. };
  9112. function adjustCSS( elem, prop, valueParts, tween ) {
  9113. var adjusted, scale,
  9114. maxIterations = 20,
  9115. currentValue = tween ?
  9116. function() {
  9117. return tween.cur();
  9118. } :
  9119. function() {
  9120. return jQuery.css( elem, prop, "" );
  9121. },
  9122. initial = currentValue(),
  9123. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  9124. // Starting value computation is required for potential unit mismatches
  9125. initialInUnit = elem.nodeType &&
  9126. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  9127. rcssNum.exec( jQuery.css( elem, prop ) );
  9128. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  9129. // Support: Firefox <=54
  9130. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  9131. initial = initial / 2;
  9132. // Trust units reported by jQuery.css
  9133. unit = unit || initialInUnit[ 3 ];
  9134. // Iteratively approximate from a nonzero starting point
  9135. initialInUnit = +initial || 1;
  9136. while ( maxIterations-- ) {
  9137. // Evaluate and update our best guess (doubling guesses that zero out).
  9138. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  9139. jQuery.style( elem, prop, initialInUnit + unit );
  9140. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  9141. maxIterations = 0;
  9142. }
  9143. initialInUnit = initialInUnit / scale;
  9144. }
  9145. initialInUnit = initialInUnit * 2;
  9146. jQuery.style( elem, prop, initialInUnit + unit );
  9147. // Make sure we update the tween properties later on
  9148. valueParts = valueParts || [];
  9149. }
  9150. if ( valueParts ) {
  9151. initialInUnit = +initialInUnit || +initial || 0;
  9152. // Apply relative offset (+=/-=) if specified
  9153. adjusted = valueParts[ 1 ] ?
  9154. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  9155. +valueParts[ 2 ];
  9156. if ( tween ) {
  9157. tween.unit = unit;
  9158. tween.start = initialInUnit;
  9159. tween.end = adjusted;
  9160. }
  9161. }
  9162. return adjusted;
  9163. }
  9164. var defaultDisplayMap = {};
  9165. function getDefaultDisplay( elem ) {
  9166. var temp,
  9167. doc = elem.ownerDocument,
  9168. nodeName = elem.nodeName,
  9169. display = defaultDisplayMap[ nodeName ];
  9170. if ( display ) {
  9171. return display;
  9172. }
  9173. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  9174. display = jQuery.css( temp, "display" );
  9175. temp.parentNode.removeChild( temp );
  9176. if ( display === "none" ) {
  9177. display = "block";
  9178. }
  9179. defaultDisplayMap[ nodeName ] = display;
  9180. return display;
  9181. }
  9182. function showHide( elements, show ) {
  9183. var display, elem,
  9184. values = [],
  9185. index = 0,
  9186. length = elements.length;
  9187. // Determine new display value for elements that need to change
  9188. for ( ; index < length; index++ ) {
  9189. elem = elements[ index ];
  9190. if ( !elem.style ) {
  9191. continue;
  9192. }
  9193. display = elem.style.display;
  9194. if ( show ) {
  9195. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  9196. // check is required in this first loop unless we have a nonempty display value (either
  9197. // inline or about-to-be-restored)
  9198. if ( display === "none" ) {
  9199. values[ index ] = dataPriv.get( elem, "display" ) || null;
  9200. if ( !values[ index ] ) {
  9201. elem.style.display = "";
  9202. }
  9203. }
  9204. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  9205. values[ index ] = getDefaultDisplay( elem );
  9206. }
  9207. } else {
  9208. if ( display !== "none" ) {
  9209. values[ index ] = "none";
  9210. // Remember what we're overwriting
  9211. dataPriv.set( elem, "display", display );
  9212. }
  9213. }
  9214. }
  9215. // Set the display of the elements in a second loop to avoid constant reflow
  9216. for ( index = 0; index < length; index++ ) {
  9217. if ( values[ index ] != null ) {
  9218. elements[ index ].style.display = values[ index ];
  9219. }
  9220. }
  9221. return elements;
  9222. }
  9223. jQuery.fn.extend( {
  9224. show: function() {
  9225. return showHide( this, true );
  9226. },
  9227. hide: function() {
  9228. return showHide( this );
  9229. },
  9230. toggle: function( state ) {
  9231. if ( typeof state === "boolean" ) {
  9232. return state ? this.show() : this.hide();
  9233. }
  9234. return this.each( function() {
  9235. if ( isHiddenWithinTree( this ) ) {
  9236. jQuery( this ).show();
  9237. } else {
  9238. jQuery( this ).hide();
  9239. }
  9240. } );
  9241. }
  9242. } );
  9243. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  9244. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  9245. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  9246. ( function() {
  9247. var fragment = document.createDocumentFragment(),
  9248. div = fragment.appendChild( document.createElement( "div" ) ),
  9249. input = document.createElement( "input" );
  9250. // Support: Android 4.0 - 4.3 only
  9251. // Check state lost if the name is set (#11217)
  9252. // Support: Windows Web Apps (WWA)
  9253. // `name` and `type` must use .setAttribute for WWA (#14901)
  9254. input.setAttribute( "type", "radio" );
  9255. input.setAttribute( "checked", "checked" );
  9256. input.setAttribute( "name", "t" );
  9257. div.appendChild( input );
  9258. // Support: Android <=4.1 only
  9259. // Older WebKit doesn't clone checked state correctly in fragments
  9260. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  9261. // Support: IE <=11 only
  9262. // Make sure textarea (and checkbox) defaultValue is properly cloned
  9263. div.innerHTML = "<textarea>x</textarea>";
  9264. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  9265. // Support: IE <=9 only
  9266. // IE <=9 replaces <option> tags with their contents when inserted outside of
  9267. // the select element.
  9268. div.innerHTML = "<option></option>";
  9269. support.option = !!div.lastChild;
  9270. } )();
  9271. // We have to close these tags to support XHTML (#13200)
  9272. var wrapMap = {
  9273. // XHTML parsers do not magically insert elements in the
  9274. // same way that tag soup parsers do. So we cannot shorten
  9275. // this by omitting <tbody> or other required elements.
  9276. thead: [ 1, "<table>", "</table>" ],
  9277. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  9278. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  9279. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  9280. _default: [ 0, "", "" ]
  9281. };
  9282. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  9283. wrapMap.th = wrapMap.td;
  9284. // Support: IE <=9 only
  9285. if ( !support.option ) {
  9286. wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
  9287. }
  9288. function getAll( context, tag ) {
  9289. // Support: IE <=9 - 11 only
  9290. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  9291. var ret;
  9292. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9293. ret = context.getElementsByTagName( tag || "*" );
  9294. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  9295. ret = context.querySelectorAll( tag || "*" );
  9296. } else {
  9297. ret = [];
  9298. }
  9299. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  9300. return jQuery.merge( [ context ], ret );
  9301. }
  9302. return ret;
  9303. }
  9304. // Mark scripts as having already been evaluated
  9305. function setGlobalEval( elems, refElements ) {
  9306. var i = 0,
  9307. l = elems.length;
  9308. for ( ; i < l; i++ ) {
  9309. dataPriv.set(
  9310. elems[ i ],
  9311. "globalEval",
  9312. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  9313. );
  9314. }
  9315. }
  9316. var rhtml = /<|&#?\w+;/;
  9317. function buildFragment( elems, context, scripts, selection, ignored ) {
  9318. var elem, tmp, tag, wrap, attached, j,
  9319. fragment = context.createDocumentFragment(),
  9320. nodes = [],
  9321. i = 0,
  9322. l = elems.length;
  9323. for ( ; i < l; i++ ) {
  9324. elem = elems[ i ];
  9325. if ( elem || elem === 0 ) {
  9326. // Add nodes directly
  9327. if ( toType( elem ) === "object" ) {
  9328. // Support: Android <=4.0 only, PhantomJS 1 only
  9329. // push.apply(_, arraylike) throws on ancient WebKit
  9330. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  9331. // Convert non-html into a text node
  9332. } else if ( !rhtml.test( elem ) ) {
  9333. nodes.push( context.createTextNode( elem ) );
  9334. // Convert html into DOM nodes
  9335. } else {
  9336. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  9337. // Deserialize a standard representation
  9338. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  9339. wrap = wrapMap[ tag ] || wrapMap._default;
  9340. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  9341. // Descend through wrappers to the right content
  9342. j = wrap[ 0 ];
  9343. while ( j-- ) {
  9344. tmp = tmp.lastChild;
  9345. }
  9346. // Support: Android <=4.0 only, PhantomJS 1 only
  9347. // push.apply(_, arraylike) throws on ancient WebKit
  9348. jQuery.merge( nodes, tmp.childNodes );
  9349. // Remember the top-level container
  9350. tmp = fragment.firstChild;
  9351. // Ensure the created nodes are orphaned (#12392)
  9352. tmp.textContent = "";
  9353. }
  9354. }
  9355. }
  9356. // Remove wrapper from fragment
  9357. fragment.textContent = "";
  9358. i = 0;
  9359. while ( ( elem = nodes[ i++ ] ) ) {
  9360. // Skip elements already in the context collection (trac-4087)
  9361. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  9362. if ( ignored ) {
  9363. ignored.push( elem );
  9364. }
  9365. continue;
  9366. }
  9367. attached = isAttached( elem );
  9368. // Append to fragment
  9369. tmp = getAll( fragment.appendChild( elem ), "script" );
  9370. // Preserve script evaluation history
  9371. if ( attached ) {
  9372. setGlobalEval( tmp );
  9373. }
  9374. // Capture executables
  9375. if ( scripts ) {
  9376. j = 0;
  9377. while ( ( elem = tmp[ j++ ] ) ) {
  9378. if ( rscriptType.test( elem.type || "" ) ) {
  9379. scripts.push( elem );
  9380. }
  9381. }
  9382. }
  9383. }
  9384. return fragment;
  9385. }
  9386. var
  9387. rkeyEvent = /^key/,
  9388. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  9389. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  9390. function returnTrue() {
  9391. return true;
  9392. }
  9393. function returnFalse() {
  9394. return false;
  9395. }
  9396. // Support: IE <=9 - 11+
  9397. // focus() and blur() are asynchronous, except when they are no-op.
  9398. // So expect focus to be synchronous when the element is already active,
  9399. // and blur to be synchronous when the element is not already active.
  9400. // (focus and blur are always synchronous in other supported browsers,
  9401. // this just defines when we can count on it).
  9402. function expectSync( elem, type ) {
  9403. return ( elem === safeActiveElement() ) === ( type === "focus" );
  9404. }
  9405. // Support: IE <=9 only
  9406. // Accessing document.activeElement can throw unexpectedly
  9407. // https://bugs.jquery.com/ticket/13393
  9408. function safeActiveElement() {
  9409. try {
  9410. return document.activeElement;
  9411. } catch ( err ) { }
  9412. }
  9413. function on( elem, types, selector, data, fn, one ) {
  9414. var origFn, type;
  9415. // Types can be a map of types/handlers
  9416. if ( typeof types === "object" ) {
  9417. // ( types-Object, selector, data )
  9418. if ( typeof selector !== "string" ) {
  9419. // ( types-Object, data )
  9420. data = data || selector;
  9421. selector = undefined;
  9422. }
  9423. for ( type in types ) {
  9424. on( elem, type, selector, data, types[ type ], one );
  9425. }
  9426. return elem;
  9427. }
  9428. if ( data == null && fn == null ) {
  9429. // ( types, fn )
  9430. fn = selector;
  9431. data = selector = undefined;
  9432. } else if ( fn == null ) {
  9433. if ( typeof selector === "string" ) {
  9434. // ( types, selector, fn )
  9435. fn = data;
  9436. data = undefined;
  9437. } else {
  9438. // ( types, data, fn )
  9439. fn = data;
  9440. data = selector;
  9441. selector = undefined;
  9442. }
  9443. }
  9444. if ( fn === false ) {
  9445. fn = returnFalse;
  9446. } else if ( !fn ) {
  9447. return elem;
  9448. }
  9449. if ( one === 1 ) {
  9450. origFn = fn;
  9451. fn = function( event ) {
  9452. // Can use an empty set, since event contains the info
  9453. jQuery().off( event );
  9454. return origFn.apply( this, arguments );
  9455. };
  9456. // Use same guid so caller can remove using origFn
  9457. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  9458. }
  9459. return elem.each( function() {
  9460. jQuery.event.add( this, types, fn, data, selector );
  9461. } );
  9462. }
  9463. /*
  9464. * Helper functions for managing events -- not part of the public interface.
  9465. * Props to Dean Edwards' addEvent library for many of the ideas.
  9466. */
  9467. jQuery.event = {
  9468. global: {},
  9469. add: function( elem, types, handler, data, selector ) {
  9470. var handleObjIn, eventHandle, tmp,
  9471. events, t, handleObj,
  9472. special, handlers, type, namespaces, origType,
  9473. elemData = dataPriv.get( elem );
  9474. // Only attach events to objects that accept data
  9475. if ( !acceptData( elem ) ) {
  9476. return;
  9477. }
  9478. // Caller can pass in an object of custom data in lieu of the handler
  9479. if ( handler.handler ) {
  9480. handleObjIn = handler;
  9481. handler = handleObjIn.handler;
  9482. selector = handleObjIn.selector;
  9483. }
  9484. // Ensure that invalid selectors throw exceptions at attach time
  9485. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  9486. if ( selector ) {
  9487. jQuery.find.matchesSelector( documentElement, selector );
  9488. }
  9489. // Make sure that the handler has a unique ID, used to find/remove it later
  9490. if ( !handler.guid ) {
  9491. handler.guid = jQuery.guid++;
  9492. }
  9493. // Init the element's event structure and main handler, if this is the first
  9494. if ( !( events = elemData.events ) ) {
  9495. events = elemData.events = Object.create( null );
  9496. }
  9497. if ( !( eventHandle = elemData.handle ) ) {
  9498. eventHandle = elemData.handle = function( e ) {
  9499. // Discard the second event of a jQuery.event.trigger() and
  9500. // when an event is called after a page has unloaded
  9501. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  9502. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  9503. };
  9504. }
  9505. // Handle multiple events separated by a space
  9506. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9507. t = types.length;
  9508. while ( t-- ) {
  9509. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9510. type = origType = tmp[ 1 ];
  9511. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9512. // There *must* be a type, no attaching namespace-only handlers
  9513. if ( !type ) {
  9514. continue;
  9515. }
  9516. // If event changes its type, use the special event handlers for the changed type
  9517. special = jQuery.event.special[ type ] || {};
  9518. // If selector defined, determine special event api type, otherwise given type
  9519. type = ( selector ? special.delegateType : special.bindType ) || type;
  9520. // Update special based on newly reset type
  9521. special = jQuery.event.special[ type ] || {};
  9522. // handleObj is passed to all event handlers
  9523. handleObj = jQuery.extend( {
  9524. type: type,
  9525. origType: origType,
  9526. data: data,
  9527. handler: handler,
  9528. guid: handler.guid,
  9529. selector: selector,
  9530. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  9531. namespace: namespaces.join( "." )
  9532. }, handleObjIn );
  9533. // Init the event handler queue if we're the first
  9534. if ( !( handlers = events[ type ] ) ) {
  9535. handlers = events[ type ] = [];
  9536. handlers.delegateCount = 0;
  9537. // Only use addEventListener if the special events handler returns false
  9538. if ( !special.setup ||
  9539. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  9540. if ( elem.addEventListener ) {
  9541. elem.addEventListener( type, eventHandle );
  9542. }
  9543. }
  9544. }
  9545. if ( special.add ) {
  9546. special.add.call( elem, handleObj );
  9547. if ( !handleObj.handler.guid ) {
  9548. handleObj.handler.guid = handler.guid;
  9549. }
  9550. }
  9551. // Add to the element's handler list, delegates in front
  9552. if ( selector ) {
  9553. handlers.splice( handlers.delegateCount++, 0, handleObj );
  9554. } else {
  9555. handlers.push( handleObj );
  9556. }
  9557. // Keep track of which events have ever been used, for event optimization
  9558. jQuery.event.global[ type ] = true;
  9559. }
  9560. },
  9561. // Detach an event or set of events from an element
  9562. remove: function( elem, types, handler, selector, mappedTypes ) {
  9563. var j, origCount, tmp,
  9564. events, t, handleObj,
  9565. special, handlers, type, namespaces, origType,
  9566. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  9567. if ( !elemData || !( events = elemData.events ) ) {
  9568. return;
  9569. }
  9570. // Once for each type.namespace in types; type may be omitted
  9571. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9572. t = types.length;
  9573. while ( t-- ) {
  9574. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9575. type = origType = tmp[ 1 ];
  9576. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9577. // Unbind all events (on this namespace, if provided) for the element
  9578. if ( !type ) {
  9579. for ( type in events ) {
  9580. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  9581. }
  9582. continue;
  9583. }
  9584. special = jQuery.event.special[ type ] || {};
  9585. type = ( selector ? special.delegateType : special.bindType ) || type;
  9586. handlers = events[ type ] || [];
  9587. tmp = tmp[ 2 ] &&
  9588. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  9589. // Remove matching events
  9590. origCount = j = handlers.length;
  9591. while ( j-- ) {
  9592. handleObj = handlers[ j ];
  9593. if ( ( mappedTypes || origType === handleObj.origType ) &&
  9594. ( !handler || handler.guid === handleObj.guid ) &&
  9595. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  9596. ( !selector || selector === handleObj.selector ||
  9597. selector === "**" && handleObj.selector ) ) {
  9598. handlers.splice( j, 1 );
  9599. if ( handleObj.selector ) {
  9600. handlers.delegateCount--;
  9601. }
  9602. if ( special.remove ) {
  9603. special.remove.call( elem, handleObj );
  9604. }
  9605. }
  9606. }
  9607. // Remove generic event handler if we removed something and no more handlers exist
  9608. // (avoids potential for endless recursion during removal of special event handlers)
  9609. if ( origCount && !handlers.length ) {
  9610. if ( !special.teardown ||
  9611. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  9612. jQuery.removeEvent( elem, type, elemData.handle );
  9613. }
  9614. delete events[ type ];
  9615. }
  9616. }
  9617. // Remove data and the expando if it's no longer used
  9618. if ( jQuery.isEmptyObject( events ) ) {
  9619. dataPriv.remove( elem, "handle events" );
  9620. }
  9621. },
  9622. dispatch: function( nativeEvent ) {
  9623. var i, j, ret, matched, handleObj, handlerQueue,
  9624. args = new Array( arguments.length ),
  9625. // Make a writable jQuery.Event from the native event object
  9626. event = jQuery.event.fix( nativeEvent ),
  9627. handlers = (
  9628. dataPriv.get( this, "events" ) || Object.create( null )
  9629. )[ event.type ] || [],
  9630. special = jQuery.event.special[ event.type ] || {};
  9631. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  9632. args[ 0 ] = event;
  9633. for ( i = 1; i < arguments.length; i++ ) {
  9634. args[ i ] = arguments[ i ];
  9635. }
  9636. event.delegateTarget = this;
  9637. // Call the preDispatch hook for the mapped type, and let it bail if desired
  9638. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  9639. return;
  9640. }
  9641. // Determine handlers
  9642. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  9643. // Run delegates first; they may want to stop propagation beneath us
  9644. i = 0;
  9645. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  9646. event.currentTarget = matched.elem;
  9647. j = 0;
  9648. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  9649. !event.isImmediatePropagationStopped() ) {
  9650. // If the event is namespaced, then each handler is only invoked if it is
  9651. // specially universal or its namespaces are a superset of the event's.
  9652. if ( !event.rnamespace || handleObj.namespace === false ||
  9653. event.rnamespace.test( handleObj.namespace ) ) {
  9654. event.handleObj = handleObj;
  9655. event.data = handleObj.data;
  9656. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  9657. handleObj.handler ).apply( matched.elem, args );
  9658. if ( ret !== undefined ) {
  9659. if ( ( event.result = ret ) === false ) {
  9660. event.preventDefault();
  9661. event.stopPropagation();
  9662. }
  9663. }
  9664. }
  9665. }
  9666. }
  9667. // Call the postDispatch hook for the mapped type
  9668. if ( special.postDispatch ) {
  9669. special.postDispatch.call( this, event );
  9670. }
  9671. return event.result;
  9672. },
  9673. handlers: function( event, handlers ) {
  9674. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  9675. handlerQueue = [],
  9676. delegateCount = handlers.delegateCount,
  9677. cur = event.target;
  9678. // Find delegate handlers
  9679. if ( delegateCount &&
  9680. // Support: IE <=9
  9681. // Black-hole SVG <use> instance trees (trac-13180)
  9682. cur.nodeType &&
  9683. // Support: Firefox <=42
  9684. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  9685. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  9686. // Support: IE 11 only
  9687. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  9688. !( event.type === "click" && event.button >= 1 ) ) {
  9689. for ( ; cur !== this; cur = cur.parentNode || this ) {
  9690. // Don't check non-elements (#13208)
  9691. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  9692. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  9693. matchedHandlers = [];
  9694. matchedSelectors = {};
  9695. for ( i = 0; i < delegateCount; i++ ) {
  9696. handleObj = handlers[ i ];
  9697. // Don't conflict with Object.prototype properties (#13203)
  9698. sel = handleObj.selector + " ";
  9699. if ( matchedSelectors[ sel ] === undefined ) {
  9700. matchedSelectors[ sel ] = handleObj.needsContext ?
  9701. jQuery( sel, this ).index( cur ) > -1 :
  9702. jQuery.find( sel, this, null, [ cur ] ).length;
  9703. }
  9704. if ( matchedSelectors[ sel ] ) {
  9705. matchedHandlers.push( handleObj );
  9706. }
  9707. }
  9708. if ( matchedHandlers.length ) {
  9709. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  9710. }
  9711. }
  9712. }
  9713. }
  9714. // Add the remaining (directly-bound) handlers
  9715. cur = this;
  9716. if ( delegateCount < handlers.length ) {
  9717. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  9718. }
  9719. return handlerQueue;
  9720. },
  9721. addProp: function( name, hook ) {
  9722. Object.defineProperty( jQuery.Event.prototype, name, {
  9723. enumerable: true,
  9724. configurable: true,
  9725. get: isFunction( hook ) ?
  9726. function() {
  9727. if ( this.originalEvent ) {
  9728. return hook( this.originalEvent );
  9729. }
  9730. } :
  9731. function() {
  9732. if ( this.originalEvent ) {
  9733. return this.originalEvent[ name ];
  9734. }
  9735. },
  9736. set: function( value ) {
  9737. Object.defineProperty( this, name, {
  9738. enumerable: true,
  9739. configurable: true,
  9740. writable: true,
  9741. value: value
  9742. } );
  9743. }
  9744. } );
  9745. },
  9746. fix: function( originalEvent ) {
  9747. return originalEvent[ jQuery.expando ] ?
  9748. originalEvent :
  9749. new jQuery.Event( originalEvent );
  9750. },
  9751. special: {
  9752. load: {
  9753. // Prevent triggered image.load events from bubbling to window.load
  9754. noBubble: true
  9755. },
  9756. click: {
  9757. // Utilize native event to ensure correct state for checkable inputs
  9758. setup: function( data ) {
  9759. // For mutual compressibility with _default, replace `this` access with a local var.
  9760. // `|| data` is dead code meant only to preserve the variable through minification.
  9761. var el = this || data;
  9762. // Claim the first handler
  9763. if ( rcheckableType.test( el.type ) &&
  9764. el.click && nodeName( el, "input" ) ) {
  9765. // dataPriv.set( el, "click", ... )
  9766. leverageNative( el, "click", returnTrue );
  9767. }
  9768. // Return false to allow normal processing in the caller
  9769. return false;
  9770. },
  9771. trigger: function( data ) {
  9772. // For mutual compressibility with _default, replace `this` access with a local var.
  9773. // `|| data` is dead code meant only to preserve the variable through minification.
  9774. var el = this || data;
  9775. // Force setup before triggering a click
  9776. if ( rcheckableType.test( el.type ) &&
  9777. el.click && nodeName( el, "input" ) ) {
  9778. leverageNative( el, "click" );
  9779. }
  9780. // Return non-false to allow normal event-path propagation
  9781. return true;
  9782. },
  9783. // For cross-browser consistency, suppress native .click() on links
  9784. // Also prevent it if we're currently inside a leveraged native-event stack
  9785. _default: function( event ) {
  9786. var target = event.target;
  9787. return rcheckableType.test( target.type ) &&
  9788. target.click && nodeName( target, "input" ) &&
  9789. dataPriv.get( target, "click" ) ||
  9790. nodeName( target, "a" );
  9791. }
  9792. },
  9793. beforeunload: {
  9794. postDispatch: function( event ) {
  9795. // Support: Firefox 20+
  9796. // Firefox doesn't alert if the returnValue field is not set.
  9797. if ( event.result !== undefined && event.originalEvent ) {
  9798. event.originalEvent.returnValue = event.result;
  9799. }
  9800. }
  9801. }
  9802. }
  9803. };
  9804. // Ensure the presence of an event listener that handles manually-triggered
  9805. // synthetic events by interrupting progress until reinvoked in response to
  9806. // *native* events that it fires directly, ensuring that state changes have
  9807. // already occurred before other listeners are invoked.
  9808. function leverageNative( el, type, expectSync ) {
  9809. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  9810. if ( !expectSync ) {
  9811. if ( dataPriv.get( el, type ) === undefined ) {
  9812. jQuery.event.add( el, type, returnTrue );
  9813. }
  9814. return;
  9815. }
  9816. // Register the controller as a special universal handler for all event namespaces
  9817. dataPriv.set( el, type, false );
  9818. jQuery.event.add( el, type, {
  9819. namespace: false,
  9820. handler: function( event ) {
  9821. var notAsync, result,
  9822. saved = dataPriv.get( this, type );
  9823. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  9824. // Interrupt processing of the outer synthetic .trigger()ed event
  9825. // Saved data should be false in such cases, but might be a leftover capture object
  9826. // from an async native handler (gh-4350)
  9827. if ( !saved.length ) {
  9828. // Store arguments for use when handling the inner native event
  9829. // There will always be at least one argument (an event object), so this array
  9830. // will not be confused with a leftover capture object.
  9831. saved = slice.call( arguments );
  9832. dataPriv.set( this, type, saved );
  9833. // Trigger the native event and capture its result
  9834. // Support: IE <=9 - 11+
  9835. // focus() and blur() are asynchronous
  9836. notAsync = expectSync( this, type );
  9837. this[ type ]();
  9838. result = dataPriv.get( this, type );
  9839. if ( saved !== result || notAsync ) {
  9840. dataPriv.set( this, type, false );
  9841. } else {
  9842. result = {};
  9843. }
  9844. if ( saved !== result ) {
  9845. // Cancel the outer synthetic event
  9846. event.stopImmediatePropagation();
  9847. event.preventDefault();
  9848. return result.value;
  9849. }
  9850. // If this is an inner synthetic event for an event with a bubbling surrogate
  9851. // (focus or blur), assume that the surrogate already propagated from triggering the
  9852. // native event and prevent that from happening again here.
  9853. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  9854. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  9855. // less bad than duplication.
  9856. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  9857. event.stopPropagation();
  9858. }
  9859. // If this is a native event triggered above, everything is now in order
  9860. // Fire an inner synthetic event with the original arguments
  9861. } else if ( saved.length ) {
  9862. // ...and capture the result
  9863. dataPriv.set( this, type, {
  9864. value: jQuery.event.trigger(
  9865. // Support: IE <=9 - 11+
  9866. // Extend with the prototype to reset the above stopImmediatePropagation()
  9867. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  9868. saved.slice( 1 ),
  9869. this
  9870. )
  9871. } );
  9872. // Abort handling of the native event
  9873. event.stopImmediatePropagation();
  9874. }
  9875. }
  9876. } );
  9877. }
  9878. jQuery.removeEvent = function( elem, type, handle ) {
  9879. // This "if" is needed for plain objects
  9880. if ( elem.removeEventListener ) {
  9881. elem.removeEventListener( type, handle );
  9882. }
  9883. };
  9884. jQuery.Event = function( src, props ) {
  9885. // Allow instantiation without the 'new' keyword
  9886. if ( !( this instanceof jQuery.Event ) ) {
  9887. return new jQuery.Event( src, props );
  9888. }
  9889. // Event object
  9890. if ( src && src.type ) {
  9891. this.originalEvent = src;
  9892. this.type = src.type;
  9893. // Events bubbling up the document may have been marked as prevented
  9894. // by a handler lower down the tree; reflect the correct value.
  9895. this.isDefaultPrevented = src.defaultPrevented ||
  9896. src.defaultPrevented === undefined &&
  9897. // Support: Android <=2.3 only
  9898. src.returnValue === false ?
  9899. returnTrue :
  9900. returnFalse;
  9901. // Create target properties
  9902. // Support: Safari <=6 - 7 only
  9903. // Target should not be a text node (#504, #13143)
  9904. this.target = ( src.target && src.target.nodeType === 3 ) ?
  9905. src.target.parentNode :
  9906. src.target;
  9907. this.currentTarget = src.currentTarget;
  9908. this.relatedTarget = src.relatedTarget;
  9909. // Event type
  9910. } else {
  9911. this.type = src;
  9912. }
  9913. // Put explicitly provided properties onto the event object
  9914. if ( props ) {
  9915. jQuery.extend( this, props );
  9916. }
  9917. // Create a timestamp if incoming event doesn't have one
  9918. this.timeStamp = src && src.timeStamp || Date.now();
  9919. // Mark it as fixed
  9920. this[ jQuery.expando ] = true;
  9921. };
  9922. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  9923. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  9924. jQuery.Event.prototype = {
  9925. constructor: jQuery.Event,
  9926. isDefaultPrevented: returnFalse,
  9927. isPropagationStopped: returnFalse,
  9928. isImmediatePropagationStopped: returnFalse,
  9929. isSimulated: false,
  9930. preventDefault: function() {
  9931. var e = this.originalEvent;
  9932. this.isDefaultPrevented = returnTrue;
  9933. if ( e && !this.isSimulated ) {
  9934. e.preventDefault();
  9935. }
  9936. },
  9937. stopPropagation: function() {
  9938. var e = this.originalEvent;
  9939. this.isPropagationStopped = returnTrue;
  9940. if ( e && !this.isSimulated ) {
  9941. e.stopPropagation();
  9942. }
  9943. },
  9944. stopImmediatePropagation: function() {
  9945. var e = this.originalEvent;
  9946. this.isImmediatePropagationStopped = returnTrue;
  9947. if ( e && !this.isSimulated ) {
  9948. e.stopImmediatePropagation();
  9949. }
  9950. this.stopPropagation();
  9951. }
  9952. };
  9953. // Includes all common event props including KeyEvent and MouseEvent specific props
  9954. jQuery.each( {
  9955. altKey: true,
  9956. bubbles: true,
  9957. cancelable: true,
  9958. changedTouches: true,
  9959. ctrlKey: true,
  9960. detail: true,
  9961. eventPhase: true,
  9962. metaKey: true,
  9963. pageX: true,
  9964. pageY: true,
  9965. shiftKey: true,
  9966. view: true,
  9967. "char": true,
  9968. code: true,
  9969. charCode: true,
  9970. key: true,
  9971. keyCode: true,
  9972. button: true,
  9973. buttons: true,
  9974. clientX: true,
  9975. clientY: true,
  9976. offsetX: true,
  9977. offsetY: true,
  9978. pointerId: true,
  9979. pointerType: true,
  9980. screenX: true,
  9981. screenY: true,
  9982. targetTouches: true,
  9983. toElement: true,
  9984. touches: true,
  9985. which: function( event ) {
  9986. var button = event.button;
  9987. // Add which for key events
  9988. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  9989. return event.charCode != null ? event.charCode : event.keyCode;
  9990. }
  9991. // Add which for click: 1 === left; 2 === middle; 3 === right
  9992. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  9993. if ( button & 1 ) {
  9994. return 1;
  9995. }
  9996. if ( button & 2 ) {
  9997. return 3;
  9998. }
  9999. if ( button & 4 ) {
  10000. return 2;
  10001. }
  10002. return 0;
  10003. }
  10004. return event.which;
  10005. }
  10006. }, jQuery.event.addProp );
  10007. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  10008. jQuery.event.special[ type ] = {
  10009. // Utilize native event if possible so blur/focus sequence is correct
  10010. setup: function() {
  10011. // Claim the first handler
  10012. // dataPriv.set( this, "focus", ... )
  10013. // dataPriv.set( this, "blur", ... )
  10014. leverageNative( this, type, expectSync );
  10015. // Return false to allow normal processing in the caller
  10016. return false;
  10017. },
  10018. trigger: function() {
  10019. // Force setup before trigger
  10020. leverageNative( this, type );
  10021. // Return non-false to allow normal event-path propagation
  10022. return true;
  10023. },
  10024. delegateType: delegateType
  10025. };
  10026. } );
  10027. // Create mouseenter/leave events using mouseover/out and event-time checks
  10028. // so that event delegation works in jQuery.
  10029. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  10030. //
  10031. // Support: Safari 7 only
  10032. // Safari sends mouseenter too often; see:
  10033. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  10034. // for the description of the bug (it existed in older Chrome versions as well).
  10035. jQuery.each( {
  10036. mouseenter: "mouseover",
  10037. mouseleave: "mouseout",
  10038. pointerenter: "pointerover",
  10039. pointerleave: "pointerout"
  10040. }, function( orig, fix ) {
  10041. jQuery.event.special[ orig ] = {
  10042. delegateType: fix,
  10043. bindType: fix,
  10044. handle: function( event ) {
  10045. var ret,
  10046. target = this,
  10047. related = event.relatedTarget,
  10048. handleObj = event.handleObj;
  10049. // For mouseenter/leave call the handler if related is outside the target.
  10050. // NB: No relatedTarget if the mouse left/entered the browser window
  10051. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  10052. event.type = handleObj.origType;
  10053. ret = handleObj.handler.apply( this, arguments );
  10054. event.type = fix;
  10055. }
  10056. return ret;
  10057. }
  10058. };
  10059. } );
  10060. jQuery.fn.extend( {
  10061. on: function( types, selector, data, fn ) {
  10062. return on( this, types, selector, data, fn );
  10063. },
  10064. one: function( types, selector, data, fn ) {
  10065. return on( this, types, selector, data, fn, 1 );
  10066. },
  10067. off: function( types, selector, fn ) {
  10068. var handleObj, type;
  10069. if ( types && types.preventDefault && types.handleObj ) {
  10070. // ( event ) dispatched jQuery.Event
  10071. handleObj = types.handleObj;
  10072. jQuery( types.delegateTarget ).off(
  10073. handleObj.namespace ?
  10074. handleObj.origType + "." + handleObj.namespace :
  10075. handleObj.origType,
  10076. handleObj.selector,
  10077. handleObj.handler
  10078. );
  10079. return this;
  10080. }
  10081. if ( typeof types === "object" ) {
  10082. // ( types-object [, selector] )
  10083. for ( type in types ) {
  10084. this.off( type, selector, types[ type ] );
  10085. }
  10086. return this;
  10087. }
  10088. if ( selector === false || typeof selector === "function" ) {
  10089. // ( types [, fn] )
  10090. fn = selector;
  10091. selector = undefined;
  10092. }
  10093. if ( fn === false ) {
  10094. fn = returnFalse;
  10095. }
  10096. return this.each( function() {
  10097. jQuery.event.remove( this, types, fn, selector );
  10098. } );
  10099. }
  10100. } );
  10101. var
  10102. // Support: IE <=10 - 11, Edge 12 - 13 only
  10103. // In IE/Edge using regex groups here causes severe slowdowns.
  10104. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  10105. rnoInnerhtml = /<script|<style|<link/i,
  10106. // checked="checked" or checked
  10107. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  10108. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  10109. // Prefer a tbody over its parent table for containing new rows
  10110. function manipulationTarget( elem, content ) {
  10111. if ( nodeName( elem, "table" ) &&
  10112. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  10113. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  10114. }
  10115. return elem;
  10116. }
  10117. // Replace/restore the type attribute of script elements for safe DOM manipulation
  10118. function disableScript( elem ) {
  10119. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  10120. return elem;
  10121. }
  10122. function restoreScript( elem ) {
  10123. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  10124. elem.type = elem.type.slice( 5 );
  10125. } else {
  10126. elem.removeAttribute( "type" );
  10127. }
  10128. return elem;
  10129. }
  10130. function cloneCopyEvent( src, dest ) {
  10131. var i, l, type, pdataOld, udataOld, udataCur, events;
  10132. if ( dest.nodeType !== 1 ) {
  10133. return;
  10134. }
  10135. // 1. Copy private data: events, handlers, etc.
  10136. if ( dataPriv.hasData( src ) ) {
  10137. pdataOld = dataPriv.get( src );
  10138. events = pdataOld.events;
  10139. if ( events ) {
  10140. dataPriv.remove( dest, "handle events" );
  10141. for ( type in events ) {
  10142. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  10143. jQuery.event.add( dest, type, events[ type ][ i ] );
  10144. }
  10145. }
  10146. }
  10147. }
  10148. // 2. Copy user data
  10149. if ( dataUser.hasData( src ) ) {
  10150. udataOld = dataUser.access( src );
  10151. udataCur = jQuery.extend( {}, udataOld );
  10152. dataUser.set( dest, udataCur );
  10153. }
  10154. }
  10155. // Fix IE bugs, see support tests
  10156. function fixInput( src, dest ) {
  10157. var nodeName = dest.nodeName.toLowerCase();
  10158. // Fails to persist the checked state of a cloned checkbox or radio button.
  10159. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  10160. dest.checked = src.checked;
  10161. // Fails to return the selected option to the default selected state when cloning options
  10162. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  10163. dest.defaultValue = src.defaultValue;
  10164. }
  10165. }
  10166. function domManip( collection, args, callback, ignored ) {
  10167. // Flatten any nested arrays
  10168. args = flat( args );
  10169. var fragment, first, scripts, hasScripts, node, doc,
  10170. i = 0,
  10171. l = collection.length,
  10172. iNoClone = l - 1,
  10173. value = args[ 0 ],
  10174. valueIsFunction = isFunction( value );
  10175. // We can't cloneNode fragments that contain checked, in WebKit
  10176. if ( valueIsFunction ||
  10177. ( l > 1 && typeof value === "string" &&
  10178. !support.checkClone && rchecked.test( value ) ) ) {
  10179. return collection.each( function( index ) {
  10180. var self = collection.eq( index );
  10181. if ( valueIsFunction ) {
  10182. args[ 0 ] = value.call( this, index, self.html() );
  10183. }
  10184. domManip( self, args, callback, ignored );
  10185. } );
  10186. }
  10187. if ( l ) {
  10188. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  10189. first = fragment.firstChild;
  10190. if ( fragment.childNodes.length === 1 ) {
  10191. fragment = first;
  10192. }
  10193. // Require either new content or an interest in ignored elements to invoke the callback
  10194. if ( first || ignored ) {
  10195. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  10196. hasScripts = scripts.length;
  10197. // Use the original fragment for the last item
  10198. // instead of the first because it can end up
  10199. // being emptied incorrectly in certain situations (#8070).
  10200. for ( ; i < l; i++ ) {
  10201. node = fragment;
  10202. if ( i !== iNoClone ) {
  10203. node = jQuery.clone( node, true, true );
  10204. // Keep references to cloned scripts for later restoration
  10205. if ( hasScripts ) {
  10206. // Support: Android <=4.0 only, PhantomJS 1 only
  10207. // push.apply(_, arraylike) throws on ancient WebKit
  10208. jQuery.merge( scripts, getAll( node, "script" ) );
  10209. }
  10210. }
  10211. callback.call( collection[ i ], node, i );
  10212. }
  10213. if ( hasScripts ) {
  10214. doc = scripts[ scripts.length - 1 ].ownerDocument;
  10215. // Reenable scripts
  10216. jQuery.map( scripts, restoreScript );
  10217. // Evaluate executable scripts on first document insertion
  10218. for ( i = 0; i < hasScripts; i++ ) {
  10219. node = scripts[ i ];
  10220. if ( rscriptType.test( node.type || "" ) &&
  10221. !dataPriv.access( node, "globalEval" ) &&
  10222. jQuery.contains( doc, node ) ) {
  10223. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  10224. // Optional AJAX dependency, but won't run scripts if not present
  10225. if ( jQuery._evalUrl && !node.noModule ) {
  10226. jQuery._evalUrl( node.src, {
  10227. nonce: node.nonce || node.getAttribute( "nonce" )
  10228. }, doc );
  10229. }
  10230. } else {
  10231. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  10232. }
  10233. }
  10234. }
  10235. }
  10236. }
  10237. }
  10238. return collection;
  10239. }
  10240. function remove( elem, selector, keepData ) {
  10241. var node,
  10242. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  10243. i = 0;
  10244. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  10245. if ( !keepData && node.nodeType === 1 ) {
  10246. jQuery.cleanData( getAll( node ) );
  10247. }
  10248. if ( node.parentNode ) {
  10249. if ( keepData && isAttached( node ) ) {
  10250. setGlobalEval( getAll( node, "script" ) );
  10251. }
  10252. node.parentNode.removeChild( node );
  10253. }
  10254. }
  10255. return elem;
  10256. }
  10257. jQuery.extend( {
  10258. htmlPrefilter: function( html ) {
  10259. return html;
  10260. },
  10261. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  10262. var i, l, srcElements, destElements,
  10263. clone = elem.cloneNode( true ),
  10264. inPage = isAttached( elem );
  10265. // Fix IE cloning issues
  10266. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  10267. !jQuery.isXMLDoc( elem ) ) {
  10268. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  10269. destElements = getAll( clone );
  10270. srcElements = getAll( elem );
  10271. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10272. fixInput( srcElements[ i ], destElements[ i ] );
  10273. }
  10274. }
  10275. // Copy the events from the original to the clone
  10276. if ( dataAndEvents ) {
  10277. if ( deepDataAndEvents ) {
  10278. srcElements = srcElements || getAll( elem );
  10279. destElements = destElements || getAll( clone );
  10280. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10281. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  10282. }
  10283. } else {
  10284. cloneCopyEvent( elem, clone );
  10285. }
  10286. }
  10287. // Preserve script evaluation history
  10288. destElements = getAll( clone, "script" );
  10289. if ( destElements.length > 0 ) {
  10290. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  10291. }
  10292. // Return the cloned set
  10293. return clone;
  10294. },
  10295. cleanData: function( elems ) {
  10296. var data, elem, type,
  10297. special = jQuery.event.special,
  10298. i = 0;
  10299. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  10300. if ( acceptData( elem ) ) {
  10301. if ( ( data = elem[ dataPriv.expando ] ) ) {
  10302. if ( data.events ) {
  10303. for ( type in data.events ) {
  10304. if ( special[ type ] ) {
  10305. jQuery.event.remove( elem, type );
  10306. // This is a shortcut to avoid jQuery.event.remove's overhead
  10307. } else {
  10308. jQuery.removeEvent( elem, type, data.handle );
  10309. }
  10310. }
  10311. }
  10312. // Support: Chrome <=35 - 45+
  10313. // Assign undefined instead of using delete, see Data#remove
  10314. elem[ dataPriv.expando ] = undefined;
  10315. }
  10316. if ( elem[ dataUser.expando ] ) {
  10317. // Support: Chrome <=35 - 45+
  10318. // Assign undefined instead of using delete, see Data#remove
  10319. elem[ dataUser.expando ] = undefined;
  10320. }
  10321. }
  10322. }
  10323. }
  10324. } );
  10325. jQuery.fn.extend( {
  10326. detach: function( selector ) {
  10327. return remove( this, selector, true );
  10328. },
  10329. remove: function( selector ) {
  10330. return remove( this, selector );
  10331. },
  10332. text: function( value ) {
  10333. return access( this, function( value ) {
  10334. return value === undefined ?
  10335. jQuery.text( this ) :
  10336. this.empty().each( function() {
  10337. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10338. this.textContent = value;
  10339. }
  10340. } );
  10341. }, null, value, arguments.length );
  10342. },
  10343. append: function() {
  10344. return domManip( this, arguments, function( elem ) {
  10345. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10346. var target = manipulationTarget( this, elem );
  10347. target.appendChild( elem );
  10348. }
  10349. } );
  10350. },
  10351. prepend: function() {
  10352. return domManip( this, arguments, function( elem ) {
  10353. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10354. var target = manipulationTarget( this, elem );
  10355. target.insertBefore( elem, target.firstChild );
  10356. }
  10357. } );
  10358. },
  10359. before: function() {
  10360. return domManip( this, arguments, function( elem ) {
  10361. if ( this.parentNode ) {
  10362. this.parentNode.insertBefore( elem, this );
  10363. }
  10364. } );
  10365. },
  10366. after: function() {
  10367. return domManip( this, arguments, function( elem ) {
  10368. if ( this.parentNode ) {
  10369. this.parentNode.insertBefore( elem, this.nextSibling );
  10370. }
  10371. } );
  10372. },
  10373. empty: function() {
  10374. var elem,
  10375. i = 0;
  10376. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  10377. if ( elem.nodeType === 1 ) {
  10378. // Prevent memory leaks
  10379. jQuery.cleanData( getAll( elem, false ) );
  10380. // Remove any remaining nodes
  10381. elem.textContent = "";
  10382. }
  10383. }
  10384. return this;
  10385. },
  10386. clone: function( dataAndEvents, deepDataAndEvents ) {
  10387. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  10388. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  10389. return this.map( function() {
  10390. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  10391. } );
  10392. },
  10393. html: function( value ) {
  10394. return access( this, function( value ) {
  10395. var elem = this[ 0 ] || {},
  10396. i = 0,
  10397. l = this.length;
  10398. if ( value === undefined && elem.nodeType === 1 ) {
  10399. return elem.innerHTML;
  10400. }
  10401. // See if we can take a shortcut and just use innerHTML
  10402. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  10403. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  10404. value = jQuery.htmlPrefilter( value );
  10405. try {
  10406. for ( ; i < l; i++ ) {
  10407. elem = this[ i ] || {};
  10408. // Remove element nodes and prevent memory leaks
  10409. if ( elem.nodeType === 1 ) {
  10410. jQuery.cleanData( getAll( elem, false ) );
  10411. elem.innerHTML = value;
  10412. }
  10413. }
  10414. elem = 0;
  10415. // If using innerHTML throws an exception, use the fallback method
  10416. } catch ( e ) {}
  10417. }
  10418. if ( elem ) {
  10419. this.empty().append( value );
  10420. }
  10421. }, null, value, arguments.length );
  10422. },
  10423. replaceWith: function() {
  10424. var ignored = [];
  10425. // Make the changes, replacing each non-ignored context element with the new content
  10426. return domManip( this, arguments, function( elem ) {
  10427. var parent = this.parentNode;
  10428. if ( jQuery.inArray( this, ignored ) < 0 ) {
  10429. jQuery.cleanData( getAll( this ) );
  10430. if ( parent ) {
  10431. parent.replaceChild( elem, this );
  10432. }
  10433. }
  10434. // Force callback invocation
  10435. }, ignored );
  10436. }
  10437. } );
  10438. jQuery.each( {
  10439. appendTo: "append",
  10440. prependTo: "prepend",
  10441. insertBefore: "before",
  10442. insertAfter: "after",
  10443. replaceAll: "replaceWith"
  10444. }, function( name, original ) {
  10445. jQuery.fn[ name ] = function( selector ) {
  10446. var elems,
  10447. ret = [],
  10448. insert = jQuery( selector ),
  10449. last = insert.length - 1,
  10450. i = 0;
  10451. for ( ; i <= last; i++ ) {
  10452. elems = i === last ? this : this.clone( true );
  10453. jQuery( insert[ i ] )[ original ]( elems );
  10454. // Support: Android <=4.0 only, PhantomJS 1 only
  10455. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  10456. push.apply( ret, elems.get() );
  10457. }
  10458. return this.pushStack( ret );
  10459. };
  10460. } );
  10461. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  10462. var getStyles = function( elem ) {
  10463. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  10464. // IE throws on elements created in popups
  10465. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  10466. var view = elem.ownerDocument.defaultView;
  10467. if ( !view || !view.opener ) {
  10468. view = window;
  10469. }
  10470. return view.getComputedStyle( elem );
  10471. };
  10472. var swap = function( elem, options, callback ) {
  10473. var ret, name,
  10474. old = {};
  10475. // Remember the old values, and insert the new ones
  10476. for ( name in options ) {
  10477. old[ name ] = elem.style[ name ];
  10478. elem.style[ name ] = options[ name ];
  10479. }
  10480. ret = callback.call( elem );
  10481. // Revert the old values
  10482. for ( name in options ) {
  10483. elem.style[ name ] = old[ name ];
  10484. }
  10485. return ret;
  10486. };
  10487. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  10488. ( function() {
  10489. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  10490. // so they're executed at the same time to save the second computation.
  10491. function computeStyleTests() {
  10492. // This is a singleton, we need to execute it only once
  10493. if ( !div ) {
  10494. return;
  10495. }
  10496. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  10497. "margin-top:1px;padding:0;border:0";
  10498. div.style.cssText =
  10499. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  10500. "margin:auto;border:1px;padding:1px;" +
  10501. "width:60%;top:1%";
  10502. documentElement.appendChild( container ).appendChild( div );
  10503. var divStyle = window.getComputedStyle( div );
  10504. pixelPositionVal = divStyle.top !== "1%";
  10505. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  10506. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  10507. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  10508. // Some styles come back with percentage values, even though they shouldn't
  10509. div.style.right = "60%";
  10510. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  10511. // Support: IE 9 - 11 only
  10512. // Detect misreporting of content dimensions for box-sizing:border-box elements
  10513. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  10514. // Support: IE 9 only
  10515. // Detect overflow:scroll screwiness (gh-3699)
  10516. // Support: Chrome <=64
  10517. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  10518. div.style.position = "absolute";
  10519. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  10520. documentElement.removeChild( container );
  10521. // Nullify the div so it wouldn't be stored in the memory and
  10522. // it will also be a sign that checks already performed
  10523. div = null;
  10524. }
  10525. function roundPixelMeasures( measure ) {
  10526. return Math.round( parseFloat( measure ) );
  10527. }
  10528. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  10529. reliableTrDimensionsVal, reliableMarginLeftVal,
  10530. container = document.createElement( "div" ),
  10531. div = document.createElement( "div" );
  10532. // Finish early in limited (non-browser) environments
  10533. if ( !div.style ) {
  10534. return;
  10535. }
  10536. // Support: IE <=9 - 11 only
  10537. // Style of cloned element affects source element cloned (#8908)
  10538. div.style.backgroundClip = "content-box";
  10539. div.cloneNode( true ).style.backgroundClip = "";
  10540. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  10541. jQuery.extend( support, {
  10542. boxSizingReliable: function() {
  10543. computeStyleTests();
  10544. return boxSizingReliableVal;
  10545. },
  10546. pixelBoxStyles: function() {
  10547. computeStyleTests();
  10548. return pixelBoxStylesVal;
  10549. },
  10550. pixelPosition: function() {
  10551. computeStyleTests();
  10552. return pixelPositionVal;
  10553. },
  10554. reliableMarginLeft: function() {
  10555. computeStyleTests();
  10556. return reliableMarginLeftVal;
  10557. },
  10558. scrollboxSize: function() {
  10559. computeStyleTests();
  10560. return scrollboxSizeVal;
  10561. },
  10562. // Support: IE 9 - 11+, Edge 15 - 18+
  10563. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  10564. // set in CSS while `offset*` properties report correct values.
  10565. // Behavior in IE 9 is more subtle than in newer versions & it passes
  10566. // some versions of this test; make sure not to make it pass there!
  10567. reliableTrDimensions: function() {
  10568. var table, tr, trChild, trStyle;
  10569. if ( reliableTrDimensionsVal == null ) {
  10570. table = document.createElement( "table" );
  10571. tr = document.createElement( "tr" );
  10572. trChild = document.createElement( "div" );
  10573. table.style.cssText = "position:absolute;left:-11111px";
  10574. tr.style.height = "1px";
  10575. trChild.style.height = "9px";
  10576. documentElement
  10577. .appendChild( table )
  10578. .appendChild( tr )
  10579. .appendChild( trChild );
  10580. trStyle = window.getComputedStyle( tr );
  10581. reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
  10582. documentElement.removeChild( table );
  10583. }
  10584. return reliableTrDimensionsVal;
  10585. }
  10586. } );
  10587. } )();
  10588. function curCSS( elem, name, computed ) {
  10589. var width, minWidth, maxWidth, ret,
  10590. // Support: Firefox 51+
  10591. // Retrieving style before computed somehow
  10592. // fixes an issue with getting wrong values
  10593. // on detached elements
  10594. style = elem.style;
  10595. computed = computed || getStyles( elem );
  10596. // getPropertyValue is needed for:
  10597. // .css('filter') (IE 9 only, #12537)
  10598. // .css('--customProperty) (#3144)
  10599. if ( computed ) {
  10600. ret = computed.getPropertyValue( name ) || computed[ name ];
  10601. if ( ret === "" && !isAttached( elem ) ) {
  10602. ret = jQuery.style( elem, name );
  10603. }
  10604. // A tribute to the "awesome hack by Dean Edwards"
  10605. // Android Browser returns percentage for some values,
  10606. // but width seems to be reliably pixels.
  10607. // This is against the CSSOM draft spec:
  10608. // https://drafts.csswg.org/cssom/#resolved-values
  10609. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  10610. // Remember the original values
  10611. width = style.width;
  10612. minWidth = style.minWidth;
  10613. maxWidth = style.maxWidth;
  10614. // Put in the new values to get a computed value out
  10615. style.minWidth = style.maxWidth = style.width = ret;
  10616. ret = computed.width;
  10617. // Revert the changed values
  10618. style.width = width;
  10619. style.minWidth = minWidth;
  10620. style.maxWidth = maxWidth;
  10621. }
  10622. }
  10623. return ret !== undefined ?
  10624. // Support: IE <=9 - 11 only
  10625. // IE returns zIndex value as an integer.
  10626. ret + "" :
  10627. ret;
  10628. }
  10629. function addGetHookIf( conditionFn, hookFn ) {
  10630. // Define the hook, we'll check on the first run if it's really needed.
  10631. return {
  10632. get: function() {
  10633. if ( conditionFn() ) {
  10634. // Hook not needed (or it's not possible to use it due
  10635. // to missing dependency), remove it.
  10636. delete this.get;
  10637. return;
  10638. }
  10639. // Hook needed; redefine it so that the support test is not executed again.
  10640. return ( this.get = hookFn ).apply( this, arguments );
  10641. }
  10642. };
  10643. }
  10644. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  10645. emptyStyle = document.createElement( "div" ).style,
  10646. vendorProps = {};
  10647. // Return a vendor-prefixed property or undefined
  10648. function vendorPropName( name ) {
  10649. // Check for vendor prefixed names
  10650. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  10651. i = cssPrefixes.length;
  10652. while ( i-- ) {
  10653. name = cssPrefixes[ i ] + capName;
  10654. if ( name in emptyStyle ) {
  10655. return name;
  10656. }
  10657. }
  10658. }
  10659. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  10660. function finalPropName( name ) {
  10661. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  10662. if ( final ) {
  10663. return final;
  10664. }
  10665. if ( name in emptyStyle ) {
  10666. return name;
  10667. }
  10668. return vendorProps[ name ] = vendorPropName( name ) || name;
  10669. }
  10670. var
  10671. // Swappable if display is none or starts with table
  10672. // except "table", "table-cell", or "table-caption"
  10673. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  10674. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  10675. rcustomProp = /^--/,
  10676. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  10677. cssNormalTransform = {
  10678. letterSpacing: "0",
  10679. fontWeight: "400"
  10680. };
  10681. function setPositiveNumber( _elem, value, subtract ) {
  10682. // Any relative (+/-) values have already been
  10683. // normalized at this point
  10684. var matches = rcssNum.exec( value );
  10685. return matches ?
  10686. // Guard against undefined "subtract", e.g., when used as in cssHooks
  10687. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  10688. value;
  10689. }
  10690. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  10691. var i = dimension === "width" ? 1 : 0,
  10692. extra = 0,
  10693. delta = 0;
  10694. // Adjustment may not be necessary
  10695. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  10696. return 0;
  10697. }
  10698. for ( ; i < 4; i += 2 ) {
  10699. // Both box models exclude margin
  10700. if ( box === "margin" ) {
  10701. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  10702. }
  10703. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  10704. if ( !isBorderBox ) {
  10705. // Add padding
  10706. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10707. // For "border" or "margin", add border
  10708. if ( box !== "padding" ) {
  10709. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10710. // But still keep track of it otherwise
  10711. } else {
  10712. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10713. }
  10714. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  10715. // "padding" or "margin"
  10716. } else {
  10717. // For "content", subtract padding
  10718. if ( box === "content" ) {
  10719. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10720. }
  10721. // For "content" or "padding", subtract border
  10722. if ( box !== "margin" ) {
  10723. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10724. }
  10725. }
  10726. }
  10727. // Account for positive content-box scroll gutter when requested by providing computedVal
  10728. if ( !isBorderBox && computedVal >= 0 ) {
  10729. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  10730. // Assuming integer scroll gutter, subtract the rest and round down
  10731. delta += Math.max( 0, Math.ceil(
  10732. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10733. computedVal -
  10734. delta -
  10735. extra -
  10736. 0.5
  10737. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  10738. // Use an explicit zero to avoid NaN (gh-3964)
  10739. ) ) || 0;
  10740. }
  10741. return delta;
  10742. }
  10743. function getWidthOrHeight( elem, dimension, extra ) {
  10744. // Start with computed style
  10745. var styles = getStyles( elem ),
  10746. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  10747. // Fake content-box until we know it's needed to know the true value.
  10748. boxSizingNeeded = !support.boxSizingReliable() || extra,
  10749. isBorderBox = boxSizingNeeded &&
  10750. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10751. valueIsBorderBox = isBorderBox,
  10752. val = curCSS( elem, dimension, styles ),
  10753. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  10754. // Support: Firefox <=54
  10755. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  10756. if ( rnumnonpx.test( val ) ) {
  10757. if ( !extra ) {
  10758. return val;
  10759. }
  10760. val = "auto";
  10761. }
  10762. // Support: IE 9 - 11 only
  10763. // Use offsetWidth/offsetHeight for when box sizing is unreliable.
  10764. // In those cases, the computed value can be trusted to be border-box.
  10765. if ( ( !support.boxSizingReliable() && isBorderBox ||
  10766. // Support: IE 10 - 11+, Edge 15 - 18+
  10767. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  10768. // set in CSS while `offset*` properties report correct values.
  10769. // Interestingly, in some cases IE 9 doesn't suffer from this issue.
  10770. !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
  10771. // Fall back to offsetWidth/offsetHeight when value is "auto"
  10772. // This happens for inline elements with no explicit setting (gh-3571)
  10773. val === "auto" ||
  10774. // Support: Android <=4.1 - 4.3 only
  10775. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  10776. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  10777. // Make sure the element is visible & connected
  10778. elem.getClientRects().length ) {
  10779. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  10780. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  10781. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  10782. // retrieved value as a content box dimension.
  10783. valueIsBorderBox = offsetProp in elem;
  10784. if ( valueIsBorderBox ) {
  10785. val = elem[ offsetProp ];
  10786. }
  10787. }
  10788. // Normalize "" and auto
  10789. val = parseFloat( val ) || 0;
  10790. // Adjust for the element's box model
  10791. return ( val +
  10792. boxModelAdjustment(
  10793. elem,
  10794. dimension,
  10795. extra || ( isBorderBox ? "border" : "content" ),
  10796. valueIsBorderBox,
  10797. styles,
  10798. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  10799. val
  10800. )
  10801. ) + "px";
  10802. }
  10803. jQuery.extend( {
  10804. // Add in style property hooks for overriding the default
  10805. // behavior of getting and setting a style property
  10806. cssHooks: {
  10807. opacity: {
  10808. get: function( elem, computed ) {
  10809. if ( computed ) {
  10810. // We should always get a number back from opacity
  10811. var ret = curCSS( elem, "opacity" );
  10812. return ret === "" ? "1" : ret;
  10813. }
  10814. }
  10815. }
  10816. },
  10817. // Don't automatically add "px" to these possibly-unitless properties
  10818. cssNumber: {
  10819. "animationIterationCount": true,
  10820. "columnCount": true,
  10821. "fillOpacity": true,
  10822. "flexGrow": true,
  10823. "flexShrink": true,
  10824. "fontWeight": true,
  10825. "gridArea": true,
  10826. "gridColumn": true,
  10827. "gridColumnEnd": true,
  10828. "gridColumnStart": true,
  10829. "gridRow": true,
  10830. "gridRowEnd": true,
  10831. "gridRowStart": true,
  10832. "lineHeight": true,
  10833. "opacity": true,
  10834. "order": true,
  10835. "orphans": true,
  10836. "widows": true,
  10837. "zIndex": true,
  10838. "zoom": true
  10839. },
  10840. // Add in properties whose names you wish to fix before
  10841. // setting or getting the value
  10842. cssProps: {},
  10843. // Get and set the style property on a DOM Node
  10844. style: function( elem, name, value, extra ) {
  10845. // Don't set styles on text and comment nodes
  10846. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  10847. return;
  10848. }
  10849. // Make sure that we're working with the right name
  10850. var ret, type, hooks,
  10851. origName = camelCase( name ),
  10852. isCustomProp = rcustomProp.test( name ),
  10853. style = elem.style;
  10854. // Make sure that we're working with the right name. We don't
  10855. // want to query the value if it is a CSS custom property
  10856. // since they are user-defined.
  10857. if ( !isCustomProp ) {
  10858. name = finalPropName( origName );
  10859. }
  10860. // Gets hook for the prefixed version, then unprefixed version
  10861. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10862. // Check if we're setting a value
  10863. if ( value !== undefined ) {
  10864. type = typeof value;
  10865. // Convert "+=" or "-=" to relative numbers (#7345)
  10866. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  10867. value = adjustCSS( elem, name, ret );
  10868. // Fixes bug #9237
  10869. type = "number";
  10870. }
  10871. // Make sure that null and NaN values aren't set (#7116)
  10872. if ( value == null || value !== value ) {
  10873. return;
  10874. }
  10875. // If a number was passed in, add the unit (except for certain CSS properties)
  10876. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  10877. // "px" to a few hardcoded values.
  10878. if ( type === "number" && !isCustomProp ) {
  10879. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  10880. }
  10881. // background-* props affect original clone's values
  10882. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  10883. style[ name ] = "inherit";
  10884. }
  10885. // If a hook was provided, use that value, otherwise just set the specified value
  10886. if ( !hooks || !( "set" in hooks ) ||
  10887. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  10888. if ( isCustomProp ) {
  10889. style.setProperty( name, value );
  10890. } else {
  10891. style[ name ] = value;
  10892. }
  10893. }
  10894. } else {
  10895. // If a hook was provided get the non-computed value from there
  10896. if ( hooks && "get" in hooks &&
  10897. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  10898. return ret;
  10899. }
  10900. // Otherwise just get the value from the style object
  10901. return style[ name ];
  10902. }
  10903. },
  10904. css: function( elem, name, extra, styles ) {
  10905. var val, num, hooks,
  10906. origName = camelCase( name ),
  10907. isCustomProp = rcustomProp.test( name );
  10908. // Make sure that we're working with the right name. We don't
  10909. // want to modify the value if it is a CSS custom property
  10910. // since they are user-defined.
  10911. if ( !isCustomProp ) {
  10912. name = finalPropName( origName );
  10913. }
  10914. // Try prefixed name followed by the unprefixed name
  10915. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10916. // If a hook was provided get the computed value from there
  10917. if ( hooks && "get" in hooks ) {
  10918. val = hooks.get( elem, true, extra );
  10919. }
  10920. // Otherwise, if a way to get the computed value exists, use that
  10921. if ( val === undefined ) {
  10922. val = curCSS( elem, name, styles );
  10923. }
  10924. // Convert "normal" to computed value
  10925. if ( val === "normal" && name in cssNormalTransform ) {
  10926. val = cssNormalTransform[ name ];
  10927. }
  10928. // Make numeric if forced or a qualifier was provided and val looks numeric
  10929. if ( extra === "" || extra ) {
  10930. num = parseFloat( val );
  10931. return extra === true || isFinite( num ) ? num || 0 : val;
  10932. }
  10933. return val;
  10934. }
  10935. } );
  10936. jQuery.each( [ "height", "width" ], function( _i, dimension ) {
  10937. jQuery.cssHooks[ dimension ] = {
  10938. get: function( elem, computed, extra ) {
  10939. if ( computed ) {
  10940. // Certain elements can have dimension info if we invisibly show them
  10941. // but it must have a current display style that would benefit
  10942. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  10943. // Support: Safari 8+
  10944. // Table columns in Safari have non-zero offsetWidth & zero
  10945. // getBoundingClientRect().width unless display is changed.
  10946. // Support: IE <=11 only
  10947. // Running getBoundingClientRect on a disconnected node
  10948. // in IE throws an error.
  10949. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  10950. swap( elem, cssShow, function() {
  10951. return getWidthOrHeight( elem, dimension, extra );
  10952. } ) :
  10953. getWidthOrHeight( elem, dimension, extra );
  10954. }
  10955. },
  10956. set: function( elem, value, extra ) {
  10957. var matches,
  10958. styles = getStyles( elem ),
  10959. // Only read styles.position if the test has a chance to fail
  10960. // to avoid forcing a reflow.
  10961. scrollboxSizeBuggy = !support.scrollboxSize() &&
  10962. styles.position === "absolute",
  10963. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  10964. boxSizingNeeded = scrollboxSizeBuggy || extra,
  10965. isBorderBox = boxSizingNeeded &&
  10966. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10967. subtract = extra ?
  10968. boxModelAdjustment(
  10969. elem,
  10970. dimension,
  10971. extra,
  10972. isBorderBox,
  10973. styles
  10974. ) :
  10975. 0;
  10976. // Account for unreliable border-box dimensions by comparing offset* to computed and
  10977. // faking a content-box to get border and padding (gh-3699)
  10978. if ( isBorderBox && scrollboxSizeBuggy ) {
  10979. subtract -= Math.ceil(
  10980. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10981. parseFloat( styles[ dimension ] ) -
  10982. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  10983. 0.5
  10984. );
  10985. }
  10986. // Convert to pixels if value adjustment is needed
  10987. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  10988. ( matches[ 3 ] || "px" ) !== "px" ) {
  10989. elem.style[ dimension ] = value;
  10990. value = jQuery.css( elem, dimension );
  10991. }
  10992. return setPositiveNumber( elem, value, subtract );
  10993. }
  10994. };
  10995. } );
  10996. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  10997. function( elem, computed ) {
  10998. if ( computed ) {
  10999. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  11000. elem.getBoundingClientRect().left -
  11001. swap( elem, { marginLeft: 0 }, function() {
  11002. return elem.getBoundingClientRect().left;
  11003. } )
  11004. ) + "px";
  11005. }
  11006. }
  11007. );
  11008. // These hooks are used by animate to expand properties
  11009. jQuery.each( {
  11010. margin: "",
  11011. padding: "",
  11012. border: "Width"
  11013. }, function( prefix, suffix ) {
  11014. jQuery.cssHooks[ prefix + suffix ] = {
  11015. expand: function( value ) {
  11016. var i = 0,
  11017. expanded = {},
  11018. // Assumes a single number if not a string
  11019. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  11020. for ( ; i < 4; i++ ) {
  11021. expanded[ prefix + cssExpand[ i ] + suffix ] =
  11022. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  11023. }
  11024. return expanded;
  11025. }
  11026. };
  11027. if ( prefix !== "margin" ) {
  11028. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  11029. }
  11030. } );
  11031. jQuery.fn.extend( {
  11032. css: function( name, value ) {
  11033. return access( this, function( elem, name, value ) {
  11034. var styles, len,
  11035. map = {},
  11036. i = 0;
  11037. if ( Array.isArray( name ) ) {
  11038. styles = getStyles( elem );
  11039. len = name.length;
  11040. for ( ; i < len; i++ ) {
  11041. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  11042. }
  11043. return map;
  11044. }
  11045. return value !== undefined ?
  11046. jQuery.style( elem, name, value ) :
  11047. jQuery.css( elem, name );
  11048. }, name, value, arguments.length > 1 );
  11049. }
  11050. } );
  11051. function Tween( elem, options, prop, end, easing ) {
  11052. return new Tween.prototype.init( elem, options, prop, end, easing );
  11053. }
  11054. jQuery.Tween = Tween;
  11055. Tween.prototype = {
  11056. constructor: Tween,
  11057. init: function( elem, options, prop, end, easing, unit ) {
  11058. this.elem = elem;
  11059. this.prop = prop;
  11060. this.easing = easing || jQuery.easing._default;
  11061. this.options = options;
  11062. this.start = this.now = this.cur();
  11063. this.end = end;
  11064. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  11065. },
  11066. cur: function() {
  11067. var hooks = Tween.propHooks[ this.prop ];
  11068. return hooks && hooks.get ?
  11069. hooks.get( this ) :
  11070. Tween.propHooks._default.get( this );
  11071. },
  11072. run: function( percent ) {
  11073. var eased,
  11074. hooks = Tween.propHooks[ this.prop ];
  11075. if ( this.options.duration ) {
  11076. this.pos = eased = jQuery.easing[ this.easing ](
  11077. percent, this.options.duration * percent, 0, 1, this.options.duration
  11078. );
  11079. } else {
  11080. this.pos = eased = percent;
  11081. }
  11082. this.now = ( this.end - this.start ) * eased + this.start;
  11083. if ( this.options.step ) {
  11084. this.options.step.call( this.elem, this.now, this );
  11085. }
  11086. if ( hooks && hooks.set ) {
  11087. hooks.set( this );
  11088. } else {
  11089. Tween.propHooks._default.set( this );
  11090. }
  11091. return this;
  11092. }
  11093. };
  11094. Tween.prototype.init.prototype = Tween.prototype;
  11095. Tween.propHooks = {
  11096. _default: {
  11097. get: function( tween ) {
  11098. var result;
  11099. // Use a property on the element directly when it is not a DOM element,
  11100. // or when there is no matching style property that exists.
  11101. if ( tween.elem.nodeType !== 1 ||
  11102. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  11103. return tween.elem[ tween.prop ];
  11104. }
  11105. // Passing an empty string as a 3rd parameter to .css will automatically
  11106. // attempt a parseFloat and fallback to a string if the parse fails.
  11107. // Simple values such as "10px" are parsed to Float;
  11108. // complex values such as "rotate(1rad)" are returned as-is.
  11109. result = jQuery.css( tween.elem, tween.prop, "" );
  11110. // Empty strings, null, undefined and "auto" are converted to 0.
  11111. return !result || result === "auto" ? 0 : result;
  11112. },
  11113. set: function( tween ) {
  11114. // Use step hook for back compat.
  11115. // Use cssHook if its there.
  11116. // Use .style if available and use plain properties where available.
  11117. if ( jQuery.fx.step[ tween.prop ] ) {
  11118. jQuery.fx.step[ tween.prop ]( tween );
  11119. } else if ( tween.elem.nodeType === 1 && (
  11120. jQuery.cssHooks[ tween.prop ] ||
  11121. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  11122. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  11123. } else {
  11124. tween.elem[ tween.prop ] = tween.now;
  11125. }
  11126. }
  11127. }
  11128. };
  11129. // Support: IE <=9 only
  11130. // Panic based approach to setting things on disconnected nodes
  11131. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  11132. set: function( tween ) {
  11133. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  11134. tween.elem[ tween.prop ] = tween.now;
  11135. }
  11136. }
  11137. };
  11138. jQuery.easing = {
  11139. linear: function( p ) {
  11140. return p;
  11141. },
  11142. swing: function( p ) {
  11143. return 0.5 - Math.cos( p * Math.PI ) / 2;
  11144. },
  11145. _default: "swing"
  11146. };
  11147. jQuery.fx = Tween.prototype.init;
  11148. // Back compat <1.8 extension point
  11149. jQuery.fx.step = {};
  11150. var
  11151. fxNow, inProgress,
  11152. rfxtypes = /^(?:toggle|show|hide)$/,
  11153. rrun = /queueHooks$/;
  11154. function schedule() {
  11155. if ( inProgress ) {
  11156. if ( document.hidden === false && window.requestAnimationFrame ) {
  11157. window.requestAnimationFrame( schedule );
  11158. } else {
  11159. window.setTimeout( schedule, jQuery.fx.interval );
  11160. }
  11161. jQuery.fx.tick();
  11162. }
  11163. }
  11164. // Animations created synchronously will run synchronously
  11165. function createFxNow() {
  11166. window.setTimeout( function() {
  11167. fxNow = undefined;
  11168. } );
  11169. return ( fxNow = Date.now() );
  11170. }
  11171. // Generate parameters to create a standard animation
  11172. function genFx( type, includeWidth ) {
  11173. var which,
  11174. i = 0,
  11175. attrs = { height: type };
  11176. // If we include width, step value is 1 to do all cssExpand values,
  11177. // otherwise step value is 2 to skip over Left and Right
  11178. includeWidth = includeWidth ? 1 : 0;
  11179. for ( ; i < 4; i += 2 - includeWidth ) {
  11180. which = cssExpand[ i ];
  11181. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  11182. }
  11183. if ( includeWidth ) {
  11184. attrs.opacity = attrs.width = type;
  11185. }
  11186. return attrs;
  11187. }
  11188. function createTween( value, prop, animation ) {
  11189. var tween,
  11190. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  11191. index = 0,
  11192. length = collection.length;
  11193. for ( ; index < length; index++ ) {
  11194. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  11195. // We're done with this property
  11196. return tween;
  11197. }
  11198. }
  11199. }
  11200. function defaultPrefilter( elem, props, opts ) {
  11201. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  11202. isBox = "width" in props || "height" in props,
  11203. anim = this,
  11204. orig = {},
  11205. style = elem.style,
  11206. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  11207. dataShow = dataPriv.get( elem, "fxshow" );
  11208. // Queue-skipping animations hijack the fx hooks
  11209. if ( !opts.queue ) {
  11210. hooks = jQuery._queueHooks( elem, "fx" );
  11211. if ( hooks.unqueued == null ) {
  11212. hooks.unqueued = 0;
  11213. oldfire = hooks.empty.fire;
  11214. hooks.empty.fire = function() {
  11215. if ( !hooks.unqueued ) {
  11216. oldfire();
  11217. }
  11218. };
  11219. }
  11220. hooks.unqueued++;
  11221. anim.always( function() {
  11222. // Ensure the complete handler is called before this completes
  11223. anim.always( function() {
  11224. hooks.unqueued--;
  11225. if ( !jQuery.queue( elem, "fx" ).length ) {
  11226. hooks.empty.fire();
  11227. }
  11228. } );
  11229. } );
  11230. }
  11231. // Detect show/hide animations
  11232. for ( prop in props ) {
  11233. value = props[ prop ];
  11234. if ( rfxtypes.test( value ) ) {
  11235. delete props[ prop ];
  11236. toggle = toggle || value === "toggle";
  11237. if ( value === ( hidden ? "hide" : "show" ) ) {
  11238. // Pretend to be hidden if this is a "show" and
  11239. // there is still data from a stopped show/hide
  11240. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  11241. hidden = true;
  11242. // Ignore all other no-op show/hide data
  11243. } else {
  11244. continue;
  11245. }
  11246. }
  11247. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  11248. }
  11249. }
  11250. // Bail out if this is a no-op like .hide().hide()
  11251. propTween = !jQuery.isEmptyObject( props );
  11252. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  11253. return;
  11254. }
  11255. // Restrict "overflow" and "display" styles during box animations
  11256. if ( isBox && elem.nodeType === 1 ) {
  11257. // Support: IE <=9 - 11, Edge 12 - 15
  11258. // Record all 3 overflow attributes because IE does not infer the shorthand
  11259. // from identically-valued overflowX and overflowY and Edge just mirrors
  11260. // the overflowX value there.
  11261. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  11262. // Identify a display type, preferring old show/hide data over the CSS cascade
  11263. restoreDisplay = dataShow && dataShow.display;
  11264. if ( restoreDisplay == null ) {
  11265. restoreDisplay = dataPriv.get( elem, "display" );
  11266. }
  11267. display = jQuery.css( elem, "display" );
  11268. if ( display === "none" ) {
  11269. if ( restoreDisplay ) {
  11270. display = restoreDisplay;
  11271. } else {
  11272. // Get nonempty value(s) by temporarily forcing visibility
  11273. showHide( [ elem ], true );
  11274. restoreDisplay = elem.style.display || restoreDisplay;
  11275. display = jQuery.css( elem, "display" );
  11276. showHide( [ elem ] );
  11277. }
  11278. }
  11279. // Animate inline elements as inline-block
  11280. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  11281. if ( jQuery.css( elem, "float" ) === "none" ) {
  11282. // Restore the original display value at the end of pure show/hide animations
  11283. if ( !propTween ) {
  11284. anim.done( function() {
  11285. style.display = restoreDisplay;
  11286. } );
  11287. if ( restoreDisplay == null ) {
  11288. display = style.display;
  11289. restoreDisplay = display === "none" ? "" : display;
  11290. }
  11291. }
  11292. style.display = "inline-block";
  11293. }
  11294. }
  11295. }
  11296. if ( opts.overflow ) {
  11297. style.overflow = "hidden";
  11298. anim.always( function() {
  11299. style.overflow = opts.overflow[ 0 ];
  11300. style.overflowX = opts.overflow[ 1 ];
  11301. style.overflowY = opts.overflow[ 2 ];
  11302. } );
  11303. }
  11304. // Implement show/hide animations
  11305. propTween = false;
  11306. for ( prop in orig ) {
  11307. // General show/hide setup for this element animation
  11308. if ( !propTween ) {
  11309. if ( dataShow ) {
  11310. if ( "hidden" in dataShow ) {
  11311. hidden = dataShow.hidden;
  11312. }
  11313. } else {
  11314. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  11315. }
  11316. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  11317. if ( toggle ) {
  11318. dataShow.hidden = !hidden;
  11319. }
  11320. // Show elements before animating them
  11321. if ( hidden ) {
  11322. showHide( [ elem ], true );
  11323. }
  11324. /* eslint-disable no-loop-func */
  11325. anim.done( function() {
  11326. /* eslint-enable no-loop-func */
  11327. // The final step of a "hide" animation is actually hiding the element
  11328. if ( !hidden ) {
  11329. showHide( [ elem ] );
  11330. }
  11331. dataPriv.remove( elem, "fxshow" );
  11332. for ( prop in orig ) {
  11333. jQuery.style( elem, prop, orig[ prop ] );
  11334. }
  11335. } );
  11336. }
  11337. // Per-property setup
  11338. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  11339. if ( !( prop in dataShow ) ) {
  11340. dataShow[ prop ] = propTween.start;
  11341. if ( hidden ) {
  11342. propTween.end = propTween.start;
  11343. propTween.start = 0;
  11344. }
  11345. }
  11346. }
  11347. }
  11348. function propFilter( props, specialEasing ) {
  11349. var index, name, easing, value, hooks;
  11350. // camelCase, specialEasing and expand cssHook pass
  11351. for ( index in props ) {
  11352. name = camelCase( index );
  11353. easing = specialEasing[ name ];
  11354. value = props[ index ];
  11355. if ( Array.isArray( value ) ) {
  11356. easing = value[ 1 ];
  11357. value = props[ index ] = value[ 0 ];
  11358. }
  11359. if ( index !== name ) {
  11360. props[ name ] = value;
  11361. delete props[ index ];
  11362. }
  11363. hooks = jQuery.cssHooks[ name ];
  11364. if ( hooks && "expand" in hooks ) {
  11365. value = hooks.expand( value );
  11366. delete props[ name ];
  11367. // Not quite $.extend, this won't overwrite existing keys.
  11368. // Reusing 'index' because we have the correct "name"
  11369. for ( index in value ) {
  11370. if ( !( index in props ) ) {
  11371. props[ index ] = value[ index ];
  11372. specialEasing[ index ] = easing;
  11373. }
  11374. }
  11375. } else {
  11376. specialEasing[ name ] = easing;
  11377. }
  11378. }
  11379. }
  11380. function Animation( elem, properties, options ) {
  11381. var result,
  11382. stopped,
  11383. index = 0,
  11384. length = Animation.prefilters.length,
  11385. deferred = jQuery.Deferred().always( function() {
  11386. // Don't match elem in the :animated selector
  11387. delete tick.elem;
  11388. } ),
  11389. tick = function() {
  11390. if ( stopped ) {
  11391. return false;
  11392. }
  11393. var currentTime = fxNow || createFxNow(),
  11394. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  11395. // Support: Android 2.3 only
  11396. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  11397. temp = remaining / animation.duration || 0,
  11398. percent = 1 - temp,
  11399. index = 0,
  11400. length = animation.tweens.length;
  11401. for ( ; index < length; index++ ) {
  11402. animation.tweens[ index ].run( percent );
  11403. }
  11404. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  11405. // If there's more to do, yield
  11406. if ( percent < 1 && length ) {
  11407. return remaining;
  11408. }
  11409. // If this was an empty animation, synthesize a final progress notification
  11410. if ( !length ) {
  11411. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11412. }
  11413. // Resolve the animation and report its conclusion
  11414. deferred.resolveWith( elem, [ animation ] );
  11415. return false;
  11416. },
  11417. animation = deferred.promise( {
  11418. elem: elem,
  11419. props: jQuery.extend( {}, properties ),
  11420. opts: jQuery.extend( true, {
  11421. specialEasing: {},
  11422. easing: jQuery.easing._default
  11423. }, options ),
  11424. originalProperties: properties,
  11425. originalOptions: options,
  11426. startTime: fxNow || createFxNow(),
  11427. duration: options.duration,
  11428. tweens: [],
  11429. createTween: function( prop, end ) {
  11430. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  11431. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  11432. animation.tweens.push( tween );
  11433. return tween;
  11434. },
  11435. stop: function( gotoEnd ) {
  11436. var index = 0,
  11437. // If we are going to the end, we want to run all the tweens
  11438. // otherwise we skip this part
  11439. length = gotoEnd ? animation.tweens.length : 0;
  11440. if ( stopped ) {
  11441. return this;
  11442. }
  11443. stopped = true;
  11444. for ( ; index < length; index++ ) {
  11445. animation.tweens[ index ].run( 1 );
  11446. }
  11447. // Resolve when we played the last frame; otherwise, reject
  11448. if ( gotoEnd ) {
  11449. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11450. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  11451. } else {
  11452. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  11453. }
  11454. return this;
  11455. }
  11456. } ),
  11457. props = animation.props;
  11458. propFilter( props, animation.opts.specialEasing );
  11459. for ( ; index < length; index++ ) {
  11460. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  11461. if ( result ) {
  11462. if ( isFunction( result.stop ) ) {
  11463. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  11464. result.stop.bind( result );
  11465. }
  11466. return result;
  11467. }
  11468. }
  11469. jQuery.map( props, createTween, animation );
  11470. if ( isFunction( animation.opts.start ) ) {
  11471. animation.opts.start.call( elem, animation );
  11472. }
  11473. // Attach callbacks from options
  11474. animation
  11475. .progress( animation.opts.progress )
  11476. .done( animation.opts.done, animation.opts.complete )
  11477. .fail( animation.opts.fail )
  11478. .always( animation.opts.always );
  11479. jQuery.fx.timer(
  11480. jQuery.extend( tick, {
  11481. elem: elem,
  11482. anim: animation,
  11483. queue: animation.opts.queue
  11484. } )
  11485. );
  11486. return animation;
  11487. }
  11488. jQuery.Animation = jQuery.extend( Animation, {
  11489. tweeners: {
  11490. "*": [ function( prop, value ) {
  11491. var tween = this.createTween( prop, value );
  11492. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  11493. return tween;
  11494. } ]
  11495. },
  11496. tweener: function( props, callback ) {
  11497. if ( isFunction( props ) ) {
  11498. callback = props;
  11499. props = [ "*" ];
  11500. } else {
  11501. props = props.match( rnothtmlwhite );
  11502. }
  11503. var prop,
  11504. index = 0,
  11505. length = props.length;
  11506. for ( ; index < length; index++ ) {
  11507. prop = props[ index ];
  11508. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  11509. Animation.tweeners[ prop ].unshift( callback );
  11510. }
  11511. },
  11512. prefilters: [ defaultPrefilter ],
  11513. prefilter: function( callback, prepend ) {
  11514. if ( prepend ) {
  11515. Animation.prefilters.unshift( callback );
  11516. } else {
  11517. Animation.prefilters.push( callback );
  11518. }
  11519. }
  11520. } );
  11521. jQuery.speed = function( speed, easing, fn ) {
  11522. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  11523. complete: fn || !fn && easing ||
  11524. isFunction( speed ) && speed,
  11525. duration: speed,
  11526. easing: fn && easing || easing && !isFunction( easing ) && easing
  11527. };
  11528. // Go to the end state if fx are off
  11529. if ( jQuery.fx.off ) {
  11530. opt.duration = 0;
  11531. } else {
  11532. if ( typeof opt.duration !== "number" ) {
  11533. if ( opt.duration in jQuery.fx.speeds ) {
  11534. opt.duration = jQuery.fx.speeds[ opt.duration ];
  11535. } else {
  11536. opt.duration = jQuery.fx.speeds._default;
  11537. }
  11538. }
  11539. }
  11540. // Normalize opt.queue - true/undefined/null -> "fx"
  11541. if ( opt.queue == null || opt.queue === true ) {
  11542. opt.queue = "fx";
  11543. }
  11544. // Queueing
  11545. opt.old = opt.complete;
  11546. opt.complete = function() {
  11547. if ( isFunction( opt.old ) ) {
  11548. opt.old.call( this );
  11549. }
  11550. if ( opt.queue ) {
  11551. jQuery.dequeue( this, opt.queue );
  11552. }
  11553. };
  11554. return opt;
  11555. };
  11556. jQuery.fn.extend( {
  11557. fadeTo: function( speed, to, easing, callback ) {
  11558. // Show any hidden elements after setting opacity to 0
  11559. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  11560. // Animate to the value specified
  11561. .end().animate( { opacity: to }, speed, easing, callback );
  11562. },
  11563. animate: function( prop, speed, easing, callback ) {
  11564. var empty = jQuery.isEmptyObject( prop ),
  11565. optall = jQuery.speed( speed, easing, callback ),
  11566. doAnimation = function() {
  11567. // Operate on a copy of prop so per-property easing won't be lost
  11568. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  11569. // Empty animations, or finishing resolves immediately
  11570. if ( empty || dataPriv.get( this, "finish" ) ) {
  11571. anim.stop( true );
  11572. }
  11573. };
  11574. doAnimation.finish = doAnimation;
  11575. return empty || optall.queue === false ?
  11576. this.each( doAnimation ) :
  11577. this.queue( optall.queue, doAnimation );
  11578. },
  11579. stop: function( type, clearQueue, gotoEnd ) {
  11580. var stopQueue = function( hooks ) {
  11581. var stop = hooks.stop;
  11582. delete hooks.stop;
  11583. stop( gotoEnd );
  11584. };
  11585. if ( typeof type !== "string" ) {
  11586. gotoEnd = clearQueue;
  11587. clearQueue = type;
  11588. type = undefined;
  11589. }
  11590. if ( clearQueue ) {
  11591. this.queue( type || "fx", [] );
  11592. }
  11593. return this.each( function() {
  11594. var dequeue = true,
  11595. index = type != null && type + "queueHooks",
  11596. timers = jQuery.timers,
  11597. data = dataPriv.get( this );
  11598. if ( index ) {
  11599. if ( data[ index ] && data[ index ].stop ) {
  11600. stopQueue( data[ index ] );
  11601. }
  11602. } else {
  11603. for ( index in data ) {
  11604. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  11605. stopQueue( data[ index ] );
  11606. }
  11607. }
  11608. }
  11609. for ( index = timers.length; index--; ) {
  11610. if ( timers[ index ].elem === this &&
  11611. ( type == null || timers[ index ].queue === type ) ) {
  11612. timers[ index ].anim.stop( gotoEnd );
  11613. dequeue = false;
  11614. timers.splice( index, 1 );
  11615. }
  11616. }
  11617. // Start the next in the queue if the last step wasn't forced.
  11618. // Timers currently will call their complete callbacks, which
  11619. // will dequeue but only if they were gotoEnd.
  11620. if ( dequeue || !gotoEnd ) {
  11621. jQuery.dequeue( this, type );
  11622. }
  11623. } );
  11624. },
  11625. finish: function( type ) {
  11626. if ( type !== false ) {
  11627. type = type || "fx";
  11628. }
  11629. return this.each( function() {
  11630. var index,
  11631. data = dataPriv.get( this ),
  11632. queue = data[ type + "queue" ],
  11633. hooks = data[ type + "queueHooks" ],
  11634. timers = jQuery.timers,
  11635. length = queue ? queue.length : 0;
  11636. // Enable finishing flag on private data
  11637. data.finish = true;
  11638. // Empty the queue first
  11639. jQuery.queue( this, type, [] );
  11640. if ( hooks && hooks.stop ) {
  11641. hooks.stop.call( this, true );
  11642. }
  11643. // Look for any active animations, and finish them
  11644. for ( index = timers.length; index--; ) {
  11645. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  11646. timers[ index ].anim.stop( true );
  11647. timers.splice( index, 1 );
  11648. }
  11649. }
  11650. // Look for any animations in the old queue and finish them
  11651. for ( index = 0; index < length; index++ ) {
  11652. if ( queue[ index ] && queue[ index ].finish ) {
  11653. queue[ index ].finish.call( this );
  11654. }
  11655. }
  11656. // Turn off finishing flag
  11657. delete data.finish;
  11658. } );
  11659. }
  11660. } );
  11661. jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
  11662. var cssFn = jQuery.fn[ name ];
  11663. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11664. return speed == null || typeof speed === "boolean" ?
  11665. cssFn.apply( this, arguments ) :
  11666. this.animate( genFx( name, true ), speed, easing, callback );
  11667. };
  11668. } );
  11669. // Generate shortcuts for custom animations
  11670. jQuery.each( {
  11671. slideDown: genFx( "show" ),
  11672. slideUp: genFx( "hide" ),
  11673. slideToggle: genFx( "toggle" ),
  11674. fadeIn: { opacity: "show" },
  11675. fadeOut: { opacity: "hide" },
  11676. fadeToggle: { opacity: "toggle" }
  11677. }, function( name, props ) {
  11678. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11679. return this.animate( props, speed, easing, callback );
  11680. };
  11681. } );
  11682. jQuery.timers = [];
  11683. jQuery.fx.tick = function() {
  11684. var timer,
  11685. i = 0,
  11686. timers = jQuery.timers;
  11687. fxNow = Date.now();
  11688. for ( ; i < timers.length; i++ ) {
  11689. timer = timers[ i ];
  11690. // Run the timer and safely remove it when done (allowing for external removal)
  11691. if ( !timer() && timers[ i ] === timer ) {
  11692. timers.splice( i--, 1 );
  11693. }
  11694. }
  11695. if ( !timers.length ) {
  11696. jQuery.fx.stop();
  11697. }
  11698. fxNow = undefined;
  11699. };
  11700. jQuery.fx.timer = function( timer ) {
  11701. jQuery.timers.push( timer );
  11702. jQuery.fx.start();
  11703. };
  11704. jQuery.fx.interval = 13;
  11705. jQuery.fx.start = function() {
  11706. if ( inProgress ) {
  11707. return;
  11708. }
  11709. inProgress = true;
  11710. schedule();
  11711. };
  11712. jQuery.fx.stop = function() {
  11713. inProgress = null;
  11714. };
  11715. jQuery.fx.speeds = {
  11716. slow: 600,
  11717. fast: 200,
  11718. // Default speed
  11719. _default: 400
  11720. };
  11721. // Based off of the plugin by Clint Helfers, with permission.
  11722. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  11723. jQuery.fn.delay = function( time, type ) {
  11724. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  11725. type = type || "fx";
  11726. return this.queue( type, function( next, hooks ) {
  11727. var timeout = window.setTimeout( next, time );
  11728. hooks.stop = function() {
  11729. window.clearTimeout( timeout );
  11730. };
  11731. } );
  11732. };
  11733. ( function() {
  11734. var input = document.createElement( "input" ),
  11735. select = document.createElement( "select" ),
  11736. opt = select.appendChild( document.createElement( "option" ) );
  11737. input.type = "checkbox";
  11738. // Support: Android <=4.3 only
  11739. // Default value for a checkbox should be "on"
  11740. support.checkOn = input.value !== "";
  11741. // Support: IE <=11 only
  11742. // Must access selectedIndex to make default options select
  11743. support.optSelected = opt.selected;
  11744. // Support: IE <=11 only
  11745. // An input loses its value after becoming a radio
  11746. input = document.createElement( "input" );
  11747. input.value = "t";
  11748. input.type = "radio";
  11749. support.radioValue = input.value === "t";
  11750. } )();
  11751. var boolHook,
  11752. attrHandle = jQuery.expr.attrHandle;
  11753. jQuery.fn.extend( {
  11754. attr: function( name, value ) {
  11755. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  11756. },
  11757. removeAttr: function( name ) {
  11758. return this.each( function() {
  11759. jQuery.removeAttr( this, name );
  11760. } );
  11761. }
  11762. } );
  11763. jQuery.extend( {
  11764. attr: function( elem, name, value ) {
  11765. var ret, hooks,
  11766. nType = elem.nodeType;
  11767. // Don't get/set attributes on text, comment and attribute nodes
  11768. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11769. return;
  11770. }
  11771. // Fallback to prop when attributes are not supported
  11772. if ( typeof elem.getAttribute === "undefined" ) {
  11773. return jQuery.prop( elem, name, value );
  11774. }
  11775. // Attribute hooks are determined by the lowercase version
  11776. // Grab necessary hook if one is defined
  11777. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11778. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  11779. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  11780. }
  11781. if ( value !== undefined ) {
  11782. if ( value === null ) {
  11783. jQuery.removeAttr( elem, name );
  11784. return;
  11785. }
  11786. if ( hooks && "set" in hooks &&
  11787. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11788. return ret;
  11789. }
  11790. elem.setAttribute( name, value + "" );
  11791. return value;
  11792. }
  11793. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11794. return ret;
  11795. }
  11796. ret = jQuery.find.attr( elem, name );
  11797. // Non-existent attributes return null, we normalize to undefined
  11798. return ret == null ? undefined : ret;
  11799. },
  11800. attrHooks: {
  11801. type: {
  11802. set: function( elem, value ) {
  11803. if ( !support.radioValue && value === "radio" &&
  11804. nodeName( elem, "input" ) ) {
  11805. var val = elem.value;
  11806. elem.setAttribute( "type", value );
  11807. if ( val ) {
  11808. elem.value = val;
  11809. }
  11810. return value;
  11811. }
  11812. }
  11813. }
  11814. },
  11815. removeAttr: function( elem, value ) {
  11816. var name,
  11817. i = 0,
  11818. // Attribute names can contain non-HTML whitespace characters
  11819. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  11820. attrNames = value && value.match( rnothtmlwhite );
  11821. if ( attrNames && elem.nodeType === 1 ) {
  11822. while ( ( name = attrNames[ i++ ] ) ) {
  11823. elem.removeAttribute( name );
  11824. }
  11825. }
  11826. }
  11827. } );
  11828. // Hooks for boolean attributes
  11829. boolHook = {
  11830. set: function( elem, value, name ) {
  11831. if ( value === false ) {
  11832. // Remove boolean attributes when set to false
  11833. jQuery.removeAttr( elem, name );
  11834. } else {
  11835. elem.setAttribute( name, name );
  11836. }
  11837. return name;
  11838. }
  11839. };
  11840. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
  11841. var getter = attrHandle[ name ] || jQuery.find.attr;
  11842. attrHandle[ name ] = function( elem, name, isXML ) {
  11843. var ret, handle,
  11844. lowercaseName = name.toLowerCase();
  11845. if ( !isXML ) {
  11846. // Avoid an infinite loop by temporarily removing this function from the getter
  11847. handle = attrHandle[ lowercaseName ];
  11848. attrHandle[ lowercaseName ] = ret;
  11849. ret = getter( elem, name, isXML ) != null ?
  11850. lowercaseName :
  11851. null;
  11852. attrHandle[ lowercaseName ] = handle;
  11853. }
  11854. return ret;
  11855. };
  11856. } );
  11857. var rfocusable = /^(?:input|select|textarea|button)$/i,
  11858. rclickable = /^(?:a|area)$/i;
  11859. jQuery.fn.extend( {
  11860. prop: function( name, value ) {
  11861. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  11862. },
  11863. removeProp: function( name ) {
  11864. return this.each( function() {
  11865. delete this[ jQuery.propFix[ name ] || name ];
  11866. } );
  11867. }
  11868. } );
  11869. jQuery.extend( {
  11870. prop: function( elem, name, value ) {
  11871. var ret, hooks,
  11872. nType = elem.nodeType;
  11873. // Don't get/set properties on text, comment and attribute nodes
  11874. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11875. return;
  11876. }
  11877. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11878. // Fix name and attach hooks
  11879. name = jQuery.propFix[ name ] || name;
  11880. hooks = jQuery.propHooks[ name ];
  11881. }
  11882. if ( value !== undefined ) {
  11883. if ( hooks && "set" in hooks &&
  11884. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11885. return ret;
  11886. }
  11887. return ( elem[ name ] = value );
  11888. }
  11889. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11890. return ret;
  11891. }
  11892. return elem[ name ];
  11893. },
  11894. propHooks: {
  11895. tabIndex: {
  11896. get: function( elem ) {
  11897. // Support: IE <=9 - 11 only
  11898. // elem.tabIndex doesn't always return the
  11899. // correct value when it hasn't been explicitly set
  11900. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  11901. // Use proper attribute retrieval(#12072)
  11902. var tabindex = jQuery.find.attr( elem, "tabindex" );
  11903. if ( tabindex ) {
  11904. return parseInt( tabindex, 10 );
  11905. }
  11906. if (
  11907. rfocusable.test( elem.nodeName ) ||
  11908. rclickable.test( elem.nodeName ) &&
  11909. elem.href
  11910. ) {
  11911. return 0;
  11912. }
  11913. return -1;
  11914. }
  11915. }
  11916. },
  11917. propFix: {
  11918. "for": "htmlFor",
  11919. "class": "className"
  11920. }
  11921. } );
  11922. // Support: IE <=11 only
  11923. // Accessing the selectedIndex property
  11924. // forces the browser to respect setting selected
  11925. // on the option
  11926. // The getter ensures a default option is selected
  11927. // when in an optgroup
  11928. // eslint rule "no-unused-expressions" is disabled for this code
  11929. // since it considers such accessions noop
  11930. if ( !support.optSelected ) {
  11931. jQuery.propHooks.selected = {
  11932. get: function( elem ) {
  11933. /* eslint no-unused-expressions: "off" */
  11934. var parent = elem.parentNode;
  11935. if ( parent && parent.parentNode ) {
  11936. parent.parentNode.selectedIndex;
  11937. }
  11938. return null;
  11939. },
  11940. set: function( elem ) {
  11941. /* eslint no-unused-expressions: "off" */
  11942. var parent = elem.parentNode;
  11943. if ( parent ) {
  11944. parent.selectedIndex;
  11945. if ( parent.parentNode ) {
  11946. parent.parentNode.selectedIndex;
  11947. }
  11948. }
  11949. }
  11950. };
  11951. }
  11952. jQuery.each( [
  11953. "tabIndex",
  11954. "readOnly",
  11955. "maxLength",
  11956. "cellSpacing",
  11957. "cellPadding",
  11958. "rowSpan",
  11959. "colSpan",
  11960. "useMap",
  11961. "frameBorder",
  11962. "contentEditable"
  11963. ], function() {
  11964. jQuery.propFix[ this.toLowerCase() ] = this;
  11965. } );
  11966. // Strip and collapse whitespace according to HTML spec
  11967. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  11968. function stripAndCollapse( value ) {
  11969. var tokens = value.match( rnothtmlwhite ) || [];
  11970. return tokens.join( " " );
  11971. }
  11972. function getClass( elem ) {
  11973. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  11974. }
  11975. function classesToArray( value ) {
  11976. if ( Array.isArray( value ) ) {
  11977. return value;
  11978. }
  11979. if ( typeof value === "string" ) {
  11980. return value.match( rnothtmlwhite ) || [];
  11981. }
  11982. return [];
  11983. }
  11984. jQuery.fn.extend( {
  11985. addClass: function( value ) {
  11986. var classes, elem, cur, curValue, clazz, j, finalValue,
  11987. i = 0;
  11988. if ( isFunction( value ) ) {
  11989. return this.each( function( j ) {
  11990. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  11991. } );
  11992. }
  11993. classes = classesToArray( value );
  11994. if ( classes.length ) {
  11995. while ( ( elem = this[ i++ ] ) ) {
  11996. curValue = getClass( elem );
  11997. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11998. if ( cur ) {
  11999. j = 0;
  12000. while ( ( clazz = classes[ j++ ] ) ) {
  12001. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  12002. cur += clazz + " ";
  12003. }
  12004. }
  12005. // Only assign if different to avoid unneeded rendering.
  12006. finalValue = stripAndCollapse( cur );
  12007. if ( curValue !== finalValue ) {
  12008. elem.setAttribute( "class", finalValue );
  12009. }
  12010. }
  12011. }
  12012. }
  12013. return this;
  12014. },
  12015. removeClass: function( value ) {
  12016. var classes, elem, cur, curValue, clazz, j, finalValue,
  12017. i = 0;
  12018. if ( isFunction( value ) ) {
  12019. return this.each( function( j ) {
  12020. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  12021. } );
  12022. }
  12023. if ( !arguments.length ) {
  12024. return this.attr( "class", "" );
  12025. }
  12026. classes = classesToArray( value );
  12027. if ( classes.length ) {
  12028. while ( ( elem = this[ i++ ] ) ) {
  12029. curValue = getClass( elem );
  12030. // This expression is here for better compressibility (see addClass)
  12031. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  12032. if ( cur ) {
  12033. j = 0;
  12034. while ( ( clazz = classes[ j++ ] ) ) {
  12035. // Remove *all* instances
  12036. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  12037. cur = cur.replace( " " + clazz + " ", " " );
  12038. }
  12039. }
  12040. // Only assign if different to avoid unneeded rendering.
  12041. finalValue = stripAndCollapse( cur );
  12042. if ( curValue !== finalValue ) {
  12043. elem.setAttribute( "class", finalValue );
  12044. }
  12045. }
  12046. }
  12047. }
  12048. return this;
  12049. },
  12050. toggleClass: function( value, stateVal ) {
  12051. var type = typeof value,
  12052. isValidValue = type === "string" || Array.isArray( value );
  12053. if ( typeof stateVal === "boolean" && isValidValue ) {
  12054. return stateVal ? this.addClass( value ) : this.removeClass( value );
  12055. }
  12056. if ( isFunction( value ) ) {
  12057. return this.each( function( i ) {
  12058. jQuery( this ).toggleClass(
  12059. value.call( this, i, getClass( this ), stateVal ),
  12060. stateVal
  12061. );
  12062. } );
  12063. }
  12064. return this.each( function() {
  12065. var className, i, self, classNames;
  12066. if ( isValidValue ) {
  12067. // Toggle individual class names
  12068. i = 0;
  12069. self = jQuery( this );
  12070. classNames = classesToArray( value );
  12071. while ( ( className = classNames[ i++ ] ) ) {
  12072. // Check each className given, space separated list
  12073. if ( self.hasClass( className ) ) {
  12074. self.removeClass( className );
  12075. } else {
  12076. self.addClass( className );
  12077. }
  12078. }
  12079. // Toggle whole class name
  12080. } else if ( value === undefined || type === "boolean" ) {
  12081. className = getClass( this );
  12082. if ( className ) {
  12083. // Store className if set
  12084. dataPriv.set( this, "__className__", className );
  12085. }
  12086. // If the element has a class name or if we're passed `false`,
  12087. // then remove the whole classname (if there was one, the above saved it).
  12088. // Otherwise bring back whatever was previously saved (if anything),
  12089. // falling back to the empty string if nothing was stored.
  12090. if ( this.setAttribute ) {
  12091. this.setAttribute( "class",
  12092. className || value === false ?
  12093. "" :
  12094. dataPriv.get( this, "__className__" ) || ""
  12095. );
  12096. }
  12097. }
  12098. } );
  12099. },
  12100. hasClass: function( selector ) {
  12101. var className, elem,
  12102. i = 0;
  12103. className = " " + selector + " ";
  12104. while ( ( elem = this[ i++ ] ) ) {
  12105. if ( elem.nodeType === 1 &&
  12106. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  12107. return true;
  12108. }
  12109. }
  12110. return false;
  12111. }
  12112. } );
  12113. var rreturn = /\r/g;
  12114. jQuery.fn.extend( {
  12115. val: function( value ) {
  12116. var hooks, ret, valueIsFunction,
  12117. elem = this[ 0 ];
  12118. if ( !arguments.length ) {
  12119. if ( elem ) {
  12120. hooks = jQuery.valHooks[ elem.type ] ||
  12121. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  12122. if ( hooks &&
  12123. "get" in hooks &&
  12124. ( ret = hooks.get( elem, "value" ) ) !== undefined
  12125. ) {
  12126. return ret;
  12127. }
  12128. ret = elem.value;
  12129. // Handle most common string cases
  12130. if ( typeof ret === "string" ) {
  12131. return ret.replace( rreturn, "" );
  12132. }
  12133. // Handle cases where value is null/undef or number
  12134. return ret == null ? "" : ret;
  12135. }
  12136. return;
  12137. }
  12138. valueIsFunction = isFunction( value );
  12139. return this.each( function( i ) {
  12140. var val;
  12141. if ( this.nodeType !== 1 ) {
  12142. return;
  12143. }
  12144. if ( valueIsFunction ) {
  12145. val = value.call( this, i, jQuery( this ).val() );
  12146. } else {
  12147. val = value;
  12148. }
  12149. // Treat null/undefined as ""; convert numbers to string
  12150. if ( val == null ) {
  12151. val = "";
  12152. } else if ( typeof val === "number" ) {
  12153. val += "";
  12154. } else if ( Array.isArray( val ) ) {
  12155. val = jQuery.map( val, function( value ) {
  12156. return value == null ? "" : value + "";
  12157. } );
  12158. }
  12159. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  12160. // If set returns undefined, fall back to normal setting
  12161. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  12162. this.value = val;
  12163. }
  12164. } );
  12165. }
  12166. } );
  12167. jQuery.extend( {
  12168. valHooks: {
  12169. option: {
  12170. get: function( elem ) {
  12171. var val = jQuery.find.attr( elem, "value" );
  12172. return val != null ?
  12173. val :
  12174. // Support: IE <=10 - 11 only
  12175. // option.text throws exceptions (#14686, #14858)
  12176. // Strip and collapse whitespace
  12177. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  12178. stripAndCollapse( jQuery.text( elem ) );
  12179. }
  12180. },
  12181. select: {
  12182. get: function( elem ) {
  12183. var value, option, i,
  12184. options = elem.options,
  12185. index = elem.selectedIndex,
  12186. one = elem.type === "select-one",
  12187. values = one ? null : [],
  12188. max = one ? index + 1 : options.length;
  12189. if ( index < 0 ) {
  12190. i = max;
  12191. } else {
  12192. i = one ? index : 0;
  12193. }
  12194. // Loop through all the selected options
  12195. for ( ; i < max; i++ ) {
  12196. option = options[ i ];
  12197. // Support: IE <=9 only
  12198. // IE8-9 doesn't update selected after form reset (#2551)
  12199. if ( ( option.selected || i === index ) &&
  12200. // Don't return options that are disabled or in a disabled optgroup
  12201. !option.disabled &&
  12202. ( !option.parentNode.disabled ||
  12203. !nodeName( option.parentNode, "optgroup" ) ) ) {
  12204. // Get the specific value for the option
  12205. value = jQuery( option ).val();
  12206. // We don't need an array for one selects
  12207. if ( one ) {
  12208. return value;
  12209. }
  12210. // Multi-Selects return an array
  12211. values.push( value );
  12212. }
  12213. }
  12214. return values;
  12215. },
  12216. set: function( elem, value ) {
  12217. var optionSet, option,
  12218. options = elem.options,
  12219. values = jQuery.makeArray( value ),
  12220. i = options.length;
  12221. while ( i-- ) {
  12222. option = options[ i ];
  12223. /* eslint-disable no-cond-assign */
  12224. if ( option.selected =
  12225. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  12226. ) {
  12227. optionSet = true;
  12228. }
  12229. /* eslint-enable no-cond-assign */
  12230. }
  12231. // Force browsers to behave consistently when non-matching value is set
  12232. if ( !optionSet ) {
  12233. elem.selectedIndex = -1;
  12234. }
  12235. return values;
  12236. }
  12237. }
  12238. }
  12239. } );
  12240. // Radios and checkboxes getter/setter
  12241. jQuery.each( [ "radio", "checkbox" ], function() {
  12242. jQuery.valHooks[ this ] = {
  12243. set: function( elem, value ) {
  12244. if ( Array.isArray( value ) ) {
  12245. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  12246. }
  12247. }
  12248. };
  12249. if ( !support.checkOn ) {
  12250. jQuery.valHooks[ this ].get = function( elem ) {
  12251. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  12252. };
  12253. }
  12254. } );
  12255. // Return jQuery for attributes-only inclusion
  12256. support.focusin = "onfocusin" in window;
  12257. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  12258. stopPropagationCallback = function( e ) {
  12259. e.stopPropagation();
  12260. };
  12261. jQuery.extend( jQuery.event, {
  12262. trigger: function( event, data, elem, onlyHandlers ) {
  12263. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  12264. eventPath = [ elem || document ],
  12265. type = hasOwn.call( event, "type" ) ? event.type : event,
  12266. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  12267. cur = lastElement = tmp = elem = elem || document;
  12268. // Don't do events on text and comment nodes
  12269. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  12270. return;
  12271. }
  12272. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  12273. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  12274. return;
  12275. }
  12276. if ( type.indexOf( "." ) > -1 ) {
  12277. // Namespaced trigger; create a regexp to match event type in handle()
  12278. namespaces = type.split( "." );
  12279. type = namespaces.shift();
  12280. namespaces.sort();
  12281. }
  12282. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  12283. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  12284. event = event[ jQuery.expando ] ?
  12285. event :
  12286. new jQuery.Event( type, typeof event === "object" && event );
  12287. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  12288. event.isTrigger = onlyHandlers ? 2 : 3;
  12289. event.namespace = namespaces.join( "." );
  12290. event.rnamespace = event.namespace ?
  12291. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  12292. null;
  12293. // Clean up the event in case it is being reused
  12294. event.result = undefined;
  12295. if ( !event.target ) {
  12296. event.target = elem;
  12297. }
  12298. // Clone any incoming data and prepend the event, creating the handler arg list
  12299. data = data == null ?
  12300. [ event ] :
  12301. jQuery.makeArray( data, [ event ] );
  12302. // Allow special events to draw outside the lines
  12303. special = jQuery.event.special[ type ] || {};
  12304. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  12305. return;
  12306. }
  12307. // Determine event propagation path in advance, per W3C events spec (#9951)
  12308. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  12309. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  12310. bubbleType = special.delegateType || type;
  12311. if ( !rfocusMorph.test( bubbleType + type ) ) {
  12312. cur = cur.parentNode;
  12313. }
  12314. for ( ; cur; cur = cur.parentNode ) {
  12315. eventPath.push( cur );
  12316. tmp = cur;
  12317. }
  12318. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  12319. if ( tmp === ( elem.ownerDocument || document ) ) {
  12320. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  12321. }
  12322. }
  12323. // Fire handlers on the event path
  12324. i = 0;
  12325. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  12326. lastElement = cur;
  12327. event.type = i > 1 ?
  12328. bubbleType :
  12329. special.bindType || type;
  12330. // jQuery handler
  12331. handle = (
  12332. dataPriv.get( cur, "events" ) || Object.create( null )
  12333. )[ event.type ] &&
  12334. dataPriv.get( cur, "handle" );
  12335. if ( handle ) {
  12336. handle.apply( cur, data );
  12337. }
  12338. // Native handler
  12339. handle = ontype && cur[ ontype ];
  12340. if ( handle && handle.apply && acceptData( cur ) ) {
  12341. event.result = handle.apply( cur, data );
  12342. if ( event.result === false ) {
  12343. event.preventDefault();
  12344. }
  12345. }
  12346. }
  12347. event.type = type;
  12348. // If nobody prevented the default action, do it now
  12349. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  12350. if ( ( !special._default ||
  12351. special._default.apply( eventPath.pop(), data ) === false ) &&
  12352. acceptData( elem ) ) {
  12353. // Call a native DOM method on the target with the same name as the event.
  12354. // Don't do default actions on window, that's where global variables be (#6170)
  12355. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  12356. // Don't re-trigger an onFOO event when we call its FOO() method
  12357. tmp = elem[ ontype ];
  12358. if ( tmp ) {
  12359. elem[ ontype ] = null;
  12360. }
  12361. // Prevent re-triggering of the same event, since we already bubbled it above
  12362. jQuery.event.triggered = type;
  12363. if ( event.isPropagationStopped() ) {
  12364. lastElement.addEventListener( type, stopPropagationCallback );
  12365. }
  12366. elem[ type ]();
  12367. if ( event.isPropagationStopped() ) {
  12368. lastElement.removeEventListener( type, stopPropagationCallback );
  12369. }
  12370. jQuery.event.triggered = undefined;
  12371. if ( tmp ) {
  12372. elem[ ontype ] = tmp;
  12373. }
  12374. }
  12375. }
  12376. }
  12377. return event.result;
  12378. },
  12379. // Piggyback on a donor event to simulate a different one
  12380. // Used only for `focus(in | out)` events
  12381. simulate: function( type, elem, event ) {
  12382. var e = jQuery.extend(
  12383. new jQuery.Event(),
  12384. event,
  12385. {
  12386. type: type,
  12387. isSimulated: true
  12388. }
  12389. );
  12390. jQuery.event.trigger( e, null, elem );
  12391. }
  12392. } );
  12393. jQuery.fn.extend( {
  12394. trigger: function( type, data ) {
  12395. return this.each( function() {
  12396. jQuery.event.trigger( type, data, this );
  12397. } );
  12398. },
  12399. triggerHandler: function( type, data ) {
  12400. var elem = this[ 0 ];
  12401. if ( elem ) {
  12402. return jQuery.event.trigger( type, data, elem, true );
  12403. }
  12404. }
  12405. } );
  12406. // Support: Firefox <=44
  12407. // Firefox doesn't have focus(in | out) events
  12408. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  12409. //
  12410. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  12411. // focus(in | out) events fire after focus & blur events,
  12412. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  12413. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  12414. if ( !support.focusin ) {
  12415. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  12416. // Attach a single capturing handler on the document while someone wants focusin/focusout
  12417. var handler = function( event ) {
  12418. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  12419. };
  12420. jQuery.event.special[ fix ] = {
  12421. setup: function() {
  12422. // Handle: regular nodes (via `this.ownerDocument`), window
  12423. // (via `this.document`) & document (via `this`).
  12424. var doc = this.ownerDocument || this.document || this,
  12425. attaches = dataPriv.access( doc, fix );
  12426. if ( !attaches ) {
  12427. doc.addEventListener( orig, handler, true );
  12428. }
  12429. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  12430. },
  12431. teardown: function() {
  12432. var doc = this.ownerDocument || this.document || this,
  12433. attaches = dataPriv.access( doc, fix ) - 1;
  12434. if ( !attaches ) {
  12435. doc.removeEventListener( orig, handler, true );
  12436. dataPriv.remove( doc, fix );
  12437. } else {
  12438. dataPriv.access( doc, fix, attaches );
  12439. }
  12440. }
  12441. };
  12442. } );
  12443. }
  12444. var location = window.location;
  12445. var nonce = { guid: Date.now() };
  12446. var rquery = ( /\?/ );
  12447. // Cross-browser xml parsing
  12448. jQuery.parseXML = function( data ) {
  12449. var xml;
  12450. if ( !data || typeof data !== "string" ) {
  12451. return null;
  12452. }
  12453. // Support: IE 9 - 11 only
  12454. // IE throws on parseFromString with invalid input.
  12455. try {
  12456. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  12457. } catch ( e ) {
  12458. xml = undefined;
  12459. }
  12460. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  12461. jQuery.error( "Invalid XML: " + data );
  12462. }
  12463. return xml;
  12464. };
  12465. var
  12466. rbracket = /\[\]$/,
  12467. rCRLF = /\r?\n/g,
  12468. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  12469. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  12470. function buildParams( prefix, obj, traditional, add ) {
  12471. var name;
  12472. if ( Array.isArray( obj ) ) {
  12473. // Serialize array item.
  12474. jQuery.each( obj, function( i, v ) {
  12475. if ( traditional || rbracket.test( prefix ) ) {
  12476. // Treat each array item as a scalar.
  12477. add( prefix, v );
  12478. } else {
  12479. // Item is non-scalar (array or object), encode its numeric index.
  12480. buildParams(
  12481. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  12482. v,
  12483. traditional,
  12484. add
  12485. );
  12486. }
  12487. } );
  12488. } else if ( !traditional && toType( obj ) === "object" ) {
  12489. // Serialize object item.
  12490. for ( name in obj ) {
  12491. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  12492. }
  12493. } else {
  12494. // Serialize scalar item.
  12495. add( prefix, obj );
  12496. }
  12497. }
  12498. // Serialize an array of form elements or a set of
  12499. // key/values into a query string
  12500. jQuery.param = function( a, traditional ) {
  12501. var prefix,
  12502. s = [],
  12503. add = function( key, valueOrFunction ) {
  12504. // If value is a function, invoke it and use its return value
  12505. var value = isFunction( valueOrFunction ) ?
  12506. valueOrFunction() :
  12507. valueOrFunction;
  12508. s[ s.length ] = encodeURIComponent( key ) + "=" +
  12509. encodeURIComponent( value == null ? "" : value );
  12510. };
  12511. if ( a == null ) {
  12512. return "";
  12513. }
  12514. // If an array was passed in, assume that it is an array of form elements.
  12515. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  12516. // Serialize the form elements
  12517. jQuery.each( a, function() {
  12518. add( this.name, this.value );
  12519. } );
  12520. } else {
  12521. // If traditional, encode the "old" way (the way 1.3.2 or older
  12522. // did it), otherwise encode params recursively.
  12523. for ( prefix in a ) {
  12524. buildParams( prefix, a[ prefix ], traditional, add );
  12525. }
  12526. }
  12527. // Return the resulting serialization
  12528. return s.join( "&" );
  12529. };
  12530. jQuery.fn.extend( {
  12531. serialize: function() {
  12532. return jQuery.param( this.serializeArray() );
  12533. },
  12534. serializeArray: function() {
  12535. return this.map( function() {
  12536. // Can add propHook for "elements" to filter or add form elements
  12537. var elements = jQuery.prop( this, "elements" );
  12538. return elements ? jQuery.makeArray( elements ) : this;
  12539. } )
  12540. .filter( function() {
  12541. var type = this.type;
  12542. // Use .is( ":disabled" ) so that fieldset[disabled] works
  12543. return this.name && !jQuery( this ).is( ":disabled" ) &&
  12544. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  12545. ( this.checked || !rcheckableType.test( type ) );
  12546. } )
  12547. .map( function( _i, elem ) {
  12548. var val = jQuery( this ).val();
  12549. if ( val == null ) {
  12550. return null;
  12551. }
  12552. if ( Array.isArray( val ) ) {
  12553. return jQuery.map( val, function( val ) {
  12554. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12555. } );
  12556. }
  12557. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12558. } ).get();
  12559. }
  12560. } );
  12561. var
  12562. r20 = /%20/g,
  12563. rhash = /#.*$/,
  12564. rantiCache = /([?&])_=[^&]*/,
  12565. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  12566. // #7653, #8125, #8152: local protocol detection
  12567. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  12568. rnoContent = /^(?:GET|HEAD)$/,
  12569. rprotocol = /^\/\//,
  12570. /* Prefilters
  12571. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  12572. * 2) These are called:
  12573. * - BEFORE asking for a transport
  12574. * - AFTER param serialization (s.data is a string if s.processData is true)
  12575. * 3) key is the dataType
  12576. * 4) the catchall symbol "*" can be used
  12577. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  12578. */
  12579. prefilters = {},
  12580. /* Transports bindings
  12581. * 1) key is the dataType
  12582. * 2) the catchall symbol "*" can be used
  12583. * 3) selection will start with transport dataType and THEN go to "*" if needed
  12584. */
  12585. transports = {},
  12586. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  12587. allTypes = "*/".concat( "*" ),
  12588. // Anchor tag for parsing the document origin
  12589. originAnchor = document.createElement( "a" );
  12590. originAnchor.href = location.href;
  12591. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  12592. function addToPrefiltersOrTransports( structure ) {
  12593. // dataTypeExpression is optional and defaults to "*"
  12594. return function( dataTypeExpression, func ) {
  12595. if ( typeof dataTypeExpression !== "string" ) {
  12596. func = dataTypeExpression;
  12597. dataTypeExpression = "*";
  12598. }
  12599. var dataType,
  12600. i = 0,
  12601. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  12602. if ( isFunction( func ) ) {
  12603. // For each dataType in the dataTypeExpression
  12604. while ( ( dataType = dataTypes[ i++ ] ) ) {
  12605. // Prepend if requested
  12606. if ( dataType[ 0 ] === "+" ) {
  12607. dataType = dataType.slice( 1 ) || "*";
  12608. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  12609. // Otherwise append
  12610. } else {
  12611. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  12612. }
  12613. }
  12614. }
  12615. };
  12616. }
  12617. // Base inspection function for prefilters and transports
  12618. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  12619. var inspected = {},
  12620. seekingTransport = ( structure === transports );
  12621. function inspect( dataType ) {
  12622. var selected;
  12623. inspected[ dataType ] = true;
  12624. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  12625. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  12626. if ( typeof dataTypeOrTransport === "string" &&
  12627. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  12628. options.dataTypes.unshift( dataTypeOrTransport );
  12629. inspect( dataTypeOrTransport );
  12630. return false;
  12631. } else if ( seekingTransport ) {
  12632. return !( selected = dataTypeOrTransport );
  12633. }
  12634. } );
  12635. return selected;
  12636. }
  12637. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  12638. }
  12639. // A special extend for ajax options
  12640. // that takes "flat" options (not to be deep extended)
  12641. // Fixes #9887
  12642. function ajaxExtend( target, src ) {
  12643. var key, deep,
  12644. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  12645. for ( key in src ) {
  12646. if ( src[ key ] !== undefined ) {
  12647. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  12648. }
  12649. }
  12650. if ( deep ) {
  12651. jQuery.extend( true, target, deep );
  12652. }
  12653. return target;
  12654. }
  12655. /* Handles responses to an ajax request:
  12656. * - finds the right dataType (mediates between content-type and expected dataType)
  12657. * - returns the corresponding response
  12658. */
  12659. function ajaxHandleResponses( s, jqXHR, responses ) {
  12660. var ct, type, finalDataType, firstDataType,
  12661. contents = s.contents,
  12662. dataTypes = s.dataTypes;
  12663. // Remove auto dataType and get content-type in the process
  12664. while ( dataTypes[ 0 ] === "*" ) {
  12665. dataTypes.shift();
  12666. if ( ct === undefined ) {
  12667. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  12668. }
  12669. }
  12670. // Check if we're dealing with a known content-type
  12671. if ( ct ) {
  12672. for ( type in contents ) {
  12673. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  12674. dataTypes.unshift( type );
  12675. break;
  12676. }
  12677. }
  12678. }
  12679. // Check to see if we have a response for the expected dataType
  12680. if ( dataTypes[ 0 ] in responses ) {
  12681. finalDataType = dataTypes[ 0 ];
  12682. } else {
  12683. // Try convertible dataTypes
  12684. for ( type in responses ) {
  12685. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  12686. finalDataType = type;
  12687. break;
  12688. }
  12689. if ( !firstDataType ) {
  12690. firstDataType = type;
  12691. }
  12692. }
  12693. // Or just use first one
  12694. finalDataType = finalDataType || firstDataType;
  12695. }
  12696. // If we found a dataType
  12697. // We add the dataType to the list if needed
  12698. // and return the corresponding response
  12699. if ( finalDataType ) {
  12700. if ( finalDataType !== dataTypes[ 0 ] ) {
  12701. dataTypes.unshift( finalDataType );
  12702. }
  12703. return responses[ finalDataType ];
  12704. }
  12705. }
  12706. /* Chain conversions given the request and the original response
  12707. * Also sets the responseXXX fields on the jqXHR instance
  12708. */
  12709. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  12710. var conv2, current, conv, tmp, prev,
  12711. converters = {},
  12712. // Work with a copy of dataTypes in case we need to modify it for conversion
  12713. dataTypes = s.dataTypes.slice();
  12714. // Create converters map with lowercased keys
  12715. if ( dataTypes[ 1 ] ) {
  12716. for ( conv in s.converters ) {
  12717. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  12718. }
  12719. }
  12720. current = dataTypes.shift();
  12721. // Convert to each sequential dataType
  12722. while ( current ) {
  12723. if ( s.responseFields[ current ] ) {
  12724. jqXHR[ s.responseFields[ current ] ] = response;
  12725. }
  12726. // Apply the dataFilter if provided
  12727. if ( !prev && isSuccess && s.dataFilter ) {
  12728. response = s.dataFilter( response, s.dataType );
  12729. }
  12730. prev = current;
  12731. current = dataTypes.shift();
  12732. if ( current ) {
  12733. // There's only work to do if current dataType is non-auto
  12734. if ( current === "*" ) {
  12735. current = prev;
  12736. // Convert response if prev dataType is non-auto and differs from current
  12737. } else if ( prev !== "*" && prev !== current ) {
  12738. // Seek a direct converter
  12739. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  12740. // If none found, seek a pair
  12741. if ( !conv ) {
  12742. for ( conv2 in converters ) {
  12743. // If conv2 outputs current
  12744. tmp = conv2.split( " " );
  12745. if ( tmp[ 1 ] === current ) {
  12746. // If prev can be converted to accepted input
  12747. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  12748. converters[ "* " + tmp[ 0 ] ];
  12749. if ( conv ) {
  12750. // Condense equivalence converters
  12751. if ( conv === true ) {
  12752. conv = converters[ conv2 ];
  12753. // Otherwise, insert the intermediate dataType
  12754. } else if ( converters[ conv2 ] !== true ) {
  12755. current = tmp[ 0 ];
  12756. dataTypes.unshift( tmp[ 1 ] );
  12757. }
  12758. break;
  12759. }
  12760. }
  12761. }
  12762. }
  12763. // Apply converter (if not an equivalence)
  12764. if ( conv !== true ) {
  12765. // Unless errors are allowed to bubble, catch and return them
  12766. if ( conv && s.throws ) {
  12767. response = conv( response );
  12768. } else {
  12769. try {
  12770. response = conv( response );
  12771. } catch ( e ) {
  12772. return {
  12773. state: "parsererror",
  12774. error: conv ? e : "No conversion from " + prev + " to " + current
  12775. };
  12776. }
  12777. }
  12778. }
  12779. }
  12780. }
  12781. }
  12782. return { state: "success", data: response };
  12783. }
  12784. jQuery.extend( {
  12785. // Counter for holding the number of active queries
  12786. active: 0,
  12787. // Last-Modified header cache for next request
  12788. lastModified: {},
  12789. etag: {},
  12790. ajaxSettings: {
  12791. url: location.href,
  12792. type: "GET",
  12793. isLocal: rlocalProtocol.test( location.protocol ),
  12794. global: true,
  12795. processData: true,
  12796. async: true,
  12797. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  12798. /*
  12799. timeout: 0,
  12800. data: null,
  12801. dataType: null,
  12802. username: null,
  12803. password: null,
  12804. cache: null,
  12805. throws: false,
  12806. traditional: false,
  12807. headers: {},
  12808. */
  12809. accepts: {
  12810. "*": allTypes,
  12811. text: "text/plain",
  12812. html: "text/html",
  12813. xml: "application/xml, text/xml",
  12814. json: "application/json, text/javascript"
  12815. },
  12816. contents: {
  12817. xml: /\bxml\b/,
  12818. html: /\bhtml/,
  12819. json: /\bjson\b/
  12820. },
  12821. responseFields: {
  12822. xml: "responseXML",
  12823. text: "responseText",
  12824. json: "responseJSON"
  12825. },
  12826. // Data converters
  12827. // Keys separate source (or catchall "*") and destination types with a single space
  12828. converters: {
  12829. // Convert anything to text
  12830. "* text": String,
  12831. // Text to html (true = no transformation)
  12832. "text html": true,
  12833. // Evaluate text as a json expression
  12834. "text json": JSON.parse,
  12835. // Parse text as xml
  12836. "text xml": jQuery.parseXML
  12837. },
  12838. // For options that shouldn't be deep extended:
  12839. // you can add your own custom options here if
  12840. // and when you create one that shouldn't be
  12841. // deep extended (see ajaxExtend)
  12842. flatOptions: {
  12843. url: true,
  12844. context: true
  12845. }
  12846. },
  12847. // Creates a full fledged settings object into target
  12848. // with both ajaxSettings and settings fields.
  12849. // If target is omitted, writes into ajaxSettings.
  12850. ajaxSetup: function( target, settings ) {
  12851. return settings ?
  12852. // Building a settings object
  12853. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  12854. // Extending ajaxSettings
  12855. ajaxExtend( jQuery.ajaxSettings, target );
  12856. },
  12857. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  12858. ajaxTransport: addToPrefiltersOrTransports( transports ),
  12859. // Main method
  12860. ajax: function( url, options ) {
  12861. // If url is an object, simulate pre-1.5 signature
  12862. if ( typeof url === "object" ) {
  12863. options = url;
  12864. url = undefined;
  12865. }
  12866. // Force options to be an object
  12867. options = options || {};
  12868. var transport,
  12869. // URL without anti-cache param
  12870. cacheURL,
  12871. // Response headers
  12872. responseHeadersString,
  12873. responseHeaders,
  12874. // timeout handle
  12875. timeoutTimer,
  12876. // Url cleanup var
  12877. urlAnchor,
  12878. // Request state (becomes false upon send and true upon completion)
  12879. completed,
  12880. // To know if global events are to be dispatched
  12881. fireGlobals,
  12882. // Loop variable
  12883. i,
  12884. // uncached part of the url
  12885. uncached,
  12886. // Create the final options object
  12887. s = jQuery.ajaxSetup( {}, options ),
  12888. // Callbacks context
  12889. callbackContext = s.context || s,
  12890. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  12891. globalEventContext = s.context &&
  12892. ( callbackContext.nodeType || callbackContext.jquery ) ?
  12893. jQuery( callbackContext ) :
  12894. jQuery.event,
  12895. // Deferreds
  12896. deferred = jQuery.Deferred(),
  12897. completeDeferred = jQuery.Callbacks( "once memory" ),
  12898. // Status-dependent callbacks
  12899. statusCode = s.statusCode || {},
  12900. // Headers (they are sent all at once)
  12901. requestHeaders = {},
  12902. requestHeadersNames = {},
  12903. // Default abort message
  12904. strAbort = "canceled",
  12905. // Fake xhr
  12906. jqXHR = {
  12907. readyState: 0,
  12908. // Builds headers hashtable if needed
  12909. getResponseHeader: function( key ) {
  12910. var match;
  12911. if ( completed ) {
  12912. if ( !responseHeaders ) {
  12913. responseHeaders = {};
  12914. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  12915. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  12916. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  12917. .concat( match[ 2 ] );
  12918. }
  12919. }
  12920. match = responseHeaders[ key.toLowerCase() + " " ];
  12921. }
  12922. return match == null ? null : match.join( ", " );
  12923. },
  12924. // Raw string
  12925. getAllResponseHeaders: function() {
  12926. return completed ? responseHeadersString : null;
  12927. },
  12928. // Caches the header
  12929. setRequestHeader: function( name, value ) {
  12930. if ( completed == null ) {
  12931. name = requestHeadersNames[ name.toLowerCase() ] =
  12932. requestHeadersNames[ name.toLowerCase() ] || name;
  12933. requestHeaders[ name ] = value;
  12934. }
  12935. return this;
  12936. },
  12937. // Overrides response content-type header
  12938. overrideMimeType: function( type ) {
  12939. if ( completed == null ) {
  12940. s.mimeType = type;
  12941. }
  12942. return this;
  12943. },
  12944. // Status-dependent callbacks
  12945. statusCode: function( map ) {
  12946. var code;
  12947. if ( map ) {
  12948. if ( completed ) {
  12949. // Execute the appropriate callbacks
  12950. jqXHR.always( map[ jqXHR.status ] );
  12951. } else {
  12952. // Lazy-add the new callbacks in a way that preserves old ones
  12953. for ( code in map ) {
  12954. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  12955. }
  12956. }
  12957. }
  12958. return this;
  12959. },
  12960. // Cancel the request
  12961. abort: function( statusText ) {
  12962. var finalText = statusText || strAbort;
  12963. if ( transport ) {
  12964. transport.abort( finalText );
  12965. }
  12966. done( 0, finalText );
  12967. return this;
  12968. }
  12969. };
  12970. // Attach deferreds
  12971. deferred.promise( jqXHR );
  12972. // Add protocol if not provided (prefilters might expect it)
  12973. // Handle falsy url in the settings object (#10093: consistency with old signature)
  12974. // We also use the url parameter if available
  12975. s.url = ( ( url || s.url || location.href ) + "" )
  12976. .replace( rprotocol, location.protocol + "//" );
  12977. // Alias method option to type as per ticket #12004
  12978. s.type = options.method || options.type || s.method || s.type;
  12979. // Extract dataTypes list
  12980. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  12981. // A cross-domain request is in order when the origin doesn't match the current origin.
  12982. if ( s.crossDomain == null ) {
  12983. urlAnchor = document.createElement( "a" );
  12984. // Support: IE <=8 - 11, Edge 12 - 15
  12985. // IE throws exception on accessing the href property if url is malformed,
  12986. // e.g. http://example.com:80x/
  12987. try {
  12988. urlAnchor.href = s.url;
  12989. // Support: IE <=8 - 11 only
  12990. // Anchor's host property isn't correctly set when s.url is relative
  12991. urlAnchor.href = urlAnchor.href;
  12992. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  12993. urlAnchor.protocol + "//" + urlAnchor.host;
  12994. } catch ( e ) {
  12995. // If there is an error parsing the URL, assume it is crossDomain,
  12996. // it can be rejected by the transport if it is invalid
  12997. s.crossDomain = true;
  12998. }
  12999. }
  13000. // Convert data if not already a string
  13001. if ( s.data && s.processData && typeof s.data !== "string" ) {
  13002. s.data = jQuery.param( s.data, s.traditional );
  13003. }
  13004. // Apply prefilters
  13005. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  13006. // If request was aborted inside a prefilter, stop there
  13007. if ( completed ) {
  13008. return jqXHR;
  13009. }
  13010. // We can fire global events as of now if asked to
  13011. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  13012. fireGlobals = jQuery.event && s.global;
  13013. // Watch for a new set of requests
  13014. if ( fireGlobals && jQuery.active++ === 0 ) {
  13015. jQuery.event.trigger( "ajaxStart" );
  13016. }
  13017. // Uppercase the type
  13018. s.type = s.type.toUpperCase();
  13019. // Determine if request has content
  13020. s.hasContent = !rnoContent.test( s.type );
  13021. // Save the URL in case we're toying with the If-Modified-Since
  13022. // and/or If-None-Match header later on
  13023. // Remove hash to simplify url manipulation
  13024. cacheURL = s.url.replace( rhash, "" );
  13025. // More options handling for requests with no content
  13026. if ( !s.hasContent ) {
  13027. // Remember the hash so we can put it back
  13028. uncached = s.url.slice( cacheURL.length );
  13029. // If data is available and should be processed, append data to url
  13030. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  13031. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  13032. // #9682: remove data so that it's not used in an eventual retry
  13033. delete s.data;
  13034. }
  13035. // Add or update anti-cache param if needed
  13036. if ( s.cache === false ) {
  13037. cacheURL = cacheURL.replace( rantiCache, "$1" );
  13038. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
  13039. uncached;
  13040. }
  13041. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  13042. s.url = cacheURL + uncached;
  13043. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  13044. } else if ( s.data && s.processData &&
  13045. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  13046. s.data = s.data.replace( r20, "+" );
  13047. }
  13048. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  13049. if ( s.ifModified ) {
  13050. if ( jQuery.lastModified[ cacheURL ] ) {
  13051. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  13052. }
  13053. if ( jQuery.etag[ cacheURL ] ) {
  13054. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  13055. }
  13056. }
  13057. // Set the correct header, if data is being sent
  13058. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  13059. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  13060. }
  13061. // Set the Accepts header for the server, depending on the dataType
  13062. jqXHR.setRequestHeader(
  13063. "Accept",
  13064. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  13065. s.accepts[ s.dataTypes[ 0 ] ] +
  13066. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  13067. s.accepts[ "*" ]
  13068. );
  13069. // Check for headers option
  13070. for ( i in s.headers ) {
  13071. jqXHR.setRequestHeader( i, s.headers[ i ] );
  13072. }
  13073. // Allow custom headers/mimetypes and early abort
  13074. if ( s.beforeSend &&
  13075. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  13076. // Abort if not done already and return
  13077. return jqXHR.abort();
  13078. }
  13079. // Aborting is no longer a cancellation
  13080. strAbort = "abort";
  13081. // Install callbacks on deferreds
  13082. completeDeferred.add( s.complete );
  13083. jqXHR.done( s.success );
  13084. jqXHR.fail( s.error );
  13085. // Get transport
  13086. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  13087. // If no transport, we auto-abort
  13088. if ( !transport ) {
  13089. done( -1, "No Transport" );
  13090. } else {
  13091. jqXHR.readyState = 1;
  13092. // Send global event
  13093. if ( fireGlobals ) {
  13094. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  13095. }
  13096. // If request was aborted inside ajaxSend, stop there
  13097. if ( completed ) {
  13098. return jqXHR;
  13099. }
  13100. // Timeout
  13101. if ( s.async && s.timeout > 0 ) {
  13102. timeoutTimer = window.setTimeout( function() {
  13103. jqXHR.abort( "timeout" );
  13104. }, s.timeout );
  13105. }
  13106. try {
  13107. completed = false;
  13108. transport.send( requestHeaders, done );
  13109. } catch ( e ) {
  13110. // Rethrow post-completion exceptions
  13111. if ( completed ) {
  13112. throw e;
  13113. }
  13114. // Propagate others as results
  13115. done( -1, e );
  13116. }
  13117. }
  13118. // Callback for when everything is done
  13119. function done( status, nativeStatusText, responses, headers ) {
  13120. var isSuccess, success, error, response, modified,
  13121. statusText = nativeStatusText;
  13122. // Ignore repeat invocations
  13123. if ( completed ) {
  13124. return;
  13125. }
  13126. completed = true;
  13127. // Clear timeout if it exists
  13128. if ( timeoutTimer ) {
  13129. window.clearTimeout( timeoutTimer );
  13130. }
  13131. // Dereference transport for early garbage collection
  13132. // (no matter how long the jqXHR object will be used)
  13133. transport = undefined;
  13134. // Cache response headers
  13135. responseHeadersString = headers || "";
  13136. // Set readyState
  13137. jqXHR.readyState = status > 0 ? 4 : 0;
  13138. // Determine if successful
  13139. isSuccess = status >= 200 && status < 300 || status === 304;
  13140. // Get response data
  13141. if ( responses ) {
  13142. response = ajaxHandleResponses( s, jqXHR, responses );
  13143. }
  13144. // Use a noop converter for missing script
  13145. if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
  13146. s.converters[ "text script" ] = function() {};
  13147. }
  13148. // Convert no matter what (that way responseXXX fields are always set)
  13149. response = ajaxConvert( s, response, jqXHR, isSuccess );
  13150. // If successful, handle type chaining
  13151. if ( isSuccess ) {
  13152. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  13153. if ( s.ifModified ) {
  13154. modified = jqXHR.getResponseHeader( "Last-Modified" );
  13155. if ( modified ) {
  13156. jQuery.lastModified[ cacheURL ] = modified;
  13157. }
  13158. modified = jqXHR.getResponseHeader( "etag" );
  13159. if ( modified ) {
  13160. jQuery.etag[ cacheURL ] = modified;
  13161. }
  13162. }
  13163. // if no content
  13164. if ( status === 204 || s.type === "HEAD" ) {
  13165. statusText = "nocontent";
  13166. // if not modified
  13167. } else if ( status === 304 ) {
  13168. statusText = "notmodified";
  13169. // If we have data, let's convert it
  13170. } else {
  13171. statusText = response.state;
  13172. success = response.data;
  13173. error = response.error;
  13174. isSuccess = !error;
  13175. }
  13176. } else {
  13177. // Extract error from statusText and normalize for non-aborts
  13178. error = statusText;
  13179. if ( status || !statusText ) {
  13180. statusText = "error";
  13181. if ( status < 0 ) {
  13182. status = 0;
  13183. }
  13184. }
  13185. }
  13186. // Set data for the fake xhr object
  13187. jqXHR.status = status;
  13188. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  13189. // Success/Error
  13190. if ( isSuccess ) {
  13191. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  13192. } else {
  13193. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  13194. }
  13195. // Status-dependent callbacks
  13196. jqXHR.statusCode( statusCode );
  13197. statusCode = undefined;
  13198. if ( fireGlobals ) {
  13199. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  13200. [ jqXHR, s, isSuccess ? success : error ] );
  13201. }
  13202. // Complete
  13203. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  13204. if ( fireGlobals ) {
  13205. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  13206. // Handle the global AJAX counter
  13207. if ( !( --jQuery.active ) ) {
  13208. jQuery.event.trigger( "ajaxStop" );
  13209. }
  13210. }
  13211. }
  13212. return jqXHR;
  13213. },
  13214. getJSON: function( url, data, callback ) {
  13215. return jQuery.get( url, data, callback, "json" );
  13216. },
  13217. getScript: function( url, callback ) {
  13218. return jQuery.get( url, undefined, callback, "script" );
  13219. }
  13220. } );
  13221. jQuery.each( [ "get", "post" ], function( _i, method ) {
  13222. jQuery[ method ] = function( url, data, callback, type ) {
  13223. // Shift arguments if data argument was omitted
  13224. if ( isFunction( data ) ) {
  13225. type = type || callback;
  13226. callback = data;
  13227. data = undefined;
  13228. }
  13229. // The url can be an options object (which then must have .url)
  13230. return jQuery.ajax( jQuery.extend( {
  13231. url: url,
  13232. type: method,
  13233. dataType: type,
  13234. data: data,
  13235. success: callback
  13236. }, jQuery.isPlainObject( url ) && url ) );
  13237. };
  13238. } );
  13239. jQuery.ajaxPrefilter( function( s ) {
  13240. var i;
  13241. for ( i in s.headers ) {
  13242. if ( i.toLowerCase() === "content-type" ) {
  13243. s.contentType = s.headers[ i ] || "";
  13244. }
  13245. }
  13246. } );
  13247. jQuery._evalUrl = function( url, options, doc ) {
  13248. return jQuery.ajax( {
  13249. url: url,
  13250. // Make this explicit, since user can override this through ajaxSetup (#11264)
  13251. type: "GET",
  13252. dataType: "script",
  13253. cache: true,
  13254. async: false,
  13255. global: false,
  13256. // Only evaluate the response if it is successful (gh-4126)
  13257. // dataFilter is not invoked for failure responses, so using it instead
  13258. // of the default converter is kludgy but it works.
  13259. converters: {
  13260. "text script": function() {}
  13261. },
  13262. dataFilter: function( response ) {
  13263. jQuery.globalEval( response, options, doc );
  13264. }
  13265. } );
  13266. };
  13267. jQuery.fn.extend( {
  13268. wrapAll: function( html ) {
  13269. var wrap;
  13270. if ( this[ 0 ] ) {
  13271. if ( isFunction( html ) ) {
  13272. html = html.call( this[ 0 ] );
  13273. }
  13274. // The elements to wrap the target around
  13275. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  13276. if ( this[ 0 ].parentNode ) {
  13277. wrap.insertBefore( this[ 0 ] );
  13278. }
  13279. wrap.map( function() {
  13280. var elem = this;
  13281. while ( elem.firstElementChild ) {
  13282. elem = elem.firstElementChild;
  13283. }
  13284. return elem;
  13285. } ).append( this );
  13286. }
  13287. return this;
  13288. },
  13289. wrapInner: function( html ) {
  13290. if ( isFunction( html ) ) {
  13291. return this.each( function( i ) {
  13292. jQuery( this ).wrapInner( html.call( this, i ) );
  13293. } );
  13294. }
  13295. return this.each( function() {
  13296. var self = jQuery( this ),
  13297. contents = self.contents();
  13298. if ( contents.length ) {
  13299. contents.wrapAll( html );
  13300. } else {
  13301. self.append( html );
  13302. }
  13303. } );
  13304. },
  13305. wrap: function( html ) {
  13306. var htmlIsFunction = isFunction( html );
  13307. return this.each( function( i ) {
  13308. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  13309. } );
  13310. },
  13311. unwrap: function( selector ) {
  13312. this.parent( selector ).not( "body" ).each( function() {
  13313. jQuery( this ).replaceWith( this.childNodes );
  13314. } );
  13315. return this;
  13316. }
  13317. } );
  13318. jQuery.expr.pseudos.hidden = function( elem ) {
  13319. return !jQuery.expr.pseudos.visible( elem );
  13320. };
  13321. jQuery.expr.pseudos.visible = function( elem ) {
  13322. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  13323. };
  13324. jQuery.ajaxSettings.xhr = function() {
  13325. try {
  13326. return new window.XMLHttpRequest();
  13327. } catch ( e ) {}
  13328. };
  13329. var xhrSuccessStatus = {
  13330. // File protocol always yields status code 0, assume 200
  13331. 0: 200,
  13332. // Support: IE <=9 only
  13333. // #1450: sometimes IE returns 1223 when it should be 204
  13334. 1223: 204
  13335. },
  13336. xhrSupported = jQuery.ajaxSettings.xhr();
  13337. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  13338. support.ajax = xhrSupported = !!xhrSupported;
  13339. jQuery.ajaxTransport( function( options ) {
  13340. var callback, errorCallback;
  13341. // Cross domain only allowed if supported through XMLHttpRequest
  13342. if ( support.cors || xhrSupported && !options.crossDomain ) {
  13343. return {
  13344. send: function( headers, complete ) {
  13345. var i,
  13346. xhr = options.xhr();
  13347. xhr.open(
  13348. options.type,
  13349. options.url,
  13350. options.async,
  13351. options.username,
  13352. options.password
  13353. );
  13354. // Apply custom fields if provided
  13355. if ( options.xhrFields ) {
  13356. for ( i in options.xhrFields ) {
  13357. xhr[ i ] = options.xhrFields[ i ];
  13358. }
  13359. }
  13360. // Override mime type if needed
  13361. if ( options.mimeType && xhr.overrideMimeType ) {
  13362. xhr.overrideMimeType( options.mimeType );
  13363. }
  13364. // X-Requested-With header
  13365. // For cross-domain requests, seeing as conditions for a preflight are
  13366. // akin to a jigsaw puzzle, we simply never set it to be sure.
  13367. // (it can always be set on a per-request basis or even using ajaxSetup)
  13368. // For same-domain requests, won't change header if already provided.
  13369. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  13370. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  13371. }
  13372. // Set headers
  13373. for ( i in headers ) {
  13374. xhr.setRequestHeader( i, headers[ i ] );
  13375. }
  13376. // Callback
  13377. callback = function( type ) {
  13378. return function() {
  13379. if ( callback ) {
  13380. callback = errorCallback = xhr.onload =
  13381. xhr.onerror = xhr.onabort = xhr.ontimeout =
  13382. xhr.onreadystatechange = null;
  13383. if ( type === "abort" ) {
  13384. xhr.abort();
  13385. } else if ( type === "error" ) {
  13386. // Support: IE <=9 only
  13387. // On a manual native abort, IE9 throws
  13388. // errors on any property access that is not readyState
  13389. if ( typeof xhr.status !== "number" ) {
  13390. complete( 0, "error" );
  13391. } else {
  13392. complete(
  13393. // File: protocol always yields status 0; see #8605, #14207
  13394. xhr.status,
  13395. xhr.statusText
  13396. );
  13397. }
  13398. } else {
  13399. complete(
  13400. xhrSuccessStatus[ xhr.status ] || xhr.status,
  13401. xhr.statusText,
  13402. // Support: IE <=9 only
  13403. // IE9 has no XHR2 but throws on binary (trac-11426)
  13404. // For XHR2 non-text, let the caller handle it (gh-2498)
  13405. ( xhr.responseType || "text" ) !== "text" ||
  13406. typeof xhr.responseText !== "string" ?
  13407. { binary: xhr.response } :
  13408. { text: xhr.responseText },
  13409. xhr.getAllResponseHeaders()
  13410. );
  13411. }
  13412. }
  13413. };
  13414. };
  13415. // Listen to events
  13416. xhr.onload = callback();
  13417. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  13418. // Support: IE 9 only
  13419. // Use onreadystatechange to replace onabort
  13420. // to handle uncaught aborts
  13421. if ( xhr.onabort !== undefined ) {
  13422. xhr.onabort = errorCallback;
  13423. } else {
  13424. xhr.onreadystatechange = function() {
  13425. // Check readyState before timeout as it changes
  13426. if ( xhr.readyState === 4 ) {
  13427. // Allow onerror to be called first,
  13428. // but that will not handle a native abort
  13429. // Also, save errorCallback to a variable
  13430. // as xhr.onerror cannot be accessed
  13431. window.setTimeout( function() {
  13432. if ( callback ) {
  13433. errorCallback();
  13434. }
  13435. } );
  13436. }
  13437. };
  13438. }
  13439. // Create the abort callback
  13440. callback = callback( "abort" );
  13441. try {
  13442. // Do send the request (this may raise an exception)
  13443. xhr.send( options.hasContent && options.data || null );
  13444. } catch ( e ) {
  13445. // #14683: Only rethrow if this hasn't been notified as an error yet
  13446. if ( callback ) {
  13447. throw e;
  13448. }
  13449. }
  13450. },
  13451. abort: function() {
  13452. if ( callback ) {
  13453. callback();
  13454. }
  13455. }
  13456. };
  13457. }
  13458. } );
  13459. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  13460. jQuery.ajaxPrefilter( function( s ) {
  13461. if ( s.crossDomain ) {
  13462. s.contents.script = false;
  13463. }
  13464. } );
  13465. // Install script dataType
  13466. jQuery.ajaxSetup( {
  13467. accepts: {
  13468. script: "text/javascript, application/javascript, " +
  13469. "application/ecmascript, application/x-ecmascript"
  13470. },
  13471. contents: {
  13472. script: /\b(?:java|ecma)script\b/
  13473. },
  13474. converters: {
  13475. "text script": function( text ) {
  13476. jQuery.globalEval( text );
  13477. return text;
  13478. }
  13479. }
  13480. } );
  13481. // Handle cache's special case and crossDomain
  13482. jQuery.ajaxPrefilter( "script", function( s ) {
  13483. if ( s.cache === undefined ) {
  13484. s.cache = false;
  13485. }
  13486. if ( s.crossDomain ) {
  13487. s.type = "GET";
  13488. }
  13489. } );
  13490. // Bind script tag hack transport
  13491. jQuery.ajaxTransport( "script", function( s ) {
  13492. // This transport only deals with cross domain or forced-by-attrs requests
  13493. if ( s.crossDomain || s.scriptAttrs ) {
  13494. var script, callback;
  13495. return {
  13496. send: function( _, complete ) {
  13497. script = jQuery( "<script>" )
  13498. .attr( s.scriptAttrs || {} )
  13499. .prop( { charset: s.scriptCharset, src: s.url } )
  13500. .on( "load error", callback = function( evt ) {
  13501. script.remove();
  13502. callback = null;
  13503. if ( evt ) {
  13504. complete( evt.type === "error" ? 404 : 200, evt.type );
  13505. }
  13506. } );
  13507. // Use native DOM manipulation to avoid our domManip AJAX trickery
  13508. document.head.appendChild( script[ 0 ] );
  13509. },
  13510. abort: function() {
  13511. if ( callback ) {
  13512. callback();
  13513. }
  13514. }
  13515. };
  13516. }
  13517. } );
  13518. var oldCallbacks = [],
  13519. rjsonp = /(=)\?(?=&|$)|\?\?/;
  13520. // Default jsonp settings
  13521. jQuery.ajaxSetup( {
  13522. jsonp: "callback",
  13523. jsonpCallback: function() {
  13524. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
  13525. this[ callback ] = true;
  13526. return callback;
  13527. }
  13528. } );
  13529. // Detect, normalize options and install callbacks for jsonp requests
  13530. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  13531. var callbackName, overwritten, responseContainer,
  13532. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  13533. "url" :
  13534. typeof s.data === "string" &&
  13535. ( s.contentType || "" )
  13536. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  13537. rjsonp.test( s.data ) && "data"
  13538. );
  13539. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  13540. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  13541. // Get callback name, remembering preexisting value associated with it
  13542. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  13543. s.jsonpCallback() :
  13544. s.jsonpCallback;
  13545. // Insert callback into url or form data
  13546. if ( jsonProp ) {
  13547. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  13548. } else if ( s.jsonp !== false ) {
  13549. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  13550. }
  13551. // Use data converter to retrieve json after script execution
  13552. s.converters[ "script json" ] = function() {
  13553. if ( !responseContainer ) {
  13554. jQuery.error( callbackName + " was not called" );
  13555. }
  13556. return responseContainer[ 0 ];
  13557. };
  13558. // Force json dataType
  13559. s.dataTypes[ 0 ] = "json";
  13560. // Install callback
  13561. overwritten = window[ callbackName ];
  13562. window[ callbackName ] = function() {
  13563. responseContainer = arguments;
  13564. };
  13565. // Clean-up function (fires after converters)
  13566. jqXHR.always( function() {
  13567. // If previous value didn't exist - remove it
  13568. if ( overwritten === undefined ) {
  13569. jQuery( window ).removeProp( callbackName );
  13570. // Otherwise restore preexisting value
  13571. } else {
  13572. window[ callbackName ] = overwritten;
  13573. }
  13574. // Save back as free
  13575. if ( s[ callbackName ] ) {
  13576. // Make sure that re-using the options doesn't screw things around
  13577. s.jsonpCallback = originalSettings.jsonpCallback;
  13578. // Save the callback name for future use
  13579. oldCallbacks.push( callbackName );
  13580. }
  13581. // Call if it was a function and we have a response
  13582. if ( responseContainer && isFunction( overwritten ) ) {
  13583. overwritten( responseContainer[ 0 ] );
  13584. }
  13585. responseContainer = overwritten = undefined;
  13586. } );
  13587. // Delegate to script
  13588. return "script";
  13589. }
  13590. } );
  13591. // Support: Safari 8 only
  13592. // In Safari 8 documents created via document.implementation.createHTMLDocument
  13593. // collapse sibling forms: the second one becomes a child of the first one.
  13594. // Because of that, this security measure has to be disabled in Safari 8.
  13595. // https://bugs.webkit.org/show_bug.cgi?id=137337
  13596. support.createHTMLDocument = ( function() {
  13597. var body = document.implementation.createHTMLDocument( "" ).body;
  13598. body.innerHTML = "<form></form><form></form>";
  13599. return body.childNodes.length === 2;
  13600. } )();
  13601. // Argument "data" should be string of html
  13602. // context (optional): If specified, the fragment will be created in this context,
  13603. // defaults to document
  13604. // keepScripts (optional): If true, will include scripts passed in the html string
  13605. jQuery.parseHTML = function( data, context, keepScripts ) {
  13606. if ( typeof data !== "string" ) {
  13607. return [];
  13608. }
  13609. if ( typeof context === "boolean" ) {
  13610. keepScripts = context;
  13611. context = false;
  13612. }
  13613. var base, parsed, scripts;
  13614. if ( !context ) {
  13615. // Stop scripts or inline event handlers from being executed immediately
  13616. // by using document.implementation
  13617. if ( support.createHTMLDocument ) {
  13618. context = document.implementation.createHTMLDocument( "" );
  13619. // Set the base href for the created document
  13620. // so any parsed elements with URLs
  13621. // are based on the document's URL (gh-2965)
  13622. base = context.createElement( "base" );
  13623. base.href = document.location.href;
  13624. context.head.appendChild( base );
  13625. } else {
  13626. context = document;
  13627. }
  13628. }
  13629. parsed = rsingleTag.exec( data );
  13630. scripts = !keepScripts && [];
  13631. // Single tag
  13632. if ( parsed ) {
  13633. return [ context.createElement( parsed[ 1 ] ) ];
  13634. }
  13635. parsed = buildFragment( [ data ], context, scripts );
  13636. if ( scripts && scripts.length ) {
  13637. jQuery( scripts ).remove();
  13638. }
  13639. return jQuery.merge( [], parsed.childNodes );
  13640. };
  13641. /**
  13642. * Load a url into a page
  13643. */
  13644. jQuery.fn.load = function( url, params, callback ) {
  13645. var selector, type, response,
  13646. self = this,
  13647. off = url.indexOf( " " );
  13648. if ( off > -1 ) {
  13649. selector = stripAndCollapse( url.slice( off ) );
  13650. url = url.slice( 0, off );
  13651. }
  13652. // If it's a function
  13653. if ( isFunction( params ) ) {
  13654. // We assume that it's the callback
  13655. callback = params;
  13656. params = undefined;
  13657. // Otherwise, build a param string
  13658. } else if ( params && typeof params === "object" ) {
  13659. type = "POST";
  13660. }
  13661. // If we have elements to modify, make the request
  13662. if ( self.length > 0 ) {
  13663. jQuery.ajax( {
  13664. url: url,
  13665. // If "type" variable is undefined, then "GET" method will be used.
  13666. // Make value of this field explicit since
  13667. // user can override it through ajaxSetup method
  13668. type: type || "GET",
  13669. dataType: "html",
  13670. data: params
  13671. } ).done( function( responseText ) {
  13672. // Save response for use in complete callback
  13673. response = arguments;
  13674. self.html( selector ?
  13675. // If a selector was specified, locate the right elements in a dummy div
  13676. // Exclude scripts to avoid IE 'Permission Denied' errors
  13677. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  13678. // Otherwise use the full result
  13679. responseText );
  13680. // If the request succeeds, this function gets "data", "status", "jqXHR"
  13681. // but they are ignored because response was set above.
  13682. // If it fails, this function gets "jqXHR", "status", "error"
  13683. } ).always( callback && function( jqXHR, status ) {
  13684. self.each( function() {
  13685. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  13686. } );
  13687. } );
  13688. }
  13689. return this;
  13690. };
  13691. jQuery.expr.pseudos.animated = function( elem ) {
  13692. return jQuery.grep( jQuery.timers, function( fn ) {
  13693. return elem === fn.elem;
  13694. } ).length;
  13695. };
  13696. jQuery.offset = {
  13697. setOffset: function( elem, options, i ) {
  13698. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  13699. position = jQuery.css( elem, "position" ),
  13700. curElem = jQuery( elem ),
  13701. props = {};
  13702. // Set position first, in-case top/left are set even on static elem
  13703. if ( position === "static" ) {
  13704. elem.style.position = "relative";
  13705. }
  13706. curOffset = curElem.offset();
  13707. curCSSTop = jQuery.css( elem, "top" );
  13708. curCSSLeft = jQuery.css( elem, "left" );
  13709. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  13710. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  13711. // Need to be able to calculate position if either
  13712. // top or left is auto and position is either absolute or fixed
  13713. if ( calculatePosition ) {
  13714. curPosition = curElem.position();
  13715. curTop = curPosition.top;
  13716. curLeft = curPosition.left;
  13717. } else {
  13718. curTop = parseFloat( curCSSTop ) || 0;
  13719. curLeft = parseFloat( curCSSLeft ) || 0;
  13720. }
  13721. if ( isFunction( options ) ) {
  13722. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  13723. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  13724. }
  13725. if ( options.top != null ) {
  13726. props.top = ( options.top - curOffset.top ) + curTop;
  13727. }
  13728. if ( options.left != null ) {
  13729. props.left = ( options.left - curOffset.left ) + curLeft;
  13730. }
  13731. if ( "using" in options ) {
  13732. options.using.call( elem, props );
  13733. } else {
  13734. if ( typeof props.top === "number" ) {
  13735. props.top += "px";
  13736. }
  13737. if ( typeof props.left === "number" ) {
  13738. props.left += "px";
  13739. }
  13740. curElem.css( props );
  13741. }
  13742. }
  13743. };
  13744. jQuery.fn.extend( {
  13745. // offset() relates an element's border box to the document origin
  13746. offset: function( options ) {
  13747. // Preserve chaining for setter
  13748. if ( arguments.length ) {
  13749. return options === undefined ?
  13750. this :
  13751. this.each( function( i ) {
  13752. jQuery.offset.setOffset( this, options, i );
  13753. } );
  13754. }
  13755. var rect, win,
  13756. elem = this[ 0 ];
  13757. if ( !elem ) {
  13758. return;
  13759. }
  13760. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  13761. // Support: IE <=11 only
  13762. // Running getBoundingClientRect on a
  13763. // disconnected node in IE throws an error
  13764. if ( !elem.getClientRects().length ) {
  13765. return { top: 0, left: 0 };
  13766. }
  13767. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  13768. rect = elem.getBoundingClientRect();
  13769. win = elem.ownerDocument.defaultView;
  13770. return {
  13771. top: rect.top + win.pageYOffset,
  13772. left: rect.left + win.pageXOffset
  13773. };
  13774. },
  13775. // position() relates an element's margin box to its offset parent's padding box
  13776. // This corresponds to the behavior of CSS absolute positioning
  13777. position: function() {
  13778. if ( !this[ 0 ] ) {
  13779. return;
  13780. }
  13781. var offsetParent, offset, doc,
  13782. elem = this[ 0 ],
  13783. parentOffset = { top: 0, left: 0 };
  13784. // position:fixed elements are offset from the viewport, which itself always has zero offset
  13785. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  13786. // Assume position:fixed implies availability of getBoundingClientRect
  13787. offset = elem.getBoundingClientRect();
  13788. } else {
  13789. offset = this.offset();
  13790. // Account for the *real* offset parent, which can be the document or its root element
  13791. // when a statically positioned element is identified
  13792. doc = elem.ownerDocument;
  13793. offsetParent = elem.offsetParent || doc.documentElement;
  13794. while ( offsetParent &&
  13795. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  13796. jQuery.css( offsetParent, "position" ) === "static" ) {
  13797. offsetParent = offsetParent.parentNode;
  13798. }
  13799. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  13800. // Incorporate borders into its offset, since they are outside its content origin
  13801. parentOffset = jQuery( offsetParent ).offset();
  13802. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  13803. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  13804. }
  13805. }
  13806. // Subtract parent offsets and element margins
  13807. return {
  13808. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  13809. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  13810. };
  13811. },
  13812. // This method will return documentElement in the following cases:
  13813. // 1) For the element inside the iframe without offsetParent, this method will return
  13814. // documentElement of the parent window
  13815. // 2) For the hidden or detached element
  13816. // 3) For body or html element, i.e. in case of the html node - it will return itself
  13817. //
  13818. // but those exceptions were never presented as a real life use-cases
  13819. // and might be considered as more preferable results.
  13820. //
  13821. // This logic, however, is not guaranteed and can change at any point in the future
  13822. offsetParent: function() {
  13823. return this.map( function() {
  13824. var offsetParent = this.offsetParent;
  13825. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  13826. offsetParent = offsetParent.offsetParent;
  13827. }
  13828. return offsetParent || documentElement;
  13829. } );
  13830. }
  13831. } );
  13832. // Create scrollLeft and scrollTop methods
  13833. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  13834. var top = "pageYOffset" === prop;
  13835. jQuery.fn[ method ] = function( val ) {
  13836. return access( this, function( elem, method, val ) {
  13837. // Coalesce documents and windows
  13838. var win;
  13839. if ( isWindow( elem ) ) {
  13840. win = elem;
  13841. } else if ( elem.nodeType === 9 ) {
  13842. win = elem.defaultView;
  13843. }
  13844. if ( val === undefined ) {
  13845. return win ? win[ prop ] : elem[ method ];
  13846. }
  13847. if ( win ) {
  13848. win.scrollTo(
  13849. !top ? val : win.pageXOffset,
  13850. top ? val : win.pageYOffset
  13851. );
  13852. } else {
  13853. elem[ method ] = val;
  13854. }
  13855. }, method, val, arguments.length );
  13856. };
  13857. } );
  13858. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  13859. // Add the top/left cssHooks using jQuery.fn.position
  13860. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  13861. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  13862. // getComputedStyle returns percent when specified for top/left/bottom/right;
  13863. // rather than make the css module depend on the offset module, just check for it here
  13864. jQuery.each( [ "top", "left" ], function( _i, prop ) {
  13865. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  13866. function( elem, computed ) {
  13867. if ( computed ) {
  13868. computed = curCSS( elem, prop );
  13869. // If curCSS returns percentage, fallback to offset
  13870. return rnumnonpx.test( computed ) ?
  13871. jQuery( elem ).position()[ prop ] + "px" :
  13872. computed;
  13873. }
  13874. }
  13875. );
  13876. } );
  13877. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  13878. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  13879. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  13880. function( defaultExtra, funcName ) {
  13881. // Margin is only for outerHeight, outerWidth
  13882. jQuery.fn[ funcName ] = function( margin, value ) {
  13883. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  13884. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  13885. return access( this, function( elem, type, value ) {
  13886. var doc;
  13887. if ( isWindow( elem ) ) {
  13888. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  13889. return funcName.indexOf( "outer" ) === 0 ?
  13890. elem[ "inner" + name ] :
  13891. elem.document.documentElement[ "client" + name ];
  13892. }
  13893. // Get document width or height
  13894. if ( elem.nodeType === 9 ) {
  13895. doc = elem.documentElement;
  13896. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  13897. // whichever is greatest
  13898. return Math.max(
  13899. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  13900. elem.body[ "offset" + name ], doc[ "offset" + name ],
  13901. doc[ "client" + name ]
  13902. );
  13903. }
  13904. return value === undefined ?
  13905. // Get width or height on the element, requesting but not forcing parseFloat
  13906. jQuery.css( elem, type, extra ) :
  13907. // Set width or height on the element
  13908. jQuery.style( elem, type, value, extra );
  13909. }, type, chainable ? margin : undefined, chainable );
  13910. };
  13911. } );
  13912. } );
  13913. jQuery.each( [
  13914. "ajaxStart",
  13915. "ajaxStop",
  13916. "ajaxComplete",
  13917. "ajaxError",
  13918. "ajaxSuccess",
  13919. "ajaxSend"
  13920. ], function( _i, type ) {
  13921. jQuery.fn[ type ] = function( fn ) {
  13922. return this.on( type, fn );
  13923. };
  13924. } );
  13925. jQuery.fn.extend( {
  13926. bind: function( types, data, fn ) {
  13927. return this.on( types, null, data, fn );
  13928. },
  13929. unbind: function( types, fn ) {
  13930. return this.off( types, null, fn );
  13931. },
  13932. delegate: function( selector, types, data, fn ) {
  13933. return this.on( types, selector, data, fn );
  13934. },
  13935. undelegate: function( selector, types, fn ) {
  13936. // ( namespace ) or ( selector, types [, fn] )
  13937. return arguments.length === 1 ?
  13938. this.off( selector, "**" ) :
  13939. this.off( types, selector || "**", fn );
  13940. },
  13941. hover: function( fnOver, fnOut ) {
  13942. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  13943. }
  13944. } );
  13945. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  13946. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  13947. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  13948. function( _i, name ) {
  13949. // Handle event binding
  13950. jQuery.fn[ name ] = function( data, fn ) {
  13951. return arguments.length > 0 ?
  13952. this.on( name, null, data, fn ) :
  13953. this.trigger( name );
  13954. };
  13955. } );
  13956. // Support: Android <=4.0 only
  13957. // Make sure we trim BOM and NBSP
  13958. var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  13959. // Bind a function to a context, optionally partially applying any
  13960. // arguments.
  13961. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  13962. // However, it is not slated for removal any time soon
  13963. jQuery.proxy = function( fn, context ) {
  13964. var tmp, args, proxy;
  13965. if ( typeof context === "string" ) {
  13966. tmp = fn[ context ];
  13967. context = fn;
  13968. fn = tmp;
  13969. }
  13970. // Quick check to determine if target is callable, in the spec
  13971. // this throws a TypeError, but we will just return undefined.
  13972. if ( !isFunction( fn ) ) {
  13973. return undefined;
  13974. }
  13975. // Simulated bind
  13976. args = slice.call( arguments, 2 );
  13977. proxy = function() {
  13978. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  13979. };
  13980. // Set the guid of unique handler to the same of original handler, so it can be removed
  13981. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  13982. return proxy;
  13983. };
  13984. jQuery.holdReady = function( hold ) {
  13985. if ( hold ) {
  13986. jQuery.readyWait++;
  13987. } else {
  13988. jQuery.ready( true );
  13989. }
  13990. };
  13991. jQuery.isArray = Array.isArray;
  13992. jQuery.parseJSON = JSON.parse;
  13993. jQuery.nodeName = nodeName;
  13994. jQuery.isFunction = isFunction;
  13995. jQuery.isWindow = isWindow;
  13996. jQuery.camelCase = camelCase;
  13997. jQuery.type = toType;
  13998. jQuery.now = Date.now;
  13999. jQuery.isNumeric = function( obj ) {
  14000. // As of jQuery 3.0, isNumeric is limited to
  14001. // strings and numbers (primitives or objects)
  14002. // that can be coerced to finite numbers (gh-2662)
  14003. var type = jQuery.type( obj );
  14004. return ( type === "number" || type === "string" ) &&
  14005. // parseFloat NaNs numeric-cast false positives ("")
  14006. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  14007. // subtraction forces infinities to NaN
  14008. !isNaN( obj - parseFloat( obj ) );
  14009. };
  14010. jQuery.trim = function( text ) {
  14011. return text == null ?
  14012. "" :
  14013. ( text + "" ).replace( rtrim, "" );
  14014. };
  14015. // Register as a named AMD module, since jQuery can be concatenated with other
  14016. // files that may use define, but not via a proper concatenation script that
  14017. // understands anonymous AMD modules. A named AMD is safest and most robust
  14018. // way to register. Lowercase jquery is used because AMD module names are
  14019. // derived from file names, and jQuery is normally delivered in a lowercase
  14020. // file name. Do this after creating the global so that if an AMD module wants
  14021. // to call noConflict to hide this version of jQuery, it will work.
  14022. // Note that for maximum portability, libraries that are not jQuery should
  14023. // declare themselves as anonymous modules, and avoid setting a global if an
  14024. // AMD loader is present. jQuery is a special case. For more information, see
  14025. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  14026. if ( true ) {
  14027. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  14028. return jQuery;
  14029. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  14030. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  14031. }
  14032. var
  14033. // Map over jQuery in case of overwrite
  14034. _jQuery = window.jQuery,
  14035. // Map over the $ in case of overwrite
  14036. _$ = window.$;
  14037. jQuery.noConflict = function( deep ) {
  14038. if ( window.$ === jQuery ) {
  14039. window.$ = _$;
  14040. }
  14041. if ( deep && window.jQuery === jQuery ) {
  14042. window.jQuery = _jQuery;
  14043. }
  14044. return jQuery;
  14045. };
  14046. // Expose jQuery and $ identifiers, even in AMD
  14047. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  14048. // and CommonJS for browser emulators (#13566)
  14049. if ( typeof noGlobal === "undefined" ) {
  14050. window.jQuery = window.$ = jQuery;
  14051. }
  14052. return jQuery;
  14053. } );
  14054. /***/ }),
  14055. /***/ "./node_modules/lodash/lodash.js":
  14056. /*!***************************************!*\
  14057. !*** ./node_modules/lodash/lodash.js ***!
  14058. \***************************************/
  14059. /*! no static exports found */
  14060. /***/ (function(module, exports, __webpack_require__) {
  14061. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  14062. * @license
  14063. * Lodash <https://lodash.com/>
  14064. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  14065. * Released under MIT license <https://lodash.com/license>
  14066. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  14067. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  14068. */
  14069. ;(function() {
  14070. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  14071. var undefined;
  14072. /** Used as the semantic version number. */
  14073. var VERSION = '4.17.15';
  14074. /** Used as the size to enable large array optimizations. */
  14075. var LARGE_ARRAY_SIZE = 200;
  14076. /** Error message constants. */
  14077. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  14078. FUNC_ERROR_TEXT = 'Expected a function';
  14079. /** Used to stand-in for `undefined` hash values. */
  14080. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  14081. /** Used as the maximum memoize cache size. */
  14082. var MAX_MEMOIZE_SIZE = 500;
  14083. /** Used as the internal argument placeholder. */
  14084. var PLACEHOLDER = '__lodash_placeholder__';
  14085. /** Used to compose bitmasks for cloning. */
  14086. var CLONE_DEEP_FLAG = 1,
  14087. CLONE_FLAT_FLAG = 2,
  14088. CLONE_SYMBOLS_FLAG = 4;
  14089. /** Used to compose bitmasks for value comparisons. */
  14090. var COMPARE_PARTIAL_FLAG = 1,
  14091. COMPARE_UNORDERED_FLAG = 2;
  14092. /** Used to compose bitmasks for function metadata. */
  14093. var WRAP_BIND_FLAG = 1,
  14094. WRAP_BIND_KEY_FLAG = 2,
  14095. WRAP_CURRY_BOUND_FLAG = 4,
  14096. WRAP_CURRY_FLAG = 8,
  14097. WRAP_CURRY_RIGHT_FLAG = 16,
  14098. WRAP_PARTIAL_FLAG = 32,
  14099. WRAP_PARTIAL_RIGHT_FLAG = 64,
  14100. WRAP_ARY_FLAG = 128,
  14101. WRAP_REARG_FLAG = 256,
  14102. WRAP_FLIP_FLAG = 512;
  14103. /** Used as default options for `_.truncate`. */
  14104. var DEFAULT_TRUNC_LENGTH = 30,
  14105. DEFAULT_TRUNC_OMISSION = '...';
  14106. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  14107. var HOT_COUNT = 800,
  14108. HOT_SPAN = 16;
  14109. /** Used to indicate the type of lazy iteratees. */
  14110. var LAZY_FILTER_FLAG = 1,
  14111. LAZY_MAP_FLAG = 2,
  14112. LAZY_WHILE_FLAG = 3;
  14113. /** Used as references for various `Number` constants. */
  14114. var INFINITY = 1 / 0,
  14115. MAX_SAFE_INTEGER = 9007199254740991,
  14116. MAX_INTEGER = 1.7976931348623157e+308,
  14117. NAN = 0 / 0;
  14118. /** Used as references for the maximum length and index of an array. */
  14119. var MAX_ARRAY_LENGTH = 4294967295,
  14120. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  14121. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  14122. /** Used to associate wrap methods with their bit flags. */
  14123. var wrapFlags = [
  14124. ['ary', WRAP_ARY_FLAG],
  14125. ['bind', WRAP_BIND_FLAG],
  14126. ['bindKey', WRAP_BIND_KEY_FLAG],
  14127. ['curry', WRAP_CURRY_FLAG],
  14128. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  14129. ['flip', WRAP_FLIP_FLAG],
  14130. ['partial', WRAP_PARTIAL_FLAG],
  14131. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  14132. ['rearg', WRAP_REARG_FLAG]
  14133. ];
  14134. /** `Object#toString` result references. */
  14135. var argsTag = '[object Arguments]',
  14136. arrayTag = '[object Array]',
  14137. asyncTag = '[object AsyncFunction]',
  14138. boolTag = '[object Boolean]',
  14139. dateTag = '[object Date]',
  14140. domExcTag = '[object DOMException]',
  14141. errorTag = '[object Error]',
  14142. funcTag = '[object Function]',
  14143. genTag = '[object GeneratorFunction]',
  14144. mapTag = '[object Map]',
  14145. numberTag = '[object Number]',
  14146. nullTag = '[object Null]',
  14147. objectTag = '[object Object]',
  14148. promiseTag = '[object Promise]',
  14149. proxyTag = '[object Proxy]',
  14150. regexpTag = '[object RegExp]',
  14151. setTag = '[object Set]',
  14152. stringTag = '[object String]',
  14153. symbolTag = '[object Symbol]',
  14154. undefinedTag = '[object Undefined]',
  14155. weakMapTag = '[object WeakMap]',
  14156. weakSetTag = '[object WeakSet]';
  14157. var arrayBufferTag = '[object ArrayBuffer]',
  14158. dataViewTag = '[object DataView]',
  14159. float32Tag = '[object Float32Array]',
  14160. float64Tag = '[object Float64Array]',
  14161. int8Tag = '[object Int8Array]',
  14162. int16Tag = '[object Int16Array]',
  14163. int32Tag = '[object Int32Array]',
  14164. uint8Tag = '[object Uint8Array]',
  14165. uint8ClampedTag = '[object Uint8ClampedArray]',
  14166. uint16Tag = '[object Uint16Array]',
  14167. uint32Tag = '[object Uint32Array]';
  14168. /** Used to match empty string literals in compiled template source. */
  14169. var reEmptyStringLeading = /\b__p \+= '';/g,
  14170. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  14171. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  14172. /** Used to match HTML entities and HTML characters. */
  14173. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  14174. reUnescapedHtml = /[&<>"']/g,
  14175. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  14176. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  14177. /** Used to match template delimiters. */
  14178. var reEscape = /<%-([\s\S]+?)%>/g,
  14179. reEvaluate = /<%([\s\S]+?)%>/g,
  14180. reInterpolate = /<%=([\s\S]+?)%>/g;
  14181. /** Used to match property names within property paths. */
  14182. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  14183. reIsPlainProp = /^\w*$/,
  14184. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  14185. /**
  14186. * Used to match `RegExp`
  14187. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  14188. */
  14189. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  14190. reHasRegExpChar = RegExp(reRegExpChar.source);
  14191. /** Used to match leading and trailing whitespace. */
  14192. var reTrim = /^\s+|\s+$/g,
  14193. reTrimStart = /^\s+/,
  14194. reTrimEnd = /\s+$/;
  14195. /** Used to match wrap detail comments. */
  14196. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  14197. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  14198. reSplitDetails = /,? & /;
  14199. /** Used to match words composed of alphanumeric characters. */
  14200. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  14201. /** Used to match backslashes in property paths. */
  14202. var reEscapeChar = /\\(\\)?/g;
  14203. /**
  14204. * Used to match
  14205. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  14206. */
  14207. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  14208. /** Used to match `RegExp` flags from their coerced string values. */
  14209. var reFlags = /\w*$/;
  14210. /** Used to detect bad signed hexadecimal string values. */
  14211. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  14212. /** Used to detect binary string values. */
  14213. var reIsBinary = /^0b[01]+$/i;
  14214. /** Used to detect host constructors (Safari). */
  14215. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  14216. /** Used to detect octal string values. */
  14217. var reIsOctal = /^0o[0-7]+$/i;
  14218. /** Used to detect unsigned integer values. */
  14219. var reIsUint = /^(?:0|[1-9]\d*)$/;
  14220. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  14221. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  14222. /** Used to ensure capturing order of template delimiters. */
  14223. var reNoMatch = /($^)/;
  14224. /** Used to match unescaped characters in compiled string literals. */
  14225. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  14226. /** Used to compose unicode character classes. */
  14227. var rsAstralRange = '\\ud800-\\udfff',
  14228. rsComboMarksRange = '\\u0300-\\u036f',
  14229. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  14230. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  14231. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  14232. rsDingbatRange = '\\u2700-\\u27bf',
  14233. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  14234. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  14235. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  14236. rsPunctuationRange = '\\u2000-\\u206f',
  14237. 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',
  14238. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  14239. rsVarRange = '\\ufe0e\\ufe0f',
  14240. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  14241. /** Used to compose unicode capture groups. */
  14242. var rsApos = "['\u2019]",
  14243. rsAstral = '[' + rsAstralRange + ']',
  14244. rsBreak = '[' + rsBreakRange + ']',
  14245. rsCombo = '[' + rsComboRange + ']',
  14246. rsDigits = '\\d+',
  14247. rsDingbat = '[' + rsDingbatRange + ']',
  14248. rsLower = '[' + rsLowerRange + ']',
  14249. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  14250. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  14251. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  14252. rsNonAstral = '[^' + rsAstralRange + ']',
  14253. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  14254. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  14255. rsUpper = '[' + rsUpperRange + ']',
  14256. rsZWJ = '\\u200d';
  14257. /** Used to compose unicode regexes. */
  14258. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  14259. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  14260. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  14261. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  14262. reOptMod = rsModifier + '?',
  14263. rsOptVar = '[' + rsVarRange + ']?',
  14264. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  14265. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  14266. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  14267. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  14268. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  14269. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  14270. /** Used to match apostrophes. */
  14271. var reApos = RegExp(rsApos, 'g');
  14272. /**
  14273. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  14274. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  14275. */
  14276. var reComboMark = RegExp(rsCombo, 'g');
  14277. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  14278. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  14279. /** Used to match complex or compound words. */
  14280. var reUnicodeWord = RegExp([
  14281. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  14282. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  14283. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  14284. rsUpper + '+' + rsOptContrUpper,
  14285. rsOrdUpper,
  14286. rsOrdLower,
  14287. rsDigits,
  14288. rsEmoji
  14289. ].join('|'), 'g');
  14290. /** 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/). */
  14291. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  14292. /** Used to detect strings that need a more robust regexp to match words. */
  14293. 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 ]/;
  14294. /** Used to assign default `context` object properties. */
  14295. var contextProps = [
  14296. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  14297. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  14298. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  14299. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  14300. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  14301. ];
  14302. /** Used to make template sourceURLs easier to identify. */
  14303. var templateCounter = -1;
  14304. /** Used to identify `toStringTag` values of typed arrays. */
  14305. var typedArrayTags = {};
  14306. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  14307. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  14308. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  14309. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  14310. typedArrayTags[uint32Tag] = true;
  14311. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  14312. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  14313. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  14314. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  14315. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  14316. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  14317. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  14318. typedArrayTags[weakMapTag] = false;
  14319. /** Used to identify `toStringTag` values supported by `_.clone`. */
  14320. var cloneableTags = {};
  14321. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  14322. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  14323. cloneableTags[boolTag] = cloneableTags[dateTag] =
  14324. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  14325. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  14326. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  14327. cloneableTags[numberTag] = cloneableTags[objectTag] =
  14328. cloneableTags[regexpTag] = cloneableTags[setTag] =
  14329. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  14330. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  14331. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  14332. cloneableTags[errorTag] = cloneableTags[funcTag] =
  14333. cloneableTags[weakMapTag] = false;
  14334. /** Used to map Latin Unicode letters to basic Latin letters. */
  14335. var deburredLetters = {
  14336. // Latin-1 Supplement block.
  14337. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  14338. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  14339. '\xc7': 'C', '\xe7': 'c',
  14340. '\xd0': 'D', '\xf0': 'd',
  14341. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  14342. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  14343. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  14344. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  14345. '\xd1': 'N', '\xf1': 'n',
  14346. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  14347. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  14348. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  14349. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  14350. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  14351. '\xc6': 'Ae', '\xe6': 'ae',
  14352. '\xde': 'Th', '\xfe': 'th',
  14353. '\xdf': 'ss',
  14354. // Latin Extended-A block.
  14355. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  14356. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  14357. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  14358. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  14359. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  14360. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  14361. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  14362. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  14363. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  14364. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  14365. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  14366. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  14367. '\u0134': 'J', '\u0135': 'j',
  14368. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  14369. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  14370. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  14371. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  14372. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  14373. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  14374. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  14375. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  14376. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  14377. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  14378. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  14379. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  14380. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  14381. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  14382. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  14383. '\u0174': 'W', '\u0175': 'w',
  14384. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  14385. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  14386. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  14387. '\u0132': 'IJ', '\u0133': 'ij',
  14388. '\u0152': 'Oe', '\u0153': 'oe',
  14389. '\u0149': "'n", '\u017f': 's'
  14390. };
  14391. /** Used to map characters to HTML entities. */
  14392. var htmlEscapes = {
  14393. '&': '&amp;',
  14394. '<': '&lt;',
  14395. '>': '&gt;',
  14396. '"': '&quot;',
  14397. "'": '&#39;'
  14398. };
  14399. /** Used to map HTML entities to characters. */
  14400. var htmlUnescapes = {
  14401. '&amp;': '&',
  14402. '&lt;': '<',
  14403. '&gt;': '>',
  14404. '&quot;': '"',
  14405. '&#39;': "'"
  14406. };
  14407. /** Used to escape characters for inclusion in compiled string literals. */
  14408. var stringEscapes = {
  14409. '\\': '\\',
  14410. "'": "'",
  14411. '\n': 'n',
  14412. '\r': 'r',
  14413. '\u2028': 'u2028',
  14414. '\u2029': 'u2029'
  14415. };
  14416. /** Built-in method references without a dependency on `root`. */
  14417. var freeParseFloat = parseFloat,
  14418. freeParseInt = parseInt;
  14419. /** Detect free variable `global` from Node.js. */
  14420. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  14421. /** Detect free variable `self`. */
  14422. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  14423. /** Used as a reference to the global object. */
  14424. var root = freeGlobal || freeSelf || Function('return this')();
  14425. /** Detect free variable `exports`. */
  14426. var freeExports = true && exports && !exports.nodeType && exports;
  14427. /** Detect free variable `module`. */
  14428. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  14429. /** Detect the popular CommonJS extension `module.exports`. */
  14430. var moduleExports = freeModule && freeModule.exports === freeExports;
  14431. /** Detect free variable `process` from Node.js. */
  14432. var freeProcess = moduleExports && freeGlobal.process;
  14433. /** Used to access faster Node.js helpers. */
  14434. var nodeUtil = (function() {
  14435. try {
  14436. // Use `util.types` for Node.js 10+.
  14437. var types = freeModule && freeModule.require && freeModule.require('util').types;
  14438. if (types) {
  14439. return types;
  14440. }
  14441. // Legacy `process.binding('util')` for Node.js < 10.
  14442. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  14443. } catch (e) {}
  14444. }());
  14445. /* Node.js helper references. */
  14446. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  14447. nodeIsDate = nodeUtil && nodeUtil.isDate,
  14448. nodeIsMap = nodeUtil && nodeUtil.isMap,
  14449. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  14450. nodeIsSet = nodeUtil && nodeUtil.isSet,
  14451. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  14452. /*--------------------------------------------------------------------------*/
  14453. /**
  14454. * A faster alternative to `Function#apply`, this function invokes `func`
  14455. * with the `this` binding of `thisArg` and the arguments of `args`.
  14456. *
  14457. * @private
  14458. * @param {Function} func The function to invoke.
  14459. * @param {*} thisArg The `this` binding of `func`.
  14460. * @param {Array} args The arguments to invoke `func` with.
  14461. * @returns {*} Returns the result of `func`.
  14462. */
  14463. function apply(func, thisArg, args) {
  14464. switch (args.length) {
  14465. case 0: return func.call(thisArg);
  14466. case 1: return func.call(thisArg, args[0]);
  14467. case 2: return func.call(thisArg, args[0], args[1]);
  14468. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  14469. }
  14470. return func.apply(thisArg, args);
  14471. }
  14472. /**
  14473. * A specialized version of `baseAggregator` for arrays.
  14474. *
  14475. * @private
  14476. * @param {Array} [array] The array to iterate over.
  14477. * @param {Function} setter The function to set `accumulator` values.
  14478. * @param {Function} iteratee The iteratee to transform keys.
  14479. * @param {Object} accumulator The initial aggregated object.
  14480. * @returns {Function} Returns `accumulator`.
  14481. */
  14482. function arrayAggregator(array, setter, iteratee, accumulator) {
  14483. var index = -1,
  14484. length = array == null ? 0 : array.length;
  14485. while (++index < length) {
  14486. var value = array[index];
  14487. setter(accumulator, value, iteratee(value), array);
  14488. }
  14489. return accumulator;
  14490. }
  14491. /**
  14492. * A specialized version of `_.forEach` for arrays without support for
  14493. * iteratee shorthands.
  14494. *
  14495. * @private
  14496. * @param {Array} [array] The array to iterate over.
  14497. * @param {Function} iteratee The function invoked per iteration.
  14498. * @returns {Array} Returns `array`.
  14499. */
  14500. function arrayEach(array, iteratee) {
  14501. var index = -1,
  14502. length = array == null ? 0 : array.length;
  14503. while (++index < length) {
  14504. if (iteratee(array[index], index, array) === false) {
  14505. break;
  14506. }
  14507. }
  14508. return array;
  14509. }
  14510. /**
  14511. * A specialized version of `_.forEachRight` for arrays without support for
  14512. * iteratee shorthands.
  14513. *
  14514. * @private
  14515. * @param {Array} [array] The array to iterate over.
  14516. * @param {Function} iteratee The function invoked per iteration.
  14517. * @returns {Array} Returns `array`.
  14518. */
  14519. function arrayEachRight(array, iteratee) {
  14520. var length = array == null ? 0 : array.length;
  14521. while (length--) {
  14522. if (iteratee(array[length], length, array) === false) {
  14523. break;
  14524. }
  14525. }
  14526. return array;
  14527. }
  14528. /**
  14529. * A specialized version of `_.every` for arrays without support for
  14530. * iteratee shorthands.
  14531. *
  14532. * @private
  14533. * @param {Array} [array] The array to iterate over.
  14534. * @param {Function} predicate The function invoked per iteration.
  14535. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  14536. * else `false`.
  14537. */
  14538. function arrayEvery(array, predicate) {
  14539. var index = -1,
  14540. length = array == null ? 0 : array.length;
  14541. while (++index < length) {
  14542. if (!predicate(array[index], index, array)) {
  14543. return false;
  14544. }
  14545. }
  14546. return true;
  14547. }
  14548. /**
  14549. * A specialized version of `_.filter` for arrays without support for
  14550. * iteratee shorthands.
  14551. *
  14552. * @private
  14553. * @param {Array} [array] The array to iterate over.
  14554. * @param {Function} predicate The function invoked per iteration.
  14555. * @returns {Array} Returns the new filtered array.
  14556. */
  14557. function arrayFilter(array, predicate) {
  14558. var index = -1,
  14559. length = array == null ? 0 : array.length,
  14560. resIndex = 0,
  14561. result = [];
  14562. while (++index < length) {
  14563. var value = array[index];
  14564. if (predicate(value, index, array)) {
  14565. result[resIndex++] = value;
  14566. }
  14567. }
  14568. return result;
  14569. }
  14570. /**
  14571. * A specialized version of `_.includes` for arrays without support for
  14572. * specifying an index to search from.
  14573. *
  14574. * @private
  14575. * @param {Array} [array] The array to inspect.
  14576. * @param {*} target The value to search for.
  14577. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14578. */
  14579. function arrayIncludes(array, value) {
  14580. var length = array == null ? 0 : array.length;
  14581. return !!length && baseIndexOf(array, value, 0) > -1;
  14582. }
  14583. /**
  14584. * This function is like `arrayIncludes` except that it accepts a comparator.
  14585. *
  14586. * @private
  14587. * @param {Array} [array] The array to inspect.
  14588. * @param {*} target The value to search for.
  14589. * @param {Function} comparator The comparator invoked per element.
  14590. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14591. */
  14592. function arrayIncludesWith(array, value, comparator) {
  14593. var index = -1,
  14594. length = array == null ? 0 : array.length;
  14595. while (++index < length) {
  14596. if (comparator(value, array[index])) {
  14597. return true;
  14598. }
  14599. }
  14600. return false;
  14601. }
  14602. /**
  14603. * A specialized version of `_.map` for arrays without support for iteratee
  14604. * shorthands.
  14605. *
  14606. * @private
  14607. * @param {Array} [array] The array to iterate over.
  14608. * @param {Function} iteratee The function invoked per iteration.
  14609. * @returns {Array} Returns the new mapped array.
  14610. */
  14611. function arrayMap(array, iteratee) {
  14612. var index = -1,
  14613. length = array == null ? 0 : array.length,
  14614. result = Array(length);
  14615. while (++index < length) {
  14616. result[index] = iteratee(array[index], index, array);
  14617. }
  14618. return result;
  14619. }
  14620. /**
  14621. * Appends the elements of `values` to `array`.
  14622. *
  14623. * @private
  14624. * @param {Array} array The array to modify.
  14625. * @param {Array} values The values to append.
  14626. * @returns {Array} Returns `array`.
  14627. */
  14628. function arrayPush(array, values) {
  14629. var index = -1,
  14630. length = values.length,
  14631. offset = array.length;
  14632. while (++index < length) {
  14633. array[offset + index] = values[index];
  14634. }
  14635. return array;
  14636. }
  14637. /**
  14638. * A specialized version of `_.reduce` for arrays without support for
  14639. * iteratee shorthands.
  14640. *
  14641. * @private
  14642. * @param {Array} [array] The array to iterate over.
  14643. * @param {Function} iteratee The function invoked per iteration.
  14644. * @param {*} [accumulator] The initial value.
  14645. * @param {boolean} [initAccum] Specify using the first element of `array` as
  14646. * the initial value.
  14647. * @returns {*} Returns the accumulated value.
  14648. */
  14649. function arrayReduce(array, iteratee, accumulator, initAccum) {
  14650. var index = -1,
  14651. length = array == null ? 0 : array.length;
  14652. if (initAccum && length) {
  14653. accumulator = array[++index];
  14654. }
  14655. while (++index < length) {
  14656. accumulator = iteratee(accumulator, array[index], index, array);
  14657. }
  14658. return accumulator;
  14659. }
  14660. /**
  14661. * A specialized version of `_.reduceRight` for arrays without support for
  14662. * iteratee shorthands.
  14663. *
  14664. * @private
  14665. * @param {Array} [array] The array to iterate over.
  14666. * @param {Function} iteratee The function invoked per iteration.
  14667. * @param {*} [accumulator] The initial value.
  14668. * @param {boolean} [initAccum] Specify using the last element of `array` as
  14669. * the initial value.
  14670. * @returns {*} Returns the accumulated value.
  14671. */
  14672. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  14673. var length = array == null ? 0 : array.length;
  14674. if (initAccum && length) {
  14675. accumulator = array[--length];
  14676. }
  14677. while (length--) {
  14678. accumulator = iteratee(accumulator, array[length], length, array);
  14679. }
  14680. return accumulator;
  14681. }
  14682. /**
  14683. * A specialized version of `_.some` for arrays without support for iteratee
  14684. * shorthands.
  14685. *
  14686. * @private
  14687. * @param {Array} [array] The array to iterate over.
  14688. * @param {Function} predicate The function invoked per iteration.
  14689. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14690. * else `false`.
  14691. */
  14692. function arraySome(array, predicate) {
  14693. var index = -1,
  14694. length = array == null ? 0 : array.length;
  14695. while (++index < length) {
  14696. if (predicate(array[index], index, array)) {
  14697. return true;
  14698. }
  14699. }
  14700. return false;
  14701. }
  14702. /**
  14703. * Gets the size of an ASCII `string`.
  14704. *
  14705. * @private
  14706. * @param {string} string The string inspect.
  14707. * @returns {number} Returns the string size.
  14708. */
  14709. var asciiSize = baseProperty('length');
  14710. /**
  14711. * Converts an ASCII `string` to an array.
  14712. *
  14713. * @private
  14714. * @param {string} string The string to convert.
  14715. * @returns {Array} Returns the converted array.
  14716. */
  14717. function asciiToArray(string) {
  14718. return string.split('');
  14719. }
  14720. /**
  14721. * Splits an ASCII `string` into an array of its words.
  14722. *
  14723. * @private
  14724. * @param {string} The string to inspect.
  14725. * @returns {Array} Returns the words of `string`.
  14726. */
  14727. function asciiWords(string) {
  14728. return string.match(reAsciiWord) || [];
  14729. }
  14730. /**
  14731. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  14732. * without support for iteratee shorthands, which iterates over `collection`
  14733. * using `eachFunc`.
  14734. *
  14735. * @private
  14736. * @param {Array|Object} collection The collection to inspect.
  14737. * @param {Function} predicate The function invoked per iteration.
  14738. * @param {Function} eachFunc The function to iterate over `collection`.
  14739. * @returns {*} Returns the found element or its key, else `undefined`.
  14740. */
  14741. function baseFindKey(collection, predicate, eachFunc) {
  14742. var result;
  14743. eachFunc(collection, function(value, key, collection) {
  14744. if (predicate(value, key, collection)) {
  14745. result = key;
  14746. return false;
  14747. }
  14748. });
  14749. return result;
  14750. }
  14751. /**
  14752. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  14753. * support for iteratee shorthands.
  14754. *
  14755. * @private
  14756. * @param {Array} array The array to inspect.
  14757. * @param {Function} predicate The function invoked per iteration.
  14758. * @param {number} fromIndex The index to search from.
  14759. * @param {boolean} [fromRight] Specify iterating from right to left.
  14760. * @returns {number} Returns the index of the matched value, else `-1`.
  14761. */
  14762. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  14763. var length = array.length,
  14764. index = fromIndex + (fromRight ? 1 : -1);
  14765. while ((fromRight ? index-- : ++index < length)) {
  14766. if (predicate(array[index], index, array)) {
  14767. return index;
  14768. }
  14769. }
  14770. return -1;
  14771. }
  14772. /**
  14773. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  14774. *
  14775. * @private
  14776. * @param {Array} array The array to inspect.
  14777. * @param {*} value The value to search for.
  14778. * @param {number} fromIndex The index to search from.
  14779. * @returns {number} Returns the index of the matched value, else `-1`.
  14780. */
  14781. function baseIndexOf(array, value, fromIndex) {
  14782. return value === value
  14783. ? strictIndexOf(array, value, fromIndex)
  14784. : baseFindIndex(array, baseIsNaN, fromIndex);
  14785. }
  14786. /**
  14787. * This function is like `baseIndexOf` except that it accepts a comparator.
  14788. *
  14789. * @private
  14790. * @param {Array} array The array to inspect.
  14791. * @param {*} value The value to search for.
  14792. * @param {number} fromIndex The index to search from.
  14793. * @param {Function} comparator The comparator invoked per element.
  14794. * @returns {number} Returns the index of the matched value, else `-1`.
  14795. */
  14796. function baseIndexOfWith(array, value, fromIndex, comparator) {
  14797. var index = fromIndex - 1,
  14798. length = array.length;
  14799. while (++index < length) {
  14800. if (comparator(array[index], value)) {
  14801. return index;
  14802. }
  14803. }
  14804. return -1;
  14805. }
  14806. /**
  14807. * The base implementation of `_.isNaN` without support for number objects.
  14808. *
  14809. * @private
  14810. * @param {*} value The value to check.
  14811. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  14812. */
  14813. function baseIsNaN(value) {
  14814. return value !== value;
  14815. }
  14816. /**
  14817. * The base implementation of `_.mean` and `_.meanBy` without support for
  14818. * iteratee shorthands.
  14819. *
  14820. * @private
  14821. * @param {Array} array The array to iterate over.
  14822. * @param {Function} iteratee The function invoked per iteration.
  14823. * @returns {number} Returns the mean.
  14824. */
  14825. function baseMean(array, iteratee) {
  14826. var length = array == null ? 0 : array.length;
  14827. return length ? (baseSum(array, iteratee) / length) : NAN;
  14828. }
  14829. /**
  14830. * The base implementation of `_.property` without support for deep paths.
  14831. *
  14832. * @private
  14833. * @param {string} key The key of the property to get.
  14834. * @returns {Function} Returns the new accessor function.
  14835. */
  14836. function baseProperty(key) {
  14837. return function(object) {
  14838. return object == null ? undefined : object[key];
  14839. };
  14840. }
  14841. /**
  14842. * The base implementation of `_.propertyOf` without support for deep paths.
  14843. *
  14844. * @private
  14845. * @param {Object} object The object to query.
  14846. * @returns {Function} Returns the new accessor function.
  14847. */
  14848. function basePropertyOf(object) {
  14849. return function(key) {
  14850. return object == null ? undefined : object[key];
  14851. };
  14852. }
  14853. /**
  14854. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  14855. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  14856. *
  14857. * @private
  14858. * @param {Array|Object} collection The collection to iterate over.
  14859. * @param {Function} iteratee The function invoked per iteration.
  14860. * @param {*} accumulator The initial value.
  14861. * @param {boolean} initAccum Specify using the first or last element of
  14862. * `collection` as the initial value.
  14863. * @param {Function} eachFunc The function to iterate over `collection`.
  14864. * @returns {*} Returns the accumulated value.
  14865. */
  14866. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  14867. eachFunc(collection, function(value, index, collection) {
  14868. accumulator = initAccum
  14869. ? (initAccum = false, value)
  14870. : iteratee(accumulator, value, index, collection);
  14871. });
  14872. return accumulator;
  14873. }
  14874. /**
  14875. * The base implementation of `_.sortBy` which uses `comparer` to define the
  14876. * sort order of `array` and replaces criteria objects with their corresponding
  14877. * values.
  14878. *
  14879. * @private
  14880. * @param {Array} array The array to sort.
  14881. * @param {Function} comparer The function to define sort order.
  14882. * @returns {Array} Returns `array`.
  14883. */
  14884. function baseSortBy(array, comparer) {
  14885. var length = array.length;
  14886. array.sort(comparer);
  14887. while (length--) {
  14888. array[length] = array[length].value;
  14889. }
  14890. return array;
  14891. }
  14892. /**
  14893. * The base implementation of `_.sum` and `_.sumBy` without support for
  14894. * iteratee shorthands.
  14895. *
  14896. * @private
  14897. * @param {Array} array The array to iterate over.
  14898. * @param {Function} iteratee The function invoked per iteration.
  14899. * @returns {number} Returns the sum.
  14900. */
  14901. function baseSum(array, iteratee) {
  14902. var result,
  14903. index = -1,
  14904. length = array.length;
  14905. while (++index < length) {
  14906. var current = iteratee(array[index]);
  14907. if (current !== undefined) {
  14908. result = result === undefined ? current : (result + current);
  14909. }
  14910. }
  14911. return result;
  14912. }
  14913. /**
  14914. * The base implementation of `_.times` without support for iteratee shorthands
  14915. * or max array length checks.
  14916. *
  14917. * @private
  14918. * @param {number} n The number of times to invoke `iteratee`.
  14919. * @param {Function} iteratee The function invoked per iteration.
  14920. * @returns {Array} Returns the array of results.
  14921. */
  14922. function baseTimes(n, iteratee) {
  14923. var index = -1,
  14924. result = Array(n);
  14925. while (++index < n) {
  14926. result[index] = iteratee(index);
  14927. }
  14928. return result;
  14929. }
  14930. /**
  14931. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  14932. * of key-value pairs for `object` corresponding to the property names of `props`.
  14933. *
  14934. * @private
  14935. * @param {Object} object The object to query.
  14936. * @param {Array} props The property names to get values for.
  14937. * @returns {Object} Returns the key-value pairs.
  14938. */
  14939. function baseToPairs(object, props) {
  14940. return arrayMap(props, function(key) {
  14941. return [key, object[key]];
  14942. });
  14943. }
  14944. /**
  14945. * The base implementation of `_.unary` without support for storing metadata.
  14946. *
  14947. * @private
  14948. * @param {Function} func The function to cap arguments for.
  14949. * @returns {Function} Returns the new capped function.
  14950. */
  14951. function baseUnary(func) {
  14952. return function(value) {
  14953. return func(value);
  14954. };
  14955. }
  14956. /**
  14957. * The base implementation of `_.values` and `_.valuesIn` which creates an
  14958. * array of `object` property values corresponding to the property names
  14959. * of `props`.
  14960. *
  14961. * @private
  14962. * @param {Object} object The object to query.
  14963. * @param {Array} props The property names to get values for.
  14964. * @returns {Object} Returns the array of property values.
  14965. */
  14966. function baseValues(object, props) {
  14967. return arrayMap(props, function(key) {
  14968. return object[key];
  14969. });
  14970. }
  14971. /**
  14972. * Checks if a `cache` value for `key` exists.
  14973. *
  14974. * @private
  14975. * @param {Object} cache The cache to query.
  14976. * @param {string} key The key of the entry to check.
  14977. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  14978. */
  14979. function cacheHas(cache, key) {
  14980. return cache.has(key);
  14981. }
  14982. /**
  14983. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  14984. * that is not found in the character symbols.
  14985. *
  14986. * @private
  14987. * @param {Array} strSymbols The string symbols to inspect.
  14988. * @param {Array} chrSymbols The character symbols to find.
  14989. * @returns {number} Returns the index of the first unmatched string symbol.
  14990. */
  14991. function charsStartIndex(strSymbols, chrSymbols) {
  14992. var index = -1,
  14993. length = strSymbols.length;
  14994. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14995. return index;
  14996. }
  14997. /**
  14998. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  14999. * that is not found in the character symbols.
  15000. *
  15001. * @private
  15002. * @param {Array} strSymbols The string symbols to inspect.
  15003. * @param {Array} chrSymbols The character symbols to find.
  15004. * @returns {number} Returns the index of the last unmatched string symbol.
  15005. */
  15006. function charsEndIndex(strSymbols, chrSymbols) {
  15007. var index = strSymbols.length;
  15008. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  15009. return index;
  15010. }
  15011. /**
  15012. * Gets the number of `placeholder` occurrences in `array`.
  15013. *
  15014. * @private
  15015. * @param {Array} array The array to inspect.
  15016. * @param {*} placeholder The placeholder to search for.
  15017. * @returns {number} Returns the placeholder count.
  15018. */
  15019. function countHolders(array, placeholder) {
  15020. var length = array.length,
  15021. result = 0;
  15022. while (length--) {
  15023. if (array[length] === placeholder) {
  15024. ++result;
  15025. }
  15026. }
  15027. return result;
  15028. }
  15029. /**
  15030. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  15031. * letters to basic Latin letters.
  15032. *
  15033. * @private
  15034. * @param {string} letter The matched letter to deburr.
  15035. * @returns {string} Returns the deburred letter.
  15036. */
  15037. var deburrLetter = basePropertyOf(deburredLetters);
  15038. /**
  15039. * Used by `_.escape` to convert characters to HTML entities.
  15040. *
  15041. * @private
  15042. * @param {string} chr The matched character to escape.
  15043. * @returns {string} Returns the escaped character.
  15044. */
  15045. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  15046. /**
  15047. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  15048. *
  15049. * @private
  15050. * @param {string} chr The matched character to escape.
  15051. * @returns {string} Returns the escaped character.
  15052. */
  15053. function escapeStringChar(chr) {
  15054. return '\\' + stringEscapes[chr];
  15055. }
  15056. /**
  15057. * Gets the value at `key` of `object`.
  15058. *
  15059. * @private
  15060. * @param {Object} [object] The object to query.
  15061. * @param {string} key The key of the property to get.
  15062. * @returns {*} Returns the property value.
  15063. */
  15064. function getValue(object, key) {
  15065. return object == null ? undefined : object[key];
  15066. }
  15067. /**
  15068. * Checks if `string` contains Unicode symbols.
  15069. *
  15070. * @private
  15071. * @param {string} string The string to inspect.
  15072. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  15073. */
  15074. function hasUnicode(string) {
  15075. return reHasUnicode.test(string);
  15076. }
  15077. /**
  15078. * Checks if `string` contains a word composed of Unicode symbols.
  15079. *
  15080. * @private
  15081. * @param {string} string The string to inspect.
  15082. * @returns {boolean} Returns `true` if a word is found, else `false`.
  15083. */
  15084. function hasUnicodeWord(string) {
  15085. return reHasUnicodeWord.test(string);
  15086. }
  15087. /**
  15088. * Converts `iterator` to an array.
  15089. *
  15090. * @private
  15091. * @param {Object} iterator The iterator to convert.
  15092. * @returns {Array} Returns the converted array.
  15093. */
  15094. function iteratorToArray(iterator) {
  15095. var data,
  15096. result = [];
  15097. while (!(data = iterator.next()).done) {
  15098. result.push(data.value);
  15099. }
  15100. return result;
  15101. }
  15102. /**
  15103. * Converts `map` to its key-value pairs.
  15104. *
  15105. * @private
  15106. * @param {Object} map The map to convert.
  15107. * @returns {Array} Returns the key-value pairs.
  15108. */
  15109. function mapToArray(map) {
  15110. var index = -1,
  15111. result = Array(map.size);
  15112. map.forEach(function(value, key) {
  15113. result[++index] = [key, value];
  15114. });
  15115. return result;
  15116. }
  15117. /**
  15118. * Creates a unary function that invokes `func` with its argument transformed.
  15119. *
  15120. * @private
  15121. * @param {Function} func The function to wrap.
  15122. * @param {Function} transform The argument transform.
  15123. * @returns {Function} Returns the new function.
  15124. */
  15125. function overArg(func, transform) {
  15126. return function(arg) {
  15127. return func(transform(arg));
  15128. };
  15129. }
  15130. /**
  15131. * Replaces all `placeholder` elements in `array` with an internal placeholder
  15132. * and returns an array of their indexes.
  15133. *
  15134. * @private
  15135. * @param {Array} array The array to modify.
  15136. * @param {*} placeholder The placeholder to replace.
  15137. * @returns {Array} Returns the new array of placeholder indexes.
  15138. */
  15139. function replaceHolders(array, placeholder) {
  15140. var index = -1,
  15141. length = array.length,
  15142. resIndex = 0,
  15143. result = [];
  15144. while (++index < length) {
  15145. var value = array[index];
  15146. if (value === placeholder || value === PLACEHOLDER) {
  15147. array[index] = PLACEHOLDER;
  15148. result[resIndex++] = index;
  15149. }
  15150. }
  15151. return result;
  15152. }
  15153. /**
  15154. * Converts `set` to an array of its values.
  15155. *
  15156. * @private
  15157. * @param {Object} set The set to convert.
  15158. * @returns {Array} Returns the values.
  15159. */
  15160. function setToArray(set) {
  15161. var index = -1,
  15162. result = Array(set.size);
  15163. set.forEach(function(value) {
  15164. result[++index] = value;
  15165. });
  15166. return result;
  15167. }
  15168. /**
  15169. * Converts `set` to its value-value pairs.
  15170. *
  15171. * @private
  15172. * @param {Object} set The set to convert.
  15173. * @returns {Array} Returns the value-value pairs.
  15174. */
  15175. function setToPairs(set) {
  15176. var index = -1,
  15177. result = Array(set.size);
  15178. set.forEach(function(value) {
  15179. result[++index] = [value, value];
  15180. });
  15181. return result;
  15182. }
  15183. /**
  15184. * A specialized version of `_.indexOf` which performs strict equality
  15185. * comparisons of values, i.e. `===`.
  15186. *
  15187. * @private
  15188. * @param {Array} array The array to inspect.
  15189. * @param {*} value The value to search for.
  15190. * @param {number} fromIndex The index to search from.
  15191. * @returns {number} Returns the index of the matched value, else `-1`.
  15192. */
  15193. function strictIndexOf(array, value, fromIndex) {
  15194. var index = fromIndex - 1,
  15195. length = array.length;
  15196. while (++index < length) {
  15197. if (array[index] === value) {
  15198. return index;
  15199. }
  15200. }
  15201. return -1;
  15202. }
  15203. /**
  15204. * A specialized version of `_.lastIndexOf` which performs strict equality
  15205. * comparisons of values, i.e. `===`.
  15206. *
  15207. * @private
  15208. * @param {Array} array The array to inspect.
  15209. * @param {*} value The value to search for.
  15210. * @param {number} fromIndex The index to search from.
  15211. * @returns {number} Returns the index of the matched value, else `-1`.
  15212. */
  15213. function strictLastIndexOf(array, value, fromIndex) {
  15214. var index = fromIndex + 1;
  15215. while (index--) {
  15216. if (array[index] === value) {
  15217. return index;
  15218. }
  15219. }
  15220. return index;
  15221. }
  15222. /**
  15223. * Gets the number of symbols in `string`.
  15224. *
  15225. * @private
  15226. * @param {string} string The string to inspect.
  15227. * @returns {number} Returns the string size.
  15228. */
  15229. function stringSize(string) {
  15230. return hasUnicode(string)
  15231. ? unicodeSize(string)
  15232. : asciiSize(string);
  15233. }
  15234. /**
  15235. * Converts `string` to an array.
  15236. *
  15237. * @private
  15238. * @param {string} string The string to convert.
  15239. * @returns {Array} Returns the converted array.
  15240. */
  15241. function stringToArray(string) {
  15242. return hasUnicode(string)
  15243. ? unicodeToArray(string)
  15244. : asciiToArray(string);
  15245. }
  15246. /**
  15247. * Used by `_.unescape` to convert HTML entities to characters.
  15248. *
  15249. * @private
  15250. * @param {string} chr The matched character to unescape.
  15251. * @returns {string} Returns the unescaped character.
  15252. */
  15253. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  15254. /**
  15255. * Gets the size of a Unicode `string`.
  15256. *
  15257. * @private
  15258. * @param {string} string The string inspect.
  15259. * @returns {number} Returns the string size.
  15260. */
  15261. function unicodeSize(string) {
  15262. var result = reUnicode.lastIndex = 0;
  15263. while (reUnicode.test(string)) {
  15264. ++result;
  15265. }
  15266. return result;
  15267. }
  15268. /**
  15269. * Converts a Unicode `string` to an array.
  15270. *
  15271. * @private
  15272. * @param {string} string The string to convert.
  15273. * @returns {Array} Returns the converted array.
  15274. */
  15275. function unicodeToArray(string) {
  15276. return string.match(reUnicode) || [];
  15277. }
  15278. /**
  15279. * Splits a Unicode `string` into an array of its words.
  15280. *
  15281. * @private
  15282. * @param {string} The string to inspect.
  15283. * @returns {Array} Returns the words of `string`.
  15284. */
  15285. function unicodeWords(string) {
  15286. return string.match(reUnicodeWord) || [];
  15287. }
  15288. /*--------------------------------------------------------------------------*/
  15289. /**
  15290. * Create a new pristine `lodash` function using the `context` object.
  15291. *
  15292. * @static
  15293. * @memberOf _
  15294. * @since 1.1.0
  15295. * @category Util
  15296. * @param {Object} [context=root] The context object.
  15297. * @returns {Function} Returns a new `lodash` function.
  15298. * @example
  15299. *
  15300. * _.mixin({ 'foo': _.constant('foo') });
  15301. *
  15302. * var lodash = _.runInContext();
  15303. * lodash.mixin({ 'bar': lodash.constant('bar') });
  15304. *
  15305. * _.isFunction(_.foo);
  15306. * // => true
  15307. * _.isFunction(_.bar);
  15308. * // => false
  15309. *
  15310. * lodash.isFunction(lodash.foo);
  15311. * // => false
  15312. * lodash.isFunction(lodash.bar);
  15313. * // => true
  15314. *
  15315. * // Create a suped-up `defer` in Node.js.
  15316. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  15317. */
  15318. var runInContext = (function runInContext(context) {
  15319. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  15320. /** Built-in constructor references. */
  15321. var Array = context.Array,
  15322. Date = context.Date,
  15323. Error = context.Error,
  15324. Function = context.Function,
  15325. Math = context.Math,
  15326. Object = context.Object,
  15327. RegExp = context.RegExp,
  15328. String = context.String,
  15329. TypeError = context.TypeError;
  15330. /** Used for built-in method references. */
  15331. var arrayProto = Array.prototype,
  15332. funcProto = Function.prototype,
  15333. objectProto = Object.prototype;
  15334. /** Used to detect overreaching core-js shims. */
  15335. var coreJsData = context['__core-js_shared__'];
  15336. /** Used to resolve the decompiled source of functions. */
  15337. var funcToString = funcProto.toString;
  15338. /** Used to check objects for own properties. */
  15339. var hasOwnProperty = objectProto.hasOwnProperty;
  15340. /** Used to generate unique IDs. */
  15341. var idCounter = 0;
  15342. /** Used to detect methods masquerading as native. */
  15343. var maskSrcKey = (function() {
  15344. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  15345. return uid ? ('Symbol(src)_1.' + uid) : '';
  15346. }());
  15347. /**
  15348. * Used to resolve the
  15349. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  15350. * of values.
  15351. */
  15352. var nativeObjectToString = objectProto.toString;
  15353. /** Used to infer the `Object` constructor. */
  15354. var objectCtorString = funcToString.call(Object);
  15355. /** Used to restore the original `_` reference in `_.noConflict`. */
  15356. var oldDash = root._;
  15357. /** Used to detect if a method is native. */
  15358. var reIsNative = RegExp('^' +
  15359. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  15360. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  15361. );
  15362. /** Built-in value references. */
  15363. var Buffer = moduleExports ? context.Buffer : undefined,
  15364. Symbol = context.Symbol,
  15365. Uint8Array = context.Uint8Array,
  15366. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  15367. getPrototype = overArg(Object.getPrototypeOf, Object),
  15368. objectCreate = Object.create,
  15369. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  15370. splice = arrayProto.splice,
  15371. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  15372. symIterator = Symbol ? Symbol.iterator : undefined,
  15373. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  15374. var defineProperty = (function() {
  15375. try {
  15376. var func = getNative(Object, 'defineProperty');
  15377. func({}, '', {});
  15378. return func;
  15379. } catch (e) {}
  15380. }());
  15381. /** Mocked built-ins. */
  15382. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  15383. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  15384. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  15385. /* Built-in method references for those with the same name as other `lodash` methods. */
  15386. var nativeCeil = Math.ceil,
  15387. nativeFloor = Math.floor,
  15388. nativeGetSymbols = Object.getOwnPropertySymbols,
  15389. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  15390. nativeIsFinite = context.isFinite,
  15391. nativeJoin = arrayProto.join,
  15392. nativeKeys = overArg(Object.keys, Object),
  15393. nativeMax = Math.max,
  15394. nativeMin = Math.min,
  15395. nativeNow = Date.now,
  15396. nativeParseInt = context.parseInt,
  15397. nativeRandom = Math.random,
  15398. nativeReverse = arrayProto.reverse;
  15399. /* Built-in method references that are verified to be native. */
  15400. var DataView = getNative(context, 'DataView'),
  15401. Map = getNative(context, 'Map'),
  15402. Promise = getNative(context, 'Promise'),
  15403. Set = getNative(context, 'Set'),
  15404. WeakMap = getNative(context, 'WeakMap'),
  15405. nativeCreate = getNative(Object, 'create');
  15406. /** Used to store function metadata. */
  15407. var metaMap = WeakMap && new WeakMap;
  15408. /** Used to lookup unminified function names. */
  15409. var realNames = {};
  15410. /** Used to detect maps, sets, and weakmaps. */
  15411. var dataViewCtorString = toSource(DataView),
  15412. mapCtorString = toSource(Map),
  15413. promiseCtorString = toSource(Promise),
  15414. setCtorString = toSource(Set),
  15415. weakMapCtorString = toSource(WeakMap);
  15416. /** Used to convert symbols to primitives and strings. */
  15417. var symbolProto = Symbol ? Symbol.prototype : undefined,
  15418. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  15419. symbolToString = symbolProto ? symbolProto.toString : undefined;
  15420. /*------------------------------------------------------------------------*/
  15421. /**
  15422. * Creates a `lodash` object which wraps `value` to enable implicit method
  15423. * chain sequences. Methods that operate on and return arrays, collections,
  15424. * and functions can be chained together. Methods that retrieve a single value
  15425. * or may return a primitive value will automatically end the chain sequence
  15426. * and return the unwrapped value. Otherwise, the value must be unwrapped
  15427. * with `_#value`.
  15428. *
  15429. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  15430. * enabled using `_.chain`.
  15431. *
  15432. * The execution of chained methods is lazy, that is, it's deferred until
  15433. * `_#value` is implicitly or explicitly called.
  15434. *
  15435. * Lazy evaluation allows several methods to support shortcut fusion.
  15436. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  15437. * the creation of intermediate arrays and can greatly reduce the number of
  15438. * iteratee executions. Sections of a chain sequence qualify for shortcut
  15439. * fusion if the section is applied to an array and iteratees accept only
  15440. * one argument. The heuristic for whether a section qualifies for shortcut
  15441. * fusion is subject to change.
  15442. *
  15443. * Chaining is supported in custom builds as long as the `_#value` method is
  15444. * directly or indirectly included in the build.
  15445. *
  15446. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  15447. *
  15448. * The wrapper `Array` methods are:
  15449. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  15450. *
  15451. * The wrapper `String` methods are:
  15452. * `replace` and `split`
  15453. *
  15454. * The wrapper methods that support shortcut fusion are:
  15455. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  15456. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  15457. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  15458. *
  15459. * The chainable wrapper methods are:
  15460. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  15461. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  15462. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  15463. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  15464. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  15465. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  15466. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  15467. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  15468. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  15469. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  15470. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  15471. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  15472. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  15473. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  15474. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  15475. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  15476. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  15477. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  15478. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  15479. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  15480. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  15481. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  15482. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  15483. * `zipObject`, `zipObjectDeep`, and `zipWith`
  15484. *
  15485. * The wrapper methods that are **not** chainable by default are:
  15486. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  15487. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  15488. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  15489. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  15490. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  15491. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  15492. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  15493. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  15494. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  15495. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  15496. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  15497. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  15498. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  15499. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  15500. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  15501. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  15502. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  15503. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  15504. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  15505. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  15506. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  15507. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  15508. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  15509. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  15510. * `upperFirst`, `value`, and `words`
  15511. *
  15512. * @name _
  15513. * @constructor
  15514. * @category Seq
  15515. * @param {*} value The value to wrap in a `lodash` instance.
  15516. * @returns {Object} Returns the new `lodash` wrapper instance.
  15517. * @example
  15518. *
  15519. * function square(n) {
  15520. * return n * n;
  15521. * }
  15522. *
  15523. * var wrapped = _([1, 2, 3]);
  15524. *
  15525. * // Returns an unwrapped value.
  15526. * wrapped.reduce(_.add);
  15527. * // => 6
  15528. *
  15529. * // Returns a wrapped value.
  15530. * var squares = wrapped.map(square);
  15531. *
  15532. * _.isArray(squares);
  15533. * // => false
  15534. *
  15535. * _.isArray(squares.value());
  15536. * // => true
  15537. */
  15538. function lodash(value) {
  15539. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  15540. if (value instanceof LodashWrapper) {
  15541. return value;
  15542. }
  15543. if (hasOwnProperty.call(value, '__wrapped__')) {
  15544. return wrapperClone(value);
  15545. }
  15546. }
  15547. return new LodashWrapper(value);
  15548. }
  15549. /**
  15550. * The base implementation of `_.create` without support for assigning
  15551. * properties to the created object.
  15552. *
  15553. * @private
  15554. * @param {Object} proto The object to inherit from.
  15555. * @returns {Object} Returns the new object.
  15556. */
  15557. var baseCreate = (function() {
  15558. function object() {}
  15559. return function(proto) {
  15560. if (!isObject(proto)) {
  15561. return {};
  15562. }
  15563. if (objectCreate) {
  15564. return objectCreate(proto);
  15565. }
  15566. object.prototype = proto;
  15567. var result = new object;
  15568. object.prototype = undefined;
  15569. return result;
  15570. };
  15571. }());
  15572. /**
  15573. * The function whose prototype chain sequence wrappers inherit from.
  15574. *
  15575. * @private
  15576. */
  15577. function baseLodash() {
  15578. // No operation performed.
  15579. }
  15580. /**
  15581. * The base constructor for creating `lodash` wrapper objects.
  15582. *
  15583. * @private
  15584. * @param {*} value The value to wrap.
  15585. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  15586. */
  15587. function LodashWrapper(value, chainAll) {
  15588. this.__wrapped__ = value;
  15589. this.__actions__ = [];
  15590. this.__chain__ = !!chainAll;
  15591. this.__index__ = 0;
  15592. this.__values__ = undefined;
  15593. }
  15594. /**
  15595. * By default, the template delimiters used by lodash are like those in
  15596. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  15597. * following template settings to use alternative delimiters.
  15598. *
  15599. * @static
  15600. * @memberOf _
  15601. * @type {Object}
  15602. */
  15603. lodash.templateSettings = {
  15604. /**
  15605. * Used to detect `data` property values to be HTML-escaped.
  15606. *
  15607. * @memberOf _.templateSettings
  15608. * @type {RegExp}
  15609. */
  15610. 'escape': reEscape,
  15611. /**
  15612. * Used to detect code to be evaluated.
  15613. *
  15614. * @memberOf _.templateSettings
  15615. * @type {RegExp}
  15616. */
  15617. 'evaluate': reEvaluate,
  15618. /**
  15619. * Used to detect `data` property values to inject.
  15620. *
  15621. * @memberOf _.templateSettings
  15622. * @type {RegExp}
  15623. */
  15624. 'interpolate': reInterpolate,
  15625. /**
  15626. * Used to reference the data object in the template text.
  15627. *
  15628. * @memberOf _.templateSettings
  15629. * @type {string}
  15630. */
  15631. 'variable': '',
  15632. /**
  15633. * Used to import variables into the compiled template.
  15634. *
  15635. * @memberOf _.templateSettings
  15636. * @type {Object}
  15637. */
  15638. 'imports': {
  15639. /**
  15640. * A reference to the `lodash` function.
  15641. *
  15642. * @memberOf _.templateSettings.imports
  15643. * @type {Function}
  15644. */
  15645. '_': lodash
  15646. }
  15647. };
  15648. // Ensure wrappers are instances of `baseLodash`.
  15649. lodash.prototype = baseLodash.prototype;
  15650. lodash.prototype.constructor = lodash;
  15651. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  15652. LodashWrapper.prototype.constructor = LodashWrapper;
  15653. /*------------------------------------------------------------------------*/
  15654. /**
  15655. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  15656. *
  15657. * @private
  15658. * @constructor
  15659. * @param {*} value The value to wrap.
  15660. */
  15661. function LazyWrapper(value) {
  15662. this.__wrapped__ = value;
  15663. this.__actions__ = [];
  15664. this.__dir__ = 1;
  15665. this.__filtered__ = false;
  15666. this.__iteratees__ = [];
  15667. this.__takeCount__ = MAX_ARRAY_LENGTH;
  15668. this.__views__ = [];
  15669. }
  15670. /**
  15671. * Creates a clone of the lazy wrapper object.
  15672. *
  15673. * @private
  15674. * @name clone
  15675. * @memberOf LazyWrapper
  15676. * @returns {Object} Returns the cloned `LazyWrapper` object.
  15677. */
  15678. function lazyClone() {
  15679. var result = new LazyWrapper(this.__wrapped__);
  15680. result.__actions__ = copyArray(this.__actions__);
  15681. result.__dir__ = this.__dir__;
  15682. result.__filtered__ = this.__filtered__;
  15683. result.__iteratees__ = copyArray(this.__iteratees__);
  15684. result.__takeCount__ = this.__takeCount__;
  15685. result.__views__ = copyArray(this.__views__);
  15686. return result;
  15687. }
  15688. /**
  15689. * Reverses the direction of lazy iteration.
  15690. *
  15691. * @private
  15692. * @name reverse
  15693. * @memberOf LazyWrapper
  15694. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  15695. */
  15696. function lazyReverse() {
  15697. if (this.__filtered__) {
  15698. var result = new LazyWrapper(this);
  15699. result.__dir__ = -1;
  15700. result.__filtered__ = true;
  15701. } else {
  15702. result = this.clone();
  15703. result.__dir__ *= -1;
  15704. }
  15705. return result;
  15706. }
  15707. /**
  15708. * Extracts the unwrapped value from its lazy wrapper.
  15709. *
  15710. * @private
  15711. * @name value
  15712. * @memberOf LazyWrapper
  15713. * @returns {*} Returns the unwrapped value.
  15714. */
  15715. function lazyValue() {
  15716. var array = this.__wrapped__.value(),
  15717. dir = this.__dir__,
  15718. isArr = isArray(array),
  15719. isRight = dir < 0,
  15720. arrLength = isArr ? array.length : 0,
  15721. view = getView(0, arrLength, this.__views__),
  15722. start = view.start,
  15723. end = view.end,
  15724. length = end - start,
  15725. index = isRight ? end : (start - 1),
  15726. iteratees = this.__iteratees__,
  15727. iterLength = iteratees.length,
  15728. resIndex = 0,
  15729. takeCount = nativeMin(length, this.__takeCount__);
  15730. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  15731. return baseWrapperValue(array, this.__actions__);
  15732. }
  15733. var result = [];
  15734. outer:
  15735. while (length-- && resIndex < takeCount) {
  15736. index += dir;
  15737. var iterIndex = -1,
  15738. value = array[index];
  15739. while (++iterIndex < iterLength) {
  15740. var data = iteratees[iterIndex],
  15741. iteratee = data.iteratee,
  15742. type = data.type,
  15743. computed = iteratee(value);
  15744. if (type == LAZY_MAP_FLAG) {
  15745. value = computed;
  15746. } else if (!computed) {
  15747. if (type == LAZY_FILTER_FLAG) {
  15748. continue outer;
  15749. } else {
  15750. break outer;
  15751. }
  15752. }
  15753. }
  15754. result[resIndex++] = value;
  15755. }
  15756. return result;
  15757. }
  15758. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  15759. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  15760. LazyWrapper.prototype.constructor = LazyWrapper;
  15761. /*------------------------------------------------------------------------*/
  15762. /**
  15763. * Creates a hash object.
  15764. *
  15765. * @private
  15766. * @constructor
  15767. * @param {Array} [entries] The key-value pairs to cache.
  15768. */
  15769. function Hash(entries) {
  15770. var index = -1,
  15771. length = entries == null ? 0 : entries.length;
  15772. this.clear();
  15773. while (++index < length) {
  15774. var entry = entries[index];
  15775. this.set(entry[0], entry[1]);
  15776. }
  15777. }
  15778. /**
  15779. * Removes all key-value entries from the hash.
  15780. *
  15781. * @private
  15782. * @name clear
  15783. * @memberOf Hash
  15784. */
  15785. function hashClear() {
  15786. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  15787. this.size = 0;
  15788. }
  15789. /**
  15790. * Removes `key` and its value from the hash.
  15791. *
  15792. * @private
  15793. * @name delete
  15794. * @memberOf Hash
  15795. * @param {Object} hash The hash to modify.
  15796. * @param {string} key The key of the value to remove.
  15797. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15798. */
  15799. function hashDelete(key) {
  15800. var result = this.has(key) && delete this.__data__[key];
  15801. this.size -= result ? 1 : 0;
  15802. return result;
  15803. }
  15804. /**
  15805. * Gets the hash value for `key`.
  15806. *
  15807. * @private
  15808. * @name get
  15809. * @memberOf Hash
  15810. * @param {string} key The key of the value to get.
  15811. * @returns {*} Returns the entry value.
  15812. */
  15813. function hashGet(key) {
  15814. var data = this.__data__;
  15815. if (nativeCreate) {
  15816. var result = data[key];
  15817. return result === HASH_UNDEFINED ? undefined : result;
  15818. }
  15819. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  15820. }
  15821. /**
  15822. * Checks if a hash value for `key` exists.
  15823. *
  15824. * @private
  15825. * @name has
  15826. * @memberOf Hash
  15827. * @param {string} key The key of the entry to check.
  15828. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15829. */
  15830. function hashHas(key) {
  15831. var data = this.__data__;
  15832. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  15833. }
  15834. /**
  15835. * Sets the hash `key` to `value`.
  15836. *
  15837. * @private
  15838. * @name set
  15839. * @memberOf Hash
  15840. * @param {string} key The key of the value to set.
  15841. * @param {*} value The value to set.
  15842. * @returns {Object} Returns the hash instance.
  15843. */
  15844. function hashSet(key, value) {
  15845. var data = this.__data__;
  15846. this.size += this.has(key) ? 0 : 1;
  15847. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  15848. return this;
  15849. }
  15850. // Add methods to `Hash`.
  15851. Hash.prototype.clear = hashClear;
  15852. Hash.prototype['delete'] = hashDelete;
  15853. Hash.prototype.get = hashGet;
  15854. Hash.prototype.has = hashHas;
  15855. Hash.prototype.set = hashSet;
  15856. /*------------------------------------------------------------------------*/
  15857. /**
  15858. * Creates an list cache object.
  15859. *
  15860. * @private
  15861. * @constructor
  15862. * @param {Array} [entries] The key-value pairs to cache.
  15863. */
  15864. function ListCache(entries) {
  15865. var index = -1,
  15866. length = entries == null ? 0 : entries.length;
  15867. this.clear();
  15868. while (++index < length) {
  15869. var entry = entries[index];
  15870. this.set(entry[0], entry[1]);
  15871. }
  15872. }
  15873. /**
  15874. * Removes all key-value entries from the list cache.
  15875. *
  15876. * @private
  15877. * @name clear
  15878. * @memberOf ListCache
  15879. */
  15880. function listCacheClear() {
  15881. this.__data__ = [];
  15882. this.size = 0;
  15883. }
  15884. /**
  15885. * Removes `key` and its value from the list cache.
  15886. *
  15887. * @private
  15888. * @name delete
  15889. * @memberOf ListCache
  15890. * @param {string} key The key of the value to remove.
  15891. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15892. */
  15893. function listCacheDelete(key) {
  15894. var data = this.__data__,
  15895. index = assocIndexOf(data, key);
  15896. if (index < 0) {
  15897. return false;
  15898. }
  15899. var lastIndex = data.length - 1;
  15900. if (index == lastIndex) {
  15901. data.pop();
  15902. } else {
  15903. splice.call(data, index, 1);
  15904. }
  15905. --this.size;
  15906. return true;
  15907. }
  15908. /**
  15909. * Gets the list cache value for `key`.
  15910. *
  15911. * @private
  15912. * @name get
  15913. * @memberOf ListCache
  15914. * @param {string} key The key of the value to get.
  15915. * @returns {*} Returns the entry value.
  15916. */
  15917. function listCacheGet(key) {
  15918. var data = this.__data__,
  15919. index = assocIndexOf(data, key);
  15920. return index < 0 ? undefined : data[index][1];
  15921. }
  15922. /**
  15923. * Checks if a list cache value for `key` exists.
  15924. *
  15925. * @private
  15926. * @name has
  15927. * @memberOf ListCache
  15928. * @param {string} key The key of the entry to check.
  15929. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15930. */
  15931. function listCacheHas(key) {
  15932. return assocIndexOf(this.__data__, key) > -1;
  15933. }
  15934. /**
  15935. * Sets the list cache `key` to `value`.
  15936. *
  15937. * @private
  15938. * @name set
  15939. * @memberOf ListCache
  15940. * @param {string} key The key of the value to set.
  15941. * @param {*} value The value to set.
  15942. * @returns {Object} Returns the list cache instance.
  15943. */
  15944. function listCacheSet(key, value) {
  15945. var data = this.__data__,
  15946. index = assocIndexOf(data, key);
  15947. if (index < 0) {
  15948. ++this.size;
  15949. data.push([key, value]);
  15950. } else {
  15951. data[index][1] = value;
  15952. }
  15953. return this;
  15954. }
  15955. // Add methods to `ListCache`.
  15956. ListCache.prototype.clear = listCacheClear;
  15957. ListCache.prototype['delete'] = listCacheDelete;
  15958. ListCache.prototype.get = listCacheGet;
  15959. ListCache.prototype.has = listCacheHas;
  15960. ListCache.prototype.set = listCacheSet;
  15961. /*------------------------------------------------------------------------*/
  15962. /**
  15963. * Creates a map cache object to store key-value pairs.
  15964. *
  15965. * @private
  15966. * @constructor
  15967. * @param {Array} [entries] The key-value pairs to cache.
  15968. */
  15969. function MapCache(entries) {
  15970. var index = -1,
  15971. length = entries == null ? 0 : entries.length;
  15972. this.clear();
  15973. while (++index < length) {
  15974. var entry = entries[index];
  15975. this.set(entry[0], entry[1]);
  15976. }
  15977. }
  15978. /**
  15979. * Removes all key-value entries from the map.
  15980. *
  15981. * @private
  15982. * @name clear
  15983. * @memberOf MapCache
  15984. */
  15985. function mapCacheClear() {
  15986. this.size = 0;
  15987. this.__data__ = {
  15988. 'hash': new Hash,
  15989. 'map': new (Map || ListCache),
  15990. 'string': new Hash
  15991. };
  15992. }
  15993. /**
  15994. * Removes `key` and its value from the map.
  15995. *
  15996. * @private
  15997. * @name delete
  15998. * @memberOf MapCache
  15999. * @param {string} key The key of the value to remove.
  16000. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  16001. */
  16002. function mapCacheDelete(key) {
  16003. var result = getMapData(this, key)['delete'](key);
  16004. this.size -= result ? 1 : 0;
  16005. return result;
  16006. }
  16007. /**
  16008. * Gets the map value for `key`.
  16009. *
  16010. * @private
  16011. * @name get
  16012. * @memberOf MapCache
  16013. * @param {string} key The key of the value to get.
  16014. * @returns {*} Returns the entry value.
  16015. */
  16016. function mapCacheGet(key) {
  16017. return getMapData(this, key).get(key);
  16018. }
  16019. /**
  16020. * Checks if a map value for `key` exists.
  16021. *
  16022. * @private
  16023. * @name has
  16024. * @memberOf MapCache
  16025. * @param {string} key The key of the entry to check.
  16026. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  16027. */
  16028. function mapCacheHas(key) {
  16029. return getMapData(this, key).has(key);
  16030. }
  16031. /**
  16032. * Sets the map `key` to `value`.
  16033. *
  16034. * @private
  16035. * @name set
  16036. * @memberOf MapCache
  16037. * @param {string} key The key of the value to set.
  16038. * @param {*} value The value to set.
  16039. * @returns {Object} Returns the map cache instance.
  16040. */
  16041. function mapCacheSet(key, value) {
  16042. var data = getMapData(this, key),
  16043. size = data.size;
  16044. data.set(key, value);
  16045. this.size += data.size == size ? 0 : 1;
  16046. return this;
  16047. }
  16048. // Add methods to `MapCache`.
  16049. MapCache.prototype.clear = mapCacheClear;
  16050. MapCache.prototype['delete'] = mapCacheDelete;
  16051. MapCache.prototype.get = mapCacheGet;
  16052. MapCache.prototype.has = mapCacheHas;
  16053. MapCache.prototype.set = mapCacheSet;
  16054. /*------------------------------------------------------------------------*/
  16055. /**
  16056. *
  16057. * Creates an array cache object to store unique values.
  16058. *
  16059. * @private
  16060. * @constructor
  16061. * @param {Array} [values] The values to cache.
  16062. */
  16063. function SetCache(values) {
  16064. var index = -1,
  16065. length = values == null ? 0 : values.length;
  16066. this.__data__ = new MapCache;
  16067. while (++index < length) {
  16068. this.add(values[index]);
  16069. }
  16070. }
  16071. /**
  16072. * Adds `value` to the array cache.
  16073. *
  16074. * @private
  16075. * @name add
  16076. * @memberOf SetCache
  16077. * @alias push
  16078. * @param {*} value The value to cache.
  16079. * @returns {Object} Returns the cache instance.
  16080. */
  16081. function setCacheAdd(value) {
  16082. this.__data__.set(value, HASH_UNDEFINED);
  16083. return this;
  16084. }
  16085. /**
  16086. * Checks if `value` is in the array cache.
  16087. *
  16088. * @private
  16089. * @name has
  16090. * @memberOf SetCache
  16091. * @param {*} value The value to search for.
  16092. * @returns {number} Returns `true` if `value` is found, else `false`.
  16093. */
  16094. function setCacheHas(value) {
  16095. return this.__data__.has(value);
  16096. }
  16097. // Add methods to `SetCache`.
  16098. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  16099. SetCache.prototype.has = setCacheHas;
  16100. /*------------------------------------------------------------------------*/
  16101. /**
  16102. * Creates a stack cache object to store key-value pairs.
  16103. *
  16104. * @private
  16105. * @constructor
  16106. * @param {Array} [entries] The key-value pairs to cache.
  16107. */
  16108. function Stack(entries) {
  16109. var data = this.__data__ = new ListCache(entries);
  16110. this.size = data.size;
  16111. }
  16112. /**
  16113. * Removes all key-value entries from the stack.
  16114. *
  16115. * @private
  16116. * @name clear
  16117. * @memberOf Stack
  16118. */
  16119. function stackClear() {
  16120. this.__data__ = new ListCache;
  16121. this.size = 0;
  16122. }
  16123. /**
  16124. * Removes `key` and its value from the stack.
  16125. *
  16126. * @private
  16127. * @name delete
  16128. * @memberOf Stack
  16129. * @param {string} key The key of the value to remove.
  16130. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  16131. */
  16132. function stackDelete(key) {
  16133. var data = this.__data__,
  16134. result = data['delete'](key);
  16135. this.size = data.size;
  16136. return result;
  16137. }
  16138. /**
  16139. * Gets the stack value for `key`.
  16140. *
  16141. * @private
  16142. * @name get
  16143. * @memberOf Stack
  16144. * @param {string} key The key of the value to get.
  16145. * @returns {*} Returns the entry value.
  16146. */
  16147. function stackGet(key) {
  16148. return this.__data__.get(key);
  16149. }
  16150. /**
  16151. * Checks if a stack value for `key` exists.
  16152. *
  16153. * @private
  16154. * @name has
  16155. * @memberOf Stack
  16156. * @param {string} key The key of the entry to check.
  16157. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  16158. */
  16159. function stackHas(key) {
  16160. return this.__data__.has(key);
  16161. }
  16162. /**
  16163. * Sets the stack `key` to `value`.
  16164. *
  16165. * @private
  16166. * @name set
  16167. * @memberOf Stack
  16168. * @param {string} key The key of the value to set.
  16169. * @param {*} value The value to set.
  16170. * @returns {Object} Returns the stack cache instance.
  16171. */
  16172. function stackSet(key, value) {
  16173. var data = this.__data__;
  16174. if (data instanceof ListCache) {
  16175. var pairs = data.__data__;
  16176. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  16177. pairs.push([key, value]);
  16178. this.size = ++data.size;
  16179. return this;
  16180. }
  16181. data = this.__data__ = new MapCache(pairs);
  16182. }
  16183. data.set(key, value);
  16184. this.size = data.size;
  16185. return this;
  16186. }
  16187. // Add methods to `Stack`.
  16188. Stack.prototype.clear = stackClear;
  16189. Stack.prototype['delete'] = stackDelete;
  16190. Stack.prototype.get = stackGet;
  16191. Stack.prototype.has = stackHas;
  16192. Stack.prototype.set = stackSet;
  16193. /*------------------------------------------------------------------------*/
  16194. /**
  16195. * Creates an array of the enumerable property names of the array-like `value`.
  16196. *
  16197. * @private
  16198. * @param {*} value The value to query.
  16199. * @param {boolean} inherited Specify returning inherited property names.
  16200. * @returns {Array} Returns the array of property names.
  16201. */
  16202. function arrayLikeKeys(value, inherited) {
  16203. var isArr = isArray(value),
  16204. isArg = !isArr && isArguments(value),
  16205. isBuff = !isArr && !isArg && isBuffer(value),
  16206. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  16207. skipIndexes = isArr || isArg || isBuff || isType,
  16208. result = skipIndexes ? baseTimes(value.length, String) : [],
  16209. length = result.length;
  16210. for (var key in value) {
  16211. if ((inherited || hasOwnProperty.call(value, key)) &&
  16212. !(skipIndexes && (
  16213. // Safari 9 has enumerable `arguments.length` in strict mode.
  16214. key == 'length' ||
  16215. // Node.js 0.10 has enumerable non-index properties on buffers.
  16216. (isBuff && (key == 'offset' || key == 'parent')) ||
  16217. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  16218. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  16219. // Skip index properties.
  16220. isIndex(key, length)
  16221. ))) {
  16222. result.push(key);
  16223. }
  16224. }
  16225. return result;
  16226. }
  16227. /**
  16228. * A specialized version of `_.sample` for arrays.
  16229. *
  16230. * @private
  16231. * @param {Array} array The array to sample.
  16232. * @returns {*} Returns the random element.
  16233. */
  16234. function arraySample(array) {
  16235. var length = array.length;
  16236. return length ? array[baseRandom(0, length - 1)] : undefined;
  16237. }
  16238. /**
  16239. * A specialized version of `_.sampleSize` for arrays.
  16240. *
  16241. * @private
  16242. * @param {Array} array The array to sample.
  16243. * @param {number} n The number of elements to sample.
  16244. * @returns {Array} Returns the random elements.
  16245. */
  16246. function arraySampleSize(array, n) {
  16247. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  16248. }
  16249. /**
  16250. * A specialized version of `_.shuffle` for arrays.
  16251. *
  16252. * @private
  16253. * @param {Array} array The array to shuffle.
  16254. * @returns {Array} Returns the new shuffled array.
  16255. */
  16256. function arrayShuffle(array) {
  16257. return shuffleSelf(copyArray(array));
  16258. }
  16259. /**
  16260. * This function is like `assignValue` except that it doesn't assign
  16261. * `undefined` values.
  16262. *
  16263. * @private
  16264. * @param {Object} object The object to modify.
  16265. * @param {string} key The key of the property to assign.
  16266. * @param {*} value The value to assign.
  16267. */
  16268. function assignMergeValue(object, key, value) {
  16269. if ((value !== undefined && !eq(object[key], value)) ||
  16270. (value === undefined && !(key in object))) {
  16271. baseAssignValue(object, key, value);
  16272. }
  16273. }
  16274. /**
  16275. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  16276. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16277. * for equality comparisons.
  16278. *
  16279. * @private
  16280. * @param {Object} object The object to modify.
  16281. * @param {string} key The key of the property to assign.
  16282. * @param {*} value The value to assign.
  16283. */
  16284. function assignValue(object, key, value) {
  16285. var objValue = object[key];
  16286. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  16287. (value === undefined && !(key in object))) {
  16288. baseAssignValue(object, key, value);
  16289. }
  16290. }
  16291. /**
  16292. * Gets the index at which the `key` is found in `array` of key-value pairs.
  16293. *
  16294. * @private
  16295. * @param {Array} array The array to inspect.
  16296. * @param {*} key The key to search for.
  16297. * @returns {number} Returns the index of the matched value, else `-1`.
  16298. */
  16299. function assocIndexOf(array, key) {
  16300. var length = array.length;
  16301. while (length--) {
  16302. if (eq(array[length][0], key)) {
  16303. return length;
  16304. }
  16305. }
  16306. return -1;
  16307. }
  16308. /**
  16309. * Aggregates elements of `collection` on `accumulator` with keys transformed
  16310. * by `iteratee` and values set by `setter`.
  16311. *
  16312. * @private
  16313. * @param {Array|Object} collection The collection to iterate over.
  16314. * @param {Function} setter The function to set `accumulator` values.
  16315. * @param {Function} iteratee The iteratee to transform keys.
  16316. * @param {Object} accumulator The initial aggregated object.
  16317. * @returns {Function} Returns `accumulator`.
  16318. */
  16319. function baseAggregator(collection, setter, iteratee, accumulator) {
  16320. baseEach(collection, function(value, key, collection) {
  16321. setter(accumulator, value, iteratee(value), collection);
  16322. });
  16323. return accumulator;
  16324. }
  16325. /**
  16326. * The base implementation of `_.assign` without support for multiple sources
  16327. * or `customizer` functions.
  16328. *
  16329. * @private
  16330. * @param {Object} object The destination object.
  16331. * @param {Object} source The source object.
  16332. * @returns {Object} Returns `object`.
  16333. */
  16334. function baseAssign(object, source) {
  16335. return object && copyObject(source, keys(source), object);
  16336. }
  16337. /**
  16338. * The base implementation of `_.assignIn` without support for multiple sources
  16339. * or `customizer` functions.
  16340. *
  16341. * @private
  16342. * @param {Object} object The destination object.
  16343. * @param {Object} source The source object.
  16344. * @returns {Object} Returns `object`.
  16345. */
  16346. function baseAssignIn(object, source) {
  16347. return object && copyObject(source, keysIn(source), object);
  16348. }
  16349. /**
  16350. * The base implementation of `assignValue` and `assignMergeValue` without
  16351. * value checks.
  16352. *
  16353. * @private
  16354. * @param {Object} object The object to modify.
  16355. * @param {string} key The key of the property to assign.
  16356. * @param {*} value The value to assign.
  16357. */
  16358. function baseAssignValue(object, key, value) {
  16359. if (key == '__proto__' && defineProperty) {
  16360. defineProperty(object, key, {
  16361. 'configurable': true,
  16362. 'enumerable': true,
  16363. 'value': value,
  16364. 'writable': true
  16365. });
  16366. } else {
  16367. object[key] = value;
  16368. }
  16369. }
  16370. /**
  16371. * The base implementation of `_.at` without support for individual paths.
  16372. *
  16373. * @private
  16374. * @param {Object} object The object to iterate over.
  16375. * @param {string[]} paths The property paths to pick.
  16376. * @returns {Array} Returns the picked elements.
  16377. */
  16378. function baseAt(object, paths) {
  16379. var index = -1,
  16380. length = paths.length,
  16381. result = Array(length),
  16382. skip = object == null;
  16383. while (++index < length) {
  16384. result[index] = skip ? undefined : get(object, paths[index]);
  16385. }
  16386. return result;
  16387. }
  16388. /**
  16389. * The base implementation of `_.clamp` which doesn't coerce arguments.
  16390. *
  16391. * @private
  16392. * @param {number} number The number to clamp.
  16393. * @param {number} [lower] The lower bound.
  16394. * @param {number} upper The upper bound.
  16395. * @returns {number} Returns the clamped number.
  16396. */
  16397. function baseClamp(number, lower, upper) {
  16398. if (number === number) {
  16399. if (upper !== undefined) {
  16400. number = number <= upper ? number : upper;
  16401. }
  16402. if (lower !== undefined) {
  16403. number = number >= lower ? number : lower;
  16404. }
  16405. }
  16406. return number;
  16407. }
  16408. /**
  16409. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  16410. * traversed objects.
  16411. *
  16412. * @private
  16413. * @param {*} value The value to clone.
  16414. * @param {boolean} bitmask The bitmask flags.
  16415. * 1 - Deep clone
  16416. * 2 - Flatten inherited properties
  16417. * 4 - Clone symbols
  16418. * @param {Function} [customizer] The function to customize cloning.
  16419. * @param {string} [key] The key of `value`.
  16420. * @param {Object} [object] The parent object of `value`.
  16421. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  16422. * @returns {*} Returns the cloned value.
  16423. */
  16424. function baseClone(value, bitmask, customizer, key, object, stack) {
  16425. var result,
  16426. isDeep = bitmask & CLONE_DEEP_FLAG,
  16427. isFlat = bitmask & CLONE_FLAT_FLAG,
  16428. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  16429. if (customizer) {
  16430. result = object ? customizer(value, key, object, stack) : customizer(value);
  16431. }
  16432. if (result !== undefined) {
  16433. return result;
  16434. }
  16435. if (!isObject(value)) {
  16436. return value;
  16437. }
  16438. var isArr = isArray(value);
  16439. if (isArr) {
  16440. result = initCloneArray(value);
  16441. if (!isDeep) {
  16442. return copyArray(value, result);
  16443. }
  16444. } else {
  16445. var tag = getTag(value),
  16446. isFunc = tag == funcTag || tag == genTag;
  16447. if (isBuffer(value)) {
  16448. return cloneBuffer(value, isDeep);
  16449. }
  16450. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  16451. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  16452. if (!isDeep) {
  16453. return isFlat
  16454. ? copySymbolsIn(value, baseAssignIn(result, value))
  16455. : copySymbols(value, baseAssign(result, value));
  16456. }
  16457. } else {
  16458. if (!cloneableTags[tag]) {
  16459. return object ? value : {};
  16460. }
  16461. result = initCloneByTag(value, tag, isDeep);
  16462. }
  16463. }
  16464. // Check for circular references and return its corresponding clone.
  16465. stack || (stack = new Stack);
  16466. var stacked = stack.get(value);
  16467. if (stacked) {
  16468. return stacked;
  16469. }
  16470. stack.set(value, result);
  16471. if (isSet(value)) {
  16472. value.forEach(function(subValue) {
  16473. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  16474. });
  16475. } else if (isMap(value)) {
  16476. value.forEach(function(subValue, key) {
  16477. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16478. });
  16479. }
  16480. var keysFunc = isFull
  16481. ? (isFlat ? getAllKeysIn : getAllKeys)
  16482. : (isFlat ? keysIn : keys);
  16483. var props = isArr ? undefined : keysFunc(value);
  16484. arrayEach(props || value, function(subValue, key) {
  16485. if (props) {
  16486. key = subValue;
  16487. subValue = value[key];
  16488. }
  16489. // Recursively populate clone (susceptible to call stack limits).
  16490. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16491. });
  16492. return result;
  16493. }
  16494. /**
  16495. * The base implementation of `_.conforms` which doesn't clone `source`.
  16496. *
  16497. * @private
  16498. * @param {Object} source The object of property predicates to conform to.
  16499. * @returns {Function} Returns the new spec function.
  16500. */
  16501. function baseConforms(source) {
  16502. var props = keys(source);
  16503. return function(object) {
  16504. return baseConformsTo(object, source, props);
  16505. };
  16506. }
  16507. /**
  16508. * The base implementation of `_.conformsTo` which accepts `props` to check.
  16509. *
  16510. * @private
  16511. * @param {Object} object The object to inspect.
  16512. * @param {Object} source The object of property predicates to conform to.
  16513. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  16514. */
  16515. function baseConformsTo(object, source, props) {
  16516. var length = props.length;
  16517. if (object == null) {
  16518. return !length;
  16519. }
  16520. object = Object(object);
  16521. while (length--) {
  16522. var key = props[length],
  16523. predicate = source[key],
  16524. value = object[key];
  16525. if ((value === undefined && !(key in object)) || !predicate(value)) {
  16526. return false;
  16527. }
  16528. }
  16529. return true;
  16530. }
  16531. /**
  16532. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  16533. * to provide to `func`.
  16534. *
  16535. * @private
  16536. * @param {Function} func The function to delay.
  16537. * @param {number} wait The number of milliseconds to delay invocation.
  16538. * @param {Array} args The arguments to provide to `func`.
  16539. * @returns {number|Object} Returns the timer id or timeout object.
  16540. */
  16541. function baseDelay(func, wait, args) {
  16542. if (typeof func != 'function') {
  16543. throw new TypeError(FUNC_ERROR_TEXT);
  16544. }
  16545. return setTimeout(function() { func.apply(undefined, args); }, wait);
  16546. }
  16547. /**
  16548. * The base implementation of methods like `_.difference` without support
  16549. * for excluding multiple arrays or iteratee shorthands.
  16550. *
  16551. * @private
  16552. * @param {Array} array The array to inspect.
  16553. * @param {Array} values The values to exclude.
  16554. * @param {Function} [iteratee] The iteratee invoked per element.
  16555. * @param {Function} [comparator] The comparator invoked per element.
  16556. * @returns {Array} Returns the new array of filtered values.
  16557. */
  16558. function baseDifference(array, values, iteratee, comparator) {
  16559. var index = -1,
  16560. includes = arrayIncludes,
  16561. isCommon = true,
  16562. length = array.length,
  16563. result = [],
  16564. valuesLength = values.length;
  16565. if (!length) {
  16566. return result;
  16567. }
  16568. if (iteratee) {
  16569. values = arrayMap(values, baseUnary(iteratee));
  16570. }
  16571. if (comparator) {
  16572. includes = arrayIncludesWith;
  16573. isCommon = false;
  16574. }
  16575. else if (values.length >= LARGE_ARRAY_SIZE) {
  16576. includes = cacheHas;
  16577. isCommon = false;
  16578. values = new SetCache(values);
  16579. }
  16580. outer:
  16581. while (++index < length) {
  16582. var value = array[index],
  16583. computed = iteratee == null ? value : iteratee(value);
  16584. value = (comparator || value !== 0) ? value : 0;
  16585. if (isCommon && computed === computed) {
  16586. var valuesIndex = valuesLength;
  16587. while (valuesIndex--) {
  16588. if (values[valuesIndex] === computed) {
  16589. continue outer;
  16590. }
  16591. }
  16592. result.push(value);
  16593. }
  16594. else if (!includes(values, computed, comparator)) {
  16595. result.push(value);
  16596. }
  16597. }
  16598. return result;
  16599. }
  16600. /**
  16601. * The base implementation of `_.forEach` without support for iteratee shorthands.
  16602. *
  16603. * @private
  16604. * @param {Array|Object} collection The collection to iterate over.
  16605. * @param {Function} iteratee The function invoked per iteration.
  16606. * @returns {Array|Object} Returns `collection`.
  16607. */
  16608. var baseEach = createBaseEach(baseForOwn);
  16609. /**
  16610. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  16611. *
  16612. * @private
  16613. * @param {Array|Object} collection The collection to iterate over.
  16614. * @param {Function} iteratee The function invoked per iteration.
  16615. * @returns {Array|Object} Returns `collection`.
  16616. */
  16617. var baseEachRight = createBaseEach(baseForOwnRight, true);
  16618. /**
  16619. * The base implementation of `_.every` without support for iteratee shorthands.
  16620. *
  16621. * @private
  16622. * @param {Array|Object} collection The collection to iterate over.
  16623. * @param {Function} predicate The function invoked per iteration.
  16624. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  16625. * else `false`
  16626. */
  16627. function baseEvery(collection, predicate) {
  16628. var result = true;
  16629. baseEach(collection, function(value, index, collection) {
  16630. result = !!predicate(value, index, collection);
  16631. return result;
  16632. });
  16633. return result;
  16634. }
  16635. /**
  16636. * The base implementation of methods like `_.max` and `_.min` which accepts a
  16637. * `comparator` to determine the extremum value.
  16638. *
  16639. * @private
  16640. * @param {Array} array The array to iterate over.
  16641. * @param {Function} iteratee The iteratee invoked per iteration.
  16642. * @param {Function} comparator The comparator used to compare values.
  16643. * @returns {*} Returns the extremum value.
  16644. */
  16645. function baseExtremum(array, iteratee, comparator) {
  16646. var index = -1,
  16647. length = array.length;
  16648. while (++index < length) {
  16649. var value = array[index],
  16650. current = iteratee(value);
  16651. if (current != null && (computed === undefined
  16652. ? (current === current && !isSymbol(current))
  16653. : comparator(current, computed)
  16654. )) {
  16655. var computed = current,
  16656. result = value;
  16657. }
  16658. }
  16659. return result;
  16660. }
  16661. /**
  16662. * The base implementation of `_.fill` without an iteratee call guard.
  16663. *
  16664. * @private
  16665. * @param {Array} array The array to fill.
  16666. * @param {*} value The value to fill `array` with.
  16667. * @param {number} [start=0] The start position.
  16668. * @param {number} [end=array.length] The end position.
  16669. * @returns {Array} Returns `array`.
  16670. */
  16671. function baseFill(array, value, start, end) {
  16672. var length = array.length;
  16673. start = toInteger(start);
  16674. if (start < 0) {
  16675. start = -start > length ? 0 : (length + start);
  16676. }
  16677. end = (end === undefined || end > length) ? length : toInteger(end);
  16678. if (end < 0) {
  16679. end += length;
  16680. }
  16681. end = start > end ? 0 : toLength(end);
  16682. while (start < end) {
  16683. array[start++] = value;
  16684. }
  16685. return array;
  16686. }
  16687. /**
  16688. * The base implementation of `_.filter` without support for iteratee shorthands.
  16689. *
  16690. * @private
  16691. * @param {Array|Object} collection The collection to iterate over.
  16692. * @param {Function} predicate The function invoked per iteration.
  16693. * @returns {Array} Returns the new filtered array.
  16694. */
  16695. function baseFilter(collection, predicate) {
  16696. var result = [];
  16697. baseEach(collection, function(value, index, collection) {
  16698. if (predicate(value, index, collection)) {
  16699. result.push(value);
  16700. }
  16701. });
  16702. return result;
  16703. }
  16704. /**
  16705. * The base implementation of `_.flatten` with support for restricting flattening.
  16706. *
  16707. * @private
  16708. * @param {Array} array The array to flatten.
  16709. * @param {number} depth The maximum recursion depth.
  16710. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  16711. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  16712. * @param {Array} [result=[]] The initial result value.
  16713. * @returns {Array} Returns the new flattened array.
  16714. */
  16715. function baseFlatten(array, depth, predicate, isStrict, result) {
  16716. var index = -1,
  16717. length = array.length;
  16718. predicate || (predicate = isFlattenable);
  16719. result || (result = []);
  16720. while (++index < length) {
  16721. var value = array[index];
  16722. if (depth > 0 && predicate(value)) {
  16723. if (depth > 1) {
  16724. // Recursively flatten arrays (susceptible to call stack limits).
  16725. baseFlatten(value, depth - 1, predicate, isStrict, result);
  16726. } else {
  16727. arrayPush(result, value);
  16728. }
  16729. } else if (!isStrict) {
  16730. result[result.length] = value;
  16731. }
  16732. }
  16733. return result;
  16734. }
  16735. /**
  16736. * The base implementation of `baseForOwn` which iterates over `object`
  16737. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  16738. * Iteratee functions may exit iteration early by explicitly returning `false`.
  16739. *
  16740. * @private
  16741. * @param {Object} object The object to iterate over.
  16742. * @param {Function} iteratee The function invoked per iteration.
  16743. * @param {Function} keysFunc The function to get the keys of `object`.
  16744. * @returns {Object} Returns `object`.
  16745. */
  16746. var baseFor = createBaseFor();
  16747. /**
  16748. * This function is like `baseFor` except that it iterates over properties
  16749. * in the opposite order.
  16750. *
  16751. * @private
  16752. * @param {Object} object The object to iterate over.
  16753. * @param {Function} iteratee The function invoked per iteration.
  16754. * @param {Function} keysFunc The function to get the keys of `object`.
  16755. * @returns {Object} Returns `object`.
  16756. */
  16757. var baseForRight = createBaseFor(true);
  16758. /**
  16759. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  16760. *
  16761. * @private
  16762. * @param {Object} object The object to iterate over.
  16763. * @param {Function} iteratee The function invoked per iteration.
  16764. * @returns {Object} Returns `object`.
  16765. */
  16766. function baseForOwn(object, iteratee) {
  16767. return object && baseFor(object, iteratee, keys);
  16768. }
  16769. /**
  16770. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  16771. *
  16772. * @private
  16773. * @param {Object} object The object to iterate over.
  16774. * @param {Function} iteratee The function invoked per iteration.
  16775. * @returns {Object} Returns `object`.
  16776. */
  16777. function baseForOwnRight(object, iteratee) {
  16778. return object && baseForRight(object, iteratee, keys);
  16779. }
  16780. /**
  16781. * The base implementation of `_.functions` which creates an array of
  16782. * `object` function property names filtered from `props`.
  16783. *
  16784. * @private
  16785. * @param {Object} object The object to inspect.
  16786. * @param {Array} props The property names to filter.
  16787. * @returns {Array} Returns the function names.
  16788. */
  16789. function baseFunctions(object, props) {
  16790. return arrayFilter(props, function(key) {
  16791. return isFunction(object[key]);
  16792. });
  16793. }
  16794. /**
  16795. * The base implementation of `_.get` without support for default values.
  16796. *
  16797. * @private
  16798. * @param {Object} object The object to query.
  16799. * @param {Array|string} path The path of the property to get.
  16800. * @returns {*} Returns the resolved value.
  16801. */
  16802. function baseGet(object, path) {
  16803. path = castPath(path, object);
  16804. var index = 0,
  16805. length = path.length;
  16806. while (object != null && index < length) {
  16807. object = object[toKey(path[index++])];
  16808. }
  16809. return (index && index == length) ? object : undefined;
  16810. }
  16811. /**
  16812. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  16813. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  16814. * symbols of `object`.
  16815. *
  16816. * @private
  16817. * @param {Object} object The object to query.
  16818. * @param {Function} keysFunc The function to get the keys of `object`.
  16819. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  16820. * @returns {Array} Returns the array of property names and symbols.
  16821. */
  16822. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  16823. var result = keysFunc(object);
  16824. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  16825. }
  16826. /**
  16827. * The base implementation of `getTag` without fallbacks for buggy environments.
  16828. *
  16829. * @private
  16830. * @param {*} value The value to query.
  16831. * @returns {string} Returns the `toStringTag`.
  16832. */
  16833. function baseGetTag(value) {
  16834. if (value == null) {
  16835. return value === undefined ? undefinedTag : nullTag;
  16836. }
  16837. return (symToStringTag && symToStringTag in Object(value))
  16838. ? getRawTag(value)
  16839. : objectToString(value);
  16840. }
  16841. /**
  16842. * The base implementation of `_.gt` which doesn't coerce arguments.
  16843. *
  16844. * @private
  16845. * @param {*} value The value to compare.
  16846. * @param {*} other The other value to compare.
  16847. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  16848. * else `false`.
  16849. */
  16850. function baseGt(value, other) {
  16851. return value > other;
  16852. }
  16853. /**
  16854. * The base implementation of `_.has` without support for deep paths.
  16855. *
  16856. * @private
  16857. * @param {Object} [object] The object to query.
  16858. * @param {Array|string} key The key to check.
  16859. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16860. */
  16861. function baseHas(object, key) {
  16862. return object != null && hasOwnProperty.call(object, key);
  16863. }
  16864. /**
  16865. * The base implementation of `_.hasIn` without support for deep paths.
  16866. *
  16867. * @private
  16868. * @param {Object} [object] The object to query.
  16869. * @param {Array|string} key The key to check.
  16870. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16871. */
  16872. function baseHasIn(object, key) {
  16873. return object != null && key in Object(object);
  16874. }
  16875. /**
  16876. * The base implementation of `_.inRange` which doesn't coerce arguments.
  16877. *
  16878. * @private
  16879. * @param {number} number The number to check.
  16880. * @param {number} start The start of the range.
  16881. * @param {number} end The end of the range.
  16882. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  16883. */
  16884. function baseInRange(number, start, end) {
  16885. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  16886. }
  16887. /**
  16888. * The base implementation of methods like `_.intersection`, without support
  16889. * for iteratee shorthands, that accepts an array of arrays to inspect.
  16890. *
  16891. * @private
  16892. * @param {Array} arrays The arrays to inspect.
  16893. * @param {Function} [iteratee] The iteratee invoked per element.
  16894. * @param {Function} [comparator] The comparator invoked per element.
  16895. * @returns {Array} Returns the new array of shared values.
  16896. */
  16897. function baseIntersection(arrays, iteratee, comparator) {
  16898. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  16899. length = arrays[0].length,
  16900. othLength = arrays.length,
  16901. othIndex = othLength,
  16902. caches = Array(othLength),
  16903. maxLength = Infinity,
  16904. result = [];
  16905. while (othIndex--) {
  16906. var array = arrays[othIndex];
  16907. if (othIndex && iteratee) {
  16908. array = arrayMap(array, baseUnary(iteratee));
  16909. }
  16910. maxLength = nativeMin(array.length, maxLength);
  16911. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  16912. ? new SetCache(othIndex && array)
  16913. : undefined;
  16914. }
  16915. array = arrays[0];
  16916. var index = -1,
  16917. seen = caches[0];
  16918. outer:
  16919. while (++index < length && result.length < maxLength) {
  16920. var value = array[index],
  16921. computed = iteratee ? iteratee(value) : value;
  16922. value = (comparator || value !== 0) ? value : 0;
  16923. if (!(seen
  16924. ? cacheHas(seen, computed)
  16925. : includes(result, computed, comparator)
  16926. )) {
  16927. othIndex = othLength;
  16928. while (--othIndex) {
  16929. var cache = caches[othIndex];
  16930. if (!(cache
  16931. ? cacheHas(cache, computed)
  16932. : includes(arrays[othIndex], computed, comparator))
  16933. ) {
  16934. continue outer;
  16935. }
  16936. }
  16937. if (seen) {
  16938. seen.push(computed);
  16939. }
  16940. result.push(value);
  16941. }
  16942. }
  16943. return result;
  16944. }
  16945. /**
  16946. * The base implementation of `_.invert` and `_.invertBy` which inverts
  16947. * `object` with values transformed by `iteratee` and set by `setter`.
  16948. *
  16949. * @private
  16950. * @param {Object} object The object to iterate over.
  16951. * @param {Function} setter The function to set `accumulator` values.
  16952. * @param {Function} iteratee The iteratee to transform values.
  16953. * @param {Object} accumulator The initial inverted object.
  16954. * @returns {Function} Returns `accumulator`.
  16955. */
  16956. function baseInverter(object, setter, iteratee, accumulator) {
  16957. baseForOwn(object, function(value, key, object) {
  16958. setter(accumulator, iteratee(value), key, object);
  16959. });
  16960. return accumulator;
  16961. }
  16962. /**
  16963. * The base implementation of `_.invoke` without support for individual
  16964. * method arguments.
  16965. *
  16966. * @private
  16967. * @param {Object} object The object to query.
  16968. * @param {Array|string} path The path of the method to invoke.
  16969. * @param {Array} args The arguments to invoke the method with.
  16970. * @returns {*} Returns the result of the invoked method.
  16971. */
  16972. function baseInvoke(object, path, args) {
  16973. path = castPath(path, object);
  16974. object = parent(object, path);
  16975. var func = object == null ? object : object[toKey(last(path))];
  16976. return func == null ? undefined : apply(func, object, args);
  16977. }
  16978. /**
  16979. * The base implementation of `_.isArguments`.
  16980. *
  16981. * @private
  16982. * @param {*} value The value to check.
  16983. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  16984. */
  16985. function baseIsArguments(value) {
  16986. return isObjectLike(value) && baseGetTag(value) == argsTag;
  16987. }
  16988. /**
  16989. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  16990. *
  16991. * @private
  16992. * @param {*} value The value to check.
  16993. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  16994. */
  16995. function baseIsArrayBuffer(value) {
  16996. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  16997. }
  16998. /**
  16999. * The base implementation of `_.isDate` without Node.js optimizations.
  17000. *
  17001. * @private
  17002. * @param {*} value The value to check.
  17003. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  17004. */
  17005. function baseIsDate(value) {
  17006. return isObjectLike(value) && baseGetTag(value) == dateTag;
  17007. }
  17008. /**
  17009. * The base implementation of `_.isEqual` which supports partial comparisons
  17010. * and tracks traversed objects.
  17011. *
  17012. * @private
  17013. * @param {*} value The value to compare.
  17014. * @param {*} other The other value to compare.
  17015. * @param {boolean} bitmask The bitmask flags.
  17016. * 1 - Unordered comparison
  17017. * 2 - Partial comparison
  17018. * @param {Function} [customizer] The function to customize comparisons.
  17019. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  17020. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  17021. */
  17022. function baseIsEqual(value, other, bitmask, customizer, stack) {
  17023. if (value === other) {
  17024. return true;
  17025. }
  17026. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  17027. return value !== value && other !== other;
  17028. }
  17029. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  17030. }
  17031. /**
  17032. * A specialized version of `baseIsEqual` for arrays and objects which performs
  17033. * deep comparisons and tracks traversed objects enabling objects with circular
  17034. * references to be compared.
  17035. *
  17036. * @private
  17037. * @param {Object} object The object to compare.
  17038. * @param {Object} other The other object to compare.
  17039. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  17040. * @param {Function} customizer The function to customize comparisons.
  17041. * @param {Function} equalFunc The function to determine equivalents of values.
  17042. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  17043. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  17044. */
  17045. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  17046. var objIsArr = isArray(object),
  17047. othIsArr = isArray(other),
  17048. objTag = objIsArr ? arrayTag : getTag(object),
  17049. othTag = othIsArr ? arrayTag : getTag(other);
  17050. objTag = objTag == argsTag ? objectTag : objTag;
  17051. othTag = othTag == argsTag ? objectTag : othTag;
  17052. var objIsObj = objTag == objectTag,
  17053. othIsObj = othTag == objectTag,
  17054. isSameTag = objTag == othTag;
  17055. if (isSameTag && isBuffer(object)) {
  17056. if (!isBuffer(other)) {
  17057. return false;
  17058. }
  17059. objIsArr = true;
  17060. objIsObj = false;
  17061. }
  17062. if (isSameTag && !objIsObj) {
  17063. stack || (stack = new Stack);
  17064. return (objIsArr || isTypedArray(object))
  17065. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  17066. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  17067. }
  17068. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  17069. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  17070. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  17071. if (objIsWrapped || othIsWrapped) {
  17072. var objUnwrapped = objIsWrapped ? object.value() : object,
  17073. othUnwrapped = othIsWrapped ? other.value() : other;
  17074. stack || (stack = new Stack);
  17075. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  17076. }
  17077. }
  17078. if (!isSameTag) {
  17079. return false;
  17080. }
  17081. stack || (stack = new Stack);
  17082. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  17083. }
  17084. /**
  17085. * The base implementation of `_.isMap` without Node.js optimizations.
  17086. *
  17087. * @private
  17088. * @param {*} value The value to check.
  17089. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  17090. */
  17091. function baseIsMap(value) {
  17092. return isObjectLike(value) && getTag(value) == mapTag;
  17093. }
  17094. /**
  17095. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  17096. *
  17097. * @private
  17098. * @param {Object} object The object to inspect.
  17099. * @param {Object} source The object of property values to match.
  17100. * @param {Array} matchData The property names, values, and compare flags to match.
  17101. * @param {Function} [customizer] The function to customize comparisons.
  17102. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  17103. */
  17104. function baseIsMatch(object, source, matchData, customizer) {
  17105. var index = matchData.length,
  17106. length = index,
  17107. noCustomizer = !customizer;
  17108. if (object == null) {
  17109. return !length;
  17110. }
  17111. object = Object(object);
  17112. while (index--) {
  17113. var data = matchData[index];
  17114. if ((noCustomizer && data[2])
  17115. ? data[1] !== object[data[0]]
  17116. : !(data[0] in object)
  17117. ) {
  17118. return false;
  17119. }
  17120. }
  17121. while (++index < length) {
  17122. data = matchData[index];
  17123. var key = data[0],
  17124. objValue = object[key],
  17125. srcValue = data[1];
  17126. if (noCustomizer && data[2]) {
  17127. if (objValue === undefined && !(key in object)) {
  17128. return false;
  17129. }
  17130. } else {
  17131. var stack = new Stack;
  17132. if (customizer) {
  17133. var result = customizer(objValue, srcValue, key, object, source, stack);
  17134. }
  17135. if (!(result === undefined
  17136. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  17137. : result
  17138. )) {
  17139. return false;
  17140. }
  17141. }
  17142. }
  17143. return true;
  17144. }
  17145. /**
  17146. * The base implementation of `_.isNative` without bad shim checks.
  17147. *
  17148. * @private
  17149. * @param {*} value The value to check.
  17150. * @returns {boolean} Returns `true` if `value` is a native function,
  17151. * else `false`.
  17152. */
  17153. function baseIsNative(value) {
  17154. if (!isObject(value) || isMasked(value)) {
  17155. return false;
  17156. }
  17157. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  17158. return pattern.test(toSource(value));
  17159. }
  17160. /**
  17161. * The base implementation of `_.isRegExp` without Node.js optimizations.
  17162. *
  17163. * @private
  17164. * @param {*} value The value to check.
  17165. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  17166. */
  17167. function baseIsRegExp(value) {
  17168. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  17169. }
  17170. /**
  17171. * The base implementation of `_.isSet` without Node.js optimizations.
  17172. *
  17173. * @private
  17174. * @param {*} value The value to check.
  17175. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  17176. */
  17177. function baseIsSet(value) {
  17178. return isObjectLike(value) && getTag(value) == setTag;
  17179. }
  17180. /**
  17181. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  17182. *
  17183. * @private
  17184. * @param {*} value The value to check.
  17185. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  17186. */
  17187. function baseIsTypedArray(value) {
  17188. return isObjectLike(value) &&
  17189. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  17190. }
  17191. /**
  17192. * The base implementation of `_.iteratee`.
  17193. *
  17194. * @private
  17195. * @param {*} [value=_.identity] The value to convert to an iteratee.
  17196. * @returns {Function} Returns the iteratee.
  17197. */
  17198. function baseIteratee(value) {
  17199. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  17200. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  17201. if (typeof value == 'function') {
  17202. return value;
  17203. }
  17204. if (value == null) {
  17205. return identity;
  17206. }
  17207. if (typeof value == 'object') {
  17208. return isArray(value)
  17209. ? baseMatchesProperty(value[0], value[1])
  17210. : baseMatches(value);
  17211. }
  17212. return property(value);
  17213. }
  17214. /**
  17215. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  17216. *
  17217. * @private
  17218. * @param {Object} object The object to query.
  17219. * @returns {Array} Returns the array of property names.
  17220. */
  17221. function baseKeys(object) {
  17222. if (!isPrototype(object)) {
  17223. return nativeKeys(object);
  17224. }
  17225. var result = [];
  17226. for (var key in Object(object)) {
  17227. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  17228. result.push(key);
  17229. }
  17230. }
  17231. return result;
  17232. }
  17233. /**
  17234. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  17235. *
  17236. * @private
  17237. * @param {Object} object The object to query.
  17238. * @returns {Array} Returns the array of property names.
  17239. */
  17240. function baseKeysIn(object) {
  17241. if (!isObject(object)) {
  17242. return nativeKeysIn(object);
  17243. }
  17244. var isProto = isPrototype(object),
  17245. result = [];
  17246. for (var key in object) {
  17247. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  17248. result.push(key);
  17249. }
  17250. }
  17251. return result;
  17252. }
  17253. /**
  17254. * The base implementation of `_.lt` which doesn't coerce arguments.
  17255. *
  17256. * @private
  17257. * @param {*} value The value to compare.
  17258. * @param {*} other The other value to compare.
  17259. * @returns {boolean} Returns `true` if `value` is less than `other`,
  17260. * else `false`.
  17261. */
  17262. function baseLt(value, other) {
  17263. return value < other;
  17264. }
  17265. /**
  17266. * The base implementation of `_.map` without support for iteratee shorthands.
  17267. *
  17268. * @private
  17269. * @param {Array|Object} collection The collection to iterate over.
  17270. * @param {Function} iteratee The function invoked per iteration.
  17271. * @returns {Array} Returns the new mapped array.
  17272. */
  17273. function baseMap(collection, iteratee) {
  17274. var index = -1,
  17275. result = isArrayLike(collection) ? Array(collection.length) : [];
  17276. baseEach(collection, function(value, key, collection) {
  17277. result[++index] = iteratee(value, key, collection);
  17278. });
  17279. return result;
  17280. }
  17281. /**
  17282. * The base implementation of `_.matches` which doesn't clone `source`.
  17283. *
  17284. * @private
  17285. * @param {Object} source The object of property values to match.
  17286. * @returns {Function} Returns the new spec function.
  17287. */
  17288. function baseMatches(source) {
  17289. var matchData = getMatchData(source);
  17290. if (matchData.length == 1 && matchData[0][2]) {
  17291. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  17292. }
  17293. return function(object) {
  17294. return object === source || baseIsMatch(object, source, matchData);
  17295. };
  17296. }
  17297. /**
  17298. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  17299. *
  17300. * @private
  17301. * @param {string} path The path of the property to get.
  17302. * @param {*} srcValue The value to match.
  17303. * @returns {Function} Returns the new spec function.
  17304. */
  17305. function baseMatchesProperty(path, srcValue) {
  17306. if (isKey(path) && isStrictComparable(srcValue)) {
  17307. return matchesStrictComparable(toKey(path), srcValue);
  17308. }
  17309. return function(object) {
  17310. var objValue = get(object, path);
  17311. return (objValue === undefined && objValue === srcValue)
  17312. ? hasIn(object, path)
  17313. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  17314. };
  17315. }
  17316. /**
  17317. * The base implementation of `_.merge` without support for multiple sources.
  17318. *
  17319. * @private
  17320. * @param {Object} object The destination object.
  17321. * @param {Object} source The source object.
  17322. * @param {number} srcIndex The index of `source`.
  17323. * @param {Function} [customizer] The function to customize merged values.
  17324. * @param {Object} [stack] Tracks traversed source values and their merged
  17325. * counterparts.
  17326. */
  17327. function baseMerge(object, source, srcIndex, customizer, stack) {
  17328. if (object === source) {
  17329. return;
  17330. }
  17331. baseFor(source, function(srcValue, key) {
  17332. stack || (stack = new Stack);
  17333. if (isObject(srcValue)) {
  17334. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  17335. }
  17336. else {
  17337. var newValue = customizer
  17338. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  17339. : undefined;
  17340. if (newValue === undefined) {
  17341. newValue = srcValue;
  17342. }
  17343. assignMergeValue(object, key, newValue);
  17344. }
  17345. }, keysIn);
  17346. }
  17347. /**
  17348. * A specialized version of `baseMerge` for arrays and objects which performs
  17349. * deep merges and tracks traversed objects enabling objects with circular
  17350. * references to be merged.
  17351. *
  17352. * @private
  17353. * @param {Object} object The destination object.
  17354. * @param {Object} source The source object.
  17355. * @param {string} key The key of the value to merge.
  17356. * @param {number} srcIndex The index of `source`.
  17357. * @param {Function} mergeFunc The function to merge values.
  17358. * @param {Function} [customizer] The function to customize assigned values.
  17359. * @param {Object} [stack] Tracks traversed source values and their merged
  17360. * counterparts.
  17361. */
  17362. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  17363. var objValue = safeGet(object, key),
  17364. srcValue = safeGet(source, key),
  17365. stacked = stack.get(srcValue);
  17366. if (stacked) {
  17367. assignMergeValue(object, key, stacked);
  17368. return;
  17369. }
  17370. var newValue = customizer
  17371. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  17372. : undefined;
  17373. var isCommon = newValue === undefined;
  17374. if (isCommon) {
  17375. var isArr = isArray(srcValue),
  17376. isBuff = !isArr && isBuffer(srcValue),
  17377. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  17378. newValue = srcValue;
  17379. if (isArr || isBuff || isTyped) {
  17380. if (isArray(objValue)) {
  17381. newValue = objValue;
  17382. }
  17383. else if (isArrayLikeObject(objValue)) {
  17384. newValue = copyArray(objValue);
  17385. }
  17386. else if (isBuff) {
  17387. isCommon = false;
  17388. newValue = cloneBuffer(srcValue, true);
  17389. }
  17390. else if (isTyped) {
  17391. isCommon = false;
  17392. newValue = cloneTypedArray(srcValue, true);
  17393. }
  17394. else {
  17395. newValue = [];
  17396. }
  17397. }
  17398. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  17399. newValue = objValue;
  17400. if (isArguments(objValue)) {
  17401. newValue = toPlainObject(objValue);
  17402. }
  17403. else if (!isObject(objValue) || isFunction(objValue)) {
  17404. newValue = initCloneObject(srcValue);
  17405. }
  17406. }
  17407. else {
  17408. isCommon = false;
  17409. }
  17410. }
  17411. if (isCommon) {
  17412. // Recursively merge objects and arrays (susceptible to call stack limits).
  17413. stack.set(srcValue, newValue);
  17414. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  17415. stack['delete'](srcValue);
  17416. }
  17417. assignMergeValue(object, key, newValue);
  17418. }
  17419. /**
  17420. * The base implementation of `_.nth` which doesn't coerce arguments.
  17421. *
  17422. * @private
  17423. * @param {Array} array The array to query.
  17424. * @param {number} n The index of the element to return.
  17425. * @returns {*} Returns the nth element of `array`.
  17426. */
  17427. function baseNth(array, n) {
  17428. var length = array.length;
  17429. if (!length) {
  17430. return;
  17431. }
  17432. n += n < 0 ? length : 0;
  17433. return isIndex(n, length) ? array[n] : undefined;
  17434. }
  17435. /**
  17436. * The base implementation of `_.orderBy` without param guards.
  17437. *
  17438. * @private
  17439. * @param {Array|Object} collection The collection to iterate over.
  17440. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  17441. * @param {string[]} orders The sort orders of `iteratees`.
  17442. * @returns {Array} Returns the new sorted array.
  17443. */
  17444. function baseOrderBy(collection, iteratees, orders) {
  17445. var index = -1;
  17446. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  17447. var result = baseMap(collection, function(value, key, collection) {
  17448. var criteria = arrayMap(iteratees, function(iteratee) {
  17449. return iteratee(value);
  17450. });
  17451. return { 'criteria': criteria, 'index': ++index, 'value': value };
  17452. });
  17453. return baseSortBy(result, function(object, other) {
  17454. return compareMultiple(object, other, orders);
  17455. });
  17456. }
  17457. /**
  17458. * The base implementation of `_.pick` without support for individual
  17459. * property identifiers.
  17460. *
  17461. * @private
  17462. * @param {Object} object The source object.
  17463. * @param {string[]} paths The property paths to pick.
  17464. * @returns {Object} Returns the new object.
  17465. */
  17466. function basePick(object, paths) {
  17467. return basePickBy(object, paths, function(value, path) {
  17468. return hasIn(object, path);
  17469. });
  17470. }
  17471. /**
  17472. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  17473. *
  17474. * @private
  17475. * @param {Object} object The source object.
  17476. * @param {string[]} paths The property paths to pick.
  17477. * @param {Function} predicate The function invoked per property.
  17478. * @returns {Object} Returns the new object.
  17479. */
  17480. function basePickBy(object, paths, predicate) {
  17481. var index = -1,
  17482. length = paths.length,
  17483. result = {};
  17484. while (++index < length) {
  17485. var path = paths[index],
  17486. value = baseGet(object, path);
  17487. if (predicate(value, path)) {
  17488. baseSet(result, castPath(path, object), value);
  17489. }
  17490. }
  17491. return result;
  17492. }
  17493. /**
  17494. * A specialized version of `baseProperty` which supports deep paths.
  17495. *
  17496. * @private
  17497. * @param {Array|string} path The path of the property to get.
  17498. * @returns {Function} Returns the new accessor function.
  17499. */
  17500. function basePropertyDeep(path) {
  17501. return function(object) {
  17502. return baseGet(object, path);
  17503. };
  17504. }
  17505. /**
  17506. * The base implementation of `_.pullAllBy` without support for iteratee
  17507. * shorthands.
  17508. *
  17509. * @private
  17510. * @param {Array} array The array to modify.
  17511. * @param {Array} values The values to remove.
  17512. * @param {Function} [iteratee] The iteratee invoked per element.
  17513. * @param {Function} [comparator] The comparator invoked per element.
  17514. * @returns {Array} Returns `array`.
  17515. */
  17516. function basePullAll(array, values, iteratee, comparator) {
  17517. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  17518. index = -1,
  17519. length = values.length,
  17520. seen = array;
  17521. if (array === values) {
  17522. values = copyArray(values);
  17523. }
  17524. if (iteratee) {
  17525. seen = arrayMap(array, baseUnary(iteratee));
  17526. }
  17527. while (++index < length) {
  17528. var fromIndex = 0,
  17529. value = values[index],
  17530. computed = iteratee ? iteratee(value) : value;
  17531. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  17532. if (seen !== array) {
  17533. splice.call(seen, fromIndex, 1);
  17534. }
  17535. splice.call(array, fromIndex, 1);
  17536. }
  17537. }
  17538. return array;
  17539. }
  17540. /**
  17541. * The base implementation of `_.pullAt` without support for individual
  17542. * indexes or capturing the removed elements.
  17543. *
  17544. * @private
  17545. * @param {Array} array The array to modify.
  17546. * @param {number[]} indexes The indexes of elements to remove.
  17547. * @returns {Array} Returns `array`.
  17548. */
  17549. function basePullAt(array, indexes) {
  17550. var length = array ? indexes.length : 0,
  17551. lastIndex = length - 1;
  17552. while (length--) {
  17553. var index = indexes[length];
  17554. if (length == lastIndex || index !== previous) {
  17555. var previous = index;
  17556. if (isIndex(index)) {
  17557. splice.call(array, index, 1);
  17558. } else {
  17559. baseUnset(array, index);
  17560. }
  17561. }
  17562. }
  17563. return array;
  17564. }
  17565. /**
  17566. * The base implementation of `_.random` without support for returning
  17567. * floating-point numbers.
  17568. *
  17569. * @private
  17570. * @param {number} lower The lower bound.
  17571. * @param {number} upper The upper bound.
  17572. * @returns {number} Returns the random number.
  17573. */
  17574. function baseRandom(lower, upper) {
  17575. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  17576. }
  17577. /**
  17578. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  17579. * coerce arguments.
  17580. *
  17581. * @private
  17582. * @param {number} start The start of the range.
  17583. * @param {number} end The end of the range.
  17584. * @param {number} step The value to increment or decrement by.
  17585. * @param {boolean} [fromRight] Specify iterating from right to left.
  17586. * @returns {Array} Returns the range of numbers.
  17587. */
  17588. function baseRange(start, end, step, fromRight) {
  17589. var index = -1,
  17590. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  17591. result = Array(length);
  17592. while (length--) {
  17593. result[fromRight ? length : ++index] = start;
  17594. start += step;
  17595. }
  17596. return result;
  17597. }
  17598. /**
  17599. * The base implementation of `_.repeat` which doesn't coerce arguments.
  17600. *
  17601. * @private
  17602. * @param {string} string The string to repeat.
  17603. * @param {number} n The number of times to repeat the string.
  17604. * @returns {string} Returns the repeated string.
  17605. */
  17606. function baseRepeat(string, n) {
  17607. var result = '';
  17608. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  17609. return result;
  17610. }
  17611. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  17612. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  17613. do {
  17614. if (n % 2) {
  17615. result += string;
  17616. }
  17617. n = nativeFloor(n / 2);
  17618. if (n) {
  17619. string += string;
  17620. }
  17621. } while (n);
  17622. return result;
  17623. }
  17624. /**
  17625. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  17626. *
  17627. * @private
  17628. * @param {Function} func The function to apply a rest parameter to.
  17629. * @param {number} [start=func.length-1] The start position of the rest parameter.
  17630. * @returns {Function} Returns the new function.
  17631. */
  17632. function baseRest(func, start) {
  17633. return setToString(overRest(func, start, identity), func + '');
  17634. }
  17635. /**
  17636. * The base implementation of `_.sample`.
  17637. *
  17638. * @private
  17639. * @param {Array|Object} collection The collection to sample.
  17640. * @returns {*} Returns the random element.
  17641. */
  17642. function baseSample(collection) {
  17643. return arraySample(values(collection));
  17644. }
  17645. /**
  17646. * The base implementation of `_.sampleSize` without param guards.
  17647. *
  17648. * @private
  17649. * @param {Array|Object} collection The collection to sample.
  17650. * @param {number} n The number of elements to sample.
  17651. * @returns {Array} Returns the random elements.
  17652. */
  17653. function baseSampleSize(collection, n) {
  17654. var array = values(collection);
  17655. return shuffleSelf(array, baseClamp(n, 0, array.length));
  17656. }
  17657. /**
  17658. * The base implementation of `_.set`.
  17659. *
  17660. * @private
  17661. * @param {Object} object The object to modify.
  17662. * @param {Array|string} path The path of the property to set.
  17663. * @param {*} value The value to set.
  17664. * @param {Function} [customizer] The function to customize path creation.
  17665. * @returns {Object} Returns `object`.
  17666. */
  17667. function baseSet(object, path, value, customizer) {
  17668. if (!isObject(object)) {
  17669. return object;
  17670. }
  17671. path = castPath(path, object);
  17672. var index = -1,
  17673. length = path.length,
  17674. lastIndex = length - 1,
  17675. nested = object;
  17676. while (nested != null && ++index < length) {
  17677. var key = toKey(path[index]),
  17678. newValue = value;
  17679. if (index != lastIndex) {
  17680. var objValue = nested[key];
  17681. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  17682. if (newValue === undefined) {
  17683. newValue = isObject(objValue)
  17684. ? objValue
  17685. : (isIndex(path[index + 1]) ? [] : {});
  17686. }
  17687. }
  17688. assignValue(nested, key, newValue);
  17689. nested = nested[key];
  17690. }
  17691. return object;
  17692. }
  17693. /**
  17694. * The base implementation of `setData` without support for hot loop shorting.
  17695. *
  17696. * @private
  17697. * @param {Function} func The function to associate metadata with.
  17698. * @param {*} data The metadata.
  17699. * @returns {Function} Returns `func`.
  17700. */
  17701. var baseSetData = !metaMap ? identity : function(func, data) {
  17702. metaMap.set(func, data);
  17703. return func;
  17704. };
  17705. /**
  17706. * The base implementation of `setToString` without support for hot loop shorting.
  17707. *
  17708. * @private
  17709. * @param {Function} func The function to modify.
  17710. * @param {Function} string The `toString` result.
  17711. * @returns {Function} Returns `func`.
  17712. */
  17713. var baseSetToString = !defineProperty ? identity : function(func, string) {
  17714. return defineProperty(func, 'toString', {
  17715. 'configurable': true,
  17716. 'enumerable': false,
  17717. 'value': constant(string),
  17718. 'writable': true
  17719. });
  17720. };
  17721. /**
  17722. * The base implementation of `_.shuffle`.
  17723. *
  17724. * @private
  17725. * @param {Array|Object} collection The collection to shuffle.
  17726. * @returns {Array} Returns the new shuffled array.
  17727. */
  17728. function baseShuffle(collection) {
  17729. return shuffleSelf(values(collection));
  17730. }
  17731. /**
  17732. * The base implementation of `_.slice` without an iteratee call guard.
  17733. *
  17734. * @private
  17735. * @param {Array} array The array to slice.
  17736. * @param {number} [start=0] The start position.
  17737. * @param {number} [end=array.length] The end position.
  17738. * @returns {Array} Returns the slice of `array`.
  17739. */
  17740. function baseSlice(array, start, end) {
  17741. var index = -1,
  17742. length = array.length;
  17743. if (start < 0) {
  17744. start = -start > length ? 0 : (length + start);
  17745. }
  17746. end = end > length ? length : end;
  17747. if (end < 0) {
  17748. end += length;
  17749. }
  17750. length = start > end ? 0 : ((end - start) >>> 0);
  17751. start >>>= 0;
  17752. var result = Array(length);
  17753. while (++index < length) {
  17754. result[index] = array[index + start];
  17755. }
  17756. return result;
  17757. }
  17758. /**
  17759. * The base implementation of `_.some` without support for iteratee shorthands.
  17760. *
  17761. * @private
  17762. * @param {Array|Object} collection The collection to iterate over.
  17763. * @param {Function} predicate The function invoked per iteration.
  17764. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17765. * else `false`.
  17766. */
  17767. function baseSome(collection, predicate) {
  17768. var result;
  17769. baseEach(collection, function(value, index, collection) {
  17770. result = predicate(value, index, collection);
  17771. return !result;
  17772. });
  17773. return !!result;
  17774. }
  17775. /**
  17776. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  17777. * performs a binary search of `array` to determine the index at which `value`
  17778. * should be inserted into `array` in order to maintain its sort order.
  17779. *
  17780. * @private
  17781. * @param {Array} array The sorted array to inspect.
  17782. * @param {*} value The value to evaluate.
  17783. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17784. * @returns {number} Returns the index at which `value` should be inserted
  17785. * into `array`.
  17786. */
  17787. function baseSortedIndex(array, value, retHighest) {
  17788. var low = 0,
  17789. high = array == null ? low : array.length;
  17790. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  17791. while (low < high) {
  17792. var mid = (low + high) >>> 1,
  17793. computed = array[mid];
  17794. if (computed !== null && !isSymbol(computed) &&
  17795. (retHighest ? (computed <= value) : (computed < value))) {
  17796. low = mid + 1;
  17797. } else {
  17798. high = mid;
  17799. }
  17800. }
  17801. return high;
  17802. }
  17803. return baseSortedIndexBy(array, value, identity, retHighest);
  17804. }
  17805. /**
  17806. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  17807. * which invokes `iteratee` for `value` and each element of `array` to compute
  17808. * their sort ranking. The iteratee is invoked with one argument; (value).
  17809. *
  17810. * @private
  17811. * @param {Array} array The sorted array to inspect.
  17812. * @param {*} value The value to evaluate.
  17813. * @param {Function} iteratee The iteratee invoked per element.
  17814. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17815. * @returns {number} Returns the index at which `value` should be inserted
  17816. * into `array`.
  17817. */
  17818. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  17819. value = iteratee(value);
  17820. var low = 0,
  17821. high = array == null ? 0 : array.length,
  17822. valIsNaN = value !== value,
  17823. valIsNull = value === null,
  17824. valIsSymbol = isSymbol(value),
  17825. valIsUndefined = value === undefined;
  17826. while (low < high) {
  17827. var mid = nativeFloor((low + high) / 2),
  17828. computed = iteratee(array[mid]),
  17829. othIsDefined = computed !== undefined,
  17830. othIsNull = computed === null,
  17831. othIsReflexive = computed === computed,
  17832. othIsSymbol = isSymbol(computed);
  17833. if (valIsNaN) {
  17834. var setLow = retHighest || othIsReflexive;
  17835. } else if (valIsUndefined) {
  17836. setLow = othIsReflexive && (retHighest || othIsDefined);
  17837. } else if (valIsNull) {
  17838. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  17839. } else if (valIsSymbol) {
  17840. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  17841. } else if (othIsNull || othIsSymbol) {
  17842. setLow = false;
  17843. } else {
  17844. setLow = retHighest ? (computed <= value) : (computed < value);
  17845. }
  17846. if (setLow) {
  17847. low = mid + 1;
  17848. } else {
  17849. high = mid;
  17850. }
  17851. }
  17852. return nativeMin(high, MAX_ARRAY_INDEX);
  17853. }
  17854. /**
  17855. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  17856. * support for iteratee shorthands.
  17857. *
  17858. * @private
  17859. * @param {Array} array The array to inspect.
  17860. * @param {Function} [iteratee] The iteratee invoked per element.
  17861. * @returns {Array} Returns the new duplicate free array.
  17862. */
  17863. function baseSortedUniq(array, iteratee) {
  17864. var index = -1,
  17865. length = array.length,
  17866. resIndex = 0,
  17867. result = [];
  17868. while (++index < length) {
  17869. var value = array[index],
  17870. computed = iteratee ? iteratee(value) : value;
  17871. if (!index || !eq(computed, seen)) {
  17872. var seen = computed;
  17873. result[resIndex++] = value === 0 ? 0 : value;
  17874. }
  17875. }
  17876. return result;
  17877. }
  17878. /**
  17879. * The base implementation of `_.toNumber` which doesn't ensure correct
  17880. * conversions of binary, hexadecimal, or octal string values.
  17881. *
  17882. * @private
  17883. * @param {*} value The value to process.
  17884. * @returns {number} Returns the number.
  17885. */
  17886. function baseToNumber(value) {
  17887. if (typeof value == 'number') {
  17888. return value;
  17889. }
  17890. if (isSymbol(value)) {
  17891. return NAN;
  17892. }
  17893. return +value;
  17894. }
  17895. /**
  17896. * The base implementation of `_.toString` which doesn't convert nullish
  17897. * values to empty strings.
  17898. *
  17899. * @private
  17900. * @param {*} value The value to process.
  17901. * @returns {string} Returns the string.
  17902. */
  17903. function baseToString(value) {
  17904. // Exit early for strings to avoid a performance hit in some environments.
  17905. if (typeof value == 'string') {
  17906. return value;
  17907. }
  17908. if (isArray(value)) {
  17909. // Recursively convert values (susceptible to call stack limits).
  17910. return arrayMap(value, baseToString) + '';
  17911. }
  17912. if (isSymbol(value)) {
  17913. return symbolToString ? symbolToString.call(value) : '';
  17914. }
  17915. var result = (value + '');
  17916. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  17917. }
  17918. /**
  17919. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  17920. *
  17921. * @private
  17922. * @param {Array} array The array to inspect.
  17923. * @param {Function} [iteratee] The iteratee invoked per element.
  17924. * @param {Function} [comparator] The comparator invoked per element.
  17925. * @returns {Array} Returns the new duplicate free array.
  17926. */
  17927. function baseUniq(array, iteratee, comparator) {
  17928. var index = -1,
  17929. includes = arrayIncludes,
  17930. length = array.length,
  17931. isCommon = true,
  17932. result = [],
  17933. seen = result;
  17934. if (comparator) {
  17935. isCommon = false;
  17936. includes = arrayIncludesWith;
  17937. }
  17938. else if (length >= LARGE_ARRAY_SIZE) {
  17939. var set = iteratee ? null : createSet(array);
  17940. if (set) {
  17941. return setToArray(set);
  17942. }
  17943. isCommon = false;
  17944. includes = cacheHas;
  17945. seen = new SetCache;
  17946. }
  17947. else {
  17948. seen = iteratee ? [] : result;
  17949. }
  17950. outer:
  17951. while (++index < length) {
  17952. var value = array[index],
  17953. computed = iteratee ? iteratee(value) : value;
  17954. value = (comparator || value !== 0) ? value : 0;
  17955. if (isCommon && computed === computed) {
  17956. var seenIndex = seen.length;
  17957. while (seenIndex--) {
  17958. if (seen[seenIndex] === computed) {
  17959. continue outer;
  17960. }
  17961. }
  17962. if (iteratee) {
  17963. seen.push(computed);
  17964. }
  17965. result.push(value);
  17966. }
  17967. else if (!includes(seen, computed, comparator)) {
  17968. if (seen !== result) {
  17969. seen.push(computed);
  17970. }
  17971. result.push(value);
  17972. }
  17973. }
  17974. return result;
  17975. }
  17976. /**
  17977. * The base implementation of `_.unset`.
  17978. *
  17979. * @private
  17980. * @param {Object} object The object to modify.
  17981. * @param {Array|string} path The property path to unset.
  17982. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17983. */
  17984. function baseUnset(object, path) {
  17985. path = castPath(path, object);
  17986. object = parent(object, path);
  17987. return object == null || delete object[toKey(last(path))];
  17988. }
  17989. /**
  17990. * The base implementation of `_.update`.
  17991. *
  17992. * @private
  17993. * @param {Object} object The object to modify.
  17994. * @param {Array|string} path The path of the property to update.
  17995. * @param {Function} updater The function to produce the updated value.
  17996. * @param {Function} [customizer] The function to customize path creation.
  17997. * @returns {Object} Returns `object`.
  17998. */
  17999. function baseUpdate(object, path, updater, customizer) {
  18000. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  18001. }
  18002. /**
  18003. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  18004. * without support for iteratee shorthands.
  18005. *
  18006. * @private
  18007. * @param {Array} array The array to query.
  18008. * @param {Function} predicate The function invoked per iteration.
  18009. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  18010. * @param {boolean} [fromRight] Specify iterating from right to left.
  18011. * @returns {Array} Returns the slice of `array`.
  18012. */
  18013. function baseWhile(array, predicate, isDrop, fromRight) {
  18014. var length = array.length,
  18015. index = fromRight ? length : -1;
  18016. while ((fromRight ? index-- : ++index < length) &&
  18017. predicate(array[index], index, array)) {}
  18018. return isDrop
  18019. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  18020. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  18021. }
  18022. /**
  18023. * The base implementation of `wrapperValue` which returns the result of
  18024. * performing a sequence of actions on the unwrapped `value`, where each
  18025. * successive action is supplied the return value of the previous.
  18026. *
  18027. * @private
  18028. * @param {*} value The unwrapped value.
  18029. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  18030. * @returns {*} Returns the resolved value.
  18031. */
  18032. function baseWrapperValue(value, actions) {
  18033. var result = value;
  18034. if (result instanceof LazyWrapper) {
  18035. result = result.value();
  18036. }
  18037. return arrayReduce(actions, function(result, action) {
  18038. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  18039. }, result);
  18040. }
  18041. /**
  18042. * The base implementation of methods like `_.xor`, without support for
  18043. * iteratee shorthands, that accepts an array of arrays to inspect.
  18044. *
  18045. * @private
  18046. * @param {Array} arrays The arrays to inspect.
  18047. * @param {Function} [iteratee] The iteratee invoked per element.
  18048. * @param {Function} [comparator] The comparator invoked per element.
  18049. * @returns {Array} Returns the new array of values.
  18050. */
  18051. function baseXor(arrays, iteratee, comparator) {
  18052. var length = arrays.length;
  18053. if (length < 2) {
  18054. return length ? baseUniq(arrays[0]) : [];
  18055. }
  18056. var index = -1,
  18057. result = Array(length);
  18058. while (++index < length) {
  18059. var array = arrays[index],
  18060. othIndex = -1;
  18061. while (++othIndex < length) {
  18062. if (othIndex != index) {
  18063. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  18064. }
  18065. }
  18066. }
  18067. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  18068. }
  18069. /**
  18070. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  18071. *
  18072. * @private
  18073. * @param {Array} props The property identifiers.
  18074. * @param {Array} values The property values.
  18075. * @param {Function} assignFunc The function to assign values.
  18076. * @returns {Object} Returns the new object.
  18077. */
  18078. function baseZipObject(props, values, assignFunc) {
  18079. var index = -1,
  18080. length = props.length,
  18081. valsLength = values.length,
  18082. result = {};
  18083. while (++index < length) {
  18084. var value = index < valsLength ? values[index] : undefined;
  18085. assignFunc(result, props[index], value);
  18086. }
  18087. return result;
  18088. }
  18089. /**
  18090. * Casts `value` to an empty array if it's not an array like object.
  18091. *
  18092. * @private
  18093. * @param {*} value The value to inspect.
  18094. * @returns {Array|Object} Returns the cast array-like object.
  18095. */
  18096. function castArrayLikeObject(value) {
  18097. return isArrayLikeObject(value) ? value : [];
  18098. }
  18099. /**
  18100. * Casts `value` to `identity` if it's not a function.
  18101. *
  18102. * @private
  18103. * @param {*} value The value to inspect.
  18104. * @returns {Function} Returns cast function.
  18105. */
  18106. function castFunction(value) {
  18107. return typeof value == 'function' ? value : identity;
  18108. }
  18109. /**
  18110. * Casts `value` to a path array if it's not one.
  18111. *
  18112. * @private
  18113. * @param {*} value The value to inspect.
  18114. * @param {Object} [object] The object to query keys on.
  18115. * @returns {Array} Returns the cast property path array.
  18116. */
  18117. function castPath(value, object) {
  18118. if (isArray(value)) {
  18119. return value;
  18120. }
  18121. return isKey(value, object) ? [value] : stringToPath(toString(value));
  18122. }
  18123. /**
  18124. * A `baseRest` alias which can be replaced with `identity` by module
  18125. * replacement plugins.
  18126. *
  18127. * @private
  18128. * @type {Function}
  18129. * @param {Function} func The function to apply a rest parameter to.
  18130. * @returns {Function} Returns the new function.
  18131. */
  18132. var castRest = baseRest;
  18133. /**
  18134. * Casts `array` to a slice if it's needed.
  18135. *
  18136. * @private
  18137. * @param {Array} array The array to inspect.
  18138. * @param {number} start The start position.
  18139. * @param {number} [end=array.length] The end position.
  18140. * @returns {Array} Returns the cast slice.
  18141. */
  18142. function castSlice(array, start, end) {
  18143. var length = array.length;
  18144. end = end === undefined ? length : end;
  18145. return (!start && end >= length) ? array : baseSlice(array, start, end);
  18146. }
  18147. /**
  18148. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  18149. *
  18150. * @private
  18151. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  18152. */
  18153. var clearTimeout = ctxClearTimeout || function(id) {
  18154. return root.clearTimeout(id);
  18155. };
  18156. /**
  18157. * Creates a clone of `buffer`.
  18158. *
  18159. * @private
  18160. * @param {Buffer} buffer The buffer to clone.
  18161. * @param {boolean} [isDeep] Specify a deep clone.
  18162. * @returns {Buffer} Returns the cloned buffer.
  18163. */
  18164. function cloneBuffer(buffer, isDeep) {
  18165. if (isDeep) {
  18166. return buffer.slice();
  18167. }
  18168. var length = buffer.length,
  18169. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  18170. buffer.copy(result);
  18171. return result;
  18172. }
  18173. /**
  18174. * Creates a clone of `arrayBuffer`.
  18175. *
  18176. * @private
  18177. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  18178. * @returns {ArrayBuffer} Returns the cloned array buffer.
  18179. */
  18180. function cloneArrayBuffer(arrayBuffer) {
  18181. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  18182. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  18183. return result;
  18184. }
  18185. /**
  18186. * Creates a clone of `dataView`.
  18187. *
  18188. * @private
  18189. * @param {Object} dataView The data view to clone.
  18190. * @param {boolean} [isDeep] Specify a deep clone.
  18191. * @returns {Object} Returns the cloned data view.
  18192. */
  18193. function cloneDataView(dataView, isDeep) {
  18194. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  18195. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  18196. }
  18197. /**
  18198. * Creates a clone of `regexp`.
  18199. *
  18200. * @private
  18201. * @param {Object} regexp The regexp to clone.
  18202. * @returns {Object} Returns the cloned regexp.
  18203. */
  18204. function cloneRegExp(regexp) {
  18205. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  18206. result.lastIndex = regexp.lastIndex;
  18207. return result;
  18208. }
  18209. /**
  18210. * Creates a clone of the `symbol` object.
  18211. *
  18212. * @private
  18213. * @param {Object} symbol The symbol object to clone.
  18214. * @returns {Object} Returns the cloned symbol object.
  18215. */
  18216. function cloneSymbol(symbol) {
  18217. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  18218. }
  18219. /**
  18220. * Creates a clone of `typedArray`.
  18221. *
  18222. * @private
  18223. * @param {Object} typedArray The typed array to clone.
  18224. * @param {boolean} [isDeep] Specify a deep clone.
  18225. * @returns {Object} Returns the cloned typed array.
  18226. */
  18227. function cloneTypedArray(typedArray, isDeep) {
  18228. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  18229. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  18230. }
  18231. /**
  18232. * Compares values to sort them in ascending order.
  18233. *
  18234. * @private
  18235. * @param {*} value The value to compare.
  18236. * @param {*} other The other value to compare.
  18237. * @returns {number} Returns the sort order indicator for `value`.
  18238. */
  18239. function compareAscending(value, other) {
  18240. if (value !== other) {
  18241. var valIsDefined = value !== undefined,
  18242. valIsNull = value === null,
  18243. valIsReflexive = value === value,
  18244. valIsSymbol = isSymbol(value);
  18245. var othIsDefined = other !== undefined,
  18246. othIsNull = other === null,
  18247. othIsReflexive = other === other,
  18248. othIsSymbol = isSymbol(other);
  18249. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  18250. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  18251. (valIsNull && othIsDefined && othIsReflexive) ||
  18252. (!valIsDefined && othIsReflexive) ||
  18253. !valIsReflexive) {
  18254. return 1;
  18255. }
  18256. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  18257. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  18258. (othIsNull && valIsDefined && valIsReflexive) ||
  18259. (!othIsDefined && valIsReflexive) ||
  18260. !othIsReflexive) {
  18261. return -1;
  18262. }
  18263. }
  18264. return 0;
  18265. }
  18266. /**
  18267. * Used by `_.orderBy` to compare multiple properties of a value to another
  18268. * and stable sort them.
  18269. *
  18270. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  18271. * specify an order of "desc" for descending or "asc" for ascending sort order
  18272. * of corresponding values.
  18273. *
  18274. * @private
  18275. * @param {Object} object The object to compare.
  18276. * @param {Object} other The other object to compare.
  18277. * @param {boolean[]|string[]} orders The order to sort by for each property.
  18278. * @returns {number} Returns the sort order indicator for `object`.
  18279. */
  18280. function compareMultiple(object, other, orders) {
  18281. var index = -1,
  18282. objCriteria = object.criteria,
  18283. othCriteria = other.criteria,
  18284. length = objCriteria.length,
  18285. ordersLength = orders.length;
  18286. while (++index < length) {
  18287. var result = compareAscending(objCriteria[index], othCriteria[index]);
  18288. if (result) {
  18289. if (index >= ordersLength) {
  18290. return result;
  18291. }
  18292. var order = orders[index];
  18293. return result * (order == 'desc' ? -1 : 1);
  18294. }
  18295. }
  18296. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  18297. // that causes it, under certain circumstances, to provide the same value for
  18298. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  18299. // for more details.
  18300. //
  18301. // This also ensures a stable sort in V8 and other engines.
  18302. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  18303. return object.index - other.index;
  18304. }
  18305. /**
  18306. * Creates an array that is the composition of partially applied arguments,
  18307. * placeholders, and provided arguments into a single array of arguments.
  18308. *
  18309. * @private
  18310. * @param {Array} args The provided arguments.
  18311. * @param {Array} partials The arguments to prepend to those provided.
  18312. * @param {Array} holders The `partials` placeholder indexes.
  18313. * @params {boolean} [isCurried] Specify composing for a curried function.
  18314. * @returns {Array} Returns the new array of composed arguments.
  18315. */
  18316. function composeArgs(args, partials, holders, isCurried) {
  18317. var argsIndex = -1,
  18318. argsLength = args.length,
  18319. holdersLength = holders.length,
  18320. leftIndex = -1,
  18321. leftLength = partials.length,
  18322. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18323. result = Array(leftLength + rangeLength),
  18324. isUncurried = !isCurried;
  18325. while (++leftIndex < leftLength) {
  18326. result[leftIndex] = partials[leftIndex];
  18327. }
  18328. while (++argsIndex < holdersLength) {
  18329. if (isUncurried || argsIndex < argsLength) {
  18330. result[holders[argsIndex]] = args[argsIndex];
  18331. }
  18332. }
  18333. while (rangeLength--) {
  18334. result[leftIndex++] = args[argsIndex++];
  18335. }
  18336. return result;
  18337. }
  18338. /**
  18339. * This function is like `composeArgs` except that the arguments composition
  18340. * is tailored for `_.partialRight`.
  18341. *
  18342. * @private
  18343. * @param {Array} args The provided arguments.
  18344. * @param {Array} partials The arguments to append to those provided.
  18345. * @param {Array} holders The `partials` placeholder indexes.
  18346. * @params {boolean} [isCurried] Specify composing for a curried function.
  18347. * @returns {Array} Returns the new array of composed arguments.
  18348. */
  18349. function composeArgsRight(args, partials, holders, isCurried) {
  18350. var argsIndex = -1,
  18351. argsLength = args.length,
  18352. holdersIndex = -1,
  18353. holdersLength = holders.length,
  18354. rightIndex = -1,
  18355. rightLength = partials.length,
  18356. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18357. result = Array(rangeLength + rightLength),
  18358. isUncurried = !isCurried;
  18359. while (++argsIndex < rangeLength) {
  18360. result[argsIndex] = args[argsIndex];
  18361. }
  18362. var offset = argsIndex;
  18363. while (++rightIndex < rightLength) {
  18364. result[offset + rightIndex] = partials[rightIndex];
  18365. }
  18366. while (++holdersIndex < holdersLength) {
  18367. if (isUncurried || argsIndex < argsLength) {
  18368. result[offset + holders[holdersIndex]] = args[argsIndex++];
  18369. }
  18370. }
  18371. return result;
  18372. }
  18373. /**
  18374. * Copies the values of `source` to `array`.
  18375. *
  18376. * @private
  18377. * @param {Array} source The array to copy values from.
  18378. * @param {Array} [array=[]] The array to copy values to.
  18379. * @returns {Array} Returns `array`.
  18380. */
  18381. function copyArray(source, array) {
  18382. var index = -1,
  18383. length = source.length;
  18384. array || (array = Array(length));
  18385. while (++index < length) {
  18386. array[index] = source[index];
  18387. }
  18388. return array;
  18389. }
  18390. /**
  18391. * Copies properties of `source` to `object`.
  18392. *
  18393. * @private
  18394. * @param {Object} source The object to copy properties from.
  18395. * @param {Array} props The property identifiers to copy.
  18396. * @param {Object} [object={}] The object to copy properties to.
  18397. * @param {Function} [customizer] The function to customize copied values.
  18398. * @returns {Object} Returns `object`.
  18399. */
  18400. function copyObject(source, props, object, customizer) {
  18401. var isNew = !object;
  18402. object || (object = {});
  18403. var index = -1,
  18404. length = props.length;
  18405. while (++index < length) {
  18406. var key = props[index];
  18407. var newValue = customizer
  18408. ? customizer(object[key], source[key], key, object, source)
  18409. : undefined;
  18410. if (newValue === undefined) {
  18411. newValue = source[key];
  18412. }
  18413. if (isNew) {
  18414. baseAssignValue(object, key, newValue);
  18415. } else {
  18416. assignValue(object, key, newValue);
  18417. }
  18418. }
  18419. return object;
  18420. }
  18421. /**
  18422. * Copies own symbols of `source` to `object`.
  18423. *
  18424. * @private
  18425. * @param {Object} source The object to copy symbols from.
  18426. * @param {Object} [object={}] The object to copy symbols to.
  18427. * @returns {Object} Returns `object`.
  18428. */
  18429. function copySymbols(source, object) {
  18430. return copyObject(source, getSymbols(source), object);
  18431. }
  18432. /**
  18433. * Copies own and inherited symbols of `source` to `object`.
  18434. *
  18435. * @private
  18436. * @param {Object} source The object to copy symbols from.
  18437. * @param {Object} [object={}] The object to copy symbols to.
  18438. * @returns {Object} Returns `object`.
  18439. */
  18440. function copySymbolsIn(source, object) {
  18441. return copyObject(source, getSymbolsIn(source), object);
  18442. }
  18443. /**
  18444. * Creates a function like `_.groupBy`.
  18445. *
  18446. * @private
  18447. * @param {Function} setter The function to set accumulator values.
  18448. * @param {Function} [initializer] The accumulator object initializer.
  18449. * @returns {Function} Returns the new aggregator function.
  18450. */
  18451. function createAggregator(setter, initializer) {
  18452. return function(collection, iteratee) {
  18453. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  18454. accumulator = initializer ? initializer() : {};
  18455. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  18456. };
  18457. }
  18458. /**
  18459. * Creates a function like `_.assign`.
  18460. *
  18461. * @private
  18462. * @param {Function} assigner The function to assign values.
  18463. * @returns {Function} Returns the new assigner function.
  18464. */
  18465. function createAssigner(assigner) {
  18466. return baseRest(function(object, sources) {
  18467. var index = -1,
  18468. length = sources.length,
  18469. customizer = length > 1 ? sources[length - 1] : undefined,
  18470. guard = length > 2 ? sources[2] : undefined;
  18471. customizer = (assigner.length > 3 && typeof customizer == 'function')
  18472. ? (length--, customizer)
  18473. : undefined;
  18474. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  18475. customizer = length < 3 ? undefined : customizer;
  18476. length = 1;
  18477. }
  18478. object = Object(object);
  18479. while (++index < length) {
  18480. var source = sources[index];
  18481. if (source) {
  18482. assigner(object, source, index, customizer);
  18483. }
  18484. }
  18485. return object;
  18486. });
  18487. }
  18488. /**
  18489. * Creates a `baseEach` or `baseEachRight` function.
  18490. *
  18491. * @private
  18492. * @param {Function} eachFunc The function to iterate over a collection.
  18493. * @param {boolean} [fromRight] Specify iterating from right to left.
  18494. * @returns {Function} Returns the new base function.
  18495. */
  18496. function createBaseEach(eachFunc, fromRight) {
  18497. return function(collection, iteratee) {
  18498. if (collection == null) {
  18499. return collection;
  18500. }
  18501. if (!isArrayLike(collection)) {
  18502. return eachFunc(collection, iteratee);
  18503. }
  18504. var length = collection.length,
  18505. index = fromRight ? length : -1,
  18506. iterable = Object(collection);
  18507. while ((fromRight ? index-- : ++index < length)) {
  18508. if (iteratee(iterable[index], index, iterable) === false) {
  18509. break;
  18510. }
  18511. }
  18512. return collection;
  18513. };
  18514. }
  18515. /**
  18516. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  18517. *
  18518. * @private
  18519. * @param {boolean} [fromRight] Specify iterating from right to left.
  18520. * @returns {Function} Returns the new base function.
  18521. */
  18522. function createBaseFor(fromRight) {
  18523. return function(object, iteratee, keysFunc) {
  18524. var index = -1,
  18525. iterable = Object(object),
  18526. props = keysFunc(object),
  18527. length = props.length;
  18528. while (length--) {
  18529. var key = props[fromRight ? length : ++index];
  18530. if (iteratee(iterable[key], key, iterable) === false) {
  18531. break;
  18532. }
  18533. }
  18534. return object;
  18535. };
  18536. }
  18537. /**
  18538. * Creates a function that wraps `func` to invoke it with the optional `this`
  18539. * binding of `thisArg`.
  18540. *
  18541. * @private
  18542. * @param {Function} func The function to wrap.
  18543. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18544. * @param {*} [thisArg] The `this` binding of `func`.
  18545. * @returns {Function} Returns the new wrapped function.
  18546. */
  18547. function createBind(func, bitmask, thisArg) {
  18548. var isBind = bitmask & WRAP_BIND_FLAG,
  18549. Ctor = createCtor(func);
  18550. function wrapper() {
  18551. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18552. return fn.apply(isBind ? thisArg : this, arguments);
  18553. }
  18554. return wrapper;
  18555. }
  18556. /**
  18557. * Creates a function like `_.lowerFirst`.
  18558. *
  18559. * @private
  18560. * @param {string} methodName The name of the `String` case method to use.
  18561. * @returns {Function} Returns the new case function.
  18562. */
  18563. function createCaseFirst(methodName) {
  18564. return function(string) {
  18565. string = toString(string);
  18566. var strSymbols = hasUnicode(string)
  18567. ? stringToArray(string)
  18568. : undefined;
  18569. var chr = strSymbols
  18570. ? strSymbols[0]
  18571. : string.charAt(0);
  18572. var trailing = strSymbols
  18573. ? castSlice(strSymbols, 1).join('')
  18574. : string.slice(1);
  18575. return chr[methodName]() + trailing;
  18576. };
  18577. }
  18578. /**
  18579. * Creates a function like `_.camelCase`.
  18580. *
  18581. * @private
  18582. * @param {Function} callback The function to combine each word.
  18583. * @returns {Function} Returns the new compounder function.
  18584. */
  18585. function createCompounder(callback) {
  18586. return function(string) {
  18587. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  18588. };
  18589. }
  18590. /**
  18591. * Creates a function that produces an instance of `Ctor` regardless of
  18592. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  18593. *
  18594. * @private
  18595. * @param {Function} Ctor The constructor to wrap.
  18596. * @returns {Function} Returns the new wrapped function.
  18597. */
  18598. function createCtor(Ctor) {
  18599. return function() {
  18600. // Use a `switch` statement to work with class constructors. See
  18601. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  18602. // for more details.
  18603. var args = arguments;
  18604. switch (args.length) {
  18605. case 0: return new Ctor;
  18606. case 1: return new Ctor(args[0]);
  18607. case 2: return new Ctor(args[0], args[1]);
  18608. case 3: return new Ctor(args[0], args[1], args[2]);
  18609. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  18610. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  18611. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  18612. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  18613. }
  18614. var thisBinding = baseCreate(Ctor.prototype),
  18615. result = Ctor.apply(thisBinding, args);
  18616. // Mimic the constructor's `return` behavior.
  18617. // See https://es5.github.io/#x13.2.2 for more details.
  18618. return isObject(result) ? result : thisBinding;
  18619. };
  18620. }
  18621. /**
  18622. * Creates a function that wraps `func` to enable currying.
  18623. *
  18624. * @private
  18625. * @param {Function} func The function to wrap.
  18626. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18627. * @param {number} arity The arity of `func`.
  18628. * @returns {Function} Returns the new wrapped function.
  18629. */
  18630. function createCurry(func, bitmask, arity) {
  18631. var Ctor = createCtor(func);
  18632. function wrapper() {
  18633. var length = arguments.length,
  18634. args = Array(length),
  18635. index = length,
  18636. placeholder = getHolder(wrapper);
  18637. while (index--) {
  18638. args[index] = arguments[index];
  18639. }
  18640. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  18641. ? []
  18642. : replaceHolders(args, placeholder);
  18643. length -= holders.length;
  18644. if (length < arity) {
  18645. return createRecurry(
  18646. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  18647. args, holders, undefined, undefined, arity - length);
  18648. }
  18649. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18650. return apply(fn, this, args);
  18651. }
  18652. return wrapper;
  18653. }
  18654. /**
  18655. * Creates a `_.find` or `_.findLast` function.
  18656. *
  18657. * @private
  18658. * @param {Function} findIndexFunc The function to find the collection index.
  18659. * @returns {Function} Returns the new find function.
  18660. */
  18661. function createFind(findIndexFunc) {
  18662. return function(collection, predicate, fromIndex) {
  18663. var iterable = Object(collection);
  18664. if (!isArrayLike(collection)) {
  18665. var iteratee = getIteratee(predicate, 3);
  18666. collection = keys(collection);
  18667. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  18668. }
  18669. var index = findIndexFunc(collection, predicate, fromIndex);
  18670. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  18671. };
  18672. }
  18673. /**
  18674. * Creates a `_.flow` or `_.flowRight` function.
  18675. *
  18676. * @private
  18677. * @param {boolean} [fromRight] Specify iterating from right to left.
  18678. * @returns {Function} Returns the new flow function.
  18679. */
  18680. function createFlow(fromRight) {
  18681. return flatRest(function(funcs) {
  18682. var length = funcs.length,
  18683. index = length,
  18684. prereq = LodashWrapper.prototype.thru;
  18685. if (fromRight) {
  18686. funcs.reverse();
  18687. }
  18688. while (index--) {
  18689. var func = funcs[index];
  18690. if (typeof func != 'function') {
  18691. throw new TypeError(FUNC_ERROR_TEXT);
  18692. }
  18693. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  18694. var wrapper = new LodashWrapper([], true);
  18695. }
  18696. }
  18697. index = wrapper ? index : length;
  18698. while (++index < length) {
  18699. func = funcs[index];
  18700. var funcName = getFuncName(func),
  18701. data = funcName == 'wrapper' ? getData(func) : undefined;
  18702. if (data && isLaziable(data[0]) &&
  18703. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  18704. !data[4].length && data[9] == 1
  18705. ) {
  18706. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  18707. } else {
  18708. wrapper = (func.length == 1 && isLaziable(func))
  18709. ? wrapper[funcName]()
  18710. : wrapper.thru(func);
  18711. }
  18712. }
  18713. return function() {
  18714. var args = arguments,
  18715. value = args[0];
  18716. if (wrapper && args.length == 1 && isArray(value)) {
  18717. return wrapper.plant(value).value();
  18718. }
  18719. var index = 0,
  18720. result = length ? funcs[index].apply(this, args) : value;
  18721. while (++index < length) {
  18722. result = funcs[index].call(this, result);
  18723. }
  18724. return result;
  18725. };
  18726. });
  18727. }
  18728. /**
  18729. * Creates a function that wraps `func` to invoke it with optional `this`
  18730. * binding of `thisArg`, partial application, and currying.
  18731. *
  18732. * @private
  18733. * @param {Function|string} func The function or method name to wrap.
  18734. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18735. * @param {*} [thisArg] The `this` binding of `func`.
  18736. * @param {Array} [partials] The arguments to prepend to those provided to
  18737. * the new function.
  18738. * @param {Array} [holders] The `partials` placeholder indexes.
  18739. * @param {Array} [partialsRight] The arguments to append to those provided
  18740. * to the new function.
  18741. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  18742. * @param {Array} [argPos] The argument positions of the new function.
  18743. * @param {number} [ary] The arity cap of `func`.
  18744. * @param {number} [arity] The arity of `func`.
  18745. * @returns {Function} Returns the new wrapped function.
  18746. */
  18747. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  18748. var isAry = bitmask & WRAP_ARY_FLAG,
  18749. isBind = bitmask & WRAP_BIND_FLAG,
  18750. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  18751. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  18752. isFlip = bitmask & WRAP_FLIP_FLAG,
  18753. Ctor = isBindKey ? undefined : createCtor(func);
  18754. function wrapper() {
  18755. var length = arguments.length,
  18756. args = Array(length),
  18757. index = length;
  18758. while (index--) {
  18759. args[index] = arguments[index];
  18760. }
  18761. if (isCurried) {
  18762. var placeholder = getHolder(wrapper),
  18763. holdersCount = countHolders(args, placeholder);
  18764. }
  18765. if (partials) {
  18766. args = composeArgs(args, partials, holders, isCurried);
  18767. }
  18768. if (partialsRight) {
  18769. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  18770. }
  18771. length -= holdersCount;
  18772. if (isCurried && length < arity) {
  18773. var newHolders = replaceHolders(args, placeholder);
  18774. return createRecurry(
  18775. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  18776. args, newHolders, argPos, ary, arity - length
  18777. );
  18778. }
  18779. var thisBinding = isBind ? thisArg : this,
  18780. fn = isBindKey ? thisBinding[func] : func;
  18781. length = args.length;
  18782. if (argPos) {
  18783. args = reorder(args, argPos);
  18784. } else if (isFlip && length > 1) {
  18785. args.reverse();
  18786. }
  18787. if (isAry && ary < length) {
  18788. args.length = ary;
  18789. }
  18790. if (this && this !== root && this instanceof wrapper) {
  18791. fn = Ctor || createCtor(fn);
  18792. }
  18793. return fn.apply(thisBinding, args);
  18794. }
  18795. return wrapper;
  18796. }
  18797. /**
  18798. * Creates a function like `_.invertBy`.
  18799. *
  18800. * @private
  18801. * @param {Function} setter The function to set accumulator values.
  18802. * @param {Function} toIteratee The function to resolve iteratees.
  18803. * @returns {Function} Returns the new inverter function.
  18804. */
  18805. function createInverter(setter, toIteratee) {
  18806. return function(object, iteratee) {
  18807. return baseInverter(object, setter, toIteratee(iteratee), {});
  18808. };
  18809. }
  18810. /**
  18811. * Creates a function that performs a mathematical operation on two values.
  18812. *
  18813. * @private
  18814. * @param {Function} operator The function to perform the operation.
  18815. * @param {number} [defaultValue] The value used for `undefined` arguments.
  18816. * @returns {Function} Returns the new mathematical operation function.
  18817. */
  18818. function createMathOperation(operator, defaultValue) {
  18819. return function(value, other) {
  18820. var result;
  18821. if (value === undefined && other === undefined) {
  18822. return defaultValue;
  18823. }
  18824. if (value !== undefined) {
  18825. result = value;
  18826. }
  18827. if (other !== undefined) {
  18828. if (result === undefined) {
  18829. return other;
  18830. }
  18831. if (typeof value == 'string' || typeof other == 'string') {
  18832. value = baseToString(value);
  18833. other = baseToString(other);
  18834. } else {
  18835. value = baseToNumber(value);
  18836. other = baseToNumber(other);
  18837. }
  18838. result = operator(value, other);
  18839. }
  18840. return result;
  18841. };
  18842. }
  18843. /**
  18844. * Creates a function like `_.over`.
  18845. *
  18846. * @private
  18847. * @param {Function} arrayFunc The function to iterate over iteratees.
  18848. * @returns {Function} Returns the new over function.
  18849. */
  18850. function createOver(arrayFunc) {
  18851. return flatRest(function(iteratees) {
  18852. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  18853. return baseRest(function(args) {
  18854. var thisArg = this;
  18855. return arrayFunc(iteratees, function(iteratee) {
  18856. return apply(iteratee, thisArg, args);
  18857. });
  18858. });
  18859. });
  18860. }
  18861. /**
  18862. * Creates the padding for `string` based on `length`. The `chars` string
  18863. * is truncated if the number of characters exceeds `length`.
  18864. *
  18865. * @private
  18866. * @param {number} length The padding length.
  18867. * @param {string} [chars=' '] The string used as padding.
  18868. * @returns {string} Returns the padding for `string`.
  18869. */
  18870. function createPadding(length, chars) {
  18871. chars = chars === undefined ? ' ' : baseToString(chars);
  18872. var charsLength = chars.length;
  18873. if (charsLength < 2) {
  18874. return charsLength ? baseRepeat(chars, length) : chars;
  18875. }
  18876. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  18877. return hasUnicode(chars)
  18878. ? castSlice(stringToArray(result), 0, length).join('')
  18879. : result.slice(0, length);
  18880. }
  18881. /**
  18882. * Creates a function that wraps `func` to invoke it with the `this` binding
  18883. * of `thisArg` and `partials` prepended to the arguments it receives.
  18884. *
  18885. * @private
  18886. * @param {Function} func The function to wrap.
  18887. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18888. * @param {*} thisArg The `this` binding of `func`.
  18889. * @param {Array} partials The arguments to prepend to those provided to
  18890. * the new function.
  18891. * @returns {Function} Returns the new wrapped function.
  18892. */
  18893. function createPartial(func, bitmask, thisArg, partials) {
  18894. var isBind = bitmask & WRAP_BIND_FLAG,
  18895. Ctor = createCtor(func);
  18896. function wrapper() {
  18897. var argsIndex = -1,
  18898. argsLength = arguments.length,
  18899. leftIndex = -1,
  18900. leftLength = partials.length,
  18901. args = Array(leftLength + argsLength),
  18902. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18903. while (++leftIndex < leftLength) {
  18904. args[leftIndex] = partials[leftIndex];
  18905. }
  18906. while (argsLength--) {
  18907. args[leftIndex++] = arguments[++argsIndex];
  18908. }
  18909. return apply(fn, isBind ? thisArg : this, args);
  18910. }
  18911. return wrapper;
  18912. }
  18913. /**
  18914. * Creates a `_.range` or `_.rangeRight` function.
  18915. *
  18916. * @private
  18917. * @param {boolean} [fromRight] Specify iterating from right to left.
  18918. * @returns {Function} Returns the new range function.
  18919. */
  18920. function createRange(fromRight) {
  18921. return function(start, end, step) {
  18922. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  18923. end = step = undefined;
  18924. }
  18925. // Ensure the sign of `-0` is preserved.
  18926. start = toFinite(start);
  18927. if (end === undefined) {
  18928. end = start;
  18929. start = 0;
  18930. } else {
  18931. end = toFinite(end);
  18932. }
  18933. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  18934. return baseRange(start, end, step, fromRight);
  18935. };
  18936. }
  18937. /**
  18938. * Creates a function that performs a relational operation on two values.
  18939. *
  18940. * @private
  18941. * @param {Function} operator The function to perform the operation.
  18942. * @returns {Function} Returns the new relational operation function.
  18943. */
  18944. function createRelationalOperation(operator) {
  18945. return function(value, other) {
  18946. if (!(typeof value == 'string' && typeof other == 'string')) {
  18947. value = toNumber(value);
  18948. other = toNumber(other);
  18949. }
  18950. return operator(value, other);
  18951. };
  18952. }
  18953. /**
  18954. * Creates a function that wraps `func` to continue currying.
  18955. *
  18956. * @private
  18957. * @param {Function} func The function to wrap.
  18958. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18959. * @param {Function} wrapFunc The function to create the `func` wrapper.
  18960. * @param {*} placeholder The placeholder value.
  18961. * @param {*} [thisArg] The `this` binding of `func`.
  18962. * @param {Array} [partials] The arguments to prepend to those provided to
  18963. * the new function.
  18964. * @param {Array} [holders] The `partials` placeholder indexes.
  18965. * @param {Array} [argPos] The argument positions of the new function.
  18966. * @param {number} [ary] The arity cap of `func`.
  18967. * @param {number} [arity] The arity of `func`.
  18968. * @returns {Function} Returns the new wrapped function.
  18969. */
  18970. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  18971. var isCurry = bitmask & WRAP_CURRY_FLAG,
  18972. newHolders = isCurry ? holders : undefined,
  18973. newHoldersRight = isCurry ? undefined : holders,
  18974. newPartials = isCurry ? partials : undefined,
  18975. newPartialsRight = isCurry ? undefined : partials;
  18976. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  18977. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  18978. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  18979. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  18980. }
  18981. var newData = [
  18982. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  18983. newHoldersRight, argPos, ary, arity
  18984. ];
  18985. var result = wrapFunc.apply(undefined, newData);
  18986. if (isLaziable(func)) {
  18987. setData(result, newData);
  18988. }
  18989. result.placeholder = placeholder;
  18990. return setWrapToString(result, func, bitmask);
  18991. }
  18992. /**
  18993. * Creates a function like `_.round`.
  18994. *
  18995. * @private
  18996. * @param {string} methodName The name of the `Math` method to use when rounding.
  18997. * @returns {Function} Returns the new round function.
  18998. */
  18999. function createRound(methodName) {
  19000. var func = Math[methodName];
  19001. return function(number, precision) {
  19002. number = toNumber(number);
  19003. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  19004. if (precision && nativeIsFinite(number)) {
  19005. // Shift with exponential notation to avoid floating-point issues.
  19006. // See [MDN](https://mdn.io/round#Examples) for more details.
  19007. var pair = (toString(number) + 'e').split('e'),
  19008. value = func(pair[0] + 'e' + (+pair[1] + precision));
  19009. pair = (toString(value) + 'e').split('e');
  19010. return +(pair[0] + 'e' + (+pair[1] - precision));
  19011. }
  19012. return func(number);
  19013. };
  19014. }
  19015. /**
  19016. * Creates a set object of `values`.
  19017. *
  19018. * @private
  19019. * @param {Array} values The values to add to the set.
  19020. * @returns {Object} Returns the new set.
  19021. */
  19022. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  19023. return new Set(values);
  19024. };
  19025. /**
  19026. * Creates a `_.toPairs` or `_.toPairsIn` function.
  19027. *
  19028. * @private
  19029. * @param {Function} keysFunc The function to get the keys of a given object.
  19030. * @returns {Function} Returns the new pairs function.
  19031. */
  19032. function createToPairs(keysFunc) {
  19033. return function(object) {
  19034. var tag = getTag(object);
  19035. if (tag == mapTag) {
  19036. return mapToArray(object);
  19037. }
  19038. if (tag == setTag) {
  19039. return setToPairs(object);
  19040. }
  19041. return baseToPairs(object, keysFunc(object));
  19042. };
  19043. }
  19044. /**
  19045. * Creates a function that either curries or invokes `func` with optional
  19046. * `this` binding and partially applied arguments.
  19047. *
  19048. * @private
  19049. * @param {Function|string} func The function or method name to wrap.
  19050. * @param {number} bitmask The bitmask flags.
  19051. * 1 - `_.bind`
  19052. * 2 - `_.bindKey`
  19053. * 4 - `_.curry` or `_.curryRight` of a bound function
  19054. * 8 - `_.curry`
  19055. * 16 - `_.curryRight`
  19056. * 32 - `_.partial`
  19057. * 64 - `_.partialRight`
  19058. * 128 - `_.rearg`
  19059. * 256 - `_.ary`
  19060. * 512 - `_.flip`
  19061. * @param {*} [thisArg] The `this` binding of `func`.
  19062. * @param {Array} [partials] The arguments to be partially applied.
  19063. * @param {Array} [holders] The `partials` placeholder indexes.
  19064. * @param {Array} [argPos] The argument positions of the new function.
  19065. * @param {number} [ary] The arity cap of `func`.
  19066. * @param {number} [arity] The arity of `func`.
  19067. * @returns {Function} Returns the new wrapped function.
  19068. */
  19069. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  19070. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  19071. if (!isBindKey && typeof func != 'function') {
  19072. throw new TypeError(FUNC_ERROR_TEXT);
  19073. }
  19074. var length = partials ? partials.length : 0;
  19075. if (!length) {
  19076. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  19077. partials = holders = undefined;
  19078. }
  19079. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  19080. arity = arity === undefined ? arity : toInteger(arity);
  19081. length -= holders ? holders.length : 0;
  19082. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  19083. var partialsRight = partials,
  19084. holdersRight = holders;
  19085. partials = holders = undefined;
  19086. }
  19087. var data = isBindKey ? undefined : getData(func);
  19088. var newData = [
  19089. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  19090. argPos, ary, arity
  19091. ];
  19092. if (data) {
  19093. mergeData(newData, data);
  19094. }
  19095. func = newData[0];
  19096. bitmask = newData[1];
  19097. thisArg = newData[2];
  19098. partials = newData[3];
  19099. holders = newData[4];
  19100. arity = newData[9] = newData[9] === undefined
  19101. ? (isBindKey ? 0 : func.length)
  19102. : nativeMax(newData[9] - length, 0);
  19103. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  19104. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  19105. }
  19106. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  19107. var result = createBind(func, bitmask, thisArg);
  19108. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  19109. result = createCurry(func, bitmask, arity);
  19110. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  19111. result = createPartial(func, bitmask, thisArg, partials);
  19112. } else {
  19113. result = createHybrid.apply(undefined, newData);
  19114. }
  19115. var setter = data ? baseSetData : setData;
  19116. return setWrapToString(setter(result, newData), func, bitmask);
  19117. }
  19118. /**
  19119. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  19120. * of source objects to the destination object for all destination properties
  19121. * that resolve to `undefined`.
  19122. *
  19123. * @private
  19124. * @param {*} objValue The destination value.
  19125. * @param {*} srcValue The source value.
  19126. * @param {string} key The key of the property to assign.
  19127. * @param {Object} object The parent object of `objValue`.
  19128. * @returns {*} Returns the value to assign.
  19129. */
  19130. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  19131. if (objValue === undefined ||
  19132. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  19133. return srcValue;
  19134. }
  19135. return objValue;
  19136. }
  19137. /**
  19138. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  19139. * objects into destination objects that are passed thru.
  19140. *
  19141. * @private
  19142. * @param {*} objValue The destination value.
  19143. * @param {*} srcValue The source value.
  19144. * @param {string} key The key of the property to merge.
  19145. * @param {Object} object The parent object of `objValue`.
  19146. * @param {Object} source The parent object of `srcValue`.
  19147. * @param {Object} [stack] Tracks traversed source values and their merged
  19148. * counterparts.
  19149. * @returns {*} Returns the value to assign.
  19150. */
  19151. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  19152. if (isObject(objValue) && isObject(srcValue)) {
  19153. // Recursively merge objects and arrays (susceptible to call stack limits).
  19154. stack.set(srcValue, objValue);
  19155. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  19156. stack['delete'](srcValue);
  19157. }
  19158. return objValue;
  19159. }
  19160. /**
  19161. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  19162. * objects.
  19163. *
  19164. * @private
  19165. * @param {*} value The value to inspect.
  19166. * @param {string} key The key of the property to inspect.
  19167. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  19168. */
  19169. function customOmitClone(value) {
  19170. return isPlainObject(value) ? undefined : value;
  19171. }
  19172. /**
  19173. * A specialized version of `baseIsEqualDeep` for arrays with support for
  19174. * partial deep comparisons.
  19175. *
  19176. * @private
  19177. * @param {Array} array The array to compare.
  19178. * @param {Array} other The other array to compare.
  19179. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19180. * @param {Function} customizer The function to customize comparisons.
  19181. * @param {Function} equalFunc The function to determine equivalents of values.
  19182. * @param {Object} stack Tracks traversed `array` and `other` objects.
  19183. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  19184. */
  19185. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  19186. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19187. arrLength = array.length,
  19188. othLength = other.length;
  19189. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  19190. return false;
  19191. }
  19192. // Assume cyclic values are equal.
  19193. var stacked = stack.get(array);
  19194. if (stacked && stack.get(other)) {
  19195. return stacked == other;
  19196. }
  19197. var index = -1,
  19198. result = true,
  19199. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  19200. stack.set(array, other);
  19201. stack.set(other, array);
  19202. // Ignore non-index properties.
  19203. while (++index < arrLength) {
  19204. var arrValue = array[index],
  19205. othValue = other[index];
  19206. if (customizer) {
  19207. var compared = isPartial
  19208. ? customizer(othValue, arrValue, index, other, array, stack)
  19209. : customizer(arrValue, othValue, index, array, other, stack);
  19210. }
  19211. if (compared !== undefined) {
  19212. if (compared) {
  19213. continue;
  19214. }
  19215. result = false;
  19216. break;
  19217. }
  19218. // Recursively compare arrays (susceptible to call stack limits).
  19219. if (seen) {
  19220. if (!arraySome(other, function(othValue, othIndex) {
  19221. if (!cacheHas(seen, othIndex) &&
  19222. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  19223. return seen.push(othIndex);
  19224. }
  19225. })) {
  19226. result = false;
  19227. break;
  19228. }
  19229. } else if (!(
  19230. arrValue === othValue ||
  19231. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  19232. )) {
  19233. result = false;
  19234. break;
  19235. }
  19236. }
  19237. stack['delete'](array);
  19238. stack['delete'](other);
  19239. return result;
  19240. }
  19241. /**
  19242. * A specialized version of `baseIsEqualDeep` for comparing objects of
  19243. * the same `toStringTag`.
  19244. *
  19245. * **Note:** This function only supports comparing values with tags of
  19246. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  19247. *
  19248. * @private
  19249. * @param {Object} object The object to compare.
  19250. * @param {Object} other The other object to compare.
  19251. * @param {string} tag The `toStringTag` of the objects to compare.
  19252. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19253. * @param {Function} customizer The function to customize comparisons.
  19254. * @param {Function} equalFunc The function to determine equivalents of values.
  19255. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19256. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19257. */
  19258. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  19259. switch (tag) {
  19260. case dataViewTag:
  19261. if ((object.byteLength != other.byteLength) ||
  19262. (object.byteOffset != other.byteOffset)) {
  19263. return false;
  19264. }
  19265. object = object.buffer;
  19266. other = other.buffer;
  19267. case arrayBufferTag:
  19268. if ((object.byteLength != other.byteLength) ||
  19269. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  19270. return false;
  19271. }
  19272. return true;
  19273. case boolTag:
  19274. case dateTag:
  19275. case numberTag:
  19276. // Coerce booleans to `1` or `0` and dates to milliseconds.
  19277. // Invalid dates are coerced to `NaN`.
  19278. return eq(+object, +other);
  19279. case errorTag:
  19280. return object.name == other.name && object.message == other.message;
  19281. case regexpTag:
  19282. case stringTag:
  19283. // Coerce regexes to strings and treat strings, primitives and objects,
  19284. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  19285. // for more details.
  19286. return object == (other + '');
  19287. case mapTag:
  19288. var convert = mapToArray;
  19289. case setTag:
  19290. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  19291. convert || (convert = setToArray);
  19292. if (object.size != other.size && !isPartial) {
  19293. return false;
  19294. }
  19295. // Assume cyclic values are equal.
  19296. var stacked = stack.get(object);
  19297. if (stacked) {
  19298. return stacked == other;
  19299. }
  19300. bitmask |= COMPARE_UNORDERED_FLAG;
  19301. // Recursively compare objects (susceptible to call stack limits).
  19302. stack.set(object, other);
  19303. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  19304. stack['delete'](object);
  19305. return result;
  19306. case symbolTag:
  19307. if (symbolValueOf) {
  19308. return symbolValueOf.call(object) == symbolValueOf.call(other);
  19309. }
  19310. }
  19311. return false;
  19312. }
  19313. /**
  19314. * A specialized version of `baseIsEqualDeep` for objects with support for
  19315. * partial deep comparisons.
  19316. *
  19317. * @private
  19318. * @param {Object} object The object to compare.
  19319. * @param {Object} other The other object to compare.
  19320. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19321. * @param {Function} customizer The function to customize comparisons.
  19322. * @param {Function} equalFunc The function to determine equivalents of values.
  19323. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19324. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19325. */
  19326. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  19327. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19328. objProps = getAllKeys(object),
  19329. objLength = objProps.length,
  19330. othProps = getAllKeys(other),
  19331. othLength = othProps.length;
  19332. if (objLength != othLength && !isPartial) {
  19333. return false;
  19334. }
  19335. var index = objLength;
  19336. while (index--) {
  19337. var key = objProps[index];
  19338. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  19339. return false;
  19340. }
  19341. }
  19342. // Assume cyclic values are equal.
  19343. var stacked = stack.get(object);
  19344. if (stacked && stack.get(other)) {
  19345. return stacked == other;
  19346. }
  19347. var result = true;
  19348. stack.set(object, other);
  19349. stack.set(other, object);
  19350. var skipCtor = isPartial;
  19351. while (++index < objLength) {
  19352. key = objProps[index];
  19353. var objValue = object[key],
  19354. othValue = other[key];
  19355. if (customizer) {
  19356. var compared = isPartial
  19357. ? customizer(othValue, objValue, key, other, object, stack)
  19358. : customizer(objValue, othValue, key, object, other, stack);
  19359. }
  19360. // Recursively compare objects (susceptible to call stack limits).
  19361. if (!(compared === undefined
  19362. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  19363. : compared
  19364. )) {
  19365. result = false;
  19366. break;
  19367. }
  19368. skipCtor || (skipCtor = key == 'constructor');
  19369. }
  19370. if (result && !skipCtor) {
  19371. var objCtor = object.constructor,
  19372. othCtor = other.constructor;
  19373. // Non `Object` object instances with different constructors are not equal.
  19374. if (objCtor != othCtor &&
  19375. ('constructor' in object && 'constructor' in other) &&
  19376. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  19377. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  19378. result = false;
  19379. }
  19380. }
  19381. stack['delete'](object);
  19382. stack['delete'](other);
  19383. return result;
  19384. }
  19385. /**
  19386. * A specialized version of `baseRest` which flattens the rest array.
  19387. *
  19388. * @private
  19389. * @param {Function} func The function to apply a rest parameter to.
  19390. * @returns {Function} Returns the new function.
  19391. */
  19392. function flatRest(func) {
  19393. return setToString(overRest(func, undefined, flatten), func + '');
  19394. }
  19395. /**
  19396. * Creates an array of own enumerable property names and symbols of `object`.
  19397. *
  19398. * @private
  19399. * @param {Object} object The object to query.
  19400. * @returns {Array} Returns the array of property names and symbols.
  19401. */
  19402. function getAllKeys(object) {
  19403. return baseGetAllKeys(object, keys, getSymbols);
  19404. }
  19405. /**
  19406. * Creates an array of own and inherited enumerable property names and
  19407. * symbols of `object`.
  19408. *
  19409. * @private
  19410. * @param {Object} object The object to query.
  19411. * @returns {Array} Returns the array of property names and symbols.
  19412. */
  19413. function getAllKeysIn(object) {
  19414. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  19415. }
  19416. /**
  19417. * Gets metadata for `func`.
  19418. *
  19419. * @private
  19420. * @param {Function} func The function to query.
  19421. * @returns {*} Returns the metadata for `func`.
  19422. */
  19423. var getData = !metaMap ? noop : function(func) {
  19424. return metaMap.get(func);
  19425. };
  19426. /**
  19427. * Gets the name of `func`.
  19428. *
  19429. * @private
  19430. * @param {Function} func The function to query.
  19431. * @returns {string} Returns the function name.
  19432. */
  19433. function getFuncName(func) {
  19434. var result = (func.name + ''),
  19435. array = realNames[result],
  19436. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  19437. while (length--) {
  19438. var data = array[length],
  19439. otherFunc = data.func;
  19440. if (otherFunc == null || otherFunc == func) {
  19441. return data.name;
  19442. }
  19443. }
  19444. return result;
  19445. }
  19446. /**
  19447. * Gets the argument placeholder value for `func`.
  19448. *
  19449. * @private
  19450. * @param {Function} func The function to inspect.
  19451. * @returns {*} Returns the placeholder value.
  19452. */
  19453. function getHolder(func) {
  19454. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  19455. return object.placeholder;
  19456. }
  19457. /**
  19458. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  19459. * this function returns the custom method, otherwise it returns `baseIteratee`.
  19460. * If arguments are provided, the chosen function is invoked with them and
  19461. * its result is returned.
  19462. *
  19463. * @private
  19464. * @param {*} [value] The value to convert to an iteratee.
  19465. * @param {number} [arity] The arity of the created iteratee.
  19466. * @returns {Function} Returns the chosen function or its result.
  19467. */
  19468. function getIteratee() {
  19469. var result = lodash.iteratee || iteratee;
  19470. result = result === iteratee ? baseIteratee : result;
  19471. return arguments.length ? result(arguments[0], arguments[1]) : result;
  19472. }
  19473. /**
  19474. * Gets the data for `map`.
  19475. *
  19476. * @private
  19477. * @param {Object} map The map to query.
  19478. * @param {string} key The reference key.
  19479. * @returns {*} Returns the map data.
  19480. */
  19481. function getMapData(map, key) {
  19482. var data = map.__data__;
  19483. return isKeyable(key)
  19484. ? data[typeof key == 'string' ? 'string' : 'hash']
  19485. : data.map;
  19486. }
  19487. /**
  19488. * Gets the property names, values, and compare flags of `object`.
  19489. *
  19490. * @private
  19491. * @param {Object} object The object to query.
  19492. * @returns {Array} Returns the match data of `object`.
  19493. */
  19494. function getMatchData(object) {
  19495. var result = keys(object),
  19496. length = result.length;
  19497. while (length--) {
  19498. var key = result[length],
  19499. value = object[key];
  19500. result[length] = [key, value, isStrictComparable(value)];
  19501. }
  19502. return result;
  19503. }
  19504. /**
  19505. * Gets the native function at `key` of `object`.
  19506. *
  19507. * @private
  19508. * @param {Object} object The object to query.
  19509. * @param {string} key The key of the method to get.
  19510. * @returns {*} Returns the function if it's native, else `undefined`.
  19511. */
  19512. function getNative(object, key) {
  19513. var value = getValue(object, key);
  19514. return baseIsNative(value) ? value : undefined;
  19515. }
  19516. /**
  19517. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  19518. *
  19519. * @private
  19520. * @param {*} value The value to query.
  19521. * @returns {string} Returns the raw `toStringTag`.
  19522. */
  19523. function getRawTag(value) {
  19524. var isOwn = hasOwnProperty.call(value, symToStringTag),
  19525. tag = value[symToStringTag];
  19526. try {
  19527. value[symToStringTag] = undefined;
  19528. var unmasked = true;
  19529. } catch (e) {}
  19530. var result = nativeObjectToString.call(value);
  19531. if (unmasked) {
  19532. if (isOwn) {
  19533. value[symToStringTag] = tag;
  19534. } else {
  19535. delete value[symToStringTag];
  19536. }
  19537. }
  19538. return result;
  19539. }
  19540. /**
  19541. * Creates an array of the own enumerable symbols of `object`.
  19542. *
  19543. * @private
  19544. * @param {Object} object The object to query.
  19545. * @returns {Array} Returns the array of symbols.
  19546. */
  19547. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  19548. if (object == null) {
  19549. return [];
  19550. }
  19551. object = Object(object);
  19552. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  19553. return propertyIsEnumerable.call(object, symbol);
  19554. });
  19555. };
  19556. /**
  19557. * Creates an array of the own and inherited enumerable symbols of `object`.
  19558. *
  19559. * @private
  19560. * @param {Object} object The object to query.
  19561. * @returns {Array} Returns the array of symbols.
  19562. */
  19563. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  19564. var result = [];
  19565. while (object) {
  19566. arrayPush(result, getSymbols(object));
  19567. object = getPrototype(object);
  19568. }
  19569. return result;
  19570. };
  19571. /**
  19572. * Gets the `toStringTag` of `value`.
  19573. *
  19574. * @private
  19575. * @param {*} value The value to query.
  19576. * @returns {string} Returns the `toStringTag`.
  19577. */
  19578. var getTag = baseGetTag;
  19579. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  19580. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  19581. (Map && getTag(new Map) != mapTag) ||
  19582. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  19583. (Set && getTag(new Set) != setTag) ||
  19584. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  19585. getTag = function(value) {
  19586. var result = baseGetTag(value),
  19587. Ctor = result == objectTag ? value.constructor : undefined,
  19588. ctorString = Ctor ? toSource(Ctor) : '';
  19589. if (ctorString) {
  19590. switch (ctorString) {
  19591. case dataViewCtorString: return dataViewTag;
  19592. case mapCtorString: return mapTag;
  19593. case promiseCtorString: return promiseTag;
  19594. case setCtorString: return setTag;
  19595. case weakMapCtorString: return weakMapTag;
  19596. }
  19597. }
  19598. return result;
  19599. };
  19600. }
  19601. /**
  19602. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  19603. *
  19604. * @private
  19605. * @param {number} start The start of the view.
  19606. * @param {number} end The end of the view.
  19607. * @param {Array} transforms The transformations to apply to the view.
  19608. * @returns {Object} Returns an object containing the `start` and `end`
  19609. * positions of the view.
  19610. */
  19611. function getView(start, end, transforms) {
  19612. var index = -1,
  19613. length = transforms.length;
  19614. while (++index < length) {
  19615. var data = transforms[index],
  19616. size = data.size;
  19617. switch (data.type) {
  19618. case 'drop': start += size; break;
  19619. case 'dropRight': end -= size; break;
  19620. case 'take': end = nativeMin(end, start + size); break;
  19621. case 'takeRight': start = nativeMax(start, end - size); break;
  19622. }
  19623. }
  19624. return { 'start': start, 'end': end };
  19625. }
  19626. /**
  19627. * Extracts wrapper details from the `source` body comment.
  19628. *
  19629. * @private
  19630. * @param {string} source The source to inspect.
  19631. * @returns {Array} Returns the wrapper details.
  19632. */
  19633. function getWrapDetails(source) {
  19634. var match = source.match(reWrapDetails);
  19635. return match ? match[1].split(reSplitDetails) : [];
  19636. }
  19637. /**
  19638. * Checks if `path` exists on `object`.
  19639. *
  19640. * @private
  19641. * @param {Object} object The object to query.
  19642. * @param {Array|string} path The path to check.
  19643. * @param {Function} hasFunc The function to check properties.
  19644. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  19645. */
  19646. function hasPath(object, path, hasFunc) {
  19647. path = castPath(path, object);
  19648. var index = -1,
  19649. length = path.length,
  19650. result = false;
  19651. while (++index < length) {
  19652. var key = toKey(path[index]);
  19653. if (!(result = object != null && hasFunc(object, key))) {
  19654. break;
  19655. }
  19656. object = object[key];
  19657. }
  19658. if (result || ++index != length) {
  19659. return result;
  19660. }
  19661. length = object == null ? 0 : object.length;
  19662. return !!length && isLength(length) && isIndex(key, length) &&
  19663. (isArray(object) || isArguments(object));
  19664. }
  19665. /**
  19666. * Initializes an array clone.
  19667. *
  19668. * @private
  19669. * @param {Array} array The array to clone.
  19670. * @returns {Array} Returns the initialized clone.
  19671. */
  19672. function initCloneArray(array) {
  19673. var length = array.length,
  19674. result = new array.constructor(length);
  19675. // Add properties assigned by `RegExp#exec`.
  19676. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  19677. result.index = array.index;
  19678. result.input = array.input;
  19679. }
  19680. return result;
  19681. }
  19682. /**
  19683. * Initializes an object clone.
  19684. *
  19685. * @private
  19686. * @param {Object} object The object to clone.
  19687. * @returns {Object} Returns the initialized clone.
  19688. */
  19689. function initCloneObject(object) {
  19690. return (typeof object.constructor == 'function' && !isPrototype(object))
  19691. ? baseCreate(getPrototype(object))
  19692. : {};
  19693. }
  19694. /**
  19695. * Initializes an object clone based on its `toStringTag`.
  19696. *
  19697. * **Note:** This function only supports cloning values with tags of
  19698. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  19699. *
  19700. * @private
  19701. * @param {Object} object The object to clone.
  19702. * @param {string} tag The `toStringTag` of the object to clone.
  19703. * @param {boolean} [isDeep] Specify a deep clone.
  19704. * @returns {Object} Returns the initialized clone.
  19705. */
  19706. function initCloneByTag(object, tag, isDeep) {
  19707. var Ctor = object.constructor;
  19708. switch (tag) {
  19709. case arrayBufferTag:
  19710. return cloneArrayBuffer(object);
  19711. case boolTag:
  19712. case dateTag:
  19713. return new Ctor(+object);
  19714. case dataViewTag:
  19715. return cloneDataView(object, isDeep);
  19716. case float32Tag: case float64Tag:
  19717. case int8Tag: case int16Tag: case int32Tag:
  19718. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  19719. return cloneTypedArray(object, isDeep);
  19720. case mapTag:
  19721. return new Ctor;
  19722. case numberTag:
  19723. case stringTag:
  19724. return new Ctor(object);
  19725. case regexpTag:
  19726. return cloneRegExp(object);
  19727. case setTag:
  19728. return new Ctor;
  19729. case symbolTag:
  19730. return cloneSymbol(object);
  19731. }
  19732. }
  19733. /**
  19734. * Inserts wrapper `details` in a comment at the top of the `source` body.
  19735. *
  19736. * @private
  19737. * @param {string} source The source to modify.
  19738. * @returns {Array} details The details to insert.
  19739. * @returns {string} Returns the modified source.
  19740. */
  19741. function insertWrapDetails(source, details) {
  19742. var length = details.length;
  19743. if (!length) {
  19744. return source;
  19745. }
  19746. var lastIndex = length - 1;
  19747. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  19748. details = details.join(length > 2 ? ', ' : ' ');
  19749. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  19750. }
  19751. /**
  19752. * Checks if `value` is a flattenable `arguments` object or array.
  19753. *
  19754. * @private
  19755. * @param {*} value The value to check.
  19756. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  19757. */
  19758. function isFlattenable(value) {
  19759. return isArray(value) || isArguments(value) ||
  19760. !!(spreadableSymbol && value && value[spreadableSymbol]);
  19761. }
  19762. /**
  19763. * Checks if `value` is a valid array-like index.
  19764. *
  19765. * @private
  19766. * @param {*} value The value to check.
  19767. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  19768. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  19769. */
  19770. function isIndex(value, length) {
  19771. var type = typeof value;
  19772. length = length == null ? MAX_SAFE_INTEGER : length;
  19773. return !!length &&
  19774. (type == 'number' ||
  19775. (type != 'symbol' && reIsUint.test(value))) &&
  19776. (value > -1 && value % 1 == 0 && value < length);
  19777. }
  19778. /**
  19779. * Checks if the given arguments are from an iteratee call.
  19780. *
  19781. * @private
  19782. * @param {*} value The potential iteratee value argument.
  19783. * @param {*} index The potential iteratee index or key argument.
  19784. * @param {*} object The potential iteratee object argument.
  19785. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  19786. * else `false`.
  19787. */
  19788. function isIterateeCall(value, index, object) {
  19789. if (!isObject(object)) {
  19790. return false;
  19791. }
  19792. var type = typeof index;
  19793. if (type == 'number'
  19794. ? (isArrayLike(object) && isIndex(index, object.length))
  19795. : (type == 'string' && index in object)
  19796. ) {
  19797. return eq(object[index], value);
  19798. }
  19799. return false;
  19800. }
  19801. /**
  19802. * Checks if `value` is a property name and not a property path.
  19803. *
  19804. * @private
  19805. * @param {*} value The value to check.
  19806. * @param {Object} [object] The object to query keys on.
  19807. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  19808. */
  19809. function isKey(value, object) {
  19810. if (isArray(value)) {
  19811. return false;
  19812. }
  19813. var type = typeof value;
  19814. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  19815. value == null || isSymbol(value)) {
  19816. return true;
  19817. }
  19818. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  19819. (object != null && value in Object(object));
  19820. }
  19821. /**
  19822. * Checks if `value` is suitable for use as unique object key.
  19823. *
  19824. * @private
  19825. * @param {*} value The value to check.
  19826. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  19827. */
  19828. function isKeyable(value) {
  19829. var type = typeof value;
  19830. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  19831. ? (value !== '__proto__')
  19832. : (value === null);
  19833. }
  19834. /**
  19835. * Checks if `func` has a lazy counterpart.
  19836. *
  19837. * @private
  19838. * @param {Function} func The function to check.
  19839. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  19840. * else `false`.
  19841. */
  19842. function isLaziable(func) {
  19843. var funcName = getFuncName(func),
  19844. other = lodash[funcName];
  19845. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  19846. return false;
  19847. }
  19848. if (func === other) {
  19849. return true;
  19850. }
  19851. var data = getData(other);
  19852. return !!data && func === data[0];
  19853. }
  19854. /**
  19855. * Checks if `func` has its source masked.
  19856. *
  19857. * @private
  19858. * @param {Function} func The function to check.
  19859. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  19860. */
  19861. function isMasked(func) {
  19862. return !!maskSrcKey && (maskSrcKey in func);
  19863. }
  19864. /**
  19865. * Checks if `func` is capable of being masked.
  19866. *
  19867. * @private
  19868. * @param {*} value The value to check.
  19869. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  19870. */
  19871. var isMaskable = coreJsData ? isFunction : stubFalse;
  19872. /**
  19873. * Checks if `value` is likely a prototype object.
  19874. *
  19875. * @private
  19876. * @param {*} value The value to check.
  19877. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  19878. */
  19879. function isPrototype(value) {
  19880. var Ctor = value && value.constructor,
  19881. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  19882. return value === proto;
  19883. }
  19884. /**
  19885. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  19886. *
  19887. * @private
  19888. * @param {*} value The value to check.
  19889. * @returns {boolean} Returns `true` if `value` if suitable for strict
  19890. * equality comparisons, else `false`.
  19891. */
  19892. function isStrictComparable(value) {
  19893. return value === value && !isObject(value);
  19894. }
  19895. /**
  19896. * A specialized version of `matchesProperty` for source values suitable
  19897. * for strict equality comparisons, i.e. `===`.
  19898. *
  19899. * @private
  19900. * @param {string} key The key of the property to get.
  19901. * @param {*} srcValue The value to match.
  19902. * @returns {Function} Returns the new spec function.
  19903. */
  19904. function matchesStrictComparable(key, srcValue) {
  19905. return function(object) {
  19906. if (object == null) {
  19907. return false;
  19908. }
  19909. return object[key] === srcValue &&
  19910. (srcValue !== undefined || (key in Object(object)));
  19911. };
  19912. }
  19913. /**
  19914. * A specialized version of `_.memoize` which clears the memoized function's
  19915. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  19916. *
  19917. * @private
  19918. * @param {Function} func The function to have its output memoized.
  19919. * @returns {Function} Returns the new memoized function.
  19920. */
  19921. function memoizeCapped(func) {
  19922. var result = memoize(func, function(key) {
  19923. if (cache.size === MAX_MEMOIZE_SIZE) {
  19924. cache.clear();
  19925. }
  19926. return key;
  19927. });
  19928. var cache = result.cache;
  19929. return result;
  19930. }
  19931. /**
  19932. * Merges the function metadata of `source` into `data`.
  19933. *
  19934. * Merging metadata reduces the number of wrappers used to invoke a function.
  19935. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  19936. * may be applied regardless of execution order. Methods like `_.ary` and
  19937. * `_.rearg` modify function arguments, making the order in which they are
  19938. * executed important, preventing the merging of metadata. However, we make
  19939. * an exception for a safe combined case where curried functions have `_.ary`
  19940. * and or `_.rearg` applied.
  19941. *
  19942. * @private
  19943. * @param {Array} data The destination metadata.
  19944. * @param {Array} source The source metadata.
  19945. * @returns {Array} Returns `data`.
  19946. */
  19947. function mergeData(data, source) {
  19948. var bitmask = data[1],
  19949. srcBitmask = source[1],
  19950. newBitmask = bitmask | srcBitmask,
  19951. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  19952. var isCombo =
  19953. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  19954. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  19955. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  19956. // Exit early if metadata can't be merged.
  19957. if (!(isCommon || isCombo)) {
  19958. return data;
  19959. }
  19960. // Use source `thisArg` if available.
  19961. if (srcBitmask & WRAP_BIND_FLAG) {
  19962. data[2] = source[2];
  19963. // Set when currying a bound function.
  19964. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  19965. }
  19966. // Compose partial arguments.
  19967. var value = source[3];
  19968. if (value) {
  19969. var partials = data[3];
  19970. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  19971. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  19972. }
  19973. // Compose partial right arguments.
  19974. value = source[5];
  19975. if (value) {
  19976. partials = data[5];
  19977. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  19978. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  19979. }
  19980. // Use source `argPos` if available.
  19981. value = source[7];
  19982. if (value) {
  19983. data[7] = value;
  19984. }
  19985. // Use source `ary` if it's smaller.
  19986. if (srcBitmask & WRAP_ARY_FLAG) {
  19987. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  19988. }
  19989. // Use source `arity` if one is not provided.
  19990. if (data[9] == null) {
  19991. data[9] = source[9];
  19992. }
  19993. // Use source `func` and merge bitmasks.
  19994. data[0] = source[0];
  19995. data[1] = newBitmask;
  19996. return data;
  19997. }
  19998. /**
  19999. * This function is like
  20000. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  20001. * except that it includes inherited enumerable properties.
  20002. *
  20003. * @private
  20004. * @param {Object} object The object to query.
  20005. * @returns {Array} Returns the array of property names.
  20006. */
  20007. function nativeKeysIn(object) {
  20008. var result = [];
  20009. if (object != null) {
  20010. for (var key in Object(object)) {
  20011. result.push(key);
  20012. }
  20013. }
  20014. return result;
  20015. }
  20016. /**
  20017. * Converts `value` to a string using `Object.prototype.toString`.
  20018. *
  20019. * @private
  20020. * @param {*} value The value to convert.
  20021. * @returns {string} Returns the converted string.
  20022. */
  20023. function objectToString(value) {
  20024. return nativeObjectToString.call(value);
  20025. }
  20026. /**
  20027. * A specialized version of `baseRest` which transforms the rest array.
  20028. *
  20029. * @private
  20030. * @param {Function} func The function to apply a rest parameter to.
  20031. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20032. * @param {Function} transform The rest array transform.
  20033. * @returns {Function} Returns the new function.
  20034. */
  20035. function overRest(func, start, transform) {
  20036. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  20037. return function() {
  20038. var args = arguments,
  20039. index = -1,
  20040. length = nativeMax(args.length - start, 0),
  20041. array = Array(length);
  20042. while (++index < length) {
  20043. array[index] = args[start + index];
  20044. }
  20045. index = -1;
  20046. var otherArgs = Array(start + 1);
  20047. while (++index < start) {
  20048. otherArgs[index] = args[index];
  20049. }
  20050. otherArgs[start] = transform(array);
  20051. return apply(func, this, otherArgs);
  20052. };
  20053. }
  20054. /**
  20055. * Gets the parent value at `path` of `object`.
  20056. *
  20057. * @private
  20058. * @param {Object} object The object to query.
  20059. * @param {Array} path The path to get the parent value of.
  20060. * @returns {*} Returns the parent value.
  20061. */
  20062. function parent(object, path) {
  20063. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  20064. }
  20065. /**
  20066. * Reorder `array` according to the specified indexes where the element at
  20067. * the first index is assigned as the first element, the element at
  20068. * the second index is assigned as the second element, and so on.
  20069. *
  20070. * @private
  20071. * @param {Array} array The array to reorder.
  20072. * @param {Array} indexes The arranged array indexes.
  20073. * @returns {Array} Returns `array`.
  20074. */
  20075. function reorder(array, indexes) {
  20076. var arrLength = array.length,
  20077. length = nativeMin(indexes.length, arrLength),
  20078. oldArray = copyArray(array);
  20079. while (length--) {
  20080. var index = indexes[length];
  20081. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  20082. }
  20083. return array;
  20084. }
  20085. /**
  20086. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  20087. *
  20088. * @private
  20089. * @param {Object} object The object to query.
  20090. * @param {string} key The key of the property to get.
  20091. * @returns {*} Returns the property value.
  20092. */
  20093. function safeGet(object, key) {
  20094. if (key === 'constructor' && typeof object[key] === 'function') {
  20095. return;
  20096. }
  20097. if (key == '__proto__') {
  20098. return;
  20099. }
  20100. return object[key];
  20101. }
  20102. /**
  20103. * Sets metadata for `func`.
  20104. *
  20105. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  20106. * period of time, it will trip its breaker and transition to an identity
  20107. * function to avoid garbage collection pauses in V8. See
  20108. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  20109. * for more details.
  20110. *
  20111. * @private
  20112. * @param {Function} func The function to associate metadata with.
  20113. * @param {*} data The metadata.
  20114. * @returns {Function} Returns `func`.
  20115. */
  20116. var setData = shortOut(baseSetData);
  20117. /**
  20118. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  20119. *
  20120. * @private
  20121. * @param {Function} func The function to delay.
  20122. * @param {number} wait The number of milliseconds to delay invocation.
  20123. * @returns {number|Object} Returns the timer id or timeout object.
  20124. */
  20125. var setTimeout = ctxSetTimeout || function(func, wait) {
  20126. return root.setTimeout(func, wait);
  20127. };
  20128. /**
  20129. * Sets the `toString` method of `func` to return `string`.
  20130. *
  20131. * @private
  20132. * @param {Function} func The function to modify.
  20133. * @param {Function} string The `toString` result.
  20134. * @returns {Function} Returns `func`.
  20135. */
  20136. var setToString = shortOut(baseSetToString);
  20137. /**
  20138. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  20139. * with wrapper details in a comment at the top of the source body.
  20140. *
  20141. * @private
  20142. * @param {Function} wrapper The function to modify.
  20143. * @param {Function} reference The reference function.
  20144. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  20145. * @returns {Function} Returns `wrapper`.
  20146. */
  20147. function setWrapToString(wrapper, reference, bitmask) {
  20148. var source = (reference + '');
  20149. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  20150. }
  20151. /**
  20152. * Creates a function that'll short out and invoke `identity` instead
  20153. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  20154. * milliseconds.
  20155. *
  20156. * @private
  20157. * @param {Function} func The function to restrict.
  20158. * @returns {Function} Returns the new shortable function.
  20159. */
  20160. function shortOut(func) {
  20161. var count = 0,
  20162. lastCalled = 0;
  20163. return function() {
  20164. var stamp = nativeNow(),
  20165. remaining = HOT_SPAN - (stamp - lastCalled);
  20166. lastCalled = stamp;
  20167. if (remaining > 0) {
  20168. if (++count >= HOT_COUNT) {
  20169. return arguments[0];
  20170. }
  20171. } else {
  20172. count = 0;
  20173. }
  20174. return func.apply(undefined, arguments);
  20175. };
  20176. }
  20177. /**
  20178. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  20179. *
  20180. * @private
  20181. * @param {Array} array The array to shuffle.
  20182. * @param {number} [size=array.length] The size of `array`.
  20183. * @returns {Array} Returns `array`.
  20184. */
  20185. function shuffleSelf(array, size) {
  20186. var index = -1,
  20187. length = array.length,
  20188. lastIndex = length - 1;
  20189. size = size === undefined ? length : size;
  20190. while (++index < size) {
  20191. var rand = baseRandom(index, lastIndex),
  20192. value = array[rand];
  20193. array[rand] = array[index];
  20194. array[index] = value;
  20195. }
  20196. array.length = size;
  20197. return array;
  20198. }
  20199. /**
  20200. * Converts `string` to a property path array.
  20201. *
  20202. * @private
  20203. * @param {string} string The string to convert.
  20204. * @returns {Array} Returns the property path array.
  20205. */
  20206. var stringToPath = memoizeCapped(function(string) {
  20207. var result = [];
  20208. if (string.charCodeAt(0) === 46 /* . */) {
  20209. result.push('');
  20210. }
  20211. string.replace(rePropName, function(match, number, quote, subString) {
  20212. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  20213. });
  20214. return result;
  20215. });
  20216. /**
  20217. * Converts `value` to a string key if it's not a string or symbol.
  20218. *
  20219. * @private
  20220. * @param {*} value The value to inspect.
  20221. * @returns {string|symbol} Returns the key.
  20222. */
  20223. function toKey(value) {
  20224. if (typeof value == 'string' || isSymbol(value)) {
  20225. return value;
  20226. }
  20227. var result = (value + '');
  20228. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20229. }
  20230. /**
  20231. * Converts `func` to its source code.
  20232. *
  20233. * @private
  20234. * @param {Function} func The function to convert.
  20235. * @returns {string} Returns the source code.
  20236. */
  20237. function toSource(func) {
  20238. if (func != null) {
  20239. try {
  20240. return funcToString.call(func);
  20241. } catch (e) {}
  20242. try {
  20243. return (func + '');
  20244. } catch (e) {}
  20245. }
  20246. return '';
  20247. }
  20248. /**
  20249. * Updates wrapper `details` based on `bitmask` flags.
  20250. *
  20251. * @private
  20252. * @returns {Array} details The details to modify.
  20253. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  20254. * @returns {Array} Returns `details`.
  20255. */
  20256. function updateWrapDetails(details, bitmask) {
  20257. arrayEach(wrapFlags, function(pair) {
  20258. var value = '_.' + pair[0];
  20259. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  20260. details.push(value);
  20261. }
  20262. });
  20263. return details.sort();
  20264. }
  20265. /**
  20266. * Creates a clone of `wrapper`.
  20267. *
  20268. * @private
  20269. * @param {Object} wrapper The wrapper to clone.
  20270. * @returns {Object} Returns the cloned wrapper.
  20271. */
  20272. function wrapperClone(wrapper) {
  20273. if (wrapper instanceof LazyWrapper) {
  20274. return wrapper.clone();
  20275. }
  20276. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  20277. result.__actions__ = copyArray(wrapper.__actions__);
  20278. result.__index__ = wrapper.__index__;
  20279. result.__values__ = wrapper.__values__;
  20280. return result;
  20281. }
  20282. /*------------------------------------------------------------------------*/
  20283. /**
  20284. * Creates an array of elements split into groups the length of `size`.
  20285. * If `array` can't be split evenly, the final chunk will be the remaining
  20286. * elements.
  20287. *
  20288. * @static
  20289. * @memberOf _
  20290. * @since 3.0.0
  20291. * @category Array
  20292. * @param {Array} array The array to process.
  20293. * @param {number} [size=1] The length of each chunk
  20294. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20295. * @returns {Array} Returns the new array of chunks.
  20296. * @example
  20297. *
  20298. * _.chunk(['a', 'b', 'c', 'd'], 2);
  20299. * // => [['a', 'b'], ['c', 'd']]
  20300. *
  20301. * _.chunk(['a', 'b', 'c', 'd'], 3);
  20302. * // => [['a', 'b', 'c'], ['d']]
  20303. */
  20304. function chunk(array, size, guard) {
  20305. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  20306. size = 1;
  20307. } else {
  20308. size = nativeMax(toInteger(size), 0);
  20309. }
  20310. var length = array == null ? 0 : array.length;
  20311. if (!length || size < 1) {
  20312. return [];
  20313. }
  20314. var index = 0,
  20315. resIndex = 0,
  20316. result = Array(nativeCeil(length / size));
  20317. while (index < length) {
  20318. result[resIndex++] = baseSlice(array, index, (index += size));
  20319. }
  20320. return result;
  20321. }
  20322. /**
  20323. * Creates an array with all falsey values removed. The values `false`, `null`,
  20324. * `0`, `""`, `undefined`, and `NaN` are falsey.
  20325. *
  20326. * @static
  20327. * @memberOf _
  20328. * @since 0.1.0
  20329. * @category Array
  20330. * @param {Array} array The array to compact.
  20331. * @returns {Array} Returns the new array of filtered values.
  20332. * @example
  20333. *
  20334. * _.compact([0, 1, false, 2, '', 3]);
  20335. * // => [1, 2, 3]
  20336. */
  20337. function compact(array) {
  20338. var index = -1,
  20339. length = array == null ? 0 : array.length,
  20340. resIndex = 0,
  20341. result = [];
  20342. while (++index < length) {
  20343. var value = array[index];
  20344. if (value) {
  20345. result[resIndex++] = value;
  20346. }
  20347. }
  20348. return result;
  20349. }
  20350. /**
  20351. * Creates a new array concatenating `array` with any additional arrays
  20352. * and/or values.
  20353. *
  20354. * @static
  20355. * @memberOf _
  20356. * @since 4.0.0
  20357. * @category Array
  20358. * @param {Array} array The array to concatenate.
  20359. * @param {...*} [values] The values to concatenate.
  20360. * @returns {Array} Returns the new concatenated array.
  20361. * @example
  20362. *
  20363. * var array = [1];
  20364. * var other = _.concat(array, 2, [3], [[4]]);
  20365. *
  20366. * console.log(other);
  20367. * // => [1, 2, 3, [4]]
  20368. *
  20369. * console.log(array);
  20370. * // => [1]
  20371. */
  20372. function concat() {
  20373. var length = arguments.length;
  20374. if (!length) {
  20375. return [];
  20376. }
  20377. var args = Array(length - 1),
  20378. array = arguments[0],
  20379. index = length;
  20380. while (index--) {
  20381. args[index - 1] = arguments[index];
  20382. }
  20383. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  20384. }
  20385. /**
  20386. * Creates an array of `array` values not included in the other given arrays
  20387. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20388. * for equality comparisons. The order and references of result values are
  20389. * determined by the first array.
  20390. *
  20391. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  20392. *
  20393. * @static
  20394. * @memberOf _
  20395. * @since 0.1.0
  20396. * @category Array
  20397. * @param {Array} array The array to inspect.
  20398. * @param {...Array} [values] The values to exclude.
  20399. * @returns {Array} Returns the new array of filtered values.
  20400. * @see _.without, _.xor
  20401. * @example
  20402. *
  20403. * _.difference([2, 1], [2, 3]);
  20404. * // => [1]
  20405. */
  20406. var difference = baseRest(function(array, values) {
  20407. return isArrayLikeObject(array)
  20408. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  20409. : [];
  20410. });
  20411. /**
  20412. * This method is like `_.difference` except that it accepts `iteratee` which
  20413. * is invoked for each element of `array` and `values` to generate the criterion
  20414. * by which they're compared. The order and references of result values are
  20415. * determined by the first array. The iteratee is invoked with one argument:
  20416. * (value).
  20417. *
  20418. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  20419. *
  20420. * @static
  20421. * @memberOf _
  20422. * @since 4.0.0
  20423. * @category Array
  20424. * @param {Array} array The array to inspect.
  20425. * @param {...Array} [values] The values to exclude.
  20426. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20427. * @returns {Array} Returns the new array of filtered values.
  20428. * @example
  20429. *
  20430. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20431. * // => [1.2]
  20432. *
  20433. * // The `_.property` iteratee shorthand.
  20434. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  20435. * // => [{ 'x': 2 }]
  20436. */
  20437. var differenceBy = baseRest(function(array, values) {
  20438. var iteratee = last(values);
  20439. if (isArrayLikeObject(iteratee)) {
  20440. iteratee = undefined;
  20441. }
  20442. return isArrayLikeObject(array)
  20443. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  20444. : [];
  20445. });
  20446. /**
  20447. * This method is like `_.difference` except that it accepts `comparator`
  20448. * which is invoked to compare elements of `array` to `values`. The order and
  20449. * references of result values are determined by the first array. The comparator
  20450. * is invoked with two arguments: (arrVal, othVal).
  20451. *
  20452. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  20453. *
  20454. * @static
  20455. * @memberOf _
  20456. * @since 4.0.0
  20457. * @category Array
  20458. * @param {Array} array The array to inspect.
  20459. * @param {...Array} [values] The values to exclude.
  20460. * @param {Function} [comparator] The comparator invoked per element.
  20461. * @returns {Array} Returns the new array of filtered values.
  20462. * @example
  20463. *
  20464. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20465. *
  20466. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  20467. * // => [{ 'x': 2, 'y': 1 }]
  20468. */
  20469. var differenceWith = baseRest(function(array, values) {
  20470. var comparator = last(values);
  20471. if (isArrayLikeObject(comparator)) {
  20472. comparator = undefined;
  20473. }
  20474. return isArrayLikeObject(array)
  20475. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  20476. : [];
  20477. });
  20478. /**
  20479. * Creates a slice of `array` with `n` elements dropped from the beginning.
  20480. *
  20481. * @static
  20482. * @memberOf _
  20483. * @since 0.5.0
  20484. * @category Array
  20485. * @param {Array} array The array to query.
  20486. * @param {number} [n=1] The number of elements to drop.
  20487. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20488. * @returns {Array} Returns the slice of `array`.
  20489. * @example
  20490. *
  20491. * _.drop([1, 2, 3]);
  20492. * // => [2, 3]
  20493. *
  20494. * _.drop([1, 2, 3], 2);
  20495. * // => [3]
  20496. *
  20497. * _.drop([1, 2, 3], 5);
  20498. * // => []
  20499. *
  20500. * _.drop([1, 2, 3], 0);
  20501. * // => [1, 2, 3]
  20502. */
  20503. function drop(array, n, guard) {
  20504. var length = array == null ? 0 : array.length;
  20505. if (!length) {
  20506. return [];
  20507. }
  20508. n = (guard || n === undefined) ? 1 : toInteger(n);
  20509. return baseSlice(array, n < 0 ? 0 : n, length);
  20510. }
  20511. /**
  20512. * Creates a slice of `array` with `n` elements dropped from the end.
  20513. *
  20514. * @static
  20515. * @memberOf _
  20516. * @since 3.0.0
  20517. * @category Array
  20518. * @param {Array} array The array to query.
  20519. * @param {number} [n=1] The number of elements to drop.
  20520. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20521. * @returns {Array} Returns the slice of `array`.
  20522. * @example
  20523. *
  20524. * _.dropRight([1, 2, 3]);
  20525. * // => [1, 2]
  20526. *
  20527. * _.dropRight([1, 2, 3], 2);
  20528. * // => [1]
  20529. *
  20530. * _.dropRight([1, 2, 3], 5);
  20531. * // => []
  20532. *
  20533. * _.dropRight([1, 2, 3], 0);
  20534. * // => [1, 2, 3]
  20535. */
  20536. function dropRight(array, n, guard) {
  20537. var length = array == null ? 0 : array.length;
  20538. if (!length) {
  20539. return [];
  20540. }
  20541. n = (guard || n === undefined) ? 1 : toInteger(n);
  20542. n = length - n;
  20543. return baseSlice(array, 0, n < 0 ? 0 : n);
  20544. }
  20545. /**
  20546. * Creates a slice of `array` excluding elements dropped from the end.
  20547. * Elements are dropped until `predicate` returns falsey. The predicate is
  20548. * invoked with three arguments: (value, index, array).
  20549. *
  20550. * @static
  20551. * @memberOf _
  20552. * @since 3.0.0
  20553. * @category Array
  20554. * @param {Array} array The array to query.
  20555. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20556. * @returns {Array} Returns the slice of `array`.
  20557. * @example
  20558. *
  20559. * var users = [
  20560. * { 'user': 'barney', 'active': true },
  20561. * { 'user': 'fred', 'active': false },
  20562. * { 'user': 'pebbles', 'active': false }
  20563. * ];
  20564. *
  20565. * _.dropRightWhile(users, function(o) { return !o.active; });
  20566. * // => objects for ['barney']
  20567. *
  20568. * // The `_.matches` iteratee shorthand.
  20569. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  20570. * // => objects for ['barney', 'fred']
  20571. *
  20572. * // The `_.matchesProperty` iteratee shorthand.
  20573. * _.dropRightWhile(users, ['active', false]);
  20574. * // => objects for ['barney']
  20575. *
  20576. * // The `_.property` iteratee shorthand.
  20577. * _.dropRightWhile(users, 'active');
  20578. * // => objects for ['barney', 'fred', 'pebbles']
  20579. */
  20580. function dropRightWhile(array, predicate) {
  20581. return (array && array.length)
  20582. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  20583. : [];
  20584. }
  20585. /**
  20586. * Creates a slice of `array` excluding elements dropped from the beginning.
  20587. * Elements are dropped until `predicate` returns falsey. The predicate is
  20588. * invoked with three arguments: (value, index, array).
  20589. *
  20590. * @static
  20591. * @memberOf _
  20592. * @since 3.0.0
  20593. * @category Array
  20594. * @param {Array} array The array to query.
  20595. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20596. * @returns {Array} Returns the slice of `array`.
  20597. * @example
  20598. *
  20599. * var users = [
  20600. * { 'user': 'barney', 'active': false },
  20601. * { 'user': 'fred', 'active': false },
  20602. * { 'user': 'pebbles', 'active': true }
  20603. * ];
  20604. *
  20605. * _.dropWhile(users, function(o) { return !o.active; });
  20606. * // => objects for ['pebbles']
  20607. *
  20608. * // The `_.matches` iteratee shorthand.
  20609. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  20610. * // => objects for ['fred', 'pebbles']
  20611. *
  20612. * // The `_.matchesProperty` iteratee shorthand.
  20613. * _.dropWhile(users, ['active', false]);
  20614. * // => objects for ['pebbles']
  20615. *
  20616. * // The `_.property` iteratee shorthand.
  20617. * _.dropWhile(users, 'active');
  20618. * // => objects for ['barney', 'fred', 'pebbles']
  20619. */
  20620. function dropWhile(array, predicate) {
  20621. return (array && array.length)
  20622. ? baseWhile(array, getIteratee(predicate, 3), true)
  20623. : [];
  20624. }
  20625. /**
  20626. * Fills elements of `array` with `value` from `start` up to, but not
  20627. * including, `end`.
  20628. *
  20629. * **Note:** This method mutates `array`.
  20630. *
  20631. * @static
  20632. * @memberOf _
  20633. * @since 3.2.0
  20634. * @category Array
  20635. * @param {Array} array The array to fill.
  20636. * @param {*} value The value to fill `array` with.
  20637. * @param {number} [start=0] The start position.
  20638. * @param {number} [end=array.length] The end position.
  20639. * @returns {Array} Returns `array`.
  20640. * @example
  20641. *
  20642. * var array = [1, 2, 3];
  20643. *
  20644. * _.fill(array, 'a');
  20645. * console.log(array);
  20646. * // => ['a', 'a', 'a']
  20647. *
  20648. * _.fill(Array(3), 2);
  20649. * // => [2, 2, 2]
  20650. *
  20651. * _.fill([4, 6, 8, 10], '*', 1, 3);
  20652. * // => [4, '*', '*', 10]
  20653. */
  20654. function fill(array, value, start, end) {
  20655. var length = array == null ? 0 : array.length;
  20656. if (!length) {
  20657. return [];
  20658. }
  20659. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  20660. start = 0;
  20661. end = length;
  20662. }
  20663. return baseFill(array, value, start, end);
  20664. }
  20665. /**
  20666. * This method is like `_.find` except that it returns the index of the first
  20667. * element `predicate` returns truthy for instead of the element itself.
  20668. *
  20669. * @static
  20670. * @memberOf _
  20671. * @since 1.1.0
  20672. * @category Array
  20673. * @param {Array} array The array to inspect.
  20674. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20675. * @param {number} [fromIndex=0] The index to search from.
  20676. * @returns {number} Returns the index of the found element, else `-1`.
  20677. * @example
  20678. *
  20679. * var users = [
  20680. * { 'user': 'barney', 'active': false },
  20681. * { 'user': 'fred', 'active': false },
  20682. * { 'user': 'pebbles', 'active': true }
  20683. * ];
  20684. *
  20685. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  20686. * // => 0
  20687. *
  20688. * // The `_.matches` iteratee shorthand.
  20689. * _.findIndex(users, { 'user': 'fred', 'active': false });
  20690. * // => 1
  20691. *
  20692. * // The `_.matchesProperty` iteratee shorthand.
  20693. * _.findIndex(users, ['active', false]);
  20694. * // => 0
  20695. *
  20696. * // The `_.property` iteratee shorthand.
  20697. * _.findIndex(users, 'active');
  20698. * // => 2
  20699. */
  20700. function findIndex(array, predicate, fromIndex) {
  20701. var length = array == null ? 0 : array.length;
  20702. if (!length) {
  20703. return -1;
  20704. }
  20705. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20706. if (index < 0) {
  20707. index = nativeMax(length + index, 0);
  20708. }
  20709. return baseFindIndex(array, getIteratee(predicate, 3), index);
  20710. }
  20711. /**
  20712. * This method is like `_.findIndex` except that it iterates over elements
  20713. * of `collection` from right to left.
  20714. *
  20715. * @static
  20716. * @memberOf _
  20717. * @since 2.0.0
  20718. * @category Array
  20719. * @param {Array} array The array to inspect.
  20720. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20721. * @param {number} [fromIndex=array.length-1] The index to search from.
  20722. * @returns {number} Returns the index of the found element, else `-1`.
  20723. * @example
  20724. *
  20725. * var users = [
  20726. * { 'user': 'barney', 'active': true },
  20727. * { 'user': 'fred', 'active': false },
  20728. * { 'user': 'pebbles', 'active': false }
  20729. * ];
  20730. *
  20731. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  20732. * // => 2
  20733. *
  20734. * // The `_.matches` iteratee shorthand.
  20735. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  20736. * // => 0
  20737. *
  20738. * // The `_.matchesProperty` iteratee shorthand.
  20739. * _.findLastIndex(users, ['active', false]);
  20740. * // => 2
  20741. *
  20742. * // The `_.property` iteratee shorthand.
  20743. * _.findLastIndex(users, 'active');
  20744. * // => 0
  20745. */
  20746. function findLastIndex(array, predicate, fromIndex) {
  20747. var length = array == null ? 0 : array.length;
  20748. if (!length) {
  20749. return -1;
  20750. }
  20751. var index = length - 1;
  20752. if (fromIndex !== undefined) {
  20753. index = toInteger(fromIndex);
  20754. index = fromIndex < 0
  20755. ? nativeMax(length + index, 0)
  20756. : nativeMin(index, length - 1);
  20757. }
  20758. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  20759. }
  20760. /**
  20761. * Flattens `array` a single level deep.
  20762. *
  20763. * @static
  20764. * @memberOf _
  20765. * @since 0.1.0
  20766. * @category Array
  20767. * @param {Array} array The array to flatten.
  20768. * @returns {Array} Returns the new flattened array.
  20769. * @example
  20770. *
  20771. * _.flatten([1, [2, [3, [4]], 5]]);
  20772. * // => [1, 2, [3, [4]], 5]
  20773. */
  20774. function flatten(array) {
  20775. var length = array == null ? 0 : array.length;
  20776. return length ? baseFlatten(array, 1) : [];
  20777. }
  20778. /**
  20779. * Recursively flattens `array`.
  20780. *
  20781. * @static
  20782. * @memberOf _
  20783. * @since 3.0.0
  20784. * @category Array
  20785. * @param {Array} array The array to flatten.
  20786. * @returns {Array} Returns the new flattened array.
  20787. * @example
  20788. *
  20789. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  20790. * // => [1, 2, 3, 4, 5]
  20791. */
  20792. function flattenDeep(array) {
  20793. var length = array == null ? 0 : array.length;
  20794. return length ? baseFlatten(array, INFINITY) : [];
  20795. }
  20796. /**
  20797. * Recursively flatten `array` up to `depth` times.
  20798. *
  20799. * @static
  20800. * @memberOf _
  20801. * @since 4.4.0
  20802. * @category Array
  20803. * @param {Array} array The array to flatten.
  20804. * @param {number} [depth=1] The maximum recursion depth.
  20805. * @returns {Array} Returns the new flattened array.
  20806. * @example
  20807. *
  20808. * var array = [1, [2, [3, [4]], 5]];
  20809. *
  20810. * _.flattenDepth(array, 1);
  20811. * // => [1, 2, [3, [4]], 5]
  20812. *
  20813. * _.flattenDepth(array, 2);
  20814. * // => [1, 2, 3, [4], 5]
  20815. */
  20816. function flattenDepth(array, depth) {
  20817. var length = array == null ? 0 : array.length;
  20818. if (!length) {
  20819. return [];
  20820. }
  20821. depth = depth === undefined ? 1 : toInteger(depth);
  20822. return baseFlatten(array, depth);
  20823. }
  20824. /**
  20825. * The inverse of `_.toPairs`; this method returns an object composed
  20826. * from key-value `pairs`.
  20827. *
  20828. * @static
  20829. * @memberOf _
  20830. * @since 4.0.0
  20831. * @category Array
  20832. * @param {Array} pairs The key-value pairs.
  20833. * @returns {Object} Returns the new object.
  20834. * @example
  20835. *
  20836. * _.fromPairs([['a', 1], ['b', 2]]);
  20837. * // => { 'a': 1, 'b': 2 }
  20838. */
  20839. function fromPairs(pairs) {
  20840. var index = -1,
  20841. length = pairs == null ? 0 : pairs.length,
  20842. result = {};
  20843. while (++index < length) {
  20844. var pair = pairs[index];
  20845. result[pair[0]] = pair[1];
  20846. }
  20847. return result;
  20848. }
  20849. /**
  20850. * Gets the first element of `array`.
  20851. *
  20852. * @static
  20853. * @memberOf _
  20854. * @since 0.1.0
  20855. * @alias first
  20856. * @category Array
  20857. * @param {Array} array The array to query.
  20858. * @returns {*} Returns the first element of `array`.
  20859. * @example
  20860. *
  20861. * _.head([1, 2, 3]);
  20862. * // => 1
  20863. *
  20864. * _.head([]);
  20865. * // => undefined
  20866. */
  20867. function head(array) {
  20868. return (array && array.length) ? array[0] : undefined;
  20869. }
  20870. /**
  20871. * Gets the index at which the first occurrence of `value` is found in `array`
  20872. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20873. * for equality comparisons. If `fromIndex` is negative, it's used as the
  20874. * offset from the end of `array`.
  20875. *
  20876. * @static
  20877. * @memberOf _
  20878. * @since 0.1.0
  20879. * @category Array
  20880. * @param {Array} array The array to inspect.
  20881. * @param {*} value The value to search for.
  20882. * @param {number} [fromIndex=0] The index to search from.
  20883. * @returns {number} Returns the index of the matched value, else `-1`.
  20884. * @example
  20885. *
  20886. * _.indexOf([1, 2, 1, 2], 2);
  20887. * // => 1
  20888. *
  20889. * // Search from the `fromIndex`.
  20890. * _.indexOf([1, 2, 1, 2], 2, 2);
  20891. * // => 3
  20892. */
  20893. function indexOf(array, value, fromIndex) {
  20894. var length = array == null ? 0 : array.length;
  20895. if (!length) {
  20896. return -1;
  20897. }
  20898. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20899. if (index < 0) {
  20900. index = nativeMax(length + index, 0);
  20901. }
  20902. return baseIndexOf(array, value, index);
  20903. }
  20904. /**
  20905. * Gets all but the last element of `array`.
  20906. *
  20907. * @static
  20908. * @memberOf _
  20909. * @since 0.1.0
  20910. * @category Array
  20911. * @param {Array} array The array to query.
  20912. * @returns {Array} Returns the slice of `array`.
  20913. * @example
  20914. *
  20915. * _.initial([1, 2, 3]);
  20916. * // => [1, 2]
  20917. */
  20918. function initial(array) {
  20919. var length = array == null ? 0 : array.length;
  20920. return length ? baseSlice(array, 0, -1) : [];
  20921. }
  20922. /**
  20923. * Creates an array of unique values that are included in all given arrays
  20924. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20925. * for equality comparisons. The order and references of result values are
  20926. * determined by the first array.
  20927. *
  20928. * @static
  20929. * @memberOf _
  20930. * @since 0.1.0
  20931. * @category Array
  20932. * @param {...Array} [arrays] The arrays to inspect.
  20933. * @returns {Array} Returns the new array of intersecting values.
  20934. * @example
  20935. *
  20936. * _.intersection([2, 1], [2, 3]);
  20937. * // => [2]
  20938. */
  20939. var intersection = baseRest(function(arrays) {
  20940. var mapped = arrayMap(arrays, castArrayLikeObject);
  20941. return (mapped.length && mapped[0] === arrays[0])
  20942. ? baseIntersection(mapped)
  20943. : [];
  20944. });
  20945. /**
  20946. * This method is like `_.intersection` except that it accepts `iteratee`
  20947. * which is invoked for each element of each `arrays` to generate the criterion
  20948. * by which they're compared. The order and references of result values are
  20949. * determined by the first array. The iteratee is invoked with one argument:
  20950. * (value).
  20951. *
  20952. * @static
  20953. * @memberOf _
  20954. * @since 4.0.0
  20955. * @category Array
  20956. * @param {...Array} [arrays] The arrays to inspect.
  20957. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20958. * @returns {Array} Returns the new array of intersecting values.
  20959. * @example
  20960. *
  20961. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20962. * // => [2.1]
  20963. *
  20964. * // The `_.property` iteratee shorthand.
  20965. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  20966. * // => [{ 'x': 1 }]
  20967. */
  20968. var intersectionBy = baseRest(function(arrays) {
  20969. var iteratee = last(arrays),
  20970. mapped = arrayMap(arrays, castArrayLikeObject);
  20971. if (iteratee === last(mapped)) {
  20972. iteratee = undefined;
  20973. } else {
  20974. mapped.pop();
  20975. }
  20976. return (mapped.length && mapped[0] === arrays[0])
  20977. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  20978. : [];
  20979. });
  20980. /**
  20981. * This method is like `_.intersection` except that it accepts `comparator`
  20982. * which is invoked to compare elements of `arrays`. The order and references
  20983. * of result values are determined by the first array. The comparator is
  20984. * invoked with two arguments: (arrVal, othVal).
  20985. *
  20986. * @static
  20987. * @memberOf _
  20988. * @since 4.0.0
  20989. * @category Array
  20990. * @param {...Array} [arrays] The arrays to inspect.
  20991. * @param {Function} [comparator] The comparator invoked per element.
  20992. * @returns {Array} Returns the new array of intersecting values.
  20993. * @example
  20994. *
  20995. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20996. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  20997. *
  20998. * _.intersectionWith(objects, others, _.isEqual);
  20999. * // => [{ 'x': 1, 'y': 2 }]
  21000. */
  21001. var intersectionWith = baseRest(function(arrays) {
  21002. var comparator = last(arrays),
  21003. mapped = arrayMap(arrays, castArrayLikeObject);
  21004. comparator = typeof comparator == 'function' ? comparator : undefined;
  21005. if (comparator) {
  21006. mapped.pop();
  21007. }
  21008. return (mapped.length && mapped[0] === arrays[0])
  21009. ? baseIntersection(mapped, undefined, comparator)
  21010. : [];
  21011. });
  21012. /**
  21013. * Converts all elements in `array` into a string separated by `separator`.
  21014. *
  21015. * @static
  21016. * @memberOf _
  21017. * @since 4.0.0
  21018. * @category Array
  21019. * @param {Array} array The array to convert.
  21020. * @param {string} [separator=','] The element separator.
  21021. * @returns {string} Returns the joined string.
  21022. * @example
  21023. *
  21024. * _.join(['a', 'b', 'c'], '~');
  21025. * // => 'a~b~c'
  21026. */
  21027. function join(array, separator) {
  21028. return array == null ? '' : nativeJoin.call(array, separator);
  21029. }
  21030. /**
  21031. * Gets the last element of `array`.
  21032. *
  21033. * @static
  21034. * @memberOf _
  21035. * @since 0.1.0
  21036. * @category Array
  21037. * @param {Array} array The array to query.
  21038. * @returns {*} Returns the last element of `array`.
  21039. * @example
  21040. *
  21041. * _.last([1, 2, 3]);
  21042. * // => 3
  21043. */
  21044. function last(array) {
  21045. var length = array == null ? 0 : array.length;
  21046. return length ? array[length - 1] : undefined;
  21047. }
  21048. /**
  21049. * This method is like `_.indexOf` except that it iterates over elements of
  21050. * `array` from right to left.
  21051. *
  21052. * @static
  21053. * @memberOf _
  21054. * @since 0.1.0
  21055. * @category Array
  21056. * @param {Array} array The array to inspect.
  21057. * @param {*} value The value to search for.
  21058. * @param {number} [fromIndex=array.length-1] The index to search from.
  21059. * @returns {number} Returns the index of the matched value, else `-1`.
  21060. * @example
  21061. *
  21062. * _.lastIndexOf([1, 2, 1, 2], 2);
  21063. * // => 3
  21064. *
  21065. * // Search from the `fromIndex`.
  21066. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  21067. * // => 1
  21068. */
  21069. function lastIndexOf(array, value, fromIndex) {
  21070. var length = array == null ? 0 : array.length;
  21071. if (!length) {
  21072. return -1;
  21073. }
  21074. var index = length;
  21075. if (fromIndex !== undefined) {
  21076. index = toInteger(fromIndex);
  21077. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  21078. }
  21079. return value === value
  21080. ? strictLastIndexOf(array, value, index)
  21081. : baseFindIndex(array, baseIsNaN, index, true);
  21082. }
  21083. /**
  21084. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  21085. * element from the end is returned.
  21086. *
  21087. * @static
  21088. * @memberOf _
  21089. * @since 4.11.0
  21090. * @category Array
  21091. * @param {Array} array The array to query.
  21092. * @param {number} [n=0] The index of the element to return.
  21093. * @returns {*} Returns the nth element of `array`.
  21094. * @example
  21095. *
  21096. * var array = ['a', 'b', 'c', 'd'];
  21097. *
  21098. * _.nth(array, 1);
  21099. * // => 'b'
  21100. *
  21101. * _.nth(array, -2);
  21102. * // => 'c';
  21103. */
  21104. function nth(array, n) {
  21105. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  21106. }
  21107. /**
  21108. * Removes all given values from `array` using
  21109. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21110. * for equality comparisons.
  21111. *
  21112. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  21113. * to remove elements from an array by predicate.
  21114. *
  21115. * @static
  21116. * @memberOf _
  21117. * @since 2.0.0
  21118. * @category Array
  21119. * @param {Array} array The array to modify.
  21120. * @param {...*} [values] The values to remove.
  21121. * @returns {Array} Returns `array`.
  21122. * @example
  21123. *
  21124. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  21125. *
  21126. * _.pull(array, 'a', 'c');
  21127. * console.log(array);
  21128. * // => ['b', 'b']
  21129. */
  21130. var pull = baseRest(pullAll);
  21131. /**
  21132. * This method is like `_.pull` except that it accepts an array of values to remove.
  21133. *
  21134. * **Note:** Unlike `_.difference`, this method mutates `array`.
  21135. *
  21136. * @static
  21137. * @memberOf _
  21138. * @since 4.0.0
  21139. * @category Array
  21140. * @param {Array} array The array to modify.
  21141. * @param {Array} values The values to remove.
  21142. * @returns {Array} Returns `array`.
  21143. * @example
  21144. *
  21145. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  21146. *
  21147. * _.pullAll(array, ['a', 'c']);
  21148. * console.log(array);
  21149. * // => ['b', 'b']
  21150. */
  21151. function pullAll(array, values) {
  21152. return (array && array.length && values && values.length)
  21153. ? basePullAll(array, values)
  21154. : array;
  21155. }
  21156. /**
  21157. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  21158. * invoked for each element of `array` and `values` to generate the criterion
  21159. * by which they're compared. The iteratee is invoked with one argument: (value).
  21160. *
  21161. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  21162. *
  21163. * @static
  21164. * @memberOf _
  21165. * @since 4.0.0
  21166. * @category Array
  21167. * @param {Array} array The array to modify.
  21168. * @param {Array} values The values to remove.
  21169. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21170. * @returns {Array} Returns `array`.
  21171. * @example
  21172. *
  21173. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  21174. *
  21175. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  21176. * console.log(array);
  21177. * // => [{ 'x': 2 }]
  21178. */
  21179. function pullAllBy(array, values, iteratee) {
  21180. return (array && array.length && values && values.length)
  21181. ? basePullAll(array, values, getIteratee(iteratee, 2))
  21182. : array;
  21183. }
  21184. /**
  21185. * This method is like `_.pullAll` except that it accepts `comparator` which
  21186. * is invoked to compare elements of `array` to `values`. The comparator is
  21187. * invoked with two arguments: (arrVal, othVal).
  21188. *
  21189. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  21190. *
  21191. * @static
  21192. * @memberOf _
  21193. * @since 4.6.0
  21194. * @category Array
  21195. * @param {Array} array The array to modify.
  21196. * @param {Array} values The values to remove.
  21197. * @param {Function} [comparator] The comparator invoked per element.
  21198. * @returns {Array} Returns `array`.
  21199. * @example
  21200. *
  21201. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  21202. *
  21203. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  21204. * console.log(array);
  21205. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  21206. */
  21207. function pullAllWith(array, values, comparator) {
  21208. return (array && array.length && values && values.length)
  21209. ? basePullAll(array, values, undefined, comparator)
  21210. : array;
  21211. }
  21212. /**
  21213. * Removes elements from `array` corresponding to `indexes` and returns an
  21214. * array of removed elements.
  21215. *
  21216. * **Note:** Unlike `_.at`, this method mutates `array`.
  21217. *
  21218. * @static
  21219. * @memberOf _
  21220. * @since 3.0.0
  21221. * @category Array
  21222. * @param {Array} array The array to modify.
  21223. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  21224. * @returns {Array} Returns the new array of removed elements.
  21225. * @example
  21226. *
  21227. * var array = ['a', 'b', 'c', 'd'];
  21228. * var pulled = _.pullAt(array, [1, 3]);
  21229. *
  21230. * console.log(array);
  21231. * // => ['a', 'c']
  21232. *
  21233. * console.log(pulled);
  21234. * // => ['b', 'd']
  21235. */
  21236. var pullAt = flatRest(function(array, indexes) {
  21237. var length = array == null ? 0 : array.length,
  21238. result = baseAt(array, indexes);
  21239. basePullAt(array, arrayMap(indexes, function(index) {
  21240. return isIndex(index, length) ? +index : index;
  21241. }).sort(compareAscending));
  21242. return result;
  21243. });
  21244. /**
  21245. * Removes all elements from `array` that `predicate` returns truthy for
  21246. * and returns an array of the removed elements. The predicate is invoked
  21247. * with three arguments: (value, index, array).
  21248. *
  21249. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  21250. * to pull elements from an array by value.
  21251. *
  21252. * @static
  21253. * @memberOf _
  21254. * @since 2.0.0
  21255. * @category Array
  21256. * @param {Array} array The array to modify.
  21257. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21258. * @returns {Array} Returns the new array of removed elements.
  21259. * @example
  21260. *
  21261. * var array = [1, 2, 3, 4];
  21262. * var evens = _.remove(array, function(n) {
  21263. * return n % 2 == 0;
  21264. * });
  21265. *
  21266. * console.log(array);
  21267. * // => [1, 3]
  21268. *
  21269. * console.log(evens);
  21270. * // => [2, 4]
  21271. */
  21272. function remove(array, predicate) {
  21273. var result = [];
  21274. if (!(array && array.length)) {
  21275. return result;
  21276. }
  21277. var index = -1,
  21278. indexes = [],
  21279. length = array.length;
  21280. predicate = getIteratee(predicate, 3);
  21281. while (++index < length) {
  21282. var value = array[index];
  21283. if (predicate(value, index, array)) {
  21284. result.push(value);
  21285. indexes.push(index);
  21286. }
  21287. }
  21288. basePullAt(array, indexes);
  21289. return result;
  21290. }
  21291. /**
  21292. * Reverses `array` so that the first element becomes the last, the second
  21293. * element becomes the second to last, and so on.
  21294. *
  21295. * **Note:** This method mutates `array` and is based on
  21296. * [`Array#reverse`](https://mdn.io/Array/reverse).
  21297. *
  21298. * @static
  21299. * @memberOf _
  21300. * @since 4.0.0
  21301. * @category Array
  21302. * @param {Array} array The array to modify.
  21303. * @returns {Array} Returns `array`.
  21304. * @example
  21305. *
  21306. * var array = [1, 2, 3];
  21307. *
  21308. * _.reverse(array);
  21309. * // => [3, 2, 1]
  21310. *
  21311. * console.log(array);
  21312. * // => [3, 2, 1]
  21313. */
  21314. function reverse(array) {
  21315. return array == null ? array : nativeReverse.call(array);
  21316. }
  21317. /**
  21318. * Creates a slice of `array` from `start` up to, but not including, `end`.
  21319. *
  21320. * **Note:** This method is used instead of
  21321. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  21322. * returned.
  21323. *
  21324. * @static
  21325. * @memberOf _
  21326. * @since 3.0.0
  21327. * @category Array
  21328. * @param {Array} array The array to slice.
  21329. * @param {number} [start=0] The start position.
  21330. * @param {number} [end=array.length] The end position.
  21331. * @returns {Array} Returns the slice of `array`.
  21332. */
  21333. function slice(array, start, end) {
  21334. var length = array == null ? 0 : array.length;
  21335. if (!length) {
  21336. return [];
  21337. }
  21338. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  21339. start = 0;
  21340. end = length;
  21341. }
  21342. else {
  21343. start = start == null ? 0 : toInteger(start);
  21344. end = end === undefined ? length : toInteger(end);
  21345. }
  21346. return baseSlice(array, start, end);
  21347. }
  21348. /**
  21349. * Uses a binary search to determine the lowest index at which `value`
  21350. * should be inserted into `array` in order to maintain its sort order.
  21351. *
  21352. * @static
  21353. * @memberOf _
  21354. * @since 0.1.0
  21355. * @category Array
  21356. * @param {Array} array The sorted array to inspect.
  21357. * @param {*} value The value to evaluate.
  21358. * @returns {number} Returns the index at which `value` should be inserted
  21359. * into `array`.
  21360. * @example
  21361. *
  21362. * _.sortedIndex([30, 50], 40);
  21363. * // => 1
  21364. */
  21365. function sortedIndex(array, value) {
  21366. return baseSortedIndex(array, value);
  21367. }
  21368. /**
  21369. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  21370. * which is invoked for `value` and each element of `array` to compute their
  21371. * sort ranking. The iteratee is invoked with one argument: (value).
  21372. *
  21373. * @static
  21374. * @memberOf _
  21375. * @since 4.0.0
  21376. * @category Array
  21377. * @param {Array} array The sorted array to inspect.
  21378. * @param {*} value The value to evaluate.
  21379. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21380. * @returns {number} Returns the index at which `value` should be inserted
  21381. * into `array`.
  21382. * @example
  21383. *
  21384. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21385. *
  21386. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21387. * // => 0
  21388. *
  21389. * // The `_.property` iteratee shorthand.
  21390. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  21391. * // => 0
  21392. */
  21393. function sortedIndexBy(array, value, iteratee) {
  21394. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  21395. }
  21396. /**
  21397. * This method is like `_.indexOf` except that it performs a binary
  21398. * search on a sorted `array`.
  21399. *
  21400. * @static
  21401. * @memberOf _
  21402. * @since 4.0.0
  21403. * @category Array
  21404. * @param {Array} array The array to inspect.
  21405. * @param {*} value The value to search for.
  21406. * @returns {number} Returns the index of the matched value, else `-1`.
  21407. * @example
  21408. *
  21409. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  21410. * // => 1
  21411. */
  21412. function sortedIndexOf(array, value) {
  21413. var length = array == null ? 0 : array.length;
  21414. if (length) {
  21415. var index = baseSortedIndex(array, value);
  21416. if (index < length && eq(array[index], value)) {
  21417. return index;
  21418. }
  21419. }
  21420. return -1;
  21421. }
  21422. /**
  21423. * This method is like `_.sortedIndex` except that it returns the highest
  21424. * index at which `value` should be inserted into `array` in order to
  21425. * maintain its sort order.
  21426. *
  21427. * @static
  21428. * @memberOf _
  21429. * @since 3.0.0
  21430. * @category Array
  21431. * @param {Array} array The sorted array to inspect.
  21432. * @param {*} value The value to evaluate.
  21433. * @returns {number} Returns the index at which `value` should be inserted
  21434. * into `array`.
  21435. * @example
  21436. *
  21437. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  21438. * // => 4
  21439. */
  21440. function sortedLastIndex(array, value) {
  21441. return baseSortedIndex(array, value, true);
  21442. }
  21443. /**
  21444. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  21445. * which is invoked for `value` and each element of `array` to compute their
  21446. * sort ranking. The iteratee is invoked with one argument: (value).
  21447. *
  21448. * @static
  21449. * @memberOf _
  21450. * @since 4.0.0
  21451. * @category Array
  21452. * @param {Array} array The sorted array to inspect.
  21453. * @param {*} value The value to evaluate.
  21454. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21455. * @returns {number} Returns the index at which `value` should be inserted
  21456. * into `array`.
  21457. * @example
  21458. *
  21459. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21460. *
  21461. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21462. * // => 1
  21463. *
  21464. * // The `_.property` iteratee shorthand.
  21465. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  21466. * // => 1
  21467. */
  21468. function sortedLastIndexBy(array, value, iteratee) {
  21469. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  21470. }
  21471. /**
  21472. * This method is like `_.lastIndexOf` except that it performs a binary
  21473. * search on a sorted `array`.
  21474. *
  21475. * @static
  21476. * @memberOf _
  21477. * @since 4.0.0
  21478. * @category Array
  21479. * @param {Array} array The array to inspect.
  21480. * @param {*} value The value to search for.
  21481. * @returns {number} Returns the index of the matched value, else `-1`.
  21482. * @example
  21483. *
  21484. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  21485. * // => 3
  21486. */
  21487. function sortedLastIndexOf(array, value) {
  21488. var length = array == null ? 0 : array.length;
  21489. if (length) {
  21490. var index = baseSortedIndex(array, value, true) - 1;
  21491. if (eq(array[index], value)) {
  21492. return index;
  21493. }
  21494. }
  21495. return -1;
  21496. }
  21497. /**
  21498. * This method is like `_.uniq` except that it's designed and optimized
  21499. * for sorted arrays.
  21500. *
  21501. * @static
  21502. * @memberOf _
  21503. * @since 4.0.0
  21504. * @category Array
  21505. * @param {Array} array The array to inspect.
  21506. * @returns {Array} Returns the new duplicate free array.
  21507. * @example
  21508. *
  21509. * _.sortedUniq([1, 1, 2]);
  21510. * // => [1, 2]
  21511. */
  21512. function sortedUniq(array) {
  21513. return (array && array.length)
  21514. ? baseSortedUniq(array)
  21515. : [];
  21516. }
  21517. /**
  21518. * This method is like `_.uniqBy` except that it's designed and optimized
  21519. * for sorted arrays.
  21520. *
  21521. * @static
  21522. * @memberOf _
  21523. * @since 4.0.0
  21524. * @category Array
  21525. * @param {Array} array The array to inspect.
  21526. * @param {Function} [iteratee] The iteratee invoked per element.
  21527. * @returns {Array} Returns the new duplicate free array.
  21528. * @example
  21529. *
  21530. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  21531. * // => [1.1, 2.3]
  21532. */
  21533. function sortedUniqBy(array, iteratee) {
  21534. return (array && array.length)
  21535. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  21536. : [];
  21537. }
  21538. /**
  21539. * Gets all but the first element of `array`.
  21540. *
  21541. * @static
  21542. * @memberOf _
  21543. * @since 4.0.0
  21544. * @category Array
  21545. * @param {Array} array The array to query.
  21546. * @returns {Array} Returns the slice of `array`.
  21547. * @example
  21548. *
  21549. * _.tail([1, 2, 3]);
  21550. * // => [2, 3]
  21551. */
  21552. function tail(array) {
  21553. var length = array == null ? 0 : array.length;
  21554. return length ? baseSlice(array, 1, length) : [];
  21555. }
  21556. /**
  21557. * Creates a slice of `array` with `n` elements taken from the beginning.
  21558. *
  21559. * @static
  21560. * @memberOf _
  21561. * @since 0.1.0
  21562. * @category Array
  21563. * @param {Array} array The array to query.
  21564. * @param {number} [n=1] The number of elements to take.
  21565. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21566. * @returns {Array} Returns the slice of `array`.
  21567. * @example
  21568. *
  21569. * _.take([1, 2, 3]);
  21570. * // => [1]
  21571. *
  21572. * _.take([1, 2, 3], 2);
  21573. * // => [1, 2]
  21574. *
  21575. * _.take([1, 2, 3], 5);
  21576. * // => [1, 2, 3]
  21577. *
  21578. * _.take([1, 2, 3], 0);
  21579. * // => []
  21580. */
  21581. function take(array, n, guard) {
  21582. if (!(array && array.length)) {
  21583. return [];
  21584. }
  21585. n = (guard || n === undefined) ? 1 : toInteger(n);
  21586. return baseSlice(array, 0, n < 0 ? 0 : n);
  21587. }
  21588. /**
  21589. * Creates a slice of `array` with `n` elements taken from the end.
  21590. *
  21591. * @static
  21592. * @memberOf _
  21593. * @since 3.0.0
  21594. * @category Array
  21595. * @param {Array} array The array to query.
  21596. * @param {number} [n=1] The number of elements to take.
  21597. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21598. * @returns {Array} Returns the slice of `array`.
  21599. * @example
  21600. *
  21601. * _.takeRight([1, 2, 3]);
  21602. * // => [3]
  21603. *
  21604. * _.takeRight([1, 2, 3], 2);
  21605. * // => [2, 3]
  21606. *
  21607. * _.takeRight([1, 2, 3], 5);
  21608. * // => [1, 2, 3]
  21609. *
  21610. * _.takeRight([1, 2, 3], 0);
  21611. * // => []
  21612. */
  21613. function takeRight(array, n, guard) {
  21614. var length = array == null ? 0 : array.length;
  21615. if (!length) {
  21616. return [];
  21617. }
  21618. n = (guard || n === undefined) ? 1 : toInteger(n);
  21619. n = length - n;
  21620. return baseSlice(array, n < 0 ? 0 : n, length);
  21621. }
  21622. /**
  21623. * Creates a slice of `array` with elements taken from the end. Elements are
  21624. * taken until `predicate` returns falsey. The predicate is invoked with
  21625. * three arguments: (value, index, array).
  21626. *
  21627. * @static
  21628. * @memberOf _
  21629. * @since 3.0.0
  21630. * @category Array
  21631. * @param {Array} array The array to query.
  21632. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21633. * @returns {Array} Returns the slice of `array`.
  21634. * @example
  21635. *
  21636. * var users = [
  21637. * { 'user': 'barney', 'active': true },
  21638. * { 'user': 'fred', 'active': false },
  21639. * { 'user': 'pebbles', 'active': false }
  21640. * ];
  21641. *
  21642. * _.takeRightWhile(users, function(o) { return !o.active; });
  21643. * // => objects for ['fred', 'pebbles']
  21644. *
  21645. * // The `_.matches` iteratee shorthand.
  21646. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  21647. * // => objects for ['pebbles']
  21648. *
  21649. * // The `_.matchesProperty` iteratee shorthand.
  21650. * _.takeRightWhile(users, ['active', false]);
  21651. * // => objects for ['fred', 'pebbles']
  21652. *
  21653. * // The `_.property` iteratee shorthand.
  21654. * _.takeRightWhile(users, 'active');
  21655. * // => []
  21656. */
  21657. function takeRightWhile(array, predicate) {
  21658. return (array && array.length)
  21659. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  21660. : [];
  21661. }
  21662. /**
  21663. * Creates a slice of `array` with elements taken from the beginning. Elements
  21664. * are taken until `predicate` returns falsey. The predicate is invoked with
  21665. * three arguments: (value, index, array).
  21666. *
  21667. * @static
  21668. * @memberOf _
  21669. * @since 3.0.0
  21670. * @category Array
  21671. * @param {Array} array The array to query.
  21672. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21673. * @returns {Array} Returns the slice of `array`.
  21674. * @example
  21675. *
  21676. * var users = [
  21677. * { 'user': 'barney', 'active': false },
  21678. * { 'user': 'fred', 'active': false },
  21679. * { 'user': 'pebbles', 'active': true }
  21680. * ];
  21681. *
  21682. * _.takeWhile(users, function(o) { return !o.active; });
  21683. * // => objects for ['barney', 'fred']
  21684. *
  21685. * // The `_.matches` iteratee shorthand.
  21686. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  21687. * // => objects for ['barney']
  21688. *
  21689. * // The `_.matchesProperty` iteratee shorthand.
  21690. * _.takeWhile(users, ['active', false]);
  21691. * // => objects for ['barney', 'fred']
  21692. *
  21693. * // The `_.property` iteratee shorthand.
  21694. * _.takeWhile(users, 'active');
  21695. * // => []
  21696. */
  21697. function takeWhile(array, predicate) {
  21698. return (array && array.length)
  21699. ? baseWhile(array, getIteratee(predicate, 3))
  21700. : [];
  21701. }
  21702. /**
  21703. * Creates an array of unique values, in order, from all given arrays using
  21704. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21705. * for equality comparisons.
  21706. *
  21707. * @static
  21708. * @memberOf _
  21709. * @since 0.1.0
  21710. * @category Array
  21711. * @param {...Array} [arrays] The arrays to inspect.
  21712. * @returns {Array} Returns the new array of combined values.
  21713. * @example
  21714. *
  21715. * _.union([2], [1, 2]);
  21716. * // => [2, 1]
  21717. */
  21718. var union = baseRest(function(arrays) {
  21719. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  21720. });
  21721. /**
  21722. * This method is like `_.union` except that it accepts `iteratee` which is
  21723. * invoked for each element of each `arrays` to generate the criterion by
  21724. * which uniqueness is computed. Result values are chosen from the first
  21725. * array in which the value occurs. The iteratee is invoked with one argument:
  21726. * (value).
  21727. *
  21728. * @static
  21729. * @memberOf _
  21730. * @since 4.0.0
  21731. * @category Array
  21732. * @param {...Array} [arrays] The arrays to inspect.
  21733. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21734. * @returns {Array} Returns the new array of combined values.
  21735. * @example
  21736. *
  21737. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  21738. * // => [2.1, 1.2]
  21739. *
  21740. * // The `_.property` iteratee shorthand.
  21741. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21742. * // => [{ 'x': 1 }, { 'x': 2 }]
  21743. */
  21744. var unionBy = baseRest(function(arrays) {
  21745. var iteratee = last(arrays);
  21746. if (isArrayLikeObject(iteratee)) {
  21747. iteratee = undefined;
  21748. }
  21749. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  21750. });
  21751. /**
  21752. * This method is like `_.union` except that it accepts `comparator` which
  21753. * is invoked to compare elements of `arrays`. Result values are chosen from
  21754. * the first array in which the value occurs. The comparator is invoked
  21755. * with two arguments: (arrVal, othVal).
  21756. *
  21757. * @static
  21758. * @memberOf _
  21759. * @since 4.0.0
  21760. * @category Array
  21761. * @param {...Array} [arrays] The arrays to inspect.
  21762. * @param {Function} [comparator] The comparator invoked per element.
  21763. * @returns {Array} Returns the new array of combined values.
  21764. * @example
  21765. *
  21766. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21767. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21768. *
  21769. * _.unionWith(objects, others, _.isEqual);
  21770. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21771. */
  21772. var unionWith = baseRest(function(arrays) {
  21773. var comparator = last(arrays);
  21774. comparator = typeof comparator == 'function' ? comparator : undefined;
  21775. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  21776. });
  21777. /**
  21778. * Creates a duplicate-free version of an array, using
  21779. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21780. * for equality comparisons, in which only the first occurrence of each element
  21781. * is kept. The order of result values is determined by the order they occur
  21782. * in the array.
  21783. *
  21784. * @static
  21785. * @memberOf _
  21786. * @since 0.1.0
  21787. * @category Array
  21788. * @param {Array} array The array to inspect.
  21789. * @returns {Array} Returns the new duplicate free array.
  21790. * @example
  21791. *
  21792. * _.uniq([2, 1, 2]);
  21793. * // => [2, 1]
  21794. */
  21795. function uniq(array) {
  21796. return (array && array.length) ? baseUniq(array) : [];
  21797. }
  21798. /**
  21799. * This method is like `_.uniq` except that it accepts `iteratee` which is
  21800. * invoked for each element in `array` to generate the criterion by which
  21801. * uniqueness is computed. The order of result values is determined by the
  21802. * order they occur in the array. The iteratee is invoked with one argument:
  21803. * (value).
  21804. *
  21805. * @static
  21806. * @memberOf _
  21807. * @since 4.0.0
  21808. * @category Array
  21809. * @param {Array} array The array to inspect.
  21810. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21811. * @returns {Array} Returns the new duplicate free array.
  21812. * @example
  21813. *
  21814. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  21815. * // => [2.1, 1.2]
  21816. *
  21817. * // The `_.property` iteratee shorthand.
  21818. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  21819. * // => [{ 'x': 1 }, { 'x': 2 }]
  21820. */
  21821. function uniqBy(array, iteratee) {
  21822. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  21823. }
  21824. /**
  21825. * This method is like `_.uniq` except that it accepts `comparator` which
  21826. * is invoked to compare elements of `array`. The order of result values is
  21827. * determined by the order they occur in the array.The comparator is invoked
  21828. * with two arguments: (arrVal, othVal).
  21829. *
  21830. * @static
  21831. * @memberOf _
  21832. * @since 4.0.0
  21833. * @category Array
  21834. * @param {Array} array The array to inspect.
  21835. * @param {Function} [comparator] The comparator invoked per element.
  21836. * @returns {Array} Returns the new duplicate free array.
  21837. * @example
  21838. *
  21839. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21840. *
  21841. * _.uniqWith(objects, _.isEqual);
  21842. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  21843. */
  21844. function uniqWith(array, comparator) {
  21845. comparator = typeof comparator == 'function' ? comparator : undefined;
  21846. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  21847. }
  21848. /**
  21849. * This method is like `_.zip` except that it accepts an array of grouped
  21850. * elements and creates an array regrouping the elements to their pre-zip
  21851. * configuration.
  21852. *
  21853. * @static
  21854. * @memberOf _
  21855. * @since 1.2.0
  21856. * @category Array
  21857. * @param {Array} array The array of grouped elements to process.
  21858. * @returns {Array} Returns the new array of regrouped elements.
  21859. * @example
  21860. *
  21861. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  21862. * // => [['a', 1, true], ['b', 2, false]]
  21863. *
  21864. * _.unzip(zipped);
  21865. * // => [['a', 'b'], [1, 2], [true, false]]
  21866. */
  21867. function unzip(array) {
  21868. if (!(array && array.length)) {
  21869. return [];
  21870. }
  21871. var length = 0;
  21872. array = arrayFilter(array, function(group) {
  21873. if (isArrayLikeObject(group)) {
  21874. length = nativeMax(group.length, length);
  21875. return true;
  21876. }
  21877. });
  21878. return baseTimes(length, function(index) {
  21879. return arrayMap(array, baseProperty(index));
  21880. });
  21881. }
  21882. /**
  21883. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  21884. * how regrouped values should be combined. The iteratee is invoked with the
  21885. * elements of each group: (...group).
  21886. *
  21887. * @static
  21888. * @memberOf _
  21889. * @since 3.8.0
  21890. * @category Array
  21891. * @param {Array} array The array of grouped elements to process.
  21892. * @param {Function} [iteratee=_.identity] The function to combine
  21893. * regrouped values.
  21894. * @returns {Array} Returns the new array of regrouped elements.
  21895. * @example
  21896. *
  21897. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  21898. * // => [[1, 10, 100], [2, 20, 200]]
  21899. *
  21900. * _.unzipWith(zipped, _.add);
  21901. * // => [3, 30, 300]
  21902. */
  21903. function unzipWith(array, iteratee) {
  21904. if (!(array && array.length)) {
  21905. return [];
  21906. }
  21907. var result = unzip(array);
  21908. if (iteratee == null) {
  21909. return result;
  21910. }
  21911. return arrayMap(result, function(group) {
  21912. return apply(iteratee, undefined, group);
  21913. });
  21914. }
  21915. /**
  21916. * Creates an array excluding all given values using
  21917. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21918. * for equality comparisons.
  21919. *
  21920. * **Note:** Unlike `_.pull`, this method returns a new array.
  21921. *
  21922. * @static
  21923. * @memberOf _
  21924. * @since 0.1.0
  21925. * @category Array
  21926. * @param {Array} array The array to inspect.
  21927. * @param {...*} [values] The values to exclude.
  21928. * @returns {Array} Returns the new array of filtered values.
  21929. * @see _.difference, _.xor
  21930. * @example
  21931. *
  21932. * _.without([2, 1, 2, 3], 1, 2);
  21933. * // => [3]
  21934. */
  21935. var without = baseRest(function(array, values) {
  21936. return isArrayLikeObject(array)
  21937. ? baseDifference(array, values)
  21938. : [];
  21939. });
  21940. /**
  21941. * Creates an array of unique values that is the
  21942. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  21943. * of the given arrays. The order of result values is determined by the order
  21944. * they occur in the arrays.
  21945. *
  21946. * @static
  21947. * @memberOf _
  21948. * @since 2.4.0
  21949. * @category Array
  21950. * @param {...Array} [arrays] The arrays to inspect.
  21951. * @returns {Array} Returns the new array of filtered values.
  21952. * @see _.difference, _.without
  21953. * @example
  21954. *
  21955. * _.xor([2, 1], [2, 3]);
  21956. * // => [1, 3]
  21957. */
  21958. var xor = baseRest(function(arrays) {
  21959. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  21960. });
  21961. /**
  21962. * This method is like `_.xor` except that it accepts `iteratee` which is
  21963. * invoked for each element of each `arrays` to generate the criterion by
  21964. * which by which they're compared. The order of result values is determined
  21965. * by the order they occur in the arrays. The iteratee is invoked with one
  21966. * argument: (value).
  21967. *
  21968. * @static
  21969. * @memberOf _
  21970. * @since 4.0.0
  21971. * @category Array
  21972. * @param {...Array} [arrays] The arrays to inspect.
  21973. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21974. * @returns {Array} Returns the new array of filtered values.
  21975. * @example
  21976. *
  21977. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  21978. * // => [1.2, 3.4]
  21979. *
  21980. * // The `_.property` iteratee shorthand.
  21981. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21982. * // => [{ 'x': 2 }]
  21983. */
  21984. var xorBy = baseRest(function(arrays) {
  21985. var iteratee = last(arrays);
  21986. if (isArrayLikeObject(iteratee)) {
  21987. iteratee = undefined;
  21988. }
  21989. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  21990. });
  21991. /**
  21992. * This method is like `_.xor` except that it accepts `comparator` which is
  21993. * invoked to compare elements of `arrays`. The order of result values is
  21994. * determined by the order they occur in the arrays. The comparator is invoked
  21995. * with two arguments: (arrVal, othVal).
  21996. *
  21997. * @static
  21998. * @memberOf _
  21999. * @since 4.0.0
  22000. * @category Array
  22001. * @param {...Array} [arrays] The arrays to inspect.
  22002. * @param {Function} [comparator] The comparator invoked per element.
  22003. * @returns {Array} Returns the new array of filtered values.
  22004. * @example
  22005. *
  22006. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  22007. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  22008. *
  22009. * _.xorWith(objects, others, _.isEqual);
  22010. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  22011. */
  22012. var xorWith = baseRest(function(arrays) {
  22013. var comparator = last(arrays);
  22014. comparator = typeof comparator == 'function' ? comparator : undefined;
  22015. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  22016. });
  22017. /**
  22018. * Creates an array of grouped elements, the first of which contains the
  22019. * first elements of the given arrays, the second of which contains the
  22020. * second elements of the given arrays, and so on.
  22021. *
  22022. * @static
  22023. * @memberOf _
  22024. * @since 0.1.0
  22025. * @category Array
  22026. * @param {...Array} [arrays] The arrays to process.
  22027. * @returns {Array} Returns the new array of grouped elements.
  22028. * @example
  22029. *
  22030. * _.zip(['a', 'b'], [1, 2], [true, false]);
  22031. * // => [['a', 1, true], ['b', 2, false]]
  22032. */
  22033. var zip = baseRest(unzip);
  22034. /**
  22035. * This method is like `_.fromPairs` except that it accepts two arrays,
  22036. * one of property identifiers and one of corresponding values.
  22037. *
  22038. * @static
  22039. * @memberOf _
  22040. * @since 0.4.0
  22041. * @category Array
  22042. * @param {Array} [props=[]] The property identifiers.
  22043. * @param {Array} [values=[]] The property values.
  22044. * @returns {Object} Returns the new object.
  22045. * @example
  22046. *
  22047. * _.zipObject(['a', 'b'], [1, 2]);
  22048. * // => { 'a': 1, 'b': 2 }
  22049. */
  22050. function zipObject(props, values) {
  22051. return baseZipObject(props || [], values || [], assignValue);
  22052. }
  22053. /**
  22054. * This method is like `_.zipObject` except that it supports property paths.
  22055. *
  22056. * @static
  22057. * @memberOf _
  22058. * @since 4.1.0
  22059. * @category Array
  22060. * @param {Array} [props=[]] The property identifiers.
  22061. * @param {Array} [values=[]] The property values.
  22062. * @returns {Object} Returns the new object.
  22063. * @example
  22064. *
  22065. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  22066. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  22067. */
  22068. function zipObjectDeep(props, values) {
  22069. return baseZipObject(props || [], values || [], baseSet);
  22070. }
  22071. /**
  22072. * This method is like `_.zip` except that it accepts `iteratee` to specify
  22073. * how grouped values should be combined. The iteratee is invoked with the
  22074. * elements of each group: (...group).
  22075. *
  22076. * @static
  22077. * @memberOf _
  22078. * @since 3.8.0
  22079. * @category Array
  22080. * @param {...Array} [arrays] The arrays to process.
  22081. * @param {Function} [iteratee=_.identity] The function to combine
  22082. * grouped values.
  22083. * @returns {Array} Returns the new array of grouped elements.
  22084. * @example
  22085. *
  22086. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  22087. * return a + b + c;
  22088. * });
  22089. * // => [111, 222]
  22090. */
  22091. var zipWith = baseRest(function(arrays) {
  22092. var length = arrays.length,
  22093. iteratee = length > 1 ? arrays[length - 1] : undefined;
  22094. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  22095. return unzipWith(arrays, iteratee);
  22096. });
  22097. /*------------------------------------------------------------------------*/
  22098. /**
  22099. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  22100. * chain sequences enabled. The result of such sequences must be unwrapped
  22101. * with `_#value`.
  22102. *
  22103. * @static
  22104. * @memberOf _
  22105. * @since 1.3.0
  22106. * @category Seq
  22107. * @param {*} value The value to wrap.
  22108. * @returns {Object} Returns the new `lodash` wrapper instance.
  22109. * @example
  22110. *
  22111. * var users = [
  22112. * { 'user': 'barney', 'age': 36 },
  22113. * { 'user': 'fred', 'age': 40 },
  22114. * { 'user': 'pebbles', 'age': 1 }
  22115. * ];
  22116. *
  22117. * var youngest = _
  22118. * .chain(users)
  22119. * .sortBy('age')
  22120. * .map(function(o) {
  22121. * return o.user + ' is ' + o.age;
  22122. * })
  22123. * .head()
  22124. * .value();
  22125. * // => 'pebbles is 1'
  22126. */
  22127. function chain(value) {
  22128. var result = lodash(value);
  22129. result.__chain__ = true;
  22130. return result;
  22131. }
  22132. /**
  22133. * This method invokes `interceptor` and returns `value`. The interceptor
  22134. * is invoked with one argument; (value). The purpose of this method is to
  22135. * "tap into" a method chain sequence in order to modify intermediate results.
  22136. *
  22137. * @static
  22138. * @memberOf _
  22139. * @since 0.1.0
  22140. * @category Seq
  22141. * @param {*} value The value to provide to `interceptor`.
  22142. * @param {Function} interceptor The function to invoke.
  22143. * @returns {*} Returns `value`.
  22144. * @example
  22145. *
  22146. * _([1, 2, 3])
  22147. * .tap(function(array) {
  22148. * // Mutate input array.
  22149. * array.pop();
  22150. * })
  22151. * .reverse()
  22152. * .value();
  22153. * // => [2, 1]
  22154. */
  22155. function tap(value, interceptor) {
  22156. interceptor(value);
  22157. return value;
  22158. }
  22159. /**
  22160. * This method is like `_.tap` except that it returns the result of `interceptor`.
  22161. * The purpose of this method is to "pass thru" values replacing intermediate
  22162. * results in a method chain sequence.
  22163. *
  22164. * @static
  22165. * @memberOf _
  22166. * @since 3.0.0
  22167. * @category Seq
  22168. * @param {*} value The value to provide to `interceptor`.
  22169. * @param {Function} interceptor The function to invoke.
  22170. * @returns {*} Returns the result of `interceptor`.
  22171. * @example
  22172. *
  22173. * _(' abc ')
  22174. * .chain()
  22175. * .trim()
  22176. * .thru(function(value) {
  22177. * return [value];
  22178. * })
  22179. * .value();
  22180. * // => ['abc']
  22181. */
  22182. function thru(value, interceptor) {
  22183. return interceptor(value);
  22184. }
  22185. /**
  22186. * This method is the wrapper version of `_.at`.
  22187. *
  22188. * @name at
  22189. * @memberOf _
  22190. * @since 1.0.0
  22191. * @category Seq
  22192. * @param {...(string|string[])} [paths] The property paths to pick.
  22193. * @returns {Object} Returns the new `lodash` wrapper instance.
  22194. * @example
  22195. *
  22196. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  22197. *
  22198. * _(object).at(['a[0].b.c', 'a[1]']).value();
  22199. * // => [3, 4]
  22200. */
  22201. var wrapperAt = flatRest(function(paths) {
  22202. var length = paths.length,
  22203. start = length ? paths[0] : 0,
  22204. value = this.__wrapped__,
  22205. interceptor = function(object) { return baseAt(object, paths); };
  22206. if (length > 1 || this.__actions__.length ||
  22207. !(value instanceof LazyWrapper) || !isIndex(start)) {
  22208. return this.thru(interceptor);
  22209. }
  22210. value = value.slice(start, +start + (length ? 1 : 0));
  22211. value.__actions__.push({
  22212. 'func': thru,
  22213. 'args': [interceptor],
  22214. 'thisArg': undefined
  22215. });
  22216. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  22217. if (length && !array.length) {
  22218. array.push(undefined);
  22219. }
  22220. return array;
  22221. });
  22222. });
  22223. /**
  22224. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  22225. *
  22226. * @name chain
  22227. * @memberOf _
  22228. * @since 0.1.0
  22229. * @category Seq
  22230. * @returns {Object} Returns the new `lodash` wrapper instance.
  22231. * @example
  22232. *
  22233. * var users = [
  22234. * { 'user': 'barney', 'age': 36 },
  22235. * { 'user': 'fred', 'age': 40 }
  22236. * ];
  22237. *
  22238. * // A sequence without explicit chaining.
  22239. * _(users).head();
  22240. * // => { 'user': 'barney', 'age': 36 }
  22241. *
  22242. * // A sequence with explicit chaining.
  22243. * _(users)
  22244. * .chain()
  22245. * .head()
  22246. * .pick('user')
  22247. * .value();
  22248. * // => { 'user': 'barney' }
  22249. */
  22250. function wrapperChain() {
  22251. return chain(this);
  22252. }
  22253. /**
  22254. * Executes the chain sequence and returns the wrapped result.
  22255. *
  22256. * @name commit
  22257. * @memberOf _
  22258. * @since 3.2.0
  22259. * @category Seq
  22260. * @returns {Object} Returns the new `lodash` wrapper instance.
  22261. * @example
  22262. *
  22263. * var array = [1, 2];
  22264. * var wrapped = _(array).push(3);
  22265. *
  22266. * console.log(array);
  22267. * // => [1, 2]
  22268. *
  22269. * wrapped = wrapped.commit();
  22270. * console.log(array);
  22271. * // => [1, 2, 3]
  22272. *
  22273. * wrapped.last();
  22274. * // => 3
  22275. *
  22276. * console.log(array);
  22277. * // => [1, 2, 3]
  22278. */
  22279. function wrapperCommit() {
  22280. return new LodashWrapper(this.value(), this.__chain__);
  22281. }
  22282. /**
  22283. * Gets the next value on a wrapped object following the
  22284. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  22285. *
  22286. * @name next
  22287. * @memberOf _
  22288. * @since 4.0.0
  22289. * @category Seq
  22290. * @returns {Object} Returns the next iterator value.
  22291. * @example
  22292. *
  22293. * var wrapped = _([1, 2]);
  22294. *
  22295. * wrapped.next();
  22296. * // => { 'done': false, 'value': 1 }
  22297. *
  22298. * wrapped.next();
  22299. * // => { 'done': false, 'value': 2 }
  22300. *
  22301. * wrapped.next();
  22302. * // => { 'done': true, 'value': undefined }
  22303. */
  22304. function wrapperNext() {
  22305. if (this.__values__ === undefined) {
  22306. this.__values__ = toArray(this.value());
  22307. }
  22308. var done = this.__index__ >= this.__values__.length,
  22309. value = done ? undefined : this.__values__[this.__index__++];
  22310. return { 'done': done, 'value': value };
  22311. }
  22312. /**
  22313. * Enables the wrapper to be iterable.
  22314. *
  22315. * @name Symbol.iterator
  22316. * @memberOf _
  22317. * @since 4.0.0
  22318. * @category Seq
  22319. * @returns {Object} Returns the wrapper object.
  22320. * @example
  22321. *
  22322. * var wrapped = _([1, 2]);
  22323. *
  22324. * wrapped[Symbol.iterator]() === wrapped;
  22325. * // => true
  22326. *
  22327. * Array.from(wrapped);
  22328. * // => [1, 2]
  22329. */
  22330. function wrapperToIterator() {
  22331. return this;
  22332. }
  22333. /**
  22334. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  22335. *
  22336. * @name plant
  22337. * @memberOf _
  22338. * @since 3.2.0
  22339. * @category Seq
  22340. * @param {*} value The value to plant.
  22341. * @returns {Object} Returns the new `lodash` wrapper instance.
  22342. * @example
  22343. *
  22344. * function square(n) {
  22345. * return n * n;
  22346. * }
  22347. *
  22348. * var wrapped = _([1, 2]).map(square);
  22349. * var other = wrapped.plant([3, 4]);
  22350. *
  22351. * other.value();
  22352. * // => [9, 16]
  22353. *
  22354. * wrapped.value();
  22355. * // => [1, 4]
  22356. */
  22357. function wrapperPlant(value) {
  22358. var result,
  22359. parent = this;
  22360. while (parent instanceof baseLodash) {
  22361. var clone = wrapperClone(parent);
  22362. clone.__index__ = 0;
  22363. clone.__values__ = undefined;
  22364. if (result) {
  22365. previous.__wrapped__ = clone;
  22366. } else {
  22367. result = clone;
  22368. }
  22369. var previous = clone;
  22370. parent = parent.__wrapped__;
  22371. }
  22372. previous.__wrapped__ = value;
  22373. return result;
  22374. }
  22375. /**
  22376. * This method is the wrapper version of `_.reverse`.
  22377. *
  22378. * **Note:** This method mutates the wrapped array.
  22379. *
  22380. * @name reverse
  22381. * @memberOf _
  22382. * @since 0.1.0
  22383. * @category Seq
  22384. * @returns {Object} Returns the new `lodash` wrapper instance.
  22385. * @example
  22386. *
  22387. * var array = [1, 2, 3];
  22388. *
  22389. * _(array).reverse().value()
  22390. * // => [3, 2, 1]
  22391. *
  22392. * console.log(array);
  22393. * // => [3, 2, 1]
  22394. */
  22395. function wrapperReverse() {
  22396. var value = this.__wrapped__;
  22397. if (value instanceof LazyWrapper) {
  22398. var wrapped = value;
  22399. if (this.__actions__.length) {
  22400. wrapped = new LazyWrapper(this);
  22401. }
  22402. wrapped = wrapped.reverse();
  22403. wrapped.__actions__.push({
  22404. 'func': thru,
  22405. 'args': [reverse],
  22406. 'thisArg': undefined
  22407. });
  22408. return new LodashWrapper(wrapped, this.__chain__);
  22409. }
  22410. return this.thru(reverse);
  22411. }
  22412. /**
  22413. * Executes the chain sequence to resolve the unwrapped value.
  22414. *
  22415. * @name value
  22416. * @memberOf _
  22417. * @since 0.1.0
  22418. * @alias toJSON, valueOf
  22419. * @category Seq
  22420. * @returns {*} Returns the resolved unwrapped value.
  22421. * @example
  22422. *
  22423. * _([1, 2, 3]).value();
  22424. * // => [1, 2, 3]
  22425. */
  22426. function wrapperValue() {
  22427. return baseWrapperValue(this.__wrapped__, this.__actions__);
  22428. }
  22429. /*------------------------------------------------------------------------*/
  22430. /**
  22431. * Creates an object composed of keys generated from the results of running
  22432. * each element of `collection` thru `iteratee`. The corresponding value of
  22433. * each key is the number of times the key was returned by `iteratee`. The
  22434. * iteratee is invoked with one argument: (value).
  22435. *
  22436. * @static
  22437. * @memberOf _
  22438. * @since 0.5.0
  22439. * @category Collection
  22440. * @param {Array|Object} collection The collection to iterate over.
  22441. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22442. * @returns {Object} Returns the composed aggregate object.
  22443. * @example
  22444. *
  22445. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  22446. * // => { '4': 1, '6': 2 }
  22447. *
  22448. * // The `_.property` iteratee shorthand.
  22449. * _.countBy(['one', 'two', 'three'], 'length');
  22450. * // => { '3': 2, '5': 1 }
  22451. */
  22452. var countBy = createAggregator(function(result, value, key) {
  22453. if (hasOwnProperty.call(result, key)) {
  22454. ++result[key];
  22455. } else {
  22456. baseAssignValue(result, key, 1);
  22457. }
  22458. });
  22459. /**
  22460. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  22461. * Iteration is stopped once `predicate` returns falsey. The predicate is
  22462. * invoked with three arguments: (value, index|key, collection).
  22463. *
  22464. * **Note:** This method returns `true` for
  22465. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  22466. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  22467. * elements of empty collections.
  22468. *
  22469. * @static
  22470. * @memberOf _
  22471. * @since 0.1.0
  22472. * @category Collection
  22473. * @param {Array|Object} collection The collection to iterate over.
  22474. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22475. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22476. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  22477. * else `false`.
  22478. * @example
  22479. *
  22480. * _.every([true, 1, null, 'yes'], Boolean);
  22481. * // => false
  22482. *
  22483. * var users = [
  22484. * { 'user': 'barney', 'age': 36, 'active': false },
  22485. * { 'user': 'fred', 'age': 40, 'active': false }
  22486. * ];
  22487. *
  22488. * // The `_.matches` iteratee shorthand.
  22489. * _.every(users, { 'user': 'barney', 'active': false });
  22490. * // => false
  22491. *
  22492. * // The `_.matchesProperty` iteratee shorthand.
  22493. * _.every(users, ['active', false]);
  22494. * // => true
  22495. *
  22496. * // The `_.property` iteratee shorthand.
  22497. * _.every(users, 'active');
  22498. * // => false
  22499. */
  22500. function every(collection, predicate, guard) {
  22501. var func = isArray(collection) ? arrayEvery : baseEvery;
  22502. if (guard && isIterateeCall(collection, predicate, guard)) {
  22503. predicate = undefined;
  22504. }
  22505. return func(collection, getIteratee(predicate, 3));
  22506. }
  22507. /**
  22508. * Iterates over elements of `collection`, returning an array of all elements
  22509. * `predicate` returns truthy for. The predicate is invoked with three
  22510. * arguments: (value, index|key, collection).
  22511. *
  22512. * **Note:** Unlike `_.remove`, this method returns a new array.
  22513. *
  22514. * @static
  22515. * @memberOf _
  22516. * @since 0.1.0
  22517. * @category Collection
  22518. * @param {Array|Object} collection The collection to iterate over.
  22519. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22520. * @returns {Array} Returns the new filtered array.
  22521. * @see _.reject
  22522. * @example
  22523. *
  22524. * var users = [
  22525. * { 'user': 'barney', 'age': 36, 'active': true },
  22526. * { 'user': 'fred', 'age': 40, 'active': false }
  22527. * ];
  22528. *
  22529. * _.filter(users, function(o) { return !o.active; });
  22530. * // => objects for ['fred']
  22531. *
  22532. * // The `_.matches` iteratee shorthand.
  22533. * _.filter(users, { 'age': 36, 'active': true });
  22534. * // => objects for ['barney']
  22535. *
  22536. * // The `_.matchesProperty` iteratee shorthand.
  22537. * _.filter(users, ['active', false]);
  22538. * // => objects for ['fred']
  22539. *
  22540. * // The `_.property` iteratee shorthand.
  22541. * _.filter(users, 'active');
  22542. * // => objects for ['barney']
  22543. */
  22544. function filter(collection, predicate) {
  22545. var func = isArray(collection) ? arrayFilter : baseFilter;
  22546. return func(collection, getIteratee(predicate, 3));
  22547. }
  22548. /**
  22549. * Iterates over elements of `collection`, returning the first element
  22550. * `predicate` returns truthy for. The predicate is invoked with three
  22551. * arguments: (value, index|key, collection).
  22552. *
  22553. * @static
  22554. * @memberOf _
  22555. * @since 0.1.0
  22556. * @category Collection
  22557. * @param {Array|Object} collection The collection to inspect.
  22558. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22559. * @param {number} [fromIndex=0] The index to search from.
  22560. * @returns {*} Returns the matched element, else `undefined`.
  22561. * @example
  22562. *
  22563. * var users = [
  22564. * { 'user': 'barney', 'age': 36, 'active': true },
  22565. * { 'user': 'fred', 'age': 40, 'active': false },
  22566. * { 'user': 'pebbles', 'age': 1, 'active': true }
  22567. * ];
  22568. *
  22569. * _.find(users, function(o) { return o.age < 40; });
  22570. * // => object for 'barney'
  22571. *
  22572. * // The `_.matches` iteratee shorthand.
  22573. * _.find(users, { 'age': 1, 'active': true });
  22574. * // => object for 'pebbles'
  22575. *
  22576. * // The `_.matchesProperty` iteratee shorthand.
  22577. * _.find(users, ['active', false]);
  22578. * // => object for 'fred'
  22579. *
  22580. * // The `_.property` iteratee shorthand.
  22581. * _.find(users, 'active');
  22582. * // => object for 'barney'
  22583. */
  22584. var find = createFind(findIndex);
  22585. /**
  22586. * This method is like `_.find` except that it iterates over elements of
  22587. * `collection` from right to left.
  22588. *
  22589. * @static
  22590. * @memberOf _
  22591. * @since 2.0.0
  22592. * @category Collection
  22593. * @param {Array|Object} collection The collection to inspect.
  22594. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22595. * @param {number} [fromIndex=collection.length-1] The index to search from.
  22596. * @returns {*} Returns the matched element, else `undefined`.
  22597. * @example
  22598. *
  22599. * _.findLast([1, 2, 3, 4], function(n) {
  22600. * return n % 2 == 1;
  22601. * });
  22602. * // => 3
  22603. */
  22604. var findLast = createFind(findLastIndex);
  22605. /**
  22606. * Creates a flattened array of values by running each element in `collection`
  22607. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  22608. * with three arguments: (value, index|key, collection).
  22609. *
  22610. * @static
  22611. * @memberOf _
  22612. * @since 4.0.0
  22613. * @category Collection
  22614. * @param {Array|Object} collection The collection to iterate over.
  22615. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22616. * @returns {Array} Returns the new flattened array.
  22617. * @example
  22618. *
  22619. * function duplicate(n) {
  22620. * return [n, n];
  22621. * }
  22622. *
  22623. * _.flatMap([1, 2], duplicate);
  22624. * // => [1, 1, 2, 2]
  22625. */
  22626. function flatMap(collection, iteratee) {
  22627. return baseFlatten(map(collection, iteratee), 1);
  22628. }
  22629. /**
  22630. * This method is like `_.flatMap` except that it recursively flattens the
  22631. * mapped results.
  22632. *
  22633. * @static
  22634. * @memberOf _
  22635. * @since 4.7.0
  22636. * @category Collection
  22637. * @param {Array|Object} collection The collection to iterate over.
  22638. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22639. * @returns {Array} Returns the new flattened array.
  22640. * @example
  22641. *
  22642. * function duplicate(n) {
  22643. * return [[[n, n]]];
  22644. * }
  22645. *
  22646. * _.flatMapDeep([1, 2], duplicate);
  22647. * // => [1, 1, 2, 2]
  22648. */
  22649. function flatMapDeep(collection, iteratee) {
  22650. return baseFlatten(map(collection, iteratee), INFINITY);
  22651. }
  22652. /**
  22653. * This method is like `_.flatMap` except that it recursively flattens the
  22654. * mapped results up to `depth` times.
  22655. *
  22656. * @static
  22657. * @memberOf _
  22658. * @since 4.7.0
  22659. * @category Collection
  22660. * @param {Array|Object} collection The collection to iterate over.
  22661. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22662. * @param {number} [depth=1] The maximum recursion depth.
  22663. * @returns {Array} Returns the new flattened array.
  22664. * @example
  22665. *
  22666. * function duplicate(n) {
  22667. * return [[[n, n]]];
  22668. * }
  22669. *
  22670. * _.flatMapDepth([1, 2], duplicate, 2);
  22671. * // => [[1, 1], [2, 2]]
  22672. */
  22673. function flatMapDepth(collection, iteratee, depth) {
  22674. depth = depth === undefined ? 1 : toInteger(depth);
  22675. return baseFlatten(map(collection, iteratee), depth);
  22676. }
  22677. /**
  22678. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  22679. * The iteratee is invoked with three arguments: (value, index|key, collection).
  22680. * Iteratee functions may exit iteration early by explicitly returning `false`.
  22681. *
  22682. * **Note:** As with other "Collections" methods, objects with a "length"
  22683. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  22684. * or `_.forOwn` for object iteration.
  22685. *
  22686. * @static
  22687. * @memberOf _
  22688. * @since 0.1.0
  22689. * @alias each
  22690. * @category Collection
  22691. * @param {Array|Object} collection The collection to iterate over.
  22692. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22693. * @returns {Array|Object} Returns `collection`.
  22694. * @see _.forEachRight
  22695. * @example
  22696. *
  22697. * _.forEach([1, 2], function(value) {
  22698. * console.log(value);
  22699. * });
  22700. * // => Logs `1` then `2`.
  22701. *
  22702. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  22703. * console.log(key);
  22704. * });
  22705. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  22706. */
  22707. function forEach(collection, iteratee) {
  22708. var func = isArray(collection) ? arrayEach : baseEach;
  22709. return func(collection, getIteratee(iteratee, 3));
  22710. }
  22711. /**
  22712. * This method is like `_.forEach` except that it iterates over elements of
  22713. * `collection` from right to left.
  22714. *
  22715. * @static
  22716. * @memberOf _
  22717. * @since 2.0.0
  22718. * @alias eachRight
  22719. * @category Collection
  22720. * @param {Array|Object} collection The collection to iterate over.
  22721. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22722. * @returns {Array|Object} Returns `collection`.
  22723. * @see _.forEach
  22724. * @example
  22725. *
  22726. * _.forEachRight([1, 2], function(value) {
  22727. * console.log(value);
  22728. * });
  22729. * // => Logs `2` then `1`.
  22730. */
  22731. function forEachRight(collection, iteratee) {
  22732. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  22733. return func(collection, getIteratee(iteratee, 3));
  22734. }
  22735. /**
  22736. * Creates an object composed of keys generated from the results of running
  22737. * each element of `collection` thru `iteratee`. The order of grouped values
  22738. * is determined by the order they occur in `collection`. The corresponding
  22739. * value of each key is an array of elements responsible for generating the
  22740. * key. The iteratee is invoked with one argument: (value).
  22741. *
  22742. * @static
  22743. * @memberOf _
  22744. * @since 0.1.0
  22745. * @category Collection
  22746. * @param {Array|Object} collection The collection to iterate over.
  22747. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22748. * @returns {Object} Returns the composed aggregate object.
  22749. * @example
  22750. *
  22751. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  22752. * // => { '4': [4.2], '6': [6.1, 6.3] }
  22753. *
  22754. * // The `_.property` iteratee shorthand.
  22755. * _.groupBy(['one', 'two', 'three'], 'length');
  22756. * // => { '3': ['one', 'two'], '5': ['three'] }
  22757. */
  22758. var groupBy = createAggregator(function(result, value, key) {
  22759. if (hasOwnProperty.call(result, key)) {
  22760. result[key].push(value);
  22761. } else {
  22762. baseAssignValue(result, key, [value]);
  22763. }
  22764. });
  22765. /**
  22766. * Checks if `value` is in `collection`. If `collection` is a string, it's
  22767. * checked for a substring of `value`, otherwise
  22768. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  22769. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  22770. * the offset from the end of `collection`.
  22771. *
  22772. * @static
  22773. * @memberOf _
  22774. * @since 0.1.0
  22775. * @category Collection
  22776. * @param {Array|Object|string} collection The collection to inspect.
  22777. * @param {*} value The value to search for.
  22778. * @param {number} [fromIndex=0] The index to search from.
  22779. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22780. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  22781. * @example
  22782. *
  22783. * _.includes([1, 2, 3], 1);
  22784. * // => true
  22785. *
  22786. * _.includes([1, 2, 3], 1, 2);
  22787. * // => false
  22788. *
  22789. * _.includes({ 'a': 1, 'b': 2 }, 1);
  22790. * // => true
  22791. *
  22792. * _.includes('abcd', 'bc');
  22793. * // => true
  22794. */
  22795. function includes(collection, value, fromIndex, guard) {
  22796. collection = isArrayLike(collection) ? collection : values(collection);
  22797. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  22798. var length = collection.length;
  22799. if (fromIndex < 0) {
  22800. fromIndex = nativeMax(length + fromIndex, 0);
  22801. }
  22802. return isString(collection)
  22803. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  22804. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  22805. }
  22806. /**
  22807. * Invokes the method at `path` of each element in `collection`, returning
  22808. * an array of the results of each invoked method. Any additional arguments
  22809. * are provided to each invoked method. If `path` is a function, it's invoked
  22810. * for, and `this` bound to, each element in `collection`.
  22811. *
  22812. * @static
  22813. * @memberOf _
  22814. * @since 4.0.0
  22815. * @category Collection
  22816. * @param {Array|Object} collection The collection to iterate over.
  22817. * @param {Array|Function|string} path The path of the method to invoke or
  22818. * the function invoked per iteration.
  22819. * @param {...*} [args] The arguments to invoke each method with.
  22820. * @returns {Array} Returns the array of results.
  22821. * @example
  22822. *
  22823. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  22824. * // => [[1, 5, 7], [1, 2, 3]]
  22825. *
  22826. * _.invokeMap([123, 456], String.prototype.split, '');
  22827. * // => [['1', '2', '3'], ['4', '5', '6']]
  22828. */
  22829. var invokeMap = baseRest(function(collection, path, args) {
  22830. var index = -1,
  22831. isFunc = typeof path == 'function',
  22832. result = isArrayLike(collection) ? Array(collection.length) : [];
  22833. baseEach(collection, function(value) {
  22834. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  22835. });
  22836. return result;
  22837. });
  22838. /**
  22839. * Creates an object composed of keys generated from the results of running
  22840. * each element of `collection` thru `iteratee`. The corresponding value of
  22841. * each key is the last element responsible for generating the key. The
  22842. * iteratee is invoked with one argument: (value).
  22843. *
  22844. * @static
  22845. * @memberOf _
  22846. * @since 4.0.0
  22847. * @category Collection
  22848. * @param {Array|Object} collection The collection to iterate over.
  22849. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22850. * @returns {Object} Returns the composed aggregate object.
  22851. * @example
  22852. *
  22853. * var array = [
  22854. * { 'dir': 'left', 'code': 97 },
  22855. * { 'dir': 'right', 'code': 100 }
  22856. * ];
  22857. *
  22858. * _.keyBy(array, function(o) {
  22859. * return String.fromCharCode(o.code);
  22860. * });
  22861. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  22862. *
  22863. * _.keyBy(array, 'dir');
  22864. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  22865. */
  22866. var keyBy = createAggregator(function(result, value, key) {
  22867. baseAssignValue(result, key, value);
  22868. });
  22869. /**
  22870. * Creates an array of values by running each element in `collection` thru
  22871. * `iteratee`. The iteratee is invoked with three arguments:
  22872. * (value, index|key, collection).
  22873. *
  22874. * Many lodash methods are guarded to work as iteratees for methods like
  22875. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  22876. *
  22877. * The guarded methods are:
  22878. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  22879. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  22880. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  22881. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  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} [iteratee=_.identity] The function invoked per iteration.
  22889. * @returns {Array} Returns the new mapped array.
  22890. * @example
  22891. *
  22892. * function square(n) {
  22893. * return n * n;
  22894. * }
  22895. *
  22896. * _.map([4, 8], square);
  22897. * // => [16, 64]
  22898. *
  22899. * _.map({ 'a': 4, 'b': 8 }, square);
  22900. * // => [16, 64] (iteration order is not guaranteed)
  22901. *
  22902. * var users = [
  22903. * { 'user': 'barney' },
  22904. * { 'user': 'fred' }
  22905. * ];
  22906. *
  22907. * // The `_.property` iteratee shorthand.
  22908. * _.map(users, 'user');
  22909. * // => ['barney', 'fred']
  22910. */
  22911. function map(collection, iteratee) {
  22912. var func = isArray(collection) ? arrayMap : baseMap;
  22913. return func(collection, getIteratee(iteratee, 3));
  22914. }
  22915. /**
  22916. * This method is like `_.sortBy` except that it allows specifying the sort
  22917. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  22918. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  22919. * descending or "asc" for ascending sort order of corresponding values.
  22920. *
  22921. * @static
  22922. * @memberOf _
  22923. * @since 4.0.0
  22924. * @category Collection
  22925. * @param {Array|Object} collection The collection to iterate over.
  22926. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  22927. * The iteratees to sort by.
  22928. * @param {string[]} [orders] The sort orders of `iteratees`.
  22929. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22930. * @returns {Array} Returns the new sorted array.
  22931. * @example
  22932. *
  22933. * var users = [
  22934. * { 'user': 'fred', 'age': 48 },
  22935. * { 'user': 'barney', 'age': 34 },
  22936. * { 'user': 'fred', 'age': 40 },
  22937. * { 'user': 'barney', 'age': 36 }
  22938. * ];
  22939. *
  22940. * // Sort by `user` in ascending order and by `age` in descending order.
  22941. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  22942. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  22943. */
  22944. function orderBy(collection, iteratees, orders, guard) {
  22945. if (collection == null) {
  22946. return [];
  22947. }
  22948. if (!isArray(iteratees)) {
  22949. iteratees = iteratees == null ? [] : [iteratees];
  22950. }
  22951. orders = guard ? undefined : orders;
  22952. if (!isArray(orders)) {
  22953. orders = orders == null ? [] : [orders];
  22954. }
  22955. return baseOrderBy(collection, iteratees, orders);
  22956. }
  22957. /**
  22958. * Creates an array of elements split into two groups, the first of which
  22959. * contains elements `predicate` returns truthy for, the second of which
  22960. * contains elements `predicate` returns falsey for. The predicate is
  22961. * invoked with one argument: (value).
  22962. *
  22963. * @static
  22964. * @memberOf _
  22965. * @since 3.0.0
  22966. * @category Collection
  22967. * @param {Array|Object} collection The collection to iterate over.
  22968. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22969. * @returns {Array} Returns the array of grouped elements.
  22970. * @example
  22971. *
  22972. * var users = [
  22973. * { 'user': 'barney', 'age': 36, 'active': false },
  22974. * { 'user': 'fred', 'age': 40, 'active': true },
  22975. * { 'user': 'pebbles', 'age': 1, 'active': false }
  22976. * ];
  22977. *
  22978. * _.partition(users, function(o) { return o.active; });
  22979. * // => objects for [['fred'], ['barney', 'pebbles']]
  22980. *
  22981. * // The `_.matches` iteratee shorthand.
  22982. * _.partition(users, { 'age': 1, 'active': false });
  22983. * // => objects for [['pebbles'], ['barney', 'fred']]
  22984. *
  22985. * // The `_.matchesProperty` iteratee shorthand.
  22986. * _.partition(users, ['active', false]);
  22987. * // => objects for [['barney', 'pebbles'], ['fred']]
  22988. *
  22989. * // The `_.property` iteratee shorthand.
  22990. * _.partition(users, 'active');
  22991. * // => objects for [['fred'], ['barney', 'pebbles']]
  22992. */
  22993. var partition = createAggregator(function(result, value, key) {
  22994. result[key ? 0 : 1].push(value);
  22995. }, function() { return [[], []]; });
  22996. /**
  22997. * Reduces `collection` to a value which is the accumulated result of running
  22998. * each element in `collection` thru `iteratee`, where each successive
  22999. * invocation is supplied the return value of the previous. If `accumulator`
  23000. * is not given, the first element of `collection` is used as the initial
  23001. * value. The iteratee is invoked with four arguments:
  23002. * (accumulator, value, index|key, collection).
  23003. *
  23004. * Many lodash methods are guarded to work as iteratees for methods like
  23005. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  23006. *
  23007. * The guarded methods are:
  23008. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  23009. * and `sortBy`
  23010. *
  23011. * @static
  23012. * @memberOf _
  23013. * @since 0.1.0
  23014. * @category Collection
  23015. * @param {Array|Object} collection The collection to iterate over.
  23016. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  23017. * @param {*} [accumulator] The initial value.
  23018. * @returns {*} Returns the accumulated value.
  23019. * @see _.reduceRight
  23020. * @example
  23021. *
  23022. * _.reduce([1, 2], function(sum, n) {
  23023. * return sum + n;
  23024. * }, 0);
  23025. * // => 3
  23026. *
  23027. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  23028. * (result[value] || (result[value] = [])).push(key);
  23029. * return result;
  23030. * }, {});
  23031. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  23032. */
  23033. function reduce(collection, iteratee, accumulator) {
  23034. var func = isArray(collection) ? arrayReduce : baseReduce,
  23035. initAccum = arguments.length < 3;
  23036. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  23037. }
  23038. /**
  23039. * This method is like `_.reduce` except that it iterates over elements of
  23040. * `collection` from right to left.
  23041. *
  23042. * @static
  23043. * @memberOf _
  23044. * @since 0.1.0
  23045. * @category Collection
  23046. * @param {Array|Object} collection The collection to iterate over.
  23047. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  23048. * @param {*} [accumulator] The initial value.
  23049. * @returns {*} Returns the accumulated value.
  23050. * @see _.reduce
  23051. * @example
  23052. *
  23053. * var array = [[0, 1], [2, 3], [4, 5]];
  23054. *
  23055. * _.reduceRight(array, function(flattened, other) {
  23056. * return flattened.concat(other);
  23057. * }, []);
  23058. * // => [4, 5, 2, 3, 0, 1]
  23059. */
  23060. function reduceRight(collection, iteratee, accumulator) {
  23061. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  23062. initAccum = arguments.length < 3;
  23063. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  23064. }
  23065. /**
  23066. * The opposite of `_.filter`; this method returns the elements of `collection`
  23067. * that `predicate` does **not** return truthy for.
  23068. *
  23069. * @static
  23070. * @memberOf _
  23071. * @since 0.1.0
  23072. * @category Collection
  23073. * @param {Array|Object} collection The collection to iterate over.
  23074. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23075. * @returns {Array} Returns the new filtered array.
  23076. * @see _.filter
  23077. * @example
  23078. *
  23079. * var users = [
  23080. * { 'user': 'barney', 'age': 36, 'active': false },
  23081. * { 'user': 'fred', 'age': 40, 'active': true }
  23082. * ];
  23083. *
  23084. * _.reject(users, function(o) { return !o.active; });
  23085. * // => objects for ['fred']
  23086. *
  23087. * // The `_.matches` iteratee shorthand.
  23088. * _.reject(users, { 'age': 40, 'active': true });
  23089. * // => objects for ['barney']
  23090. *
  23091. * // The `_.matchesProperty` iteratee shorthand.
  23092. * _.reject(users, ['active', false]);
  23093. * // => objects for ['fred']
  23094. *
  23095. * // The `_.property` iteratee shorthand.
  23096. * _.reject(users, 'active');
  23097. * // => objects for ['barney']
  23098. */
  23099. function reject(collection, predicate) {
  23100. var func = isArray(collection) ? arrayFilter : baseFilter;
  23101. return func(collection, negate(getIteratee(predicate, 3)));
  23102. }
  23103. /**
  23104. * Gets a random element from `collection`.
  23105. *
  23106. * @static
  23107. * @memberOf _
  23108. * @since 2.0.0
  23109. * @category Collection
  23110. * @param {Array|Object} collection The collection to sample.
  23111. * @returns {*} Returns the random element.
  23112. * @example
  23113. *
  23114. * _.sample([1, 2, 3, 4]);
  23115. * // => 2
  23116. */
  23117. function sample(collection) {
  23118. var func = isArray(collection) ? arraySample : baseSample;
  23119. return func(collection);
  23120. }
  23121. /**
  23122. * Gets `n` random elements at unique keys from `collection` up to the
  23123. * size of `collection`.
  23124. *
  23125. * @static
  23126. * @memberOf _
  23127. * @since 4.0.0
  23128. * @category Collection
  23129. * @param {Array|Object} collection The collection to sample.
  23130. * @param {number} [n=1] The number of elements to sample.
  23131. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23132. * @returns {Array} Returns the random elements.
  23133. * @example
  23134. *
  23135. * _.sampleSize([1, 2, 3], 2);
  23136. * // => [3, 1]
  23137. *
  23138. * _.sampleSize([1, 2, 3], 4);
  23139. * // => [2, 3, 1]
  23140. */
  23141. function sampleSize(collection, n, guard) {
  23142. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  23143. n = 1;
  23144. } else {
  23145. n = toInteger(n);
  23146. }
  23147. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  23148. return func(collection, n);
  23149. }
  23150. /**
  23151. * Creates an array of shuffled values, using a version of the
  23152. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  23153. *
  23154. * @static
  23155. * @memberOf _
  23156. * @since 0.1.0
  23157. * @category Collection
  23158. * @param {Array|Object} collection The collection to shuffle.
  23159. * @returns {Array} Returns the new shuffled array.
  23160. * @example
  23161. *
  23162. * _.shuffle([1, 2, 3, 4]);
  23163. * // => [4, 1, 3, 2]
  23164. */
  23165. function shuffle(collection) {
  23166. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  23167. return func(collection);
  23168. }
  23169. /**
  23170. * Gets the size of `collection` by returning its length for array-like
  23171. * values or the number of own enumerable string keyed properties for objects.
  23172. *
  23173. * @static
  23174. * @memberOf _
  23175. * @since 0.1.0
  23176. * @category Collection
  23177. * @param {Array|Object|string} collection The collection to inspect.
  23178. * @returns {number} Returns the collection size.
  23179. * @example
  23180. *
  23181. * _.size([1, 2, 3]);
  23182. * // => 3
  23183. *
  23184. * _.size({ 'a': 1, 'b': 2 });
  23185. * // => 2
  23186. *
  23187. * _.size('pebbles');
  23188. * // => 7
  23189. */
  23190. function size(collection) {
  23191. if (collection == null) {
  23192. return 0;
  23193. }
  23194. if (isArrayLike(collection)) {
  23195. return isString(collection) ? stringSize(collection) : collection.length;
  23196. }
  23197. var tag = getTag(collection);
  23198. if (tag == mapTag || tag == setTag) {
  23199. return collection.size;
  23200. }
  23201. return baseKeys(collection).length;
  23202. }
  23203. /**
  23204. * Checks if `predicate` returns truthy for **any** element of `collection`.
  23205. * Iteration is stopped once `predicate` returns truthy. The predicate is
  23206. * invoked with three arguments: (value, index|key, collection).
  23207. *
  23208. * @static
  23209. * @memberOf _
  23210. * @since 0.1.0
  23211. * @category Collection
  23212. * @param {Array|Object} collection The collection to iterate over.
  23213. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23214. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23215. * @returns {boolean} Returns `true` if any element passes the predicate check,
  23216. * else `false`.
  23217. * @example
  23218. *
  23219. * _.some([null, 0, 'yes', false], Boolean);
  23220. * // => true
  23221. *
  23222. * var users = [
  23223. * { 'user': 'barney', 'active': true },
  23224. * { 'user': 'fred', 'active': false }
  23225. * ];
  23226. *
  23227. * // The `_.matches` iteratee shorthand.
  23228. * _.some(users, { 'user': 'barney', 'active': false });
  23229. * // => false
  23230. *
  23231. * // The `_.matchesProperty` iteratee shorthand.
  23232. * _.some(users, ['active', false]);
  23233. * // => true
  23234. *
  23235. * // The `_.property` iteratee shorthand.
  23236. * _.some(users, 'active');
  23237. * // => true
  23238. */
  23239. function some(collection, predicate, guard) {
  23240. var func = isArray(collection) ? arraySome : baseSome;
  23241. if (guard && isIterateeCall(collection, predicate, guard)) {
  23242. predicate = undefined;
  23243. }
  23244. return func(collection, getIteratee(predicate, 3));
  23245. }
  23246. /**
  23247. * Creates an array of elements, sorted in ascending order by the results of
  23248. * running each element in a collection thru each iteratee. This method
  23249. * performs a stable sort, that is, it preserves the original sort order of
  23250. * equal elements. The iteratees are invoked with one argument: (value).
  23251. *
  23252. * @static
  23253. * @memberOf _
  23254. * @since 0.1.0
  23255. * @category Collection
  23256. * @param {Array|Object} collection The collection to iterate over.
  23257. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  23258. * The iteratees to sort by.
  23259. * @returns {Array} Returns the new sorted array.
  23260. * @example
  23261. *
  23262. * var users = [
  23263. * { 'user': 'fred', 'age': 48 },
  23264. * { 'user': 'barney', 'age': 36 },
  23265. * { 'user': 'fred', 'age': 40 },
  23266. * { 'user': 'barney', 'age': 34 }
  23267. * ];
  23268. *
  23269. * _.sortBy(users, [function(o) { return o.user; }]);
  23270. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  23271. *
  23272. * _.sortBy(users, ['user', 'age']);
  23273. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  23274. */
  23275. var sortBy = baseRest(function(collection, iteratees) {
  23276. if (collection == null) {
  23277. return [];
  23278. }
  23279. var length = iteratees.length;
  23280. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  23281. iteratees = [];
  23282. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  23283. iteratees = [iteratees[0]];
  23284. }
  23285. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  23286. });
  23287. /*------------------------------------------------------------------------*/
  23288. /**
  23289. * Gets the timestamp of the number of milliseconds that have elapsed since
  23290. * the Unix epoch (1 January 1970 00:00:00 UTC).
  23291. *
  23292. * @static
  23293. * @memberOf _
  23294. * @since 2.4.0
  23295. * @category Date
  23296. * @returns {number} Returns the timestamp.
  23297. * @example
  23298. *
  23299. * _.defer(function(stamp) {
  23300. * console.log(_.now() - stamp);
  23301. * }, _.now());
  23302. * // => Logs the number of milliseconds it took for the deferred invocation.
  23303. */
  23304. var now = ctxNow || function() {
  23305. return root.Date.now();
  23306. };
  23307. /*------------------------------------------------------------------------*/
  23308. /**
  23309. * The opposite of `_.before`; this method creates a function that invokes
  23310. * `func` once it's called `n` or more times.
  23311. *
  23312. * @static
  23313. * @memberOf _
  23314. * @since 0.1.0
  23315. * @category Function
  23316. * @param {number} n The number of calls before `func` is invoked.
  23317. * @param {Function} func The function to restrict.
  23318. * @returns {Function} Returns the new restricted function.
  23319. * @example
  23320. *
  23321. * var saves = ['profile', 'settings'];
  23322. *
  23323. * var done = _.after(saves.length, function() {
  23324. * console.log('done saving!');
  23325. * });
  23326. *
  23327. * _.forEach(saves, function(type) {
  23328. * asyncSave({ 'type': type, 'complete': done });
  23329. * });
  23330. * // => Logs 'done saving!' after the two async saves have completed.
  23331. */
  23332. function after(n, func) {
  23333. if (typeof func != 'function') {
  23334. throw new TypeError(FUNC_ERROR_TEXT);
  23335. }
  23336. n = toInteger(n);
  23337. return function() {
  23338. if (--n < 1) {
  23339. return func.apply(this, arguments);
  23340. }
  23341. };
  23342. }
  23343. /**
  23344. * Creates a function that invokes `func`, with up to `n` arguments,
  23345. * ignoring any additional arguments.
  23346. *
  23347. * @static
  23348. * @memberOf _
  23349. * @since 3.0.0
  23350. * @category Function
  23351. * @param {Function} func The function to cap arguments for.
  23352. * @param {number} [n=func.length] The arity cap.
  23353. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23354. * @returns {Function} Returns the new capped function.
  23355. * @example
  23356. *
  23357. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  23358. * // => [6, 8, 10]
  23359. */
  23360. function ary(func, n, guard) {
  23361. n = guard ? undefined : n;
  23362. n = (func && n == null) ? func.length : n;
  23363. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  23364. }
  23365. /**
  23366. * Creates a function that invokes `func`, with the `this` binding and arguments
  23367. * of the created function, while it's called less than `n` times. Subsequent
  23368. * calls to the created function return the result of the last `func` invocation.
  23369. *
  23370. * @static
  23371. * @memberOf _
  23372. * @since 3.0.0
  23373. * @category Function
  23374. * @param {number} n The number of calls at which `func` is no longer invoked.
  23375. * @param {Function} func The function to restrict.
  23376. * @returns {Function} Returns the new restricted function.
  23377. * @example
  23378. *
  23379. * jQuery(element).on('click', _.before(5, addContactToList));
  23380. * // => Allows adding up to 4 contacts to the list.
  23381. */
  23382. function before(n, func) {
  23383. var result;
  23384. if (typeof func != 'function') {
  23385. throw new TypeError(FUNC_ERROR_TEXT);
  23386. }
  23387. n = toInteger(n);
  23388. return function() {
  23389. if (--n > 0) {
  23390. result = func.apply(this, arguments);
  23391. }
  23392. if (n <= 1) {
  23393. func = undefined;
  23394. }
  23395. return result;
  23396. };
  23397. }
  23398. /**
  23399. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  23400. * and `partials` prepended to the arguments it receives.
  23401. *
  23402. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  23403. * may be used as a placeholder for partially applied arguments.
  23404. *
  23405. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  23406. * property of bound functions.
  23407. *
  23408. * @static
  23409. * @memberOf _
  23410. * @since 0.1.0
  23411. * @category Function
  23412. * @param {Function} func The function to bind.
  23413. * @param {*} thisArg The `this` binding of `func`.
  23414. * @param {...*} [partials] The arguments to be partially applied.
  23415. * @returns {Function} Returns the new bound function.
  23416. * @example
  23417. *
  23418. * function greet(greeting, punctuation) {
  23419. * return greeting + ' ' + this.user + punctuation;
  23420. * }
  23421. *
  23422. * var object = { 'user': 'fred' };
  23423. *
  23424. * var bound = _.bind(greet, object, 'hi');
  23425. * bound('!');
  23426. * // => 'hi fred!'
  23427. *
  23428. * // Bound with placeholders.
  23429. * var bound = _.bind(greet, object, _, '!');
  23430. * bound('hi');
  23431. * // => 'hi fred!'
  23432. */
  23433. var bind = baseRest(function(func, thisArg, partials) {
  23434. var bitmask = WRAP_BIND_FLAG;
  23435. if (partials.length) {
  23436. var holders = replaceHolders(partials, getHolder(bind));
  23437. bitmask |= WRAP_PARTIAL_FLAG;
  23438. }
  23439. return createWrap(func, bitmask, thisArg, partials, holders);
  23440. });
  23441. /**
  23442. * Creates a function that invokes the method at `object[key]` with `partials`
  23443. * prepended to the arguments it receives.
  23444. *
  23445. * This method differs from `_.bind` by allowing bound functions to reference
  23446. * methods that may be redefined or don't yet exist. See
  23447. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  23448. * for more details.
  23449. *
  23450. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  23451. * builds, may be used as a placeholder for partially applied arguments.
  23452. *
  23453. * @static
  23454. * @memberOf _
  23455. * @since 0.10.0
  23456. * @category Function
  23457. * @param {Object} object The object to invoke the method on.
  23458. * @param {string} key The key of the method.
  23459. * @param {...*} [partials] The arguments to be partially applied.
  23460. * @returns {Function} Returns the new bound function.
  23461. * @example
  23462. *
  23463. * var object = {
  23464. * 'user': 'fred',
  23465. * 'greet': function(greeting, punctuation) {
  23466. * return greeting + ' ' + this.user + punctuation;
  23467. * }
  23468. * };
  23469. *
  23470. * var bound = _.bindKey(object, 'greet', 'hi');
  23471. * bound('!');
  23472. * // => 'hi fred!'
  23473. *
  23474. * object.greet = function(greeting, punctuation) {
  23475. * return greeting + 'ya ' + this.user + punctuation;
  23476. * };
  23477. *
  23478. * bound('!');
  23479. * // => 'hiya fred!'
  23480. *
  23481. * // Bound with placeholders.
  23482. * var bound = _.bindKey(object, 'greet', _, '!');
  23483. * bound('hi');
  23484. * // => 'hiya fred!'
  23485. */
  23486. var bindKey = baseRest(function(object, key, partials) {
  23487. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  23488. if (partials.length) {
  23489. var holders = replaceHolders(partials, getHolder(bindKey));
  23490. bitmask |= WRAP_PARTIAL_FLAG;
  23491. }
  23492. return createWrap(key, bitmask, object, partials, holders);
  23493. });
  23494. /**
  23495. * Creates a function that accepts arguments of `func` and either invokes
  23496. * `func` returning its result, if at least `arity` number of arguments have
  23497. * been provided, or returns a function that accepts the remaining `func`
  23498. * arguments, and so on. The arity of `func` may be specified if `func.length`
  23499. * is not sufficient.
  23500. *
  23501. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  23502. * may be used as a placeholder for provided arguments.
  23503. *
  23504. * **Note:** This method doesn't set the "length" property of curried functions.
  23505. *
  23506. * @static
  23507. * @memberOf _
  23508. * @since 2.0.0
  23509. * @category Function
  23510. * @param {Function} func The function to curry.
  23511. * @param {number} [arity=func.length] The arity of `func`.
  23512. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23513. * @returns {Function} Returns the new curried function.
  23514. * @example
  23515. *
  23516. * var abc = function(a, b, c) {
  23517. * return [a, b, c];
  23518. * };
  23519. *
  23520. * var curried = _.curry(abc);
  23521. *
  23522. * curried(1)(2)(3);
  23523. * // => [1, 2, 3]
  23524. *
  23525. * curried(1, 2)(3);
  23526. * // => [1, 2, 3]
  23527. *
  23528. * curried(1, 2, 3);
  23529. * // => [1, 2, 3]
  23530. *
  23531. * // Curried with placeholders.
  23532. * curried(1)(_, 3)(2);
  23533. * // => [1, 2, 3]
  23534. */
  23535. function curry(func, arity, guard) {
  23536. arity = guard ? undefined : arity;
  23537. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23538. result.placeholder = curry.placeholder;
  23539. return result;
  23540. }
  23541. /**
  23542. * This method is like `_.curry` except that arguments are applied to `func`
  23543. * in the manner of `_.partialRight` instead of `_.partial`.
  23544. *
  23545. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  23546. * builds, may be used as a placeholder for provided arguments.
  23547. *
  23548. * **Note:** This method doesn't set the "length" property of curried functions.
  23549. *
  23550. * @static
  23551. * @memberOf _
  23552. * @since 3.0.0
  23553. * @category Function
  23554. * @param {Function} func The function to curry.
  23555. * @param {number} [arity=func.length] The arity of `func`.
  23556. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23557. * @returns {Function} Returns the new curried function.
  23558. * @example
  23559. *
  23560. * var abc = function(a, b, c) {
  23561. * return [a, b, c];
  23562. * };
  23563. *
  23564. * var curried = _.curryRight(abc);
  23565. *
  23566. * curried(3)(2)(1);
  23567. * // => [1, 2, 3]
  23568. *
  23569. * curried(2, 3)(1);
  23570. * // => [1, 2, 3]
  23571. *
  23572. * curried(1, 2, 3);
  23573. * // => [1, 2, 3]
  23574. *
  23575. * // Curried with placeholders.
  23576. * curried(3)(1, _)(2);
  23577. * // => [1, 2, 3]
  23578. */
  23579. function curryRight(func, arity, guard) {
  23580. arity = guard ? undefined : arity;
  23581. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23582. result.placeholder = curryRight.placeholder;
  23583. return result;
  23584. }
  23585. /**
  23586. * Creates a debounced function that delays invoking `func` until after `wait`
  23587. * milliseconds have elapsed since the last time the debounced function was
  23588. * invoked. The debounced function comes with a `cancel` method to cancel
  23589. * delayed `func` invocations and a `flush` method to immediately invoke them.
  23590. * Provide `options` to indicate whether `func` should be invoked on the
  23591. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  23592. * with the last arguments provided to the debounced function. Subsequent
  23593. * calls to the debounced function return the result of the last `func`
  23594. * invocation.
  23595. *
  23596. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23597. * invoked on the trailing edge of the timeout only if the debounced function
  23598. * is invoked more than once during the `wait` timeout.
  23599. *
  23600. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23601. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23602. *
  23603. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23604. * for details over the differences between `_.debounce` and `_.throttle`.
  23605. *
  23606. * @static
  23607. * @memberOf _
  23608. * @since 0.1.0
  23609. * @category Function
  23610. * @param {Function} func The function to debounce.
  23611. * @param {number} [wait=0] The number of milliseconds to delay.
  23612. * @param {Object} [options={}] The options object.
  23613. * @param {boolean} [options.leading=false]
  23614. * Specify invoking on the leading edge of the timeout.
  23615. * @param {number} [options.maxWait]
  23616. * The maximum time `func` is allowed to be delayed before it's invoked.
  23617. * @param {boolean} [options.trailing=true]
  23618. * Specify invoking on the trailing edge of the timeout.
  23619. * @returns {Function} Returns the new debounced function.
  23620. * @example
  23621. *
  23622. * // Avoid costly calculations while the window size is in flux.
  23623. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  23624. *
  23625. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  23626. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  23627. * 'leading': true,
  23628. * 'trailing': false
  23629. * }));
  23630. *
  23631. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  23632. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  23633. * var source = new EventSource('/stream');
  23634. * jQuery(source).on('message', debounced);
  23635. *
  23636. * // Cancel the trailing debounced invocation.
  23637. * jQuery(window).on('popstate', debounced.cancel);
  23638. */
  23639. function debounce(func, wait, options) {
  23640. var lastArgs,
  23641. lastThis,
  23642. maxWait,
  23643. result,
  23644. timerId,
  23645. lastCallTime,
  23646. lastInvokeTime = 0,
  23647. leading = false,
  23648. maxing = false,
  23649. trailing = true;
  23650. if (typeof func != 'function') {
  23651. throw new TypeError(FUNC_ERROR_TEXT);
  23652. }
  23653. wait = toNumber(wait) || 0;
  23654. if (isObject(options)) {
  23655. leading = !!options.leading;
  23656. maxing = 'maxWait' in options;
  23657. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  23658. trailing = 'trailing' in options ? !!options.trailing : trailing;
  23659. }
  23660. function invokeFunc(time) {
  23661. var args = lastArgs,
  23662. thisArg = lastThis;
  23663. lastArgs = lastThis = undefined;
  23664. lastInvokeTime = time;
  23665. result = func.apply(thisArg, args);
  23666. return result;
  23667. }
  23668. function leadingEdge(time) {
  23669. // Reset any `maxWait` timer.
  23670. lastInvokeTime = time;
  23671. // Start the timer for the trailing edge.
  23672. timerId = setTimeout(timerExpired, wait);
  23673. // Invoke the leading edge.
  23674. return leading ? invokeFunc(time) : result;
  23675. }
  23676. function remainingWait(time) {
  23677. var timeSinceLastCall = time - lastCallTime,
  23678. timeSinceLastInvoke = time - lastInvokeTime,
  23679. timeWaiting = wait - timeSinceLastCall;
  23680. return maxing
  23681. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  23682. : timeWaiting;
  23683. }
  23684. function shouldInvoke(time) {
  23685. var timeSinceLastCall = time - lastCallTime,
  23686. timeSinceLastInvoke = time - lastInvokeTime;
  23687. // Either this is the first call, activity has stopped and we're at the
  23688. // trailing edge, the system time has gone backwards and we're treating
  23689. // it as the trailing edge, or we've hit the `maxWait` limit.
  23690. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  23691. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  23692. }
  23693. function timerExpired() {
  23694. var time = now();
  23695. if (shouldInvoke(time)) {
  23696. return trailingEdge(time);
  23697. }
  23698. // Restart the timer.
  23699. timerId = setTimeout(timerExpired, remainingWait(time));
  23700. }
  23701. function trailingEdge(time) {
  23702. timerId = undefined;
  23703. // Only invoke if we have `lastArgs` which means `func` has been
  23704. // debounced at least once.
  23705. if (trailing && lastArgs) {
  23706. return invokeFunc(time);
  23707. }
  23708. lastArgs = lastThis = undefined;
  23709. return result;
  23710. }
  23711. function cancel() {
  23712. if (timerId !== undefined) {
  23713. clearTimeout(timerId);
  23714. }
  23715. lastInvokeTime = 0;
  23716. lastArgs = lastCallTime = lastThis = timerId = undefined;
  23717. }
  23718. function flush() {
  23719. return timerId === undefined ? result : trailingEdge(now());
  23720. }
  23721. function debounced() {
  23722. var time = now(),
  23723. isInvoking = shouldInvoke(time);
  23724. lastArgs = arguments;
  23725. lastThis = this;
  23726. lastCallTime = time;
  23727. if (isInvoking) {
  23728. if (timerId === undefined) {
  23729. return leadingEdge(lastCallTime);
  23730. }
  23731. if (maxing) {
  23732. // Handle invocations in a tight loop.
  23733. clearTimeout(timerId);
  23734. timerId = setTimeout(timerExpired, wait);
  23735. return invokeFunc(lastCallTime);
  23736. }
  23737. }
  23738. if (timerId === undefined) {
  23739. timerId = setTimeout(timerExpired, wait);
  23740. }
  23741. return result;
  23742. }
  23743. debounced.cancel = cancel;
  23744. debounced.flush = flush;
  23745. return debounced;
  23746. }
  23747. /**
  23748. * Defers invoking the `func` until the current call stack has cleared. Any
  23749. * additional arguments are provided to `func` when it's invoked.
  23750. *
  23751. * @static
  23752. * @memberOf _
  23753. * @since 0.1.0
  23754. * @category Function
  23755. * @param {Function} func The function to defer.
  23756. * @param {...*} [args] The arguments to invoke `func` with.
  23757. * @returns {number} Returns the timer id.
  23758. * @example
  23759. *
  23760. * _.defer(function(text) {
  23761. * console.log(text);
  23762. * }, 'deferred');
  23763. * // => Logs 'deferred' after one millisecond.
  23764. */
  23765. var defer = baseRest(function(func, args) {
  23766. return baseDelay(func, 1, args);
  23767. });
  23768. /**
  23769. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  23770. * provided to `func` when it's invoked.
  23771. *
  23772. * @static
  23773. * @memberOf _
  23774. * @since 0.1.0
  23775. * @category Function
  23776. * @param {Function} func The function to delay.
  23777. * @param {number} wait The number of milliseconds to delay invocation.
  23778. * @param {...*} [args] The arguments to invoke `func` with.
  23779. * @returns {number} Returns the timer id.
  23780. * @example
  23781. *
  23782. * _.delay(function(text) {
  23783. * console.log(text);
  23784. * }, 1000, 'later');
  23785. * // => Logs 'later' after one second.
  23786. */
  23787. var delay = baseRest(function(func, wait, args) {
  23788. return baseDelay(func, toNumber(wait) || 0, args);
  23789. });
  23790. /**
  23791. * Creates a function that invokes `func` with arguments reversed.
  23792. *
  23793. * @static
  23794. * @memberOf _
  23795. * @since 4.0.0
  23796. * @category Function
  23797. * @param {Function} func The function to flip arguments for.
  23798. * @returns {Function} Returns the new flipped function.
  23799. * @example
  23800. *
  23801. * var flipped = _.flip(function() {
  23802. * return _.toArray(arguments);
  23803. * });
  23804. *
  23805. * flipped('a', 'b', 'c', 'd');
  23806. * // => ['d', 'c', 'b', 'a']
  23807. */
  23808. function flip(func) {
  23809. return createWrap(func, WRAP_FLIP_FLAG);
  23810. }
  23811. /**
  23812. * Creates a function that memoizes the result of `func`. If `resolver` is
  23813. * provided, it determines the cache key for storing the result based on the
  23814. * arguments provided to the memoized function. By default, the first argument
  23815. * provided to the memoized function is used as the map cache key. The `func`
  23816. * is invoked with the `this` binding of the memoized function.
  23817. *
  23818. * **Note:** The cache is exposed as the `cache` property on the memoized
  23819. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  23820. * constructor with one whose instances implement the
  23821. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  23822. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  23823. *
  23824. * @static
  23825. * @memberOf _
  23826. * @since 0.1.0
  23827. * @category Function
  23828. * @param {Function} func The function to have its output memoized.
  23829. * @param {Function} [resolver] The function to resolve the cache key.
  23830. * @returns {Function} Returns the new memoized function.
  23831. * @example
  23832. *
  23833. * var object = { 'a': 1, 'b': 2 };
  23834. * var other = { 'c': 3, 'd': 4 };
  23835. *
  23836. * var values = _.memoize(_.values);
  23837. * values(object);
  23838. * // => [1, 2]
  23839. *
  23840. * values(other);
  23841. * // => [3, 4]
  23842. *
  23843. * object.a = 2;
  23844. * values(object);
  23845. * // => [1, 2]
  23846. *
  23847. * // Modify the result cache.
  23848. * values.cache.set(object, ['a', 'b']);
  23849. * values(object);
  23850. * // => ['a', 'b']
  23851. *
  23852. * // Replace `_.memoize.Cache`.
  23853. * _.memoize.Cache = WeakMap;
  23854. */
  23855. function memoize(func, resolver) {
  23856. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  23857. throw new TypeError(FUNC_ERROR_TEXT);
  23858. }
  23859. var memoized = function() {
  23860. var args = arguments,
  23861. key = resolver ? resolver.apply(this, args) : args[0],
  23862. cache = memoized.cache;
  23863. if (cache.has(key)) {
  23864. return cache.get(key);
  23865. }
  23866. var result = func.apply(this, args);
  23867. memoized.cache = cache.set(key, result) || cache;
  23868. return result;
  23869. };
  23870. memoized.cache = new (memoize.Cache || MapCache);
  23871. return memoized;
  23872. }
  23873. // Expose `MapCache`.
  23874. memoize.Cache = MapCache;
  23875. /**
  23876. * Creates a function that negates the result of the predicate `func`. The
  23877. * `func` predicate is invoked with the `this` binding and arguments of the
  23878. * created function.
  23879. *
  23880. * @static
  23881. * @memberOf _
  23882. * @since 3.0.0
  23883. * @category Function
  23884. * @param {Function} predicate The predicate to negate.
  23885. * @returns {Function} Returns the new negated function.
  23886. * @example
  23887. *
  23888. * function isEven(n) {
  23889. * return n % 2 == 0;
  23890. * }
  23891. *
  23892. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  23893. * // => [1, 3, 5]
  23894. */
  23895. function negate(predicate) {
  23896. if (typeof predicate != 'function') {
  23897. throw new TypeError(FUNC_ERROR_TEXT);
  23898. }
  23899. return function() {
  23900. var args = arguments;
  23901. switch (args.length) {
  23902. case 0: return !predicate.call(this);
  23903. case 1: return !predicate.call(this, args[0]);
  23904. case 2: return !predicate.call(this, args[0], args[1]);
  23905. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  23906. }
  23907. return !predicate.apply(this, args);
  23908. };
  23909. }
  23910. /**
  23911. * Creates a function that is restricted to invoking `func` once. Repeat calls
  23912. * to the function return the value of the first invocation. The `func` is
  23913. * invoked with the `this` binding and arguments of the created function.
  23914. *
  23915. * @static
  23916. * @memberOf _
  23917. * @since 0.1.0
  23918. * @category Function
  23919. * @param {Function} func The function to restrict.
  23920. * @returns {Function} Returns the new restricted function.
  23921. * @example
  23922. *
  23923. * var initialize = _.once(createApplication);
  23924. * initialize();
  23925. * initialize();
  23926. * // => `createApplication` is invoked once
  23927. */
  23928. function once(func) {
  23929. return before(2, func);
  23930. }
  23931. /**
  23932. * Creates a function that invokes `func` with its arguments transformed.
  23933. *
  23934. * @static
  23935. * @since 4.0.0
  23936. * @memberOf _
  23937. * @category Function
  23938. * @param {Function} func The function to wrap.
  23939. * @param {...(Function|Function[])} [transforms=[_.identity]]
  23940. * The argument transforms.
  23941. * @returns {Function} Returns the new function.
  23942. * @example
  23943. *
  23944. * function doubled(n) {
  23945. * return n * 2;
  23946. * }
  23947. *
  23948. * function square(n) {
  23949. * return n * n;
  23950. * }
  23951. *
  23952. * var func = _.overArgs(function(x, y) {
  23953. * return [x, y];
  23954. * }, [square, doubled]);
  23955. *
  23956. * func(9, 3);
  23957. * // => [81, 6]
  23958. *
  23959. * func(10, 5);
  23960. * // => [100, 10]
  23961. */
  23962. var overArgs = castRest(function(func, transforms) {
  23963. transforms = (transforms.length == 1 && isArray(transforms[0]))
  23964. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  23965. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  23966. var funcsLength = transforms.length;
  23967. return baseRest(function(args) {
  23968. var index = -1,
  23969. length = nativeMin(args.length, funcsLength);
  23970. while (++index < length) {
  23971. args[index] = transforms[index].call(this, args[index]);
  23972. }
  23973. return apply(func, this, args);
  23974. });
  23975. });
  23976. /**
  23977. * Creates a function that invokes `func` with `partials` prepended to the
  23978. * arguments it receives. This method is like `_.bind` except it does **not**
  23979. * alter the `this` binding.
  23980. *
  23981. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  23982. * builds, may be used as a placeholder for partially applied arguments.
  23983. *
  23984. * **Note:** This method doesn't set the "length" property of partially
  23985. * applied functions.
  23986. *
  23987. * @static
  23988. * @memberOf _
  23989. * @since 0.2.0
  23990. * @category Function
  23991. * @param {Function} func The function to partially apply arguments to.
  23992. * @param {...*} [partials] The arguments to be partially applied.
  23993. * @returns {Function} Returns the new partially applied function.
  23994. * @example
  23995. *
  23996. * function greet(greeting, name) {
  23997. * return greeting + ' ' + name;
  23998. * }
  23999. *
  24000. * var sayHelloTo = _.partial(greet, 'hello');
  24001. * sayHelloTo('fred');
  24002. * // => 'hello fred'
  24003. *
  24004. * // Partially applied with placeholders.
  24005. * var greetFred = _.partial(greet, _, 'fred');
  24006. * greetFred('hi');
  24007. * // => 'hi fred'
  24008. */
  24009. var partial = baseRest(function(func, partials) {
  24010. var holders = replaceHolders(partials, getHolder(partial));
  24011. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  24012. });
  24013. /**
  24014. * This method is like `_.partial` except that partially applied arguments
  24015. * are appended to the arguments it receives.
  24016. *
  24017. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  24018. * builds, may be used as a placeholder for partially applied arguments.
  24019. *
  24020. * **Note:** This method doesn't set the "length" property of partially
  24021. * applied functions.
  24022. *
  24023. * @static
  24024. * @memberOf _
  24025. * @since 1.0.0
  24026. * @category Function
  24027. * @param {Function} func The function to partially apply arguments to.
  24028. * @param {...*} [partials] The arguments to be partially applied.
  24029. * @returns {Function} Returns the new partially applied function.
  24030. * @example
  24031. *
  24032. * function greet(greeting, name) {
  24033. * return greeting + ' ' + name;
  24034. * }
  24035. *
  24036. * var greetFred = _.partialRight(greet, 'fred');
  24037. * greetFred('hi');
  24038. * // => 'hi fred'
  24039. *
  24040. * // Partially applied with placeholders.
  24041. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  24042. * sayHelloTo('fred');
  24043. * // => 'hello fred'
  24044. */
  24045. var partialRight = baseRest(function(func, partials) {
  24046. var holders = replaceHolders(partials, getHolder(partialRight));
  24047. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  24048. });
  24049. /**
  24050. * Creates a function that invokes `func` with arguments arranged according
  24051. * to the specified `indexes` where the argument value at the first index is
  24052. * provided as the first argument, the argument value at the second index is
  24053. * provided as the second argument, and so on.
  24054. *
  24055. * @static
  24056. * @memberOf _
  24057. * @since 3.0.0
  24058. * @category Function
  24059. * @param {Function} func The function to rearrange arguments for.
  24060. * @param {...(number|number[])} indexes The arranged argument indexes.
  24061. * @returns {Function} Returns the new function.
  24062. * @example
  24063. *
  24064. * var rearged = _.rearg(function(a, b, c) {
  24065. * return [a, b, c];
  24066. * }, [2, 0, 1]);
  24067. *
  24068. * rearged('b', 'c', 'a')
  24069. * // => ['a', 'b', 'c']
  24070. */
  24071. var rearg = flatRest(function(func, indexes) {
  24072. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  24073. });
  24074. /**
  24075. * Creates a function that invokes `func` with the `this` binding of the
  24076. * created function and arguments from `start` and beyond provided as
  24077. * an array.
  24078. *
  24079. * **Note:** This method is based on the
  24080. * [rest parameter](https://mdn.io/rest_parameters).
  24081. *
  24082. * @static
  24083. * @memberOf _
  24084. * @since 4.0.0
  24085. * @category Function
  24086. * @param {Function} func The function to apply a rest parameter to.
  24087. * @param {number} [start=func.length-1] The start position of the rest parameter.
  24088. * @returns {Function} Returns the new function.
  24089. * @example
  24090. *
  24091. * var say = _.rest(function(what, names) {
  24092. * return what + ' ' + _.initial(names).join(', ') +
  24093. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  24094. * });
  24095. *
  24096. * say('hello', 'fred', 'barney', 'pebbles');
  24097. * // => 'hello fred, barney, & pebbles'
  24098. */
  24099. function rest(func, start) {
  24100. if (typeof func != 'function') {
  24101. throw new TypeError(FUNC_ERROR_TEXT);
  24102. }
  24103. start = start === undefined ? start : toInteger(start);
  24104. return baseRest(func, start);
  24105. }
  24106. /**
  24107. * Creates a function that invokes `func` with the `this` binding of the
  24108. * create function and an array of arguments much like
  24109. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  24110. *
  24111. * **Note:** This method is based on the
  24112. * [spread operator](https://mdn.io/spread_operator).
  24113. *
  24114. * @static
  24115. * @memberOf _
  24116. * @since 3.2.0
  24117. * @category Function
  24118. * @param {Function} func The function to spread arguments over.
  24119. * @param {number} [start=0] The start position of the spread.
  24120. * @returns {Function} Returns the new function.
  24121. * @example
  24122. *
  24123. * var say = _.spread(function(who, what) {
  24124. * return who + ' says ' + what;
  24125. * });
  24126. *
  24127. * say(['fred', 'hello']);
  24128. * // => 'fred says hello'
  24129. *
  24130. * var numbers = Promise.all([
  24131. * Promise.resolve(40),
  24132. * Promise.resolve(36)
  24133. * ]);
  24134. *
  24135. * numbers.then(_.spread(function(x, y) {
  24136. * return x + y;
  24137. * }));
  24138. * // => a Promise of 76
  24139. */
  24140. function spread(func, start) {
  24141. if (typeof func != 'function') {
  24142. throw new TypeError(FUNC_ERROR_TEXT);
  24143. }
  24144. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  24145. return baseRest(function(args) {
  24146. var array = args[start],
  24147. otherArgs = castSlice(args, 0, start);
  24148. if (array) {
  24149. arrayPush(otherArgs, array);
  24150. }
  24151. return apply(func, this, otherArgs);
  24152. });
  24153. }
  24154. /**
  24155. * Creates a throttled function that only invokes `func` at most once per
  24156. * every `wait` milliseconds. The throttled function comes with a `cancel`
  24157. * method to cancel delayed `func` invocations and a `flush` method to
  24158. * immediately invoke them. Provide `options` to indicate whether `func`
  24159. * should be invoked on the leading and/or trailing edge of the `wait`
  24160. * timeout. The `func` is invoked with the last arguments provided to the
  24161. * throttled function. Subsequent calls to the throttled function return the
  24162. * result of the last `func` invocation.
  24163. *
  24164. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  24165. * invoked on the trailing edge of the timeout only if the throttled function
  24166. * is invoked more than once during the `wait` timeout.
  24167. *
  24168. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  24169. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  24170. *
  24171. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  24172. * for details over the differences between `_.throttle` and `_.debounce`.
  24173. *
  24174. * @static
  24175. * @memberOf _
  24176. * @since 0.1.0
  24177. * @category Function
  24178. * @param {Function} func The function to throttle.
  24179. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  24180. * @param {Object} [options={}] The options object.
  24181. * @param {boolean} [options.leading=true]
  24182. * Specify invoking on the leading edge of the timeout.
  24183. * @param {boolean} [options.trailing=true]
  24184. * Specify invoking on the trailing edge of the timeout.
  24185. * @returns {Function} Returns the new throttled function.
  24186. * @example
  24187. *
  24188. * // Avoid excessively updating the position while scrolling.
  24189. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  24190. *
  24191. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  24192. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  24193. * jQuery(element).on('click', throttled);
  24194. *
  24195. * // Cancel the trailing throttled invocation.
  24196. * jQuery(window).on('popstate', throttled.cancel);
  24197. */
  24198. function throttle(func, wait, options) {
  24199. var leading = true,
  24200. trailing = true;
  24201. if (typeof func != 'function') {
  24202. throw new TypeError(FUNC_ERROR_TEXT);
  24203. }
  24204. if (isObject(options)) {
  24205. leading = 'leading' in options ? !!options.leading : leading;
  24206. trailing = 'trailing' in options ? !!options.trailing : trailing;
  24207. }
  24208. return debounce(func, wait, {
  24209. 'leading': leading,
  24210. 'maxWait': wait,
  24211. 'trailing': trailing
  24212. });
  24213. }
  24214. /**
  24215. * Creates a function that accepts up to one argument, ignoring any
  24216. * additional arguments.
  24217. *
  24218. * @static
  24219. * @memberOf _
  24220. * @since 4.0.0
  24221. * @category Function
  24222. * @param {Function} func The function to cap arguments for.
  24223. * @returns {Function} Returns the new capped function.
  24224. * @example
  24225. *
  24226. * _.map(['6', '8', '10'], _.unary(parseInt));
  24227. * // => [6, 8, 10]
  24228. */
  24229. function unary(func) {
  24230. return ary(func, 1);
  24231. }
  24232. /**
  24233. * Creates a function that provides `value` to `wrapper` as its first
  24234. * argument. Any additional arguments provided to the function are appended
  24235. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  24236. * binding of the created function.
  24237. *
  24238. * @static
  24239. * @memberOf _
  24240. * @since 0.1.0
  24241. * @category Function
  24242. * @param {*} value The value to wrap.
  24243. * @param {Function} [wrapper=identity] The wrapper function.
  24244. * @returns {Function} Returns the new function.
  24245. * @example
  24246. *
  24247. * var p = _.wrap(_.escape, function(func, text) {
  24248. * return '<p>' + func(text) + '</p>';
  24249. * });
  24250. *
  24251. * p('fred, barney, & pebbles');
  24252. * // => '<p>fred, barney, &amp; pebbles</p>'
  24253. */
  24254. function wrap(value, wrapper) {
  24255. return partial(castFunction(wrapper), value);
  24256. }
  24257. /*------------------------------------------------------------------------*/
  24258. /**
  24259. * Casts `value` as an array if it's not one.
  24260. *
  24261. * @static
  24262. * @memberOf _
  24263. * @since 4.4.0
  24264. * @category Lang
  24265. * @param {*} value The value to inspect.
  24266. * @returns {Array} Returns the cast array.
  24267. * @example
  24268. *
  24269. * _.castArray(1);
  24270. * // => [1]
  24271. *
  24272. * _.castArray({ 'a': 1 });
  24273. * // => [{ 'a': 1 }]
  24274. *
  24275. * _.castArray('abc');
  24276. * // => ['abc']
  24277. *
  24278. * _.castArray(null);
  24279. * // => [null]
  24280. *
  24281. * _.castArray(undefined);
  24282. * // => [undefined]
  24283. *
  24284. * _.castArray();
  24285. * // => []
  24286. *
  24287. * var array = [1, 2, 3];
  24288. * console.log(_.castArray(array) === array);
  24289. * // => true
  24290. */
  24291. function castArray() {
  24292. if (!arguments.length) {
  24293. return [];
  24294. }
  24295. var value = arguments[0];
  24296. return isArray(value) ? value : [value];
  24297. }
  24298. /**
  24299. * Creates a shallow clone of `value`.
  24300. *
  24301. * **Note:** This method is loosely based on the
  24302. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  24303. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  24304. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  24305. * arrays. The own enumerable properties of `arguments` objects are cloned
  24306. * as plain objects. An empty object is returned for uncloneable values such
  24307. * as error objects, functions, DOM nodes, and WeakMaps.
  24308. *
  24309. * @static
  24310. * @memberOf _
  24311. * @since 0.1.0
  24312. * @category Lang
  24313. * @param {*} value The value to clone.
  24314. * @returns {*} Returns the cloned value.
  24315. * @see _.cloneDeep
  24316. * @example
  24317. *
  24318. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24319. *
  24320. * var shallow = _.clone(objects);
  24321. * console.log(shallow[0] === objects[0]);
  24322. * // => true
  24323. */
  24324. function clone(value) {
  24325. return baseClone(value, CLONE_SYMBOLS_FLAG);
  24326. }
  24327. /**
  24328. * This method is like `_.clone` except that it accepts `customizer` which
  24329. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  24330. * cloning is handled by the method instead. The `customizer` is invoked with
  24331. * up to four arguments; (value [, index|key, object, stack]).
  24332. *
  24333. * @static
  24334. * @memberOf _
  24335. * @since 4.0.0
  24336. * @category Lang
  24337. * @param {*} value The value to clone.
  24338. * @param {Function} [customizer] The function to customize cloning.
  24339. * @returns {*} Returns the cloned value.
  24340. * @see _.cloneDeepWith
  24341. * @example
  24342. *
  24343. * function customizer(value) {
  24344. * if (_.isElement(value)) {
  24345. * return value.cloneNode(false);
  24346. * }
  24347. * }
  24348. *
  24349. * var el = _.cloneWith(document.body, customizer);
  24350. *
  24351. * console.log(el === document.body);
  24352. * // => false
  24353. * console.log(el.nodeName);
  24354. * // => 'BODY'
  24355. * console.log(el.childNodes.length);
  24356. * // => 0
  24357. */
  24358. function cloneWith(value, customizer) {
  24359. customizer = typeof customizer == 'function' ? customizer : undefined;
  24360. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  24361. }
  24362. /**
  24363. * This method is like `_.clone` except that it recursively clones `value`.
  24364. *
  24365. * @static
  24366. * @memberOf _
  24367. * @since 1.0.0
  24368. * @category Lang
  24369. * @param {*} value The value to recursively clone.
  24370. * @returns {*} Returns the deep cloned value.
  24371. * @see _.clone
  24372. * @example
  24373. *
  24374. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24375. *
  24376. * var deep = _.cloneDeep(objects);
  24377. * console.log(deep[0] === objects[0]);
  24378. * // => false
  24379. */
  24380. function cloneDeep(value) {
  24381. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  24382. }
  24383. /**
  24384. * This method is like `_.cloneWith` except that it recursively clones `value`.
  24385. *
  24386. * @static
  24387. * @memberOf _
  24388. * @since 4.0.0
  24389. * @category Lang
  24390. * @param {*} value The value to recursively clone.
  24391. * @param {Function} [customizer] The function to customize cloning.
  24392. * @returns {*} Returns the deep cloned value.
  24393. * @see _.cloneWith
  24394. * @example
  24395. *
  24396. * function customizer(value) {
  24397. * if (_.isElement(value)) {
  24398. * return value.cloneNode(true);
  24399. * }
  24400. * }
  24401. *
  24402. * var el = _.cloneDeepWith(document.body, customizer);
  24403. *
  24404. * console.log(el === document.body);
  24405. * // => false
  24406. * console.log(el.nodeName);
  24407. * // => 'BODY'
  24408. * console.log(el.childNodes.length);
  24409. * // => 20
  24410. */
  24411. function cloneDeepWith(value, customizer) {
  24412. customizer = typeof customizer == 'function' ? customizer : undefined;
  24413. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  24414. }
  24415. /**
  24416. * Checks if `object` conforms to `source` by invoking the predicate
  24417. * properties of `source` with the corresponding property values of `object`.
  24418. *
  24419. * **Note:** This method is equivalent to `_.conforms` when `source` is
  24420. * partially applied.
  24421. *
  24422. * @static
  24423. * @memberOf _
  24424. * @since 4.14.0
  24425. * @category Lang
  24426. * @param {Object} object The object to inspect.
  24427. * @param {Object} source The object of property predicates to conform to.
  24428. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  24429. * @example
  24430. *
  24431. * var object = { 'a': 1, 'b': 2 };
  24432. *
  24433. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  24434. * // => true
  24435. *
  24436. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  24437. * // => false
  24438. */
  24439. function conformsTo(object, source) {
  24440. return source == null || baseConformsTo(object, source, keys(source));
  24441. }
  24442. /**
  24443. * Performs a
  24444. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24445. * comparison between two values to determine if they are equivalent.
  24446. *
  24447. * @static
  24448. * @memberOf _
  24449. * @since 4.0.0
  24450. * @category Lang
  24451. * @param {*} value The value to compare.
  24452. * @param {*} other The other value to compare.
  24453. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24454. * @example
  24455. *
  24456. * var object = { 'a': 1 };
  24457. * var other = { 'a': 1 };
  24458. *
  24459. * _.eq(object, object);
  24460. * // => true
  24461. *
  24462. * _.eq(object, other);
  24463. * // => false
  24464. *
  24465. * _.eq('a', 'a');
  24466. * // => true
  24467. *
  24468. * _.eq('a', Object('a'));
  24469. * // => false
  24470. *
  24471. * _.eq(NaN, NaN);
  24472. * // => true
  24473. */
  24474. function eq(value, other) {
  24475. return value === other || (value !== value && other !== other);
  24476. }
  24477. /**
  24478. * Checks if `value` is greater than `other`.
  24479. *
  24480. * @static
  24481. * @memberOf _
  24482. * @since 3.9.0
  24483. * @category Lang
  24484. * @param {*} value The value to compare.
  24485. * @param {*} other The other value to compare.
  24486. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  24487. * else `false`.
  24488. * @see _.lt
  24489. * @example
  24490. *
  24491. * _.gt(3, 1);
  24492. * // => true
  24493. *
  24494. * _.gt(3, 3);
  24495. * // => false
  24496. *
  24497. * _.gt(1, 3);
  24498. * // => false
  24499. */
  24500. var gt = createRelationalOperation(baseGt);
  24501. /**
  24502. * Checks if `value` is greater than or equal to `other`.
  24503. *
  24504. * @static
  24505. * @memberOf _
  24506. * @since 3.9.0
  24507. * @category Lang
  24508. * @param {*} value The value to compare.
  24509. * @param {*} other The other value to compare.
  24510. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  24511. * `other`, else `false`.
  24512. * @see _.lte
  24513. * @example
  24514. *
  24515. * _.gte(3, 1);
  24516. * // => true
  24517. *
  24518. * _.gte(3, 3);
  24519. * // => true
  24520. *
  24521. * _.gte(1, 3);
  24522. * // => false
  24523. */
  24524. var gte = createRelationalOperation(function(value, other) {
  24525. return value >= other;
  24526. });
  24527. /**
  24528. * Checks if `value` is likely an `arguments` object.
  24529. *
  24530. * @static
  24531. * @memberOf _
  24532. * @since 0.1.0
  24533. * @category Lang
  24534. * @param {*} value The value to check.
  24535. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  24536. * else `false`.
  24537. * @example
  24538. *
  24539. * _.isArguments(function() { return arguments; }());
  24540. * // => true
  24541. *
  24542. * _.isArguments([1, 2, 3]);
  24543. * // => false
  24544. */
  24545. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  24546. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  24547. !propertyIsEnumerable.call(value, 'callee');
  24548. };
  24549. /**
  24550. * Checks if `value` is classified as an `Array` object.
  24551. *
  24552. * @static
  24553. * @memberOf _
  24554. * @since 0.1.0
  24555. * @category Lang
  24556. * @param {*} value The value to check.
  24557. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  24558. * @example
  24559. *
  24560. * _.isArray([1, 2, 3]);
  24561. * // => true
  24562. *
  24563. * _.isArray(document.body.children);
  24564. * // => false
  24565. *
  24566. * _.isArray('abc');
  24567. * // => false
  24568. *
  24569. * _.isArray(_.noop);
  24570. * // => false
  24571. */
  24572. var isArray = Array.isArray;
  24573. /**
  24574. * Checks if `value` is classified as an `ArrayBuffer` object.
  24575. *
  24576. * @static
  24577. * @memberOf _
  24578. * @since 4.3.0
  24579. * @category Lang
  24580. * @param {*} value The value to check.
  24581. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  24582. * @example
  24583. *
  24584. * _.isArrayBuffer(new ArrayBuffer(2));
  24585. * // => true
  24586. *
  24587. * _.isArrayBuffer(new Array(2));
  24588. * // => false
  24589. */
  24590. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  24591. /**
  24592. * Checks if `value` is array-like. A value is considered array-like if it's
  24593. * not a function and has a `value.length` that's an integer greater than or
  24594. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  24595. *
  24596. * @static
  24597. * @memberOf _
  24598. * @since 4.0.0
  24599. * @category Lang
  24600. * @param {*} value The value to check.
  24601. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  24602. * @example
  24603. *
  24604. * _.isArrayLike([1, 2, 3]);
  24605. * // => true
  24606. *
  24607. * _.isArrayLike(document.body.children);
  24608. * // => true
  24609. *
  24610. * _.isArrayLike('abc');
  24611. * // => true
  24612. *
  24613. * _.isArrayLike(_.noop);
  24614. * // => false
  24615. */
  24616. function isArrayLike(value) {
  24617. return value != null && isLength(value.length) && !isFunction(value);
  24618. }
  24619. /**
  24620. * This method is like `_.isArrayLike` except that it also checks if `value`
  24621. * is an object.
  24622. *
  24623. * @static
  24624. * @memberOf _
  24625. * @since 4.0.0
  24626. * @category Lang
  24627. * @param {*} value The value to check.
  24628. * @returns {boolean} Returns `true` if `value` is an array-like object,
  24629. * else `false`.
  24630. * @example
  24631. *
  24632. * _.isArrayLikeObject([1, 2, 3]);
  24633. * // => true
  24634. *
  24635. * _.isArrayLikeObject(document.body.children);
  24636. * // => true
  24637. *
  24638. * _.isArrayLikeObject('abc');
  24639. * // => false
  24640. *
  24641. * _.isArrayLikeObject(_.noop);
  24642. * // => false
  24643. */
  24644. function isArrayLikeObject(value) {
  24645. return isObjectLike(value) && isArrayLike(value);
  24646. }
  24647. /**
  24648. * Checks if `value` is classified as a boolean primitive or object.
  24649. *
  24650. * @static
  24651. * @memberOf _
  24652. * @since 0.1.0
  24653. * @category Lang
  24654. * @param {*} value The value to check.
  24655. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  24656. * @example
  24657. *
  24658. * _.isBoolean(false);
  24659. * // => true
  24660. *
  24661. * _.isBoolean(null);
  24662. * // => false
  24663. */
  24664. function isBoolean(value) {
  24665. return value === true || value === false ||
  24666. (isObjectLike(value) && baseGetTag(value) == boolTag);
  24667. }
  24668. /**
  24669. * Checks if `value` is a buffer.
  24670. *
  24671. * @static
  24672. * @memberOf _
  24673. * @since 4.3.0
  24674. * @category Lang
  24675. * @param {*} value The value to check.
  24676. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  24677. * @example
  24678. *
  24679. * _.isBuffer(new Buffer(2));
  24680. * // => true
  24681. *
  24682. * _.isBuffer(new Uint8Array(2));
  24683. * // => false
  24684. */
  24685. var isBuffer = nativeIsBuffer || stubFalse;
  24686. /**
  24687. * Checks if `value` is classified as a `Date` object.
  24688. *
  24689. * @static
  24690. * @memberOf _
  24691. * @since 0.1.0
  24692. * @category Lang
  24693. * @param {*} value The value to check.
  24694. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  24695. * @example
  24696. *
  24697. * _.isDate(new Date);
  24698. * // => true
  24699. *
  24700. * _.isDate('Mon April 23 2012');
  24701. * // => false
  24702. */
  24703. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  24704. /**
  24705. * Checks if `value` is likely a DOM element.
  24706. *
  24707. * @static
  24708. * @memberOf _
  24709. * @since 0.1.0
  24710. * @category Lang
  24711. * @param {*} value The value to check.
  24712. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  24713. * @example
  24714. *
  24715. * _.isElement(document.body);
  24716. * // => true
  24717. *
  24718. * _.isElement('<body>');
  24719. * // => false
  24720. */
  24721. function isElement(value) {
  24722. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  24723. }
  24724. /**
  24725. * Checks if `value` is an empty object, collection, map, or set.
  24726. *
  24727. * Objects are considered empty if they have no own enumerable string keyed
  24728. * properties.
  24729. *
  24730. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  24731. * jQuery-like collections are considered empty if they have a `length` of `0`.
  24732. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  24733. *
  24734. * @static
  24735. * @memberOf _
  24736. * @since 0.1.0
  24737. * @category Lang
  24738. * @param {*} value The value to check.
  24739. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  24740. * @example
  24741. *
  24742. * _.isEmpty(null);
  24743. * // => true
  24744. *
  24745. * _.isEmpty(true);
  24746. * // => true
  24747. *
  24748. * _.isEmpty(1);
  24749. * // => true
  24750. *
  24751. * _.isEmpty([1, 2, 3]);
  24752. * // => false
  24753. *
  24754. * _.isEmpty({ 'a': 1 });
  24755. * // => false
  24756. */
  24757. function isEmpty(value) {
  24758. if (value == null) {
  24759. return true;
  24760. }
  24761. if (isArrayLike(value) &&
  24762. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  24763. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  24764. return !value.length;
  24765. }
  24766. var tag = getTag(value);
  24767. if (tag == mapTag || tag == setTag) {
  24768. return !value.size;
  24769. }
  24770. if (isPrototype(value)) {
  24771. return !baseKeys(value).length;
  24772. }
  24773. for (var key in value) {
  24774. if (hasOwnProperty.call(value, key)) {
  24775. return false;
  24776. }
  24777. }
  24778. return true;
  24779. }
  24780. /**
  24781. * Performs a deep comparison between two values to determine if they are
  24782. * equivalent.
  24783. *
  24784. * **Note:** This method supports comparing arrays, array buffers, booleans,
  24785. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  24786. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  24787. * by their own, not inherited, enumerable properties. Functions and DOM
  24788. * nodes are compared by strict equality, i.e. `===`.
  24789. *
  24790. * @static
  24791. * @memberOf _
  24792. * @since 0.1.0
  24793. * @category Lang
  24794. * @param {*} value The value to compare.
  24795. * @param {*} other The other value to compare.
  24796. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24797. * @example
  24798. *
  24799. * var object = { 'a': 1 };
  24800. * var other = { 'a': 1 };
  24801. *
  24802. * _.isEqual(object, other);
  24803. * // => true
  24804. *
  24805. * object === other;
  24806. * // => false
  24807. */
  24808. function isEqual(value, other) {
  24809. return baseIsEqual(value, other);
  24810. }
  24811. /**
  24812. * This method is like `_.isEqual` except that it accepts `customizer` which
  24813. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24814. * are handled by the method instead. The `customizer` is invoked with up to
  24815. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  24816. *
  24817. * @static
  24818. * @memberOf _
  24819. * @since 4.0.0
  24820. * @category Lang
  24821. * @param {*} value The value to compare.
  24822. * @param {*} other The other value to compare.
  24823. * @param {Function} [customizer] The function to customize comparisons.
  24824. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24825. * @example
  24826. *
  24827. * function isGreeting(value) {
  24828. * return /^h(?:i|ello)$/.test(value);
  24829. * }
  24830. *
  24831. * function customizer(objValue, othValue) {
  24832. * if (isGreeting(objValue) && isGreeting(othValue)) {
  24833. * return true;
  24834. * }
  24835. * }
  24836. *
  24837. * var array = ['hello', 'goodbye'];
  24838. * var other = ['hi', 'goodbye'];
  24839. *
  24840. * _.isEqualWith(array, other, customizer);
  24841. * // => true
  24842. */
  24843. function isEqualWith(value, other, customizer) {
  24844. customizer = typeof customizer == 'function' ? customizer : undefined;
  24845. var result = customizer ? customizer(value, other) : undefined;
  24846. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  24847. }
  24848. /**
  24849. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  24850. * `SyntaxError`, `TypeError`, or `URIError` object.
  24851. *
  24852. * @static
  24853. * @memberOf _
  24854. * @since 3.0.0
  24855. * @category Lang
  24856. * @param {*} value The value to check.
  24857. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  24858. * @example
  24859. *
  24860. * _.isError(new Error);
  24861. * // => true
  24862. *
  24863. * _.isError(Error);
  24864. * // => false
  24865. */
  24866. function isError(value) {
  24867. if (!isObjectLike(value)) {
  24868. return false;
  24869. }
  24870. var tag = baseGetTag(value);
  24871. return tag == errorTag || tag == domExcTag ||
  24872. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  24873. }
  24874. /**
  24875. * Checks if `value` is a finite primitive number.
  24876. *
  24877. * **Note:** This method is based on
  24878. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  24879. *
  24880. * @static
  24881. * @memberOf _
  24882. * @since 0.1.0
  24883. * @category Lang
  24884. * @param {*} value The value to check.
  24885. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  24886. * @example
  24887. *
  24888. * _.isFinite(3);
  24889. * // => true
  24890. *
  24891. * _.isFinite(Number.MIN_VALUE);
  24892. * // => true
  24893. *
  24894. * _.isFinite(Infinity);
  24895. * // => false
  24896. *
  24897. * _.isFinite('3');
  24898. * // => false
  24899. */
  24900. function isFinite(value) {
  24901. return typeof value == 'number' && nativeIsFinite(value);
  24902. }
  24903. /**
  24904. * Checks if `value` is classified as a `Function` object.
  24905. *
  24906. * @static
  24907. * @memberOf _
  24908. * @since 0.1.0
  24909. * @category Lang
  24910. * @param {*} value The value to check.
  24911. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  24912. * @example
  24913. *
  24914. * _.isFunction(_);
  24915. * // => true
  24916. *
  24917. * _.isFunction(/abc/);
  24918. * // => false
  24919. */
  24920. function isFunction(value) {
  24921. if (!isObject(value)) {
  24922. return false;
  24923. }
  24924. // The use of `Object#toString` avoids issues with the `typeof` operator
  24925. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  24926. var tag = baseGetTag(value);
  24927. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  24928. }
  24929. /**
  24930. * Checks if `value` is an integer.
  24931. *
  24932. * **Note:** This method is based on
  24933. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  24934. *
  24935. * @static
  24936. * @memberOf _
  24937. * @since 4.0.0
  24938. * @category Lang
  24939. * @param {*} value The value to check.
  24940. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  24941. * @example
  24942. *
  24943. * _.isInteger(3);
  24944. * // => true
  24945. *
  24946. * _.isInteger(Number.MIN_VALUE);
  24947. * // => false
  24948. *
  24949. * _.isInteger(Infinity);
  24950. * // => false
  24951. *
  24952. * _.isInteger('3');
  24953. * // => false
  24954. */
  24955. function isInteger(value) {
  24956. return typeof value == 'number' && value == toInteger(value);
  24957. }
  24958. /**
  24959. * Checks if `value` is a valid array-like length.
  24960. *
  24961. * **Note:** This method is loosely based on
  24962. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  24963. *
  24964. * @static
  24965. * @memberOf _
  24966. * @since 4.0.0
  24967. * @category Lang
  24968. * @param {*} value The value to check.
  24969. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  24970. * @example
  24971. *
  24972. * _.isLength(3);
  24973. * // => true
  24974. *
  24975. * _.isLength(Number.MIN_VALUE);
  24976. * // => false
  24977. *
  24978. * _.isLength(Infinity);
  24979. * // => false
  24980. *
  24981. * _.isLength('3');
  24982. * // => false
  24983. */
  24984. function isLength(value) {
  24985. return typeof value == 'number' &&
  24986. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  24987. }
  24988. /**
  24989. * Checks if `value` is the
  24990. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  24991. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  24992. *
  24993. * @static
  24994. * @memberOf _
  24995. * @since 0.1.0
  24996. * @category Lang
  24997. * @param {*} value The value to check.
  24998. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  24999. * @example
  25000. *
  25001. * _.isObject({});
  25002. * // => true
  25003. *
  25004. * _.isObject([1, 2, 3]);
  25005. * // => true
  25006. *
  25007. * _.isObject(_.noop);
  25008. * // => true
  25009. *
  25010. * _.isObject(null);
  25011. * // => false
  25012. */
  25013. function isObject(value) {
  25014. var type = typeof value;
  25015. return value != null && (type == 'object' || type == 'function');
  25016. }
  25017. /**
  25018. * Checks if `value` is object-like. A value is object-like if it's not `null`
  25019. * and has a `typeof` result of "object".
  25020. *
  25021. * @static
  25022. * @memberOf _
  25023. * @since 4.0.0
  25024. * @category Lang
  25025. * @param {*} value The value to check.
  25026. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  25027. * @example
  25028. *
  25029. * _.isObjectLike({});
  25030. * // => true
  25031. *
  25032. * _.isObjectLike([1, 2, 3]);
  25033. * // => true
  25034. *
  25035. * _.isObjectLike(_.noop);
  25036. * // => false
  25037. *
  25038. * _.isObjectLike(null);
  25039. * // => false
  25040. */
  25041. function isObjectLike(value) {
  25042. return value != null && typeof value == 'object';
  25043. }
  25044. /**
  25045. * Checks if `value` is classified as a `Map` object.
  25046. *
  25047. * @static
  25048. * @memberOf _
  25049. * @since 4.3.0
  25050. * @category Lang
  25051. * @param {*} value The value to check.
  25052. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  25053. * @example
  25054. *
  25055. * _.isMap(new Map);
  25056. * // => true
  25057. *
  25058. * _.isMap(new WeakMap);
  25059. * // => false
  25060. */
  25061. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  25062. /**
  25063. * Performs a partial deep comparison between `object` and `source` to
  25064. * determine if `object` contains equivalent property values.
  25065. *
  25066. * **Note:** This method is equivalent to `_.matches` when `source` is
  25067. * partially applied.
  25068. *
  25069. * Partial comparisons will match empty array and empty object `source`
  25070. * values against any array or object value, respectively. See `_.isEqual`
  25071. * for a list of supported value comparisons.
  25072. *
  25073. * @static
  25074. * @memberOf _
  25075. * @since 3.0.0
  25076. * @category Lang
  25077. * @param {Object} object The object to inspect.
  25078. * @param {Object} source The object of property values to match.
  25079. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  25080. * @example
  25081. *
  25082. * var object = { 'a': 1, 'b': 2 };
  25083. *
  25084. * _.isMatch(object, { 'b': 2 });
  25085. * // => true
  25086. *
  25087. * _.isMatch(object, { 'b': 1 });
  25088. * // => false
  25089. */
  25090. function isMatch(object, source) {
  25091. return object === source || baseIsMatch(object, source, getMatchData(source));
  25092. }
  25093. /**
  25094. * This method is like `_.isMatch` except that it accepts `customizer` which
  25095. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  25096. * are handled by the method instead. The `customizer` is invoked with five
  25097. * arguments: (objValue, srcValue, index|key, object, source).
  25098. *
  25099. * @static
  25100. * @memberOf _
  25101. * @since 4.0.0
  25102. * @category Lang
  25103. * @param {Object} object The object to inspect.
  25104. * @param {Object} source The object of property values to match.
  25105. * @param {Function} [customizer] The function to customize comparisons.
  25106. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  25107. * @example
  25108. *
  25109. * function isGreeting(value) {
  25110. * return /^h(?:i|ello)$/.test(value);
  25111. * }
  25112. *
  25113. * function customizer(objValue, srcValue) {
  25114. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  25115. * return true;
  25116. * }
  25117. * }
  25118. *
  25119. * var object = { 'greeting': 'hello' };
  25120. * var source = { 'greeting': 'hi' };
  25121. *
  25122. * _.isMatchWith(object, source, customizer);
  25123. * // => true
  25124. */
  25125. function isMatchWith(object, source, customizer) {
  25126. customizer = typeof customizer == 'function' ? customizer : undefined;
  25127. return baseIsMatch(object, source, getMatchData(source), customizer);
  25128. }
  25129. /**
  25130. * Checks if `value` is `NaN`.
  25131. *
  25132. * **Note:** This method is based on
  25133. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  25134. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  25135. * `undefined` and other non-number values.
  25136. *
  25137. * @static
  25138. * @memberOf _
  25139. * @since 0.1.0
  25140. * @category Lang
  25141. * @param {*} value The value to check.
  25142. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  25143. * @example
  25144. *
  25145. * _.isNaN(NaN);
  25146. * // => true
  25147. *
  25148. * _.isNaN(new Number(NaN));
  25149. * // => true
  25150. *
  25151. * isNaN(undefined);
  25152. * // => true
  25153. *
  25154. * _.isNaN(undefined);
  25155. * // => false
  25156. */
  25157. function isNaN(value) {
  25158. // An `NaN` primitive is the only value that is not equal to itself.
  25159. // Perform the `toStringTag` check first to avoid errors with some
  25160. // ActiveX objects in IE.
  25161. return isNumber(value) && value != +value;
  25162. }
  25163. /**
  25164. * Checks if `value` is a pristine native function.
  25165. *
  25166. * **Note:** This method can't reliably detect native functions in the presence
  25167. * of the core-js package because core-js circumvents this kind of detection.
  25168. * Despite multiple requests, the core-js maintainer has made it clear: any
  25169. * attempt to fix the detection will be obstructed. As a result, we're left
  25170. * with little choice but to throw an error. Unfortunately, this also affects
  25171. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  25172. * which rely on core-js.
  25173. *
  25174. * @static
  25175. * @memberOf _
  25176. * @since 3.0.0
  25177. * @category Lang
  25178. * @param {*} value The value to check.
  25179. * @returns {boolean} Returns `true` if `value` is a native function,
  25180. * else `false`.
  25181. * @example
  25182. *
  25183. * _.isNative(Array.prototype.push);
  25184. * // => true
  25185. *
  25186. * _.isNative(_);
  25187. * // => false
  25188. */
  25189. function isNative(value) {
  25190. if (isMaskable(value)) {
  25191. throw new Error(CORE_ERROR_TEXT);
  25192. }
  25193. return baseIsNative(value);
  25194. }
  25195. /**
  25196. * Checks if `value` is `null`.
  25197. *
  25198. * @static
  25199. * @memberOf _
  25200. * @since 0.1.0
  25201. * @category Lang
  25202. * @param {*} value The value to check.
  25203. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  25204. * @example
  25205. *
  25206. * _.isNull(null);
  25207. * // => true
  25208. *
  25209. * _.isNull(void 0);
  25210. * // => false
  25211. */
  25212. function isNull(value) {
  25213. return value === null;
  25214. }
  25215. /**
  25216. * Checks if `value` is `null` or `undefined`.
  25217. *
  25218. * @static
  25219. * @memberOf _
  25220. * @since 4.0.0
  25221. * @category Lang
  25222. * @param {*} value The value to check.
  25223. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  25224. * @example
  25225. *
  25226. * _.isNil(null);
  25227. * // => true
  25228. *
  25229. * _.isNil(void 0);
  25230. * // => true
  25231. *
  25232. * _.isNil(NaN);
  25233. * // => false
  25234. */
  25235. function isNil(value) {
  25236. return value == null;
  25237. }
  25238. /**
  25239. * Checks if `value` is classified as a `Number` primitive or object.
  25240. *
  25241. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  25242. * classified as numbers, use the `_.isFinite` method.
  25243. *
  25244. * @static
  25245. * @memberOf _
  25246. * @since 0.1.0
  25247. * @category Lang
  25248. * @param {*} value The value to check.
  25249. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  25250. * @example
  25251. *
  25252. * _.isNumber(3);
  25253. * // => true
  25254. *
  25255. * _.isNumber(Number.MIN_VALUE);
  25256. * // => true
  25257. *
  25258. * _.isNumber(Infinity);
  25259. * // => true
  25260. *
  25261. * _.isNumber('3');
  25262. * // => false
  25263. */
  25264. function isNumber(value) {
  25265. return typeof value == 'number' ||
  25266. (isObjectLike(value) && baseGetTag(value) == numberTag);
  25267. }
  25268. /**
  25269. * Checks if `value` is a plain object, that is, an object created by the
  25270. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  25271. *
  25272. * @static
  25273. * @memberOf _
  25274. * @since 0.8.0
  25275. * @category Lang
  25276. * @param {*} value The value to check.
  25277. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  25278. * @example
  25279. *
  25280. * function Foo() {
  25281. * this.a = 1;
  25282. * }
  25283. *
  25284. * _.isPlainObject(new Foo);
  25285. * // => false
  25286. *
  25287. * _.isPlainObject([1, 2, 3]);
  25288. * // => false
  25289. *
  25290. * _.isPlainObject({ 'x': 0, 'y': 0 });
  25291. * // => true
  25292. *
  25293. * _.isPlainObject(Object.create(null));
  25294. * // => true
  25295. */
  25296. function isPlainObject(value) {
  25297. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  25298. return false;
  25299. }
  25300. var proto = getPrototype(value);
  25301. if (proto === null) {
  25302. return true;
  25303. }
  25304. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  25305. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  25306. funcToString.call(Ctor) == objectCtorString;
  25307. }
  25308. /**
  25309. * Checks if `value` is classified as a `RegExp` object.
  25310. *
  25311. * @static
  25312. * @memberOf _
  25313. * @since 0.1.0
  25314. * @category Lang
  25315. * @param {*} value The value to check.
  25316. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  25317. * @example
  25318. *
  25319. * _.isRegExp(/abc/);
  25320. * // => true
  25321. *
  25322. * _.isRegExp('/abc/');
  25323. * // => false
  25324. */
  25325. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  25326. /**
  25327. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  25328. * double precision number which isn't the result of a rounded unsafe integer.
  25329. *
  25330. * **Note:** This method is based on
  25331. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  25332. *
  25333. * @static
  25334. * @memberOf _
  25335. * @since 4.0.0
  25336. * @category Lang
  25337. * @param {*} value The value to check.
  25338. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  25339. * @example
  25340. *
  25341. * _.isSafeInteger(3);
  25342. * // => true
  25343. *
  25344. * _.isSafeInteger(Number.MIN_VALUE);
  25345. * // => false
  25346. *
  25347. * _.isSafeInteger(Infinity);
  25348. * // => false
  25349. *
  25350. * _.isSafeInteger('3');
  25351. * // => false
  25352. */
  25353. function isSafeInteger(value) {
  25354. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  25355. }
  25356. /**
  25357. * Checks if `value` is classified as a `Set` object.
  25358. *
  25359. * @static
  25360. * @memberOf _
  25361. * @since 4.3.0
  25362. * @category Lang
  25363. * @param {*} value The value to check.
  25364. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  25365. * @example
  25366. *
  25367. * _.isSet(new Set);
  25368. * // => true
  25369. *
  25370. * _.isSet(new WeakSet);
  25371. * // => false
  25372. */
  25373. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  25374. /**
  25375. * Checks if `value` is classified as a `String` primitive or object.
  25376. *
  25377. * @static
  25378. * @since 0.1.0
  25379. * @memberOf _
  25380. * @category Lang
  25381. * @param {*} value The value to check.
  25382. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  25383. * @example
  25384. *
  25385. * _.isString('abc');
  25386. * // => true
  25387. *
  25388. * _.isString(1);
  25389. * // => false
  25390. */
  25391. function isString(value) {
  25392. return typeof value == 'string' ||
  25393. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  25394. }
  25395. /**
  25396. * Checks if `value` is classified as a `Symbol` primitive or object.
  25397. *
  25398. * @static
  25399. * @memberOf _
  25400. * @since 4.0.0
  25401. * @category Lang
  25402. * @param {*} value The value to check.
  25403. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  25404. * @example
  25405. *
  25406. * _.isSymbol(Symbol.iterator);
  25407. * // => true
  25408. *
  25409. * _.isSymbol('abc');
  25410. * // => false
  25411. */
  25412. function isSymbol(value) {
  25413. return typeof value == 'symbol' ||
  25414. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  25415. }
  25416. /**
  25417. * Checks if `value` is classified as a typed array.
  25418. *
  25419. * @static
  25420. * @memberOf _
  25421. * @since 3.0.0
  25422. * @category Lang
  25423. * @param {*} value The value to check.
  25424. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  25425. * @example
  25426. *
  25427. * _.isTypedArray(new Uint8Array);
  25428. * // => true
  25429. *
  25430. * _.isTypedArray([]);
  25431. * // => false
  25432. */
  25433. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  25434. /**
  25435. * Checks if `value` is `undefined`.
  25436. *
  25437. * @static
  25438. * @since 0.1.0
  25439. * @memberOf _
  25440. * @category Lang
  25441. * @param {*} value The value to check.
  25442. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  25443. * @example
  25444. *
  25445. * _.isUndefined(void 0);
  25446. * // => true
  25447. *
  25448. * _.isUndefined(null);
  25449. * // => false
  25450. */
  25451. function isUndefined(value) {
  25452. return value === undefined;
  25453. }
  25454. /**
  25455. * Checks if `value` is classified as a `WeakMap` object.
  25456. *
  25457. * @static
  25458. * @memberOf _
  25459. * @since 4.3.0
  25460. * @category Lang
  25461. * @param {*} value The value to check.
  25462. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  25463. * @example
  25464. *
  25465. * _.isWeakMap(new WeakMap);
  25466. * // => true
  25467. *
  25468. * _.isWeakMap(new Map);
  25469. * // => false
  25470. */
  25471. function isWeakMap(value) {
  25472. return isObjectLike(value) && getTag(value) == weakMapTag;
  25473. }
  25474. /**
  25475. * Checks if `value` is classified as a `WeakSet` object.
  25476. *
  25477. * @static
  25478. * @memberOf _
  25479. * @since 4.3.0
  25480. * @category Lang
  25481. * @param {*} value The value to check.
  25482. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  25483. * @example
  25484. *
  25485. * _.isWeakSet(new WeakSet);
  25486. * // => true
  25487. *
  25488. * _.isWeakSet(new Set);
  25489. * // => false
  25490. */
  25491. function isWeakSet(value) {
  25492. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  25493. }
  25494. /**
  25495. * Checks if `value` is less than `other`.
  25496. *
  25497. * @static
  25498. * @memberOf _
  25499. * @since 3.9.0
  25500. * @category Lang
  25501. * @param {*} value The value to compare.
  25502. * @param {*} other The other value to compare.
  25503. * @returns {boolean} Returns `true` if `value` is less than `other`,
  25504. * else `false`.
  25505. * @see _.gt
  25506. * @example
  25507. *
  25508. * _.lt(1, 3);
  25509. * // => true
  25510. *
  25511. * _.lt(3, 3);
  25512. * // => false
  25513. *
  25514. * _.lt(3, 1);
  25515. * // => false
  25516. */
  25517. var lt = createRelationalOperation(baseLt);
  25518. /**
  25519. * Checks if `value` is less than or equal to `other`.
  25520. *
  25521. * @static
  25522. * @memberOf _
  25523. * @since 3.9.0
  25524. * @category Lang
  25525. * @param {*} value The value to compare.
  25526. * @param {*} other The other value to compare.
  25527. * @returns {boolean} Returns `true` if `value` is less than or equal to
  25528. * `other`, else `false`.
  25529. * @see _.gte
  25530. * @example
  25531. *
  25532. * _.lte(1, 3);
  25533. * // => true
  25534. *
  25535. * _.lte(3, 3);
  25536. * // => true
  25537. *
  25538. * _.lte(3, 1);
  25539. * // => false
  25540. */
  25541. var lte = createRelationalOperation(function(value, other) {
  25542. return value <= other;
  25543. });
  25544. /**
  25545. * Converts `value` to an array.
  25546. *
  25547. * @static
  25548. * @since 0.1.0
  25549. * @memberOf _
  25550. * @category Lang
  25551. * @param {*} value The value to convert.
  25552. * @returns {Array} Returns the converted array.
  25553. * @example
  25554. *
  25555. * _.toArray({ 'a': 1, 'b': 2 });
  25556. * // => [1, 2]
  25557. *
  25558. * _.toArray('abc');
  25559. * // => ['a', 'b', 'c']
  25560. *
  25561. * _.toArray(1);
  25562. * // => []
  25563. *
  25564. * _.toArray(null);
  25565. * // => []
  25566. */
  25567. function toArray(value) {
  25568. if (!value) {
  25569. return [];
  25570. }
  25571. if (isArrayLike(value)) {
  25572. return isString(value) ? stringToArray(value) : copyArray(value);
  25573. }
  25574. if (symIterator && value[symIterator]) {
  25575. return iteratorToArray(value[symIterator]());
  25576. }
  25577. var tag = getTag(value),
  25578. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  25579. return func(value);
  25580. }
  25581. /**
  25582. * Converts `value` to a finite number.
  25583. *
  25584. * @static
  25585. * @memberOf _
  25586. * @since 4.12.0
  25587. * @category Lang
  25588. * @param {*} value The value to convert.
  25589. * @returns {number} Returns the converted number.
  25590. * @example
  25591. *
  25592. * _.toFinite(3.2);
  25593. * // => 3.2
  25594. *
  25595. * _.toFinite(Number.MIN_VALUE);
  25596. * // => 5e-324
  25597. *
  25598. * _.toFinite(Infinity);
  25599. * // => 1.7976931348623157e+308
  25600. *
  25601. * _.toFinite('3.2');
  25602. * // => 3.2
  25603. */
  25604. function toFinite(value) {
  25605. if (!value) {
  25606. return value === 0 ? value : 0;
  25607. }
  25608. value = toNumber(value);
  25609. if (value === INFINITY || value === -INFINITY) {
  25610. var sign = (value < 0 ? -1 : 1);
  25611. return sign * MAX_INTEGER;
  25612. }
  25613. return value === value ? value : 0;
  25614. }
  25615. /**
  25616. * Converts `value` to an integer.
  25617. *
  25618. * **Note:** This method is loosely based on
  25619. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  25620. *
  25621. * @static
  25622. * @memberOf _
  25623. * @since 4.0.0
  25624. * @category Lang
  25625. * @param {*} value The value to convert.
  25626. * @returns {number} Returns the converted integer.
  25627. * @example
  25628. *
  25629. * _.toInteger(3.2);
  25630. * // => 3
  25631. *
  25632. * _.toInteger(Number.MIN_VALUE);
  25633. * // => 0
  25634. *
  25635. * _.toInteger(Infinity);
  25636. * // => 1.7976931348623157e+308
  25637. *
  25638. * _.toInteger('3.2');
  25639. * // => 3
  25640. */
  25641. function toInteger(value) {
  25642. var result = toFinite(value),
  25643. remainder = result % 1;
  25644. return result === result ? (remainder ? result - remainder : result) : 0;
  25645. }
  25646. /**
  25647. * Converts `value` to an integer suitable for use as the length of an
  25648. * array-like object.
  25649. *
  25650. * **Note:** This method is based on
  25651. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  25652. *
  25653. * @static
  25654. * @memberOf _
  25655. * @since 4.0.0
  25656. * @category Lang
  25657. * @param {*} value The value to convert.
  25658. * @returns {number} Returns the converted integer.
  25659. * @example
  25660. *
  25661. * _.toLength(3.2);
  25662. * // => 3
  25663. *
  25664. * _.toLength(Number.MIN_VALUE);
  25665. * // => 0
  25666. *
  25667. * _.toLength(Infinity);
  25668. * // => 4294967295
  25669. *
  25670. * _.toLength('3.2');
  25671. * // => 3
  25672. */
  25673. function toLength(value) {
  25674. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  25675. }
  25676. /**
  25677. * Converts `value` to a number.
  25678. *
  25679. * @static
  25680. * @memberOf _
  25681. * @since 4.0.0
  25682. * @category Lang
  25683. * @param {*} value The value to process.
  25684. * @returns {number} Returns the number.
  25685. * @example
  25686. *
  25687. * _.toNumber(3.2);
  25688. * // => 3.2
  25689. *
  25690. * _.toNumber(Number.MIN_VALUE);
  25691. * // => 5e-324
  25692. *
  25693. * _.toNumber(Infinity);
  25694. * // => Infinity
  25695. *
  25696. * _.toNumber('3.2');
  25697. * // => 3.2
  25698. */
  25699. function toNumber(value) {
  25700. if (typeof value == 'number') {
  25701. return value;
  25702. }
  25703. if (isSymbol(value)) {
  25704. return NAN;
  25705. }
  25706. if (isObject(value)) {
  25707. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  25708. value = isObject(other) ? (other + '') : other;
  25709. }
  25710. if (typeof value != 'string') {
  25711. return value === 0 ? value : +value;
  25712. }
  25713. value = value.replace(reTrim, '');
  25714. var isBinary = reIsBinary.test(value);
  25715. return (isBinary || reIsOctal.test(value))
  25716. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  25717. : (reIsBadHex.test(value) ? NAN : +value);
  25718. }
  25719. /**
  25720. * Converts `value` to a plain object flattening inherited enumerable string
  25721. * keyed properties of `value` to own properties of the plain object.
  25722. *
  25723. * @static
  25724. * @memberOf _
  25725. * @since 3.0.0
  25726. * @category Lang
  25727. * @param {*} value The value to convert.
  25728. * @returns {Object} Returns the converted plain object.
  25729. * @example
  25730. *
  25731. * function Foo() {
  25732. * this.b = 2;
  25733. * }
  25734. *
  25735. * Foo.prototype.c = 3;
  25736. *
  25737. * _.assign({ 'a': 1 }, new Foo);
  25738. * // => { 'a': 1, 'b': 2 }
  25739. *
  25740. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  25741. * // => { 'a': 1, 'b': 2, 'c': 3 }
  25742. */
  25743. function toPlainObject(value) {
  25744. return copyObject(value, keysIn(value));
  25745. }
  25746. /**
  25747. * Converts `value` to a safe integer. A safe integer can be compared and
  25748. * represented correctly.
  25749. *
  25750. * @static
  25751. * @memberOf _
  25752. * @since 4.0.0
  25753. * @category Lang
  25754. * @param {*} value The value to convert.
  25755. * @returns {number} Returns the converted integer.
  25756. * @example
  25757. *
  25758. * _.toSafeInteger(3.2);
  25759. * // => 3
  25760. *
  25761. * _.toSafeInteger(Number.MIN_VALUE);
  25762. * // => 0
  25763. *
  25764. * _.toSafeInteger(Infinity);
  25765. * // => 9007199254740991
  25766. *
  25767. * _.toSafeInteger('3.2');
  25768. * // => 3
  25769. */
  25770. function toSafeInteger(value) {
  25771. return value
  25772. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  25773. : (value === 0 ? value : 0);
  25774. }
  25775. /**
  25776. * Converts `value` to a string. An empty string is returned for `null`
  25777. * and `undefined` values. The sign of `-0` is preserved.
  25778. *
  25779. * @static
  25780. * @memberOf _
  25781. * @since 4.0.0
  25782. * @category Lang
  25783. * @param {*} value The value to convert.
  25784. * @returns {string} Returns the converted string.
  25785. * @example
  25786. *
  25787. * _.toString(null);
  25788. * // => ''
  25789. *
  25790. * _.toString(-0);
  25791. * // => '-0'
  25792. *
  25793. * _.toString([1, 2, 3]);
  25794. * // => '1,2,3'
  25795. */
  25796. function toString(value) {
  25797. return value == null ? '' : baseToString(value);
  25798. }
  25799. /*------------------------------------------------------------------------*/
  25800. /**
  25801. * Assigns own enumerable string keyed properties of source objects to the
  25802. * destination object. Source objects are applied from left to right.
  25803. * Subsequent sources overwrite property assignments of previous sources.
  25804. *
  25805. * **Note:** This method mutates `object` and is loosely based on
  25806. * [`Object.assign`](https://mdn.io/Object/assign).
  25807. *
  25808. * @static
  25809. * @memberOf _
  25810. * @since 0.10.0
  25811. * @category Object
  25812. * @param {Object} object The destination object.
  25813. * @param {...Object} [sources] The source objects.
  25814. * @returns {Object} Returns `object`.
  25815. * @see _.assignIn
  25816. * @example
  25817. *
  25818. * function Foo() {
  25819. * this.a = 1;
  25820. * }
  25821. *
  25822. * function Bar() {
  25823. * this.c = 3;
  25824. * }
  25825. *
  25826. * Foo.prototype.b = 2;
  25827. * Bar.prototype.d = 4;
  25828. *
  25829. * _.assign({ 'a': 0 }, new Foo, new Bar);
  25830. * // => { 'a': 1, 'c': 3 }
  25831. */
  25832. var assign = createAssigner(function(object, source) {
  25833. if (isPrototype(source) || isArrayLike(source)) {
  25834. copyObject(source, keys(source), object);
  25835. return;
  25836. }
  25837. for (var key in source) {
  25838. if (hasOwnProperty.call(source, key)) {
  25839. assignValue(object, key, source[key]);
  25840. }
  25841. }
  25842. });
  25843. /**
  25844. * This method is like `_.assign` except that it iterates over own and
  25845. * inherited source properties.
  25846. *
  25847. * **Note:** This method mutates `object`.
  25848. *
  25849. * @static
  25850. * @memberOf _
  25851. * @since 4.0.0
  25852. * @alias extend
  25853. * @category Object
  25854. * @param {Object} object The destination object.
  25855. * @param {...Object} [sources] The source objects.
  25856. * @returns {Object} Returns `object`.
  25857. * @see _.assign
  25858. * @example
  25859. *
  25860. * function Foo() {
  25861. * this.a = 1;
  25862. * }
  25863. *
  25864. * function Bar() {
  25865. * this.c = 3;
  25866. * }
  25867. *
  25868. * Foo.prototype.b = 2;
  25869. * Bar.prototype.d = 4;
  25870. *
  25871. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  25872. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  25873. */
  25874. var assignIn = createAssigner(function(object, source) {
  25875. copyObject(source, keysIn(source), object);
  25876. });
  25877. /**
  25878. * This method is like `_.assignIn` except that it accepts `customizer`
  25879. * which is invoked to produce the assigned values. If `customizer` returns
  25880. * `undefined`, assignment is handled by the method instead. The `customizer`
  25881. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25882. *
  25883. * **Note:** This method mutates `object`.
  25884. *
  25885. * @static
  25886. * @memberOf _
  25887. * @since 4.0.0
  25888. * @alias extendWith
  25889. * @category Object
  25890. * @param {Object} object The destination object.
  25891. * @param {...Object} sources The source objects.
  25892. * @param {Function} [customizer] The function to customize assigned values.
  25893. * @returns {Object} Returns `object`.
  25894. * @see _.assignWith
  25895. * @example
  25896. *
  25897. * function customizer(objValue, srcValue) {
  25898. * return _.isUndefined(objValue) ? srcValue : objValue;
  25899. * }
  25900. *
  25901. * var defaults = _.partialRight(_.assignInWith, customizer);
  25902. *
  25903. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25904. * // => { 'a': 1, 'b': 2 }
  25905. */
  25906. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  25907. copyObject(source, keysIn(source), object, customizer);
  25908. });
  25909. /**
  25910. * This method is like `_.assign` except that it accepts `customizer`
  25911. * which is invoked to produce the assigned values. If `customizer` returns
  25912. * `undefined`, assignment is handled by the method instead. The `customizer`
  25913. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25914. *
  25915. * **Note:** This method mutates `object`.
  25916. *
  25917. * @static
  25918. * @memberOf _
  25919. * @since 4.0.0
  25920. * @category Object
  25921. * @param {Object} object The destination object.
  25922. * @param {...Object} sources The source objects.
  25923. * @param {Function} [customizer] The function to customize assigned values.
  25924. * @returns {Object} Returns `object`.
  25925. * @see _.assignInWith
  25926. * @example
  25927. *
  25928. * function customizer(objValue, srcValue) {
  25929. * return _.isUndefined(objValue) ? srcValue : objValue;
  25930. * }
  25931. *
  25932. * var defaults = _.partialRight(_.assignWith, customizer);
  25933. *
  25934. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25935. * // => { 'a': 1, 'b': 2 }
  25936. */
  25937. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  25938. copyObject(source, keys(source), object, customizer);
  25939. });
  25940. /**
  25941. * Creates an array of values corresponding to `paths` of `object`.
  25942. *
  25943. * @static
  25944. * @memberOf _
  25945. * @since 1.0.0
  25946. * @category Object
  25947. * @param {Object} object The object to iterate over.
  25948. * @param {...(string|string[])} [paths] The property paths to pick.
  25949. * @returns {Array} Returns the picked values.
  25950. * @example
  25951. *
  25952. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25953. *
  25954. * _.at(object, ['a[0].b.c', 'a[1]']);
  25955. * // => [3, 4]
  25956. */
  25957. var at = flatRest(baseAt);
  25958. /**
  25959. * Creates an object that inherits from the `prototype` object. If a
  25960. * `properties` object is given, its own enumerable string keyed properties
  25961. * are assigned to the created object.
  25962. *
  25963. * @static
  25964. * @memberOf _
  25965. * @since 2.3.0
  25966. * @category Object
  25967. * @param {Object} prototype The object to inherit from.
  25968. * @param {Object} [properties] The properties to assign to the object.
  25969. * @returns {Object} Returns the new object.
  25970. * @example
  25971. *
  25972. * function Shape() {
  25973. * this.x = 0;
  25974. * this.y = 0;
  25975. * }
  25976. *
  25977. * function Circle() {
  25978. * Shape.call(this);
  25979. * }
  25980. *
  25981. * Circle.prototype = _.create(Shape.prototype, {
  25982. * 'constructor': Circle
  25983. * });
  25984. *
  25985. * var circle = new Circle;
  25986. * circle instanceof Circle;
  25987. * // => true
  25988. *
  25989. * circle instanceof Shape;
  25990. * // => true
  25991. */
  25992. function create(prototype, properties) {
  25993. var result = baseCreate(prototype);
  25994. return properties == null ? result : baseAssign(result, properties);
  25995. }
  25996. /**
  25997. * Assigns own and inherited enumerable string keyed properties of source
  25998. * objects to the destination object for all destination properties that
  25999. * resolve to `undefined`. Source objects are applied from left to right.
  26000. * Once a property is set, additional values of the same property are ignored.
  26001. *
  26002. * **Note:** This method mutates `object`.
  26003. *
  26004. * @static
  26005. * @since 0.1.0
  26006. * @memberOf _
  26007. * @category Object
  26008. * @param {Object} object The destination object.
  26009. * @param {...Object} [sources] The source objects.
  26010. * @returns {Object} Returns `object`.
  26011. * @see _.defaultsDeep
  26012. * @example
  26013. *
  26014. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  26015. * // => { 'a': 1, 'b': 2 }
  26016. */
  26017. var defaults = baseRest(function(object, sources) {
  26018. object = Object(object);
  26019. var index = -1;
  26020. var length = sources.length;
  26021. var guard = length > 2 ? sources[2] : undefined;
  26022. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  26023. length = 1;
  26024. }
  26025. while (++index < length) {
  26026. var source = sources[index];
  26027. var props = keysIn(source);
  26028. var propsIndex = -1;
  26029. var propsLength = props.length;
  26030. while (++propsIndex < propsLength) {
  26031. var key = props[propsIndex];
  26032. var value = object[key];
  26033. if (value === undefined ||
  26034. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  26035. object[key] = source[key];
  26036. }
  26037. }
  26038. }
  26039. return object;
  26040. });
  26041. /**
  26042. * This method is like `_.defaults` except that it recursively assigns
  26043. * default properties.
  26044. *
  26045. * **Note:** This method mutates `object`.
  26046. *
  26047. * @static
  26048. * @memberOf _
  26049. * @since 3.10.0
  26050. * @category Object
  26051. * @param {Object} object The destination object.
  26052. * @param {...Object} [sources] The source objects.
  26053. * @returns {Object} Returns `object`.
  26054. * @see _.defaults
  26055. * @example
  26056. *
  26057. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  26058. * // => { 'a': { 'b': 2, 'c': 3 } }
  26059. */
  26060. var defaultsDeep = baseRest(function(args) {
  26061. args.push(undefined, customDefaultsMerge);
  26062. return apply(mergeWith, undefined, args);
  26063. });
  26064. /**
  26065. * This method is like `_.find` except that it returns the key of the first
  26066. * element `predicate` returns truthy for instead of the element itself.
  26067. *
  26068. * @static
  26069. * @memberOf _
  26070. * @since 1.1.0
  26071. * @category Object
  26072. * @param {Object} object The object to inspect.
  26073. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26074. * @returns {string|undefined} Returns the key of the matched element,
  26075. * else `undefined`.
  26076. * @example
  26077. *
  26078. * var users = {
  26079. * 'barney': { 'age': 36, 'active': true },
  26080. * 'fred': { 'age': 40, 'active': false },
  26081. * 'pebbles': { 'age': 1, 'active': true }
  26082. * };
  26083. *
  26084. * _.findKey(users, function(o) { return o.age < 40; });
  26085. * // => 'barney' (iteration order is not guaranteed)
  26086. *
  26087. * // The `_.matches` iteratee shorthand.
  26088. * _.findKey(users, { 'age': 1, 'active': true });
  26089. * // => 'pebbles'
  26090. *
  26091. * // The `_.matchesProperty` iteratee shorthand.
  26092. * _.findKey(users, ['active', false]);
  26093. * // => 'fred'
  26094. *
  26095. * // The `_.property` iteratee shorthand.
  26096. * _.findKey(users, 'active');
  26097. * // => 'barney'
  26098. */
  26099. function findKey(object, predicate) {
  26100. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  26101. }
  26102. /**
  26103. * This method is like `_.findKey` except that it iterates over elements of
  26104. * a collection in the opposite order.
  26105. *
  26106. * @static
  26107. * @memberOf _
  26108. * @since 2.0.0
  26109. * @category Object
  26110. * @param {Object} object The object to inspect.
  26111. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26112. * @returns {string|undefined} Returns the key of the matched element,
  26113. * else `undefined`.
  26114. * @example
  26115. *
  26116. * var users = {
  26117. * 'barney': { 'age': 36, 'active': true },
  26118. * 'fred': { 'age': 40, 'active': false },
  26119. * 'pebbles': { 'age': 1, 'active': true }
  26120. * };
  26121. *
  26122. * _.findLastKey(users, function(o) { return o.age < 40; });
  26123. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  26124. *
  26125. * // The `_.matches` iteratee shorthand.
  26126. * _.findLastKey(users, { 'age': 36, 'active': true });
  26127. * // => 'barney'
  26128. *
  26129. * // The `_.matchesProperty` iteratee shorthand.
  26130. * _.findLastKey(users, ['active', false]);
  26131. * // => 'fred'
  26132. *
  26133. * // The `_.property` iteratee shorthand.
  26134. * _.findLastKey(users, 'active');
  26135. * // => 'pebbles'
  26136. */
  26137. function findLastKey(object, predicate) {
  26138. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  26139. }
  26140. /**
  26141. * Iterates over own and inherited enumerable string keyed properties of an
  26142. * object and invokes `iteratee` for each property. The iteratee is invoked
  26143. * with three arguments: (value, key, object). Iteratee functions may exit
  26144. * iteration early by explicitly returning `false`.
  26145. *
  26146. * @static
  26147. * @memberOf _
  26148. * @since 0.3.0
  26149. * @category Object
  26150. * @param {Object} object The object to iterate over.
  26151. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26152. * @returns {Object} Returns `object`.
  26153. * @see _.forInRight
  26154. * @example
  26155. *
  26156. * function Foo() {
  26157. * this.a = 1;
  26158. * this.b = 2;
  26159. * }
  26160. *
  26161. * Foo.prototype.c = 3;
  26162. *
  26163. * _.forIn(new Foo, function(value, key) {
  26164. * console.log(key);
  26165. * });
  26166. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  26167. */
  26168. function forIn(object, iteratee) {
  26169. return object == null
  26170. ? object
  26171. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  26172. }
  26173. /**
  26174. * This method is like `_.forIn` except that it iterates over properties of
  26175. * `object` in the opposite order.
  26176. *
  26177. * @static
  26178. * @memberOf _
  26179. * @since 2.0.0
  26180. * @category Object
  26181. * @param {Object} object The object to iterate over.
  26182. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26183. * @returns {Object} Returns `object`.
  26184. * @see _.forIn
  26185. * @example
  26186. *
  26187. * function Foo() {
  26188. * this.a = 1;
  26189. * this.b = 2;
  26190. * }
  26191. *
  26192. * Foo.prototype.c = 3;
  26193. *
  26194. * _.forInRight(new Foo, function(value, key) {
  26195. * console.log(key);
  26196. * });
  26197. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  26198. */
  26199. function forInRight(object, iteratee) {
  26200. return object == null
  26201. ? object
  26202. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  26203. }
  26204. /**
  26205. * Iterates over own enumerable string keyed properties of an object and
  26206. * invokes `iteratee` for each property. The iteratee is invoked with three
  26207. * arguments: (value, key, object). Iteratee functions may exit iteration
  26208. * early by explicitly returning `false`.
  26209. *
  26210. * @static
  26211. * @memberOf _
  26212. * @since 0.3.0
  26213. * @category Object
  26214. * @param {Object} object The object to iterate over.
  26215. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26216. * @returns {Object} Returns `object`.
  26217. * @see _.forOwnRight
  26218. * @example
  26219. *
  26220. * function Foo() {
  26221. * this.a = 1;
  26222. * this.b = 2;
  26223. * }
  26224. *
  26225. * Foo.prototype.c = 3;
  26226. *
  26227. * _.forOwn(new Foo, function(value, key) {
  26228. * console.log(key);
  26229. * });
  26230. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26231. */
  26232. function forOwn(object, iteratee) {
  26233. return object && baseForOwn(object, getIteratee(iteratee, 3));
  26234. }
  26235. /**
  26236. * This method is like `_.forOwn` except that it iterates over properties of
  26237. * `object` in the opposite order.
  26238. *
  26239. * @static
  26240. * @memberOf _
  26241. * @since 2.0.0
  26242. * @category Object
  26243. * @param {Object} object The object to iterate over.
  26244. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26245. * @returns {Object} Returns `object`.
  26246. * @see _.forOwn
  26247. * @example
  26248. *
  26249. * function Foo() {
  26250. * this.a = 1;
  26251. * this.b = 2;
  26252. * }
  26253. *
  26254. * Foo.prototype.c = 3;
  26255. *
  26256. * _.forOwnRight(new Foo, function(value, key) {
  26257. * console.log(key);
  26258. * });
  26259. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  26260. */
  26261. function forOwnRight(object, iteratee) {
  26262. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  26263. }
  26264. /**
  26265. * Creates an array of function property names from own enumerable properties
  26266. * of `object`.
  26267. *
  26268. * @static
  26269. * @since 0.1.0
  26270. * @memberOf _
  26271. * @category Object
  26272. * @param {Object} object The object to inspect.
  26273. * @returns {Array} Returns the function names.
  26274. * @see _.functionsIn
  26275. * @example
  26276. *
  26277. * function Foo() {
  26278. * this.a = _.constant('a');
  26279. * this.b = _.constant('b');
  26280. * }
  26281. *
  26282. * Foo.prototype.c = _.constant('c');
  26283. *
  26284. * _.functions(new Foo);
  26285. * // => ['a', 'b']
  26286. */
  26287. function functions(object) {
  26288. return object == null ? [] : baseFunctions(object, keys(object));
  26289. }
  26290. /**
  26291. * Creates an array of function property names from own and inherited
  26292. * enumerable properties of `object`.
  26293. *
  26294. * @static
  26295. * @memberOf _
  26296. * @since 4.0.0
  26297. * @category Object
  26298. * @param {Object} object The object to inspect.
  26299. * @returns {Array} Returns the function names.
  26300. * @see _.functions
  26301. * @example
  26302. *
  26303. * function Foo() {
  26304. * this.a = _.constant('a');
  26305. * this.b = _.constant('b');
  26306. * }
  26307. *
  26308. * Foo.prototype.c = _.constant('c');
  26309. *
  26310. * _.functionsIn(new Foo);
  26311. * // => ['a', 'b', 'c']
  26312. */
  26313. function functionsIn(object) {
  26314. return object == null ? [] : baseFunctions(object, keysIn(object));
  26315. }
  26316. /**
  26317. * Gets the value at `path` of `object`. If the resolved value is
  26318. * `undefined`, the `defaultValue` is returned in its place.
  26319. *
  26320. * @static
  26321. * @memberOf _
  26322. * @since 3.7.0
  26323. * @category Object
  26324. * @param {Object} object The object to query.
  26325. * @param {Array|string} path The path of the property to get.
  26326. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26327. * @returns {*} Returns the resolved value.
  26328. * @example
  26329. *
  26330. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26331. *
  26332. * _.get(object, 'a[0].b.c');
  26333. * // => 3
  26334. *
  26335. * _.get(object, ['a', '0', 'b', 'c']);
  26336. * // => 3
  26337. *
  26338. * _.get(object, 'a.b.c', 'default');
  26339. * // => 'default'
  26340. */
  26341. function get(object, path, defaultValue) {
  26342. var result = object == null ? undefined : baseGet(object, path);
  26343. return result === undefined ? defaultValue : result;
  26344. }
  26345. /**
  26346. * Checks if `path` is a direct property of `object`.
  26347. *
  26348. * @static
  26349. * @since 0.1.0
  26350. * @memberOf _
  26351. * @category Object
  26352. * @param {Object} object The object to query.
  26353. * @param {Array|string} path The path to check.
  26354. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26355. * @example
  26356. *
  26357. * var object = { 'a': { 'b': 2 } };
  26358. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  26359. *
  26360. * _.has(object, 'a');
  26361. * // => true
  26362. *
  26363. * _.has(object, 'a.b');
  26364. * // => true
  26365. *
  26366. * _.has(object, ['a', 'b']);
  26367. * // => true
  26368. *
  26369. * _.has(other, 'a');
  26370. * // => false
  26371. */
  26372. function has(object, path) {
  26373. return object != null && hasPath(object, path, baseHas);
  26374. }
  26375. /**
  26376. * Checks if `path` is a direct or inherited property of `object`.
  26377. *
  26378. * @static
  26379. * @memberOf _
  26380. * @since 4.0.0
  26381. * @category Object
  26382. * @param {Object} object The object to query.
  26383. * @param {Array|string} path The path to check.
  26384. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26385. * @example
  26386. *
  26387. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  26388. *
  26389. * _.hasIn(object, 'a');
  26390. * // => true
  26391. *
  26392. * _.hasIn(object, 'a.b');
  26393. * // => true
  26394. *
  26395. * _.hasIn(object, ['a', 'b']);
  26396. * // => true
  26397. *
  26398. * _.hasIn(object, 'b');
  26399. * // => false
  26400. */
  26401. function hasIn(object, path) {
  26402. return object != null && hasPath(object, path, baseHasIn);
  26403. }
  26404. /**
  26405. * Creates an object composed of the inverted keys and values of `object`.
  26406. * If `object` contains duplicate values, subsequent values overwrite
  26407. * property assignments of previous values.
  26408. *
  26409. * @static
  26410. * @memberOf _
  26411. * @since 0.7.0
  26412. * @category Object
  26413. * @param {Object} object The object to invert.
  26414. * @returns {Object} Returns the new inverted object.
  26415. * @example
  26416. *
  26417. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26418. *
  26419. * _.invert(object);
  26420. * // => { '1': 'c', '2': 'b' }
  26421. */
  26422. var invert = createInverter(function(result, value, key) {
  26423. if (value != null &&
  26424. typeof value.toString != 'function') {
  26425. value = nativeObjectToString.call(value);
  26426. }
  26427. result[value] = key;
  26428. }, constant(identity));
  26429. /**
  26430. * This method is like `_.invert` except that the inverted object is generated
  26431. * from the results of running each element of `object` thru `iteratee`. The
  26432. * corresponding inverted value of each inverted key is an array of keys
  26433. * responsible for generating the inverted value. The iteratee is invoked
  26434. * with one argument: (value).
  26435. *
  26436. * @static
  26437. * @memberOf _
  26438. * @since 4.1.0
  26439. * @category Object
  26440. * @param {Object} object The object to invert.
  26441. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  26442. * @returns {Object} Returns the new inverted object.
  26443. * @example
  26444. *
  26445. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26446. *
  26447. * _.invertBy(object);
  26448. * // => { '1': ['a', 'c'], '2': ['b'] }
  26449. *
  26450. * _.invertBy(object, function(value) {
  26451. * return 'group' + value;
  26452. * });
  26453. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  26454. */
  26455. var invertBy = createInverter(function(result, value, key) {
  26456. if (value != null &&
  26457. typeof value.toString != 'function') {
  26458. value = nativeObjectToString.call(value);
  26459. }
  26460. if (hasOwnProperty.call(result, value)) {
  26461. result[value].push(key);
  26462. } else {
  26463. result[value] = [key];
  26464. }
  26465. }, getIteratee);
  26466. /**
  26467. * Invokes the method at `path` of `object`.
  26468. *
  26469. * @static
  26470. * @memberOf _
  26471. * @since 4.0.0
  26472. * @category Object
  26473. * @param {Object} object The object to query.
  26474. * @param {Array|string} path The path of the method to invoke.
  26475. * @param {...*} [args] The arguments to invoke the method with.
  26476. * @returns {*} Returns the result of the invoked method.
  26477. * @example
  26478. *
  26479. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  26480. *
  26481. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  26482. * // => [2, 3]
  26483. */
  26484. var invoke = baseRest(baseInvoke);
  26485. /**
  26486. * Creates an array of the own enumerable property names of `object`.
  26487. *
  26488. * **Note:** Non-object values are coerced to objects. See the
  26489. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  26490. * for more details.
  26491. *
  26492. * @static
  26493. * @since 0.1.0
  26494. * @memberOf _
  26495. * @category Object
  26496. * @param {Object} object The object to query.
  26497. * @returns {Array} Returns the array of property names.
  26498. * @example
  26499. *
  26500. * function Foo() {
  26501. * this.a = 1;
  26502. * this.b = 2;
  26503. * }
  26504. *
  26505. * Foo.prototype.c = 3;
  26506. *
  26507. * _.keys(new Foo);
  26508. * // => ['a', 'b'] (iteration order is not guaranteed)
  26509. *
  26510. * _.keys('hi');
  26511. * // => ['0', '1']
  26512. */
  26513. function keys(object) {
  26514. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  26515. }
  26516. /**
  26517. * Creates an array of the own and inherited enumerable property names of `object`.
  26518. *
  26519. * **Note:** Non-object values are coerced to objects.
  26520. *
  26521. * @static
  26522. * @memberOf _
  26523. * @since 3.0.0
  26524. * @category Object
  26525. * @param {Object} object The object to query.
  26526. * @returns {Array} Returns the array of property names.
  26527. * @example
  26528. *
  26529. * function Foo() {
  26530. * this.a = 1;
  26531. * this.b = 2;
  26532. * }
  26533. *
  26534. * Foo.prototype.c = 3;
  26535. *
  26536. * _.keysIn(new Foo);
  26537. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  26538. */
  26539. function keysIn(object) {
  26540. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  26541. }
  26542. /**
  26543. * The opposite of `_.mapValues`; this method creates an object with the
  26544. * same values as `object` and keys generated by running each own enumerable
  26545. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  26546. * with three arguments: (value, key, object).
  26547. *
  26548. * @static
  26549. * @memberOf _
  26550. * @since 3.8.0
  26551. * @category Object
  26552. * @param {Object} object The object to iterate over.
  26553. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26554. * @returns {Object} Returns the new mapped object.
  26555. * @see _.mapValues
  26556. * @example
  26557. *
  26558. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  26559. * return key + value;
  26560. * });
  26561. * // => { 'a1': 1, 'b2': 2 }
  26562. */
  26563. function mapKeys(object, iteratee) {
  26564. var result = {};
  26565. iteratee = getIteratee(iteratee, 3);
  26566. baseForOwn(object, function(value, key, object) {
  26567. baseAssignValue(result, iteratee(value, key, object), value);
  26568. });
  26569. return result;
  26570. }
  26571. /**
  26572. * Creates an object with the same keys as `object` and values generated
  26573. * by running each own enumerable string keyed property of `object` thru
  26574. * `iteratee`. The iteratee is invoked with three arguments:
  26575. * (value, key, object).
  26576. *
  26577. * @static
  26578. * @memberOf _
  26579. * @since 2.4.0
  26580. * @category Object
  26581. * @param {Object} object The object to iterate over.
  26582. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26583. * @returns {Object} Returns the new mapped object.
  26584. * @see _.mapKeys
  26585. * @example
  26586. *
  26587. * var users = {
  26588. * 'fred': { 'user': 'fred', 'age': 40 },
  26589. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  26590. * };
  26591. *
  26592. * _.mapValues(users, function(o) { return o.age; });
  26593. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26594. *
  26595. * // The `_.property` iteratee shorthand.
  26596. * _.mapValues(users, 'age');
  26597. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26598. */
  26599. function mapValues(object, iteratee) {
  26600. var result = {};
  26601. iteratee = getIteratee(iteratee, 3);
  26602. baseForOwn(object, function(value, key, object) {
  26603. baseAssignValue(result, key, iteratee(value, key, object));
  26604. });
  26605. return result;
  26606. }
  26607. /**
  26608. * This method is like `_.assign` except that it recursively merges own and
  26609. * inherited enumerable string keyed properties of source objects into the
  26610. * destination object. Source properties that resolve to `undefined` are
  26611. * skipped if a destination value exists. Array and plain object properties
  26612. * are merged recursively. Other objects and value types are overridden by
  26613. * assignment. Source objects are applied from left to right. Subsequent
  26614. * sources overwrite property assignments of previous sources.
  26615. *
  26616. * **Note:** This method mutates `object`.
  26617. *
  26618. * @static
  26619. * @memberOf _
  26620. * @since 0.5.0
  26621. * @category Object
  26622. * @param {Object} object The destination object.
  26623. * @param {...Object} [sources] The source objects.
  26624. * @returns {Object} Returns `object`.
  26625. * @example
  26626. *
  26627. * var object = {
  26628. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  26629. * };
  26630. *
  26631. * var other = {
  26632. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  26633. * };
  26634. *
  26635. * _.merge(object, other);
  26636. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  26637. */
  26638. var merge = createAssigner(function(object, source, srcIndex) {
  26639. baseMerge(object, source, srcIndex);
  26640. });
  26641. /**
  26642. * This method is like `_.merge` except that it accepts `customizer` which
  26643. * is invoked to produce the merged values of the destination and source
  26644. * properties. If `customizer` returns `undefined`, merging is handled by the
  26645. * method instead. The `customizer` is invoked with six arguments:
  26646. * (objValue, srcValue, key, object, source, stack).
  26647. *
  26648. * **Note:** This method mutates `object`.
  26649. *
  26650. * @static
  26651. * @memberOf _
  26652. * @since 4.0.0
  26653. * @category Object
  26654. * @param {Object} object The destination object.
  26655. * @param {...Object} sources The source objects.
  26656. * @param {Function} customizer The function to customize assigned values.
  26657. * @returns {Object} Returns `object`.
  26658. * @example
  26659. *
  26660. * function customizer(objValue, srcValue) {
  26661. * if (_.isArray(objValue)) {
  26662. * return objValue.concat(srcValue);
  26663. * }
  26664. * }
  26665. *
  26666. * var object = { 'a': [1], 'b': [2] };
  26667. * var other = { 'a': [3], 'b': [4] };
  26668. *
  26669. * _.mergeWith(object, other, customizer);
  26670. * // => { 'a': [1, 3], 'b': [2, 4] }
  26671. */
  26672. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  26673. baseMerge(object, source, srcIndex, customizer);
  26674. });
  26675. /**
  26676. * The opposite of `_.pick`; this method creates an object composed of the
  26677. * own and inherited enumerable property paths of `object` that are not omitted.
  26678. *
  26679. * **Note:** This method is considerably slower than `_.pick`.
  26680. *
  26681. * @static
  26682. * @since 0.1.0
  26683. * @memberOf _
  26684. * @category Object
  26685. * @param {Object} object The source object.
  26686. * @param {...(string|string[])} [paths] The property paths to omit.
  26687. * @returns {Object} Returns the new object.
  26688. * @example
  26689. *
  26690. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26691. *
  26692. * _.omit(object, ['a', 'c']);
  26693. * // => { 'b': '2' }
  26694. */
  26695. var omit = flatRest(function(object, paths) {
  26696. var result = {};
  26697. if (object == null) {
  26698. return result;
  26699. }
  26700. var isDeep = false;
  26701. paths = arrayMap(paths, function(path) {
  26702. path = castPath(path, object);
  26703. isDeep || (isDeep = path.length > 1);
  26704. return path;
  26705. });
  26706. copyObject(object, getAllKeysIn(object), result);
  26707. if (isDeep) {
  26708. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  26709. }
  26710. var length = paths.length;
  26711. while (length--) {
  26712. baseUnset(result, paths[length]);
  26713. }
  26714. return result;
  26715. });
  26716. /**
  26717. * The opposite of `_.pickBy`; this method creates an object composed of
  26718. * the own and inherited enumerable string keyed properties of `object` that
  26719. * `predicate` doesn't return truthy for. The predicate is invoked with two
  26720. * arguments: (value, key).
  26721. *
  26722. * @static
  26723. * @memberOf _
  26724. * @since 4.0.0
  26725. * @category Object
  26726. * @param {Object} object The source object.
  26727. * @param {Function} [predicate=_.identity] The function invoked per property.
  26728. * @returns {Object} Returns the new object.
  26729. * @example
  26730. *
  26731. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26732. *
  26733. * _.omitBy(object, _.isNumber);
  26734. * // => { 'b': '2' }
  26735. */
  26736. function omitBy(object, predicate) {
  26737. return pickBy(object, negate(getIteratee(predicate)));
  26738. }
  26739. /**
  26740. * Creates an object composed of the picked `object` properties.
  26741. *
  26742. * @static
  26743. * @since 0.1.0
  26744. * @memberOf _
  26745. * @category Object
  26746. * @param {Object} object The source object.
  26747. * @param {...(string|string[])} [paths] The property paths to pick.
  26748. * @returns {Object} Returns the new object.
  26749. * @example
  26750. *
  26751. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26752. *
  26753. * _.pick(object, ['a', 'c']);
  26754. * // => { 'a': 1, 'c': 3 }
  26755. */
  26756. var pick = flatRest(function(object, paths) {
  26757. return object == null ? {} : basePick(object, paths);
  26758. });
  26759. /**
  26760. * Creates an object composed of the `object` properties `predicate` returns
  26761. * truthy for. The predicate is invoked with two arguments: (value, key).
  26762. *
  26763. * @static
  26764. * @memberOf _
  26765. * @since 4.0.0
  26766. * @category Object
  26767. * @param {Object} object The source object.
  26768. * @param {Function} [predicate=_.identity] The function invoked per property.
  26769. * @returns {Object} Returns the new object.
  26770. * @example
  26771. *
  26772. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26773. *
  26774. * _.pickBy(object, _.isNumber);
  26775. * // => { 'a': 1, 'c': 3 }
  26776. */
  26777. function pickBy(object, predicate) {
  26778. if (object == null) {
  26779. return {};
  26780. }
  26781. var props = arrayMap(getAllKeysIn(object), function(prop) {
  26782. return [prop];
  26783. });
  26784. predicate = getIteratee(predicate);
  26785. return basePickBy(object, props, function(value, path) {
  26786. return predicate(value, path[0]);
  26787. });
  26788. }
  26789. /**
  26790. * This method is like `_.get` except that if the resolved value is a
  26791. * function it's invoked with the `this` binding of its parent object and
  26792. * its result is returned.
  26793. *
  26794. * @static
  26795. * @since 0.1.0
  26796. * @memberOf _
  26797. * @category Object
  26798. * @param {Object} object The object to query.
  26799. * @param {Array|string} path The path of the property to resolve.
  26800. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26801. * @returns {*} Returns the resolved value.
  26802. * @example
  26803. *
  26804. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  26805. *
  26806. * _.result(object, 'a[0].b.c1');
  26807. * // => 3
  26808. *
  26809. * _.result(object, 'a[0].b.c2');
  26810. * // => 4
  26811. *
  26812. * _.result(object, 'a[0].b.c3', 'default');
  26813. * // => 'default'
  26814. *
  26815. * _.result(object, 'a[0].b.c3', _.constant('default'));
  26816. * // => 'default'
  26817. */
  26818. function result(object, path, defaultValue) {
  26819. path = castPath(path, object);
  26820. var index = -1,
  26821. length = path.length;
  26822. // Ensure the loop is entered when path is empty.
  26823. if (!length) {
  26824. length = 1;
  26825. object = undefined;
  26826. }
  26827. while (++index < length) {
  26828. var value = object == null ? undefined : object[toKey(path[index])];
  26829. if (value === undefined) {
  26830. index = length;
  26831. value = defaultValue;
  26832. }
  26833. object = isFunction(value) ? value.call(object) : value;
  26834. }
  26835. return object;
  26836. }
  26837. /**
  26838. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  26839. * it's created. Arrays are created for missing index properties while objects
  26840. * are created for all other missing properties. Use `_.setWith` to customize
  26841. * `path` creation.
  26842. *
  26843. * **Note:** This method mutates `object`.
  26844. *
  26845. * @static
  26846. * @memberOf _
  26847. * @since 3.7.0
  26848. * @category Object
  26849. * @param {Object} object The object to modify.
  26850. * @param {Array|string} path The path of the property to set.
  26851. * @param {*} value The value to set.
  26852. * @returns {Object} Returns `object`.
  26853. * @example
  26854. *
  26855. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26856. *
  26857. * _.set(object, 'a[0].b.c', 4);
  26858. * console.log(object.a[0].b.c);
  26859. * // => 4
  26860. *
  26861. * _.set(object, ['x', '0', 'y', 'z'], 5);
  26862. * console.log(object.x[0].y.z);
  26863. * // => 5
  26864. */
  26865. function set(object, path, value) {
  26866. return object == null ? object : baseSet(object, path, value);
  26867. }
  26868. /**
  26869. * This method is like `_.set` except that it accepts `customizer` which is
  26870. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26871. * path creation is handled by the method instead. The `customizer` is invoked
  26872. * with three arguments: (nsValue, key, nsObject).
  26873. *
  26874. * **Note:** This method mutates `object`.
  26875. *
  26876. * @static
  26877. * @memberOf _
  26878. * @since 4.0.0
  26879. * @category Object
  26880. * @param {Object} object The object to modify.
  26881. * @param {Array|string} path The path of the property to set.
  26882. * @param {*} value The value to set.
  26883. * @param {Function} [customizer] The function to customize assigned values.
  26884. * @returns {Object} Returns `object`.
  26885. * @example
  26886. *
  26887. * var object = {};
  26888. *
  26889. * _.setWith(object, '[0][1]', 'a', Object);
  26890. * // => { '0': { '1': 'a' } }
  26891. */
  26892. function setWith(object, path, value, customizer) {
  26893. customizer = typeof customizer == 'function' ? customizer : undefined;
  26894. return object == null ? object : baseSet(object, path, value, customizer);
  26895. }
  26896. /**
  26897. * Creates an array of own enumerable string keyed-value pairs for `object`
  26898. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  26899. * entries are returned.
  26900. *
  26901. * @static
  26902. * @memberOf _
  26903. * @since 4.0.0
  26904. * @alias entries
  26905. * @category Object
  26906. * @param {Object} object The object to query.
  26907. * @returns {Array} Returns the key-value pairs.
  26908. * @example
  26909. *
  26910. * function Foo() {
  26911. * this.a = 1;
  26912. * this.b = 2;
  26913. * }
  26914. *
  26915. * Foo.prototype.c = 3;
  26916. *
  26917. * _.toPairs(new Foo);
  26918. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  26919. */
  26920. var toPairs = createToPairs(keys);
  26921. /**
  26922. * Creates an array of own and inherited enumerable string keyed-value pairs
  26923. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  26924. * or set, its entries are returned.
  26925. *
  26926. * @static
  26927. * @memberOf _
  26928. * @since 4.0.0
  26929. * @alias entriesIn
  26930. * @category Object
  26931. * @param {Object} object The object to query.
  26932. * @returns {Array} Returns the key-value pairs.
  26933. * @example
  26934. *
  26935. * function Foo() {
  26936. * this.a = 1;
  26937. * this.b = 2;
  26938. * }
  26939. *
  26940. * Foo.prototype.c = 3;
  26941. *
  26942. * _.toPairsIn(new Foo);
  26943. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  26944. */
  26945. var toPairsIn = createToPairs(keysIn);
  26946. /**
  26947. * An alternative to `_.reduce`; this method transforms `object` to a new
  26948. * `accumulator` object which is the result of running each of its own
  26949. * enumerable string keyed properties thru `iteratee`, with each invocation
  26950. * potentially mutating the `accumulator` object. If `accumulator` is not
  26951. * provided, a new object with the same `[[Prototype]]` will be used. The
  26952. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  26953. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26954. *
  26955. * @static
  26956. * @memberOf _
  26957. * @since 1.3.0
  26958. * @category Object
  26959. * @param {Object} object The object to iterate over.
  26960. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26961. * @param {*} [accumulator] The custom accumulator value.
  26962. * @returns {*} Returns the accumulated value.
  26963. * @example
  26964. *
  26965. * _.transform([2, 3, 4], function(result, n) {
  26966. * result.push(n *= n);
  26967. * return n % 2 == 0;
  26968. * }, []);
  26969. * // => [4, 9]
  26970. *
  26971. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26972. * (result[value] || (result[value] = [])).push(key);
  26973. * }, {});
  26974. * // => { '1': ['a', 'c'], '2': ['b'] }
  26975. */
  26976. function transform(object, iteratee, accumulator) {
  26977. var isArr = isArray(object),
  26978. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  26979. iteratee = getIteratee(iteratee, 4);
  26980. if (accumulator == null) {
  26981. var Ctor = object && object.constructor;
  26982. if (isArrLike) {
  26983. accumulator = isArr ? new Ctor : [];
  26984. }
  26985. else if (isObject(object)) {
  26986. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  26987. }
  26988. else {
  26989. accumulator = {};
  26990. }
  26991. }
  26992. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  26993. return iteratee(accumulator, value, index, object);
  26994. });
  26995. return accumulator;
  26996. }
  26997. /**
  26998. * Removes the property at `path` of `object`.
  26999. *
  27000. * **Note:** This method mutates `object`.
  27001. *
  27002. * @static
  27003. * @memberOf _
  27004. * @since 4.0.0
  27005. * @category Object
  27006. * @param {Object} object The object to modify.
  27007. * @param {Array|string} path The path of the property to unset.
  27008. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  27009. * @example
  27010. *
  27011. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  27012. * _.unset(object, 'a[0].b.c');
  27013. * // => true
  27014. *
  27015. * console.log(object);
  27016. * // => { 'a': [{ 'b': {} }] };
  27017. *
  27018. * _.unset(object, ['a', '0', 'b', 'c']);
  27019. * // => true
  27020. *
  27021. * console.log(object);
  27022. * // => { 'a': [{ 'b': {} }] };
  27023. */
  27024. function unset(object, path) {
  27025. return object == null ? true : baseUnset(object, path);
  27026. }
  27027. /**
  27028. * This method is like `_.set` except that accepts `updater` to produce the
  27029. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  27030. * is invoked with one argument: (value).
  27031. *
  27032. * **Note:** This method mutates `object`.
  27033. *
  27034. * @static
  27035. * @memberOf _
  27036. * @since 4.6.0
  27037. * @category Object
  27038. * @param {Object} object The object to modify.
  27039. * @param {Array|string} path The path of the property to set.
  27040. * @param {Function} updater The function to produce the updated value.
  27041. * @returns {Object} Returns `object`.
  27042. * @example
  27043. *
  27044. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  27045. *
  27046. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  27047. * console.log(object.a[0].b.c);
  27048. * // => 9
  27049. *
  27050. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  27051. * console.log(object.x[0].y.z);
  27052. * // => 0
  27053. */
  27054. function update(object, path, updater) {
  27055. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  27056. }
  27057. /**
  27058. * This method is like `_.update` except that it accepts `customizer` which is
  27059. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  27060. * path creation is handled by the method instead. The `customizer` is invoked
  27061. * with three arguments: (nsValue, key, nsObject).
  27062. *
  27063. * **Note:** This method mutates `object`.
  27064. *
  27065. * @static
  27066. * @memberOf _
  27067. * @since 4.6.0
  27068. * @category Object
  27069. * @param {Object} object The object to modify.
  27070. * @param {Array|string} path The path of the property to set.
  27071. * @param {Function} updater The function to produce the updated value.
  27072. * @param {Function} [customizer] The function to customize assigned values.
  27073. * @returns {Object} Returns `object`.
  27074. * @example
  27075. *
  27076. * var object = {};
  27077. *
  27078. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  27079. * // => { '0': { '1': 'a' } }
  27080. */
  27081. function updateWith(object, path, updater, customizer) {
  27082. customizer = typeof customizer == 'function' ? customizer : undefined;
  27083. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  27084. }
  27085. /**
  27086. * Creates an array of the own enumerable string keyed property values of `object`.
  27087. *
  27088. * **Note:** Non-object values are coerced to objects.
  27089. *
  27090. * @static
  27091. * @since 0.1.0
  27092. * @memberOf _
  27093. * @category Object
  27094. * @param {Object} object The object to query.
  27095. * @returns {Array} Returns the array of property values.
  27096. * @example
  27097. *
  27098. * function Foo() {
  27099. * this.a = 1;
  27100. * this.b = 2;
  27101. * }
  27102. *
  27103. * Foo.prototype.c = 3;
  27104. *
  27105. * _.values(new Foo);
  27106. * // => [1, 2] (iteration order is not guaranteed)
  27107. *
  27108. * _.values('hi');
  27109. * // => ['h', 'i']
  27110. */
  27111. function values(object) {
  27112. return object == null ? [] : baseValues(object, keys(object));
  27113. }
  27114. /**
  27115. * Creates an array of the own and inherited enumerable string keyed property
  27116. * values of `object`.
  27117. *
  27118. * **Note:** Non-object values are coerced to objects.
  27119. *
  27120. * @static
  27121. * @memberOf _
  27122. * @since 3.0.0
  27123. * @category Object
  27124. * @param {Object} object The object to query.
  27125. * @returns {Array} Returns the array of property values.
  27126. * @example
  27127. *
  27128. * function Foo() {
  27129. * this.a = 1;
  27130. * this.b = 2;
  27131. * }
  27132. *
  27133. * Foo.prototype.c = 3;
  27134. *
  27135. * _.valuesIn(new Foo);
  27136. * // => [1, 2, 3] (iteration order is not guaranteed)
  27137. */
  27138. function valuesIn(object) {
  27139. return object == null ? [] : baseValues(object, keysIn(object));
  27140. }
  27141. /*------------------------------------------------------------------------*/
  27142. /**
  27143. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  27144. *
  27145. * @static
  27146. * @memberOf _
  27147. * @since 4.0.0
  27148. * @category Number
  27149. * @param {number} number The number to clamp.
  27150. * @param {number} [lower] The lower bound.
  27151. * @param {number} upper The upper bound.
  27152. * @returns {number} Returns the clamped number.
  27153. * @example
  27154. *
  27155. * _.clamp(-10, -5, 5);
  27156. * // => -5
  27157. *
  27158. * _.clamp(10, -5, 5);
  27159. * // => 5
  27160. */
  27161. function clamp(number, lower, upper) {
  27162. if (upper === undefined) {
  27163. upper = lower;
  27164. lower = undefined;
  27165. }
  27166. if (upper !== undefined) {
  27167. upper = toNumber(upper);
  27168. upper = upper === upper ? upper : 0;
  27169. }
  27170. if (lower !== undefined) {
  27171. lower = toNumber(lower);
  27172. lower = lower === lower ? lower : 0;
  27173. }
  27174. return baseClamp(toNumber(number), lower, upper);
  27175. }
  27176. /**
  27177. * Checks if `n` is between `start` and up to, but not including, `end`. If
  27178. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  27179. * If `start` is greater than `end` the params are swapped to support
  27180. * negative ranges.
  27181. *
  27182. * @static
  27183. * @memberOf _
  27184. * @since 3.3.0
  27185. * @category Number
  27186. * @param {number} number The number to check.
  27187. * @param {number} [start=0] The start of the range.
  27188. * @param {number} end The end of the range.
  27189. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  27190. * @see _.range, _.rangeRight
  27191. * @example
  27192. *
  27193. * _.inRange(3, 2, 4);
  27194. * // => true
  27195. *
  27196. * _.inRange(4, 8);
  27197. * // => true
  27198. *
  27199. * _.inRange(4, 2);
  27200. * // => false
  27201. *
  27202. * _.inRange(2, 2);
  27203. * // => false
  27204. *
  27205. * _.inRange(1.2, 2);
  27206. * // => true
  27207. *
  27208. * _.inRange(5.2, 4);
  27209. * // => false
  27210. *
  27211. * _.inRange(-3, -2, -6);
  27212. * // => true
  27213. */
  27214. function inRange(number, start, end) {
  27215. start = toFinite(start);
  27216. if (end === undefined) {
  27217. end = start;
  27218. start = 0;
  27219. } else {
  27220. end = toFinite(end);
  27221. }
  27222. number = toNumber(number);
  27223. return baseInRange(number, start, end);
  27224. }
  27225. /**
  27226. * Produces a random number between the inclusive `lower` and `upper` bounds.
  27227. * If only one argument is provided a number between `0` and the given number
  27228. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  27229. * floats, a floating-point number is returned instead of an integer.
  27230. *
  27231. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  27232. * floating-point values which can produce unexpected results.
  27233. *
  27234. * @static
  27235. * @memberOf _
  27236. * @since 0.7.0
  27237. * @category Number
  27238. * @param {number} [lower=0] The lower bound.
  27239. * @param {number} [upper=1] The upper bound.
  27240. * @param {boolean} [floating] Specify returning a floating-point number.
  27241. * @returns {number} Returns the random number.
  27242. * @example
  27243. *
  27244. * _.random(0, 5);
  27245. * // => an integer between 0 and 5
  27246. *
  27247. * _.random(5);
  27248. * // => also an integer between 0 and 5
  27249. *
  27250. * _.random(5, true);
  27251. * // => a floating-point number between 0 and 5
  27252. *
  27253. * _.random(1.2, 5.2);
  27254. * // => a floating-point number between 1.2 and 5.2
  27255. */
  27256. function random(lower, upper, floating) {
  27257. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  27258. upper = floating = undefined;
  27259. }
  27260. if (floating === undefined) {
  27261. if (typeof upper == 'boolean') {
  27262. floating = upper;
  27263. upper = undefined;
  27264. }
  27265. else if (typeof lower == 'boolean') {
  27266. floating = lower;
  27267. lower = undefined;
  27268. }
  27269. }
  27270. if (lower === undefined && upper === undefined) {
  27271. lower = 0;
  27272. upper = 1;
  27273. }
  27274. else {
  27275. lower = toFinite(lower);
  27276. if (upper === undefined) {
  27277. upper = lower;
  27278. lower = 0;
  27279. } else {
  27280. upper = toFinite(upper);
  27281. }
  27282. }
  27283. if (lower > upper) {
  27284. var temp = lower;
  27285. lower = upper;
  27286. upper = temp;
  27287. }
  27288. if (floating || lower % 1 || upper % 1) {
  27289. var rand = nativeRandom();
  27290. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  27291. }
  27292. return baseRandom(lower, upper);
  27293. }
  27294. /*------------------------------------------------------------------------*/
  27295. /**
  27296. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  27297. *
  27298. * @static
  27299. * @memberOf _
  27300. * @since 3.0.0
  27301. * @category String
  27302. * @param {string} [string=''] The string to convert.
  27303. * @returns {string} Returns the camel cased string.
  27304. * @example
  27305. *
  27306. * _.camelCase('Foo Bar');
  27307. * // => 'fooBar'
  27308. *
  27309. * _.camelCase('--foo-bar--');
  27310. * // => 'fooBar'
  27311. *
  27312. * _.camelCase('__FOO_BAR__');
  27313. * // => 'fooBar'
  27314. */
  27315. var camelCase = createCompounder(function(result, word, index) {
  27316. word = word.toLowerCase();
  27317. return result + (index ? capitalize(word) : word);
  27318. });
  27319. /**
  27320. * Converts the first character of `string` to upper case and the remaining
  27321. * to lower case.
  27322. *
  27323. * @static
  27324. * @memberOf _
  27325. * @since 3.0.0
  27326. * @category String
  27327. * @param {string} [string=''] The string to capitalize.
  27328. * @returns {string} Returns the capitalized string.
  27329. * @example
  27330. *
  27331. * _.capitalize('FRED');
  27332. * // => 'Fred'
  27333. */
  27334. function capitalize(string) {
  27335. return upperFirst(toString(string).toLowerCase());
  27336. }
  27337. /**
  27338. * Deburrs `string` by converting
  27339. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  27340. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  27341. * letters to basic Latin letters and removing
  27342. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  27343. *
  27344. * @static
  27345. * @memberOf _
  27346. * @since 3.0.0
  27347. * @category String
  27348. * @param {string} [string=''] The string to deburr.
  27349. * @returns {string} Returns the deburred string.
  27350. * @example
  27351. *
  27352. * _.deburr('déjà vu');
  27353. * // => 'deja vu'
  27354. */
  27355. function deburr(string) {
  27356. string = toString(string);
  27357. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  27358. }
  27359. /**
  27360. * Checks if `string` ends with the given target string.
  27361. *
  27362. * @static
  27363. * @memberOf _
  27364. * @since 3.0.0
  27365. * @category String
  27366. * @param {string} [string=''] The string to inspect.
  27367. * @param {string} [target] The string to search for.
  27368. * @param {number} [position=string.length] The position to search up to.
  27369. * @returns {boolean} Returns `true` if `string` ends with `target`,
  27370. * else `false`.
  27371. * @example
  27372. *
  27373. * _.endsWith('abc', 'c');
  27374. * // => true
  27375. *
  27376. * _.endsWith('abc', 'b');
  27377. * // => false
  27378. *
  27379. * _.endsWith('abc', 'b', 2);
  27380. * // => true
  27381. */
  27382. function endsWith(string, target, position) {
  27383. string = toString(string);
  27384. target = baseToString(target);
  27385. var length = string.length;
  27386. position = position === undefined
  27387. ? length
  27388. : baseClamp(toInteger(position), 0, length);
  27389. var end = position;
  27390. position -= target.length;
  27391. return position >= 0 && string.slice(position, end) == target;
  27392. }
  27393. /**
  27394. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  27395. * corresponding HTML entities.
  27396. *
  27397. * **Note:** No other characters are escaped. To escape additional
  27398. * characters use a third-party library like [_he_](https://mths.be/he).
  27399. *
  27400. * Though the ">" character is escaped for symmetry, characters like
  27401. * ">" and "/" don't need escaping in HTML and have no special meaning
  27402. * unless they're part of a tag or unquoted attribute value. See
  27403. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  27404. * (under "semi-related fun fact") for more details.
  27405. *
  27406. * When working with HTML you should always
  27407. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  27408. * XSS vectors.
  27409. *
  27410. * @static
  27411. * @since 0.1.0
  27412. * @memberOf _
  27413. * @category String
  27414. * @param {string} [string=''] The string to escape.
  27415. * @returns {string} Returns the escaped string.
  27416. * @example
  27417. *
  27418. * _.escape('fred, barney, & pebbles');
  27419. * // => 'fred, barney, &amp; pebbles'
  27420. */
  27421. function escape(string) {
  27422. string = toString(string);
  27423. return (string && reHasUnescapedHtml.test(string))
  27424. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  27425. : string;
  27426. }
  27427. /**
  27428. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  27429. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  27430. *
  27431. * @static
  27432. * @memberOf _
  27433. * @since 3.0.0
  27434. * @category String
  27435. * @param {string} [string=''] The string to escape.
  27436. * @returns {string} Returns the escaped string.
  27437. * @example
  27438. *
  27439. * _.escapeRegExp('[lodash](https://lodash.com/)');
  27440. * // => '\[lodash\]\(https://lodash\.com/\)'
  27441. */
  27442. function escapeRegExp(string) {
  27443. string = toString(string);
  27444. return (string && reHasRegExpChar.test(string))
  27445. ? string.replace(reRegExpChar, '\\$&')
  27446. : string;
  27447. }
  27448. /**
  27449. * Converts `string` to
  27450. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  27451. *
  27452. * @static
  27453. * @memberOf _
  27454. * @since 3.0.0
  27455. * @category String
  27456. * @param {string} [string=''] The string to convert.
  27457. * @returns {string} Returns the kebab cased string.
  27458. * @example
  27459. *
  27460. * _.kebabCase('Foo Bar');
  27461. * // => 'foo-bar'
  27462. *
  27463. * _.kebabCase('fooBar');
  27464. * // => 'foo-bar'
  27465. *
  27466. * _.kebabCase('__FOO_BAR__');
  27467. * // => 'foo-bar'
  27468. */
  27469. var kebabCase = createCompounder(function(result, word, index) {
  27470. return result + (index ? '-' : '') + word.toLowerCase();
  27471. });
  27472. /**
  27473. * Converts `string`, as space separated words, to lower case.
  27474. *
  27475. * @static
  27476. * @memberOf _
  27477. * @since 4.0.0
  27478. * @category String
  27479. * @param {string} [string=''] The string to convert.
  27480. * @returns {string} Returns the lower cased string.
  27481. * @example
  27482. *
  27483. * _.lowerCase('--Foo-Bar--');
  27484. * // => 'foo bar'
  27485. *
  27486. * _.lowerCase('fooBar');
  27487. * // => 'foo bar'
  27488. *
  27489. * _.lowerCase('__FOO_BAR__');
  27490. * // => 'foo bar'
  27491. */
  27492. var lowerCase = createCompounder(function(result, word, index) {
  27493. return result + (index ? ' ' : '') + word.toLowerCase();
  27494. });
  27495. /**
  27496. * Converts the first character of `string` to lower case.
  27497. *
  27498. * @static
  27499. * @memberOf _
  27500. * @since 4.0.0
  27501. * @category String
  27502. * @param {string} [string=''] The string to convert.
  27503. * @returns {string} Returns the converted string.
  27504. * @example
  27505. *
  27506. * _.lowerFirst('Fred');
  27507. * // => 'fred'
  27508. *
  27509. * _.lowerFirst('FRED');
  27510. * // => 'fRED'
  27511. */
  27512. var lowerFirst = createCaseFirst('toLowerCase');
  27513. /**
  27514. * Pads `string` on the left and right sides if it's shorter than `length`.
  27515. * Padding characters are truncated if they can't be evenly divided by `length`.
  27516. *
  27517. * @static
  27518. * @memberOf _
  27519. * @since 3.0.0
  27520. * @category String
  27521. * @param {string} [string=''] The string to pad.
  27522. * @param {number} [length=0] The padding length.
  27523. * @param {string} [chars=' '] The string used as padding.
  27524. * @returns {string} Returns the padded string.
  27525. * @example
  27526. *
  27527. * _.pad('abc', 8);
  27528. * // => ' abc '
  27529. *
  27530. * _.pad('abc', 8, '_-');
  27531. * // => '_-abc_-_'
  27532. *
  27533. * _.pad('abc', 3);
  27534. * // => 'abc'
  27535. */
  27536. function pad(string, length, chars) {
  27537. string = toString(string);
  27538. length = toInteger(length);
  27539. var strLength = length ? stringSize(string) : 0;
  27540. if (!length || strLength >= length) {
  27541. return string;
  27542. }
  27543. var mid = (length - strLength) / 2;
  27544. return (
  27545. createPadding(nativeFloor(mid), chars) +
  27546. string +
  27547. createPadding(nativeCeil(mid), chars)
  27548. );
  27549. }
  27550. /**
  27551. * Pads `string` on the right side if it's shorter than `length`. Padding
  27552. * characters are truncated if they exceed `length`.
  27553. *
  27554. * @static
  27555. * @memberOf _
  27556. * @since 4.0.0
  27557. * @category String
  27558. * @param {string} [string=''] The string to pad.
  27559. * @param {number} [length=0] The padding length.
  27560. * @param {string} [chars=' '] The string used as padding.
  27561. * @returns {string} Returns the padded string.
  27562. * @example
  27563. *
  27564. * _.padEnd('abc', 6);
  27565. * // => 'abc '
  27566. *
  27567. * _.padEnd('abc', 6, '_-');
  27568. * // => 'abc_-_'
  27569. *
  27570. * _.padEnd('abc', 3);
  27571. * // => 'abc'
  27572. */
  27573. function padEnd(string, length, chars) {
  27574. string = toString(string);
  27575. length = toInteger(length);
  27576. var strLength = length ? stringSize(string) : 0;
  27577. return (length && strLength < length)
  27578. ? (string + createPadding(length - strLength, chars))
  27579. : string;
  27580. }
  27581. /**
  27582. * Pads `string` on the left side if it's shorter than `length`. Padding
  27583. * characters are truncated if they exceed `length`.
  27584. *
  27585. * @static
  27586. * @memberOf _
  27587. * @since 4.0.0
  27588. * @category String
  27589. * @param {string} [string=''] The string to pad.
  27590. * @param {number} [length=0] The padding length.
  27591. * @param {string} [chars=' '] The string used as padding.
  27592. * @returns {string} Returns the padded string.
  27593. * @example
  27594. *
  27595. * _.padStart('abc', 6);
  27596. * // => ' abc'
  27597. *
  27598. * _.padStart('abc', 6, '_-');
  27599. * // => '_-_abc'
  27600. *
  27601. * _.padStart('abc', 3);
  27602. * // => 'abc'
  27603. */
  27604. function padStart(string, length, chars) {
  27605. string = toString(string);
  27606. length = toInteger(length);
  27607. var strLength = length ? stringSize(string) : 0;
  27608. return (length && strLength < length)
  27609. ? (createPadding(length - strLength, chars) + string)
  27610. : string;
  27611. }
  27612. /**
  27613. * Converts `string` to an integer of the specified radix. If `radix` is
  27614. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  27615. * hexadecimal, in which case a `radix` of `16` is used.
  27616. *
  27617. * **Note:** This method aligns with the
  27618. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  27619. *
  27620. * @static
  27621. * @memberOf _
  27622. * @since 1.1.0
  27623. * @category String
  27624. * @param {string} string The string to convert.
  27625. * @param {number} [radix=10] The radix to interpret `value` by.
  27626. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27627. * @returns {number} Returns the converted integer.
  27628. * @example
  27629. *
  27630. * _.parseInt('08');
  27631. * // => 8
  27632. *
  27633. * _.map(['6', '08', '10'], _.parseInt);
  27634. * // => [6, 8, 10]
  27635. */
  27636. function parseInt(string, radix, guard) {
  27637. if (guard || radix == null) {
  27638. radix = 0;
  27639. } else if (radix) {
  27640. radix = +radix;
  27641. }
  27642. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  27643. }
  27644. /**
  27645. * Repeats the given string `n` times.
  27646. *
  27647. * @static
  27648. * @memberOf _
  27649. * @since 3.0.0
  27650. * @category String
  27651. * @param {string} [string=''] The string to repeat.
  27652. * @param {number} [n=1] The number of times to repeat the string.
  27653. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27654. * @returns {string} Returns the repeated string.
  27655. * @example
  27656. *
  27657. * _.repeat('*', 3);
  27658. * // => '***'
  27659. *
  27660. * _.repeat('abc', 2);
  27661. * // => 'abcabc'
  27662. *
  27663. * _.repeat('abc', 0);
  27664. * // => ''
  27665. */
  27666. function repeat(string, n, guard) {
  27667. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  27668. n = 1;
  27669. } else {
  27670. n = toInteger(n);
  27671. }
  27672. return baseRepeat(toString(string), n);
  27673. }
  27674. /**
  27675. * Replaces matches for `pattern` in `string` with `replacement`.
  27676. *
  27677. * **Note:** This method is based on
  27678. * [`String#replace`](https://mdn.io/String/replace).
  27679. *
  27680. * @static
  27681. * @memberOf _
  27682. * @since 4.0.0
  27683. * @category String
  27684. * @param {string} [string=''] The string to modify.
  27685. * @param {RegExp|string} pattern The pattern to replace.
  27686. * @param {Function|string} replacement The match replacement.
  27687. * @returns {string} Returns the modified string.
  27688. * @example
  27689. *
  27690. * _.replace('Hi Fred', 'Fred', 'Barney');
  27691. * // => 'Hi Barney'
  27692. */
  27693. function replace() {
  27694. var args = arguments,
  27695. string = toString(args[0]);
  27696. return args.length < 3 ? string : string.replace(args[1], args[2]);
  27697. }
  27698. /**
  27699. * Converts `string` to
  27700. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  27701. *
  27702. * @static
  27703. * @memberOf _
  27704. * @since 3.0.0
  27705. * @category String
  27706. * @param {string} [string=''] The string to convert.
  27707. * @returns {string} Returns the snake cased string.
  27708. * @example
  27709. *
  27710. * _.snakeCase('Foo Bar');
  27711. * // => 'foo_bar'
  27712. *
  27713. * _.snakeCase('fooBar');
  27714. * // => 'foo_bar'
  27715. *
  27716. * _.snakeCase('--FOO-BAR--');
  27717. * // => 'foo_bar'
  27718. */
  27719. var snakeCase = createCompounder(function(result, word, index) {
  27720. return result + (index ? '_' : '') + word.toLowerCase();
  27721. });
  27722. /**
  27723. * Splits `string` by `separator`.
  27724. *
  27725. * **Note:** This method is based on
  27726. * [`String#split`](https://mdn.io/String/split).
  27727. *
  27728. * @static
  27729. * @memberOf _
  27730. * @since 4.0.0
  27731. * @category String
  27732. * @param {string} [string=''] The string to split.
  27733. * @param {RegExp|string} separator The separator pattern to split by.
  27734. * @param {number} [limit] The length to truncate results to.
  27735. * @returns {Array} Returns the string segments.
  27736. * @example
  27737. *
  27738. * _.split('a-b-c', '-', 2);
  27739. * // => ['a', 'b']
  27740. */
  27741. function split(string, separator, limit) {
  27742. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  27743. separator = limit = undefined;
  27744. }
  27745. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  27746. if (!limit) {
  27747. return [];
  27748. }
  27749. string = toString(string);
  27750. if (string && (
  27751. typeof separator == 'string' ||
  27752. (separator != null && !isRegExp(separator))
  27753. )) {
  27754. separator = baseToString(separator);
  27755. if (!separator && hasUnicode(string)) {
  27756. return castSlice(stringToArray(string), 0, limit);
  27757. }
  27758. }
  27759. return string.split(separator, limit);
  27760. }
  27761. /**
  27762. * Converts `string` to
  27763. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  27764. *
  27765. * @static
  27766. * @memberOf _
  27767. * @since 3.1.0
  27768. * @category String
  27769. * @param {string} [string=''] The string to convert.
  27770. * @returns {string} Returns the start cased string.
  27771. * @example
  27772. *
  27773. * _.startCase('--foo-bar--');
  27774. * // => 'Foo Bar'
  27775. *
  27776. * _.startCase('fooBar');
  27777. * // => 'Foo Bar'
  27778. *
  27779. * _.startCase('__FOO_BAR__');
  27780. * // => 'FOO BAR'
  27781. */
  27782. var startCase = createCompounder(function(result, word, index) {
  27783. return result + (index ? ' ' : '') + upperFirst(word);
  27784. });
  27785. /**
  27786. * Checks if `string` starts with the given target string.
  27787. *
  27788. * @static
  27789. * @memberOf _
  27790. * @since 3.0.0
  27791. * @category String
  27792. * @param {string} [string=''] The string to inspect.
  27793. * @param {string} [target] The string to search for.
  27794. * @param {number} [position=0] The position to search from.
  27795. * @returns {boolean} Returns `true` if `string` starts with `target`,
  27796. * else `false`.
  27797. * @example
  27798. *
  27799. * _.startsWith('abc', 'a');
  27800. * // => true
  27801. *
  27802. * _.startsWith('abc', 'b');
  27803. * // => false
  27804. *
  27805. * _.startsWith('abc', 'b', 1);
  27806. * // => true
  27807. */
  27808. function startsWith(string, target, position) {
  27809. string = toString(string);
  27810. position = position == null
  27811. ? 0
  27812. : baseClamp(toInteger(position), 0, string.length);
  27813. target = baseToString(target);
  27814. return string.slice(position, position + target.length) == target;
  27815. }
  27816. /**
  27817. * Creates a compiled template function that can interpolate data properties
  27818. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  27819. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  27820. * properties may be accessed as free variables in the template. If a setting
  27821. * object is given, it takes precedence over `_.templateSettings` values.
  27822. *
  27823. * **Note:** In the development build `_.template` utilizes
  27824. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  27825. * for easier debugging.
  27826. *
  27827. * For more information on precompiling templates see
  27828. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  27829. *
  27830. * For more information on Chrome extension sandboxes see
  27831. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  27832. *
  27833. * @static
  27834. * @since 0.1.0
  27835. * @memberOf _
  27836. * @category String
  27837. * @param {string} [string=''] The template string.
  27838. * @param {Object} [options={}] The options object.
  27839. * @param {RegExp} [options.escape=_.templateSettings.escape]
  27840. * The HTML "escape" delimiter.
  27841. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  27842. * The "evaluate" delimiter.
  27843. * @param {Object} [options.imports=_.templateSettings.imports]
  27844. * An object to import into the template as free variables.
  27845. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  27846. * The "interpolate" delimiter.
  27847. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  27848. * The sourceURL of the compiled template.
  27849. * @param {string} [options.variable='obj']
  27850. * The data object variable name.
  27851. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27852. * @returns {Function} Returns the compiled template function.
  27853. * @example
  27854. *
  27855. * // Use the "interpolate" delimiter to create a compiled template.
  27856. * var compiled = _.template('hello <%= user %>!');
  27857. * compiled({ 'user': 'fred' });
  27858. * // => 'hello fred!'
  27859. *
  27860. * // Use the HTML "escape" delimiter to escape data property values.
  27861. * var compiled = _.template('<b><%- value %></b>');
  27862. * compiled({ 'value': '<script>' });
  27863. * // => '<b>&lt;script&gt;</b>'
  27864. *
  27865. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  27866. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  27867. * compiled({ 'users': ['fred', 'barney'] });
  27868. * // => '<li>fred</li><li>barney</li>'
  27869. *
  27870. * // Use the internal `print` function in "evaluate" delimiters.
  27871. * var compiled = _.template('<% print("hello " + user); %>!');
  27872. * compiled({ 'user': 'barney' });
  27873. * // => 'hello barney!'
  27874. *
  27875. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  27876. * // Disable support by replacing the "interpolate" delimiter.
  27877. * var compiled = _.template('hello ${ user }!');
  27878. * compiled({ 'user': 'pebbles' });
  27879. * // => 'hello pebbles!'
  27880. *
  27881. * // Use backslashes to treat delimiters as plain text.
  27882. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  27883. * compiled({ 'value': 'ignored' });
  27884. * // => '<%- value %>'
  27885. *
  27886. * // Use the `imports` option to import `jQuery` as `jq`.
  27887. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  27888. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  27889. * compiled({ 'users': ['fred', 'barney'] });
  27890. * // => '<li>fred</li><li>barney</li>'
  27891. *
  27892. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  27893. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  27894. * compiled(data);
  27895. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  27896. *
  27897. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  27898. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  27899. * compiled.source;
  27900. * // => function(data) {
  27901. * // var __t, __p = '';
  27902. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  27903. * // return __p;
  27904. * // }
  27905. *
  27906. * // Use custom template delimiters.
  27907. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  27908. * var compiled = _.template('hello {{ user }}!');
  27909. * compiled({ 'user': 'mustache' });
  27910. * // => 'hello mustache!'
  27911. *
  27912. * // Use the `source` property to inline compiled templates for meaningful
  27913. * // line numbers in error messages and stack traces.
  27914. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  27915. * var JST = {\
  27916. * "main": ' + _.template(mainText).source + '\
  27917. * };\
  27918. * ');
  27919. */
  27920. function template(string, options, guard) {
  27921. // Based on John Resig's `tmpl` implementation
  27922. // (http://ejohn.org/blog/javascript-micro-templating/)
  27923. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  27924. var settings = lodash.templateSettings;
  27925. if (guard && isIterateeCall(string, options, guard)) {
  27926. options = undefined;
  27927. }
  27928. string = toString(string);
  27929. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  27930. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  27931. importsKeys = keys(imports),
  27932. importsValues = baseValues(imports, importsKeys);
  27933. var isEscaping,
  27934. isEvaluating,
  27935. index = 0,
  27936. interpolate = options.interpolate || reNoMatch,
  27937. source = "__p += '";
  27938. // Compile the regexp to match each delimiter.
  27939. var reDelimiters = RegExp(
  27940. (options.escape || reNoMatch).source + '|' +
  27941. interpolate.source + '|' +
  27942. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  27943. (options.evaluate || reNoMatch).source + '|$'
  27944. , 'g');
  27945. // Use a sourceURL for easier debugging.
  27946. // The sourceURL gets injected into the source that's eval-ed, so be careful
  27947. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  27948. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  27949. var sourceURL = '//# sourceURL=' +
  27950. (hasOwnProperty.call(options, 'sourceURL')
  27951. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  27952. : ('lodash.templateSources[' + (++templateCounter) + ']')
  27953. ) + '\n';
  27954. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  27955. interpolateValue || (interpolateValue = esTemplateValue);
  27956. // Escape characters that can't be included in string literals.
  27957. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  27958. // Replace delimiters with snippets.
  27959. if (escapeValue) {
  27960. isEscaping = true;
  27961. source += "' +\n__e(" + escapeValue + ") +\n'";
  27962. }
  27963. if (evaluateValue) {
  27964. isEvaluating = true;
  27965. source += "';\n" + evaluateValue + ";\n__p += '";
  27966. }
  27967. if (interpolateValue) {
  27968. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  27969. }
  27970. index = offset + match.length;
  27971. // The JS engine embedded in Adobe products needs `match` returned in
  27972. // order to produce the correct `offset` value.
  27973. return match;
  27974. });
  27975. source += "';\n";
  27976. // If `variable` is not specified wrap a with-statement around the generated
  27977. // code to add the data object to the top of the scope chain.
  27978. // Like with sourceURL, we take care to not check the option's prototype,
  27979. // as this configuration is a code injection vector.
  27980. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  27981. if (!variable) {
  27982. source = 'with (obj) {\n' + source + '\n}\n';
  27983. }
  27984. // Cleanup code by stripping empty strings.
  27985. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  27986. .replace(reEmptyStringMiddle, '$1')
  27987. .replace(reEmptyStringTrailing, '$1;');
  27988. // Frame code as the function body.
  27989. source = 'function(' + (variable || 'obj') + ') {\n' +
  27990. (variable
  27991. ? ''
  27992. : 'obj || (obj = {});\n'
  27993. ) +
  27994. "var __t, __p = ''" +
  27995. (isEscaping
  27996. ? ', __e = _.escape'
  27997. : ''
  27998. ) +
  27999. (isEvaluating
  28000. ? ', __j = Array.prototype.join;\n' +
  28001. "function print() { __p += __j.call(arguments, '') }\n"
  28002. : ';\n'
  28003. ) +
  28004. source +
  28005. 'return __p\n}';
  28006. var result = attempt(function() {
  28007. return Function(importsKeys, sourceURL + 'return ' + source)
  28008. .apply(undefined, importsValues);
  28009. });
  28010. // Provide the compiled function's source by its `toString` method or
  28011. // the `source` property as a convenience for inlining compiled templates.
  28012. result.source = source;
  28013. if (isError(result)) {
  28014. throw result;
  28015. }
  28016. return result;
  28017. }
  28018. /**
  28019. * Converts `string`, as a whole, to lower case just like
  28020. * [String#toLowerCase](https://mdn.io/toLowerCase).
  28021. *
  28022. * @static
  28023. * @memberOf _
  28024. * @since 4.0.0
  28025. * @category String
  28026. * @param {string} [string=''] The string to convert.
  28027. * @returns {string} Returns the lower cased string.
  28028. * @example
  28029. *
  28030. * _.toLower('--Foo-Bar--');
  28031. * // => '--foo-bar--'
  28032. *
  28033. * _.toLower('fooBar');
  28034. * // => 'foobar'
  28035. *
  28036. * _.toLower('__FOO_BAR__');
  28037. * // => '__foo_bar__'
  28038. */
  28039. function toLower(value) {
  28040. return toString(value).toLowerCase();
  28041. }
  28042. /**
  28043. * Converts `string`, as a whole, to upper case just like
  28044. * [String#toUpperCase](https://mdn.io/toUpperCase).
  28045. *
  28046. * @static
  28047. * @memberOf _
  28048. * @since 4.0.0
  28049. * @category String
  28050. * @param {string} [string=''] The string to convert.
  28051. * @returns {string} Returns the upper cased string.
  28052. * @example
  28053. *
  28054. * _.toUpper('--foo-bar--');
  28055. * // => '--FOO-BAR--'
  28056. *
  28057. * _.toUpper('fooBar');
  28058. * // => 'FOOBAR'
  28059. *
  28060. * _.toUpper('__foo_bar__');
  28061. * // => '__FOO_BAR__'
  28062. */
  28063. function toUpper(value) {
  28064. return toString(value).toUpperCase();
  28065. }
  28066. /**
  28067. * Removes leading and trailing whitespace or specified characters from `string`.
  28068. *
  28069. * @static
  28070. * @memberOf _
  28071. * @since 3.0.0
  28072. * @category String
  28073. * @param {string} [string=''] The string to trim.
  28074. * @param {string} [chars=whitespace] The characters to trim.
  28075. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28076. * @returns {string} Returns the trimmed string.
  28077. * @example
  28078. *
  28079. * _.trim(' abc ');
  28080. * // => 'abc'
  28081. *
  28082. * _.trim('-_-abc-_-', '_-');
  28083. * // => 'abc'
  28084. *
  28085. * _.map([' foo ', ' bar '], _.trim);
  28086. * // => ['foo', 'bar']
  28087. */
  28088. function trim(string, chars, guard) {
  28089. string = toString(string);
  28090. if (string && (guard || chars === undefined)) {
  28091. return string.replace(reTrim, '');
  28092. }
  28093. if (!string || !(chars = baseToString(chars))) {
  28094. return string;
  28095. }
  28096. var strSymbols = stringToArray(string),
  28097. chrSymbols = stringToArray(chars),
  28098. start = charsStartIndex(strSymbols, chrSymbols),
  28099. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  28100. return castSlice(strSymbols, start, end).join('');
  28101. }
  28102. /**
  28103. * Removes trailing whitespace or specified characters from `string`.
  28104. *
  28105. * @static
  28106. * @memberOf _
  28107. * @since 4.0.0
  28108. * @category String
  28109. * @param {string} [string=''] The string to trim.
  28110. * @param {string} [chars=whitespace] The characters to trim.
  28111. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28112. * @returns {string} Returns the trimmed string.
  28113. * @example
  28114. *
  28115. * _.trimEnd(' abc ');
  28116. * // => ' abc'
  28117. *
  28118. * _.trimEnd('-_-abc-_-', '_-');
  28119. * // => '-_-abc'
  28120. */
  28121. function trimEnd(string, chars, guard) {
  28122. string = toString(string);
  28123. if (string && (guard || chars === undefined)) {
  28124. return string.replace(reTrimEnd, '');
  28125. }
  28126. if (!string || !(chars = baseToString(chars))) {
  28127. return string;
  28128. }
  28129. var strSymbols = stringToArray(string),
  28130. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  28131. return castSlice(strSymbols, 0, end).join('');
  28132. }
  28133. /**
  28134. * Removes leading whitespace or specified characters from `string`.
  28135. *
  28136. * @static
  28137. * @memberOf _
  28138. * @since 4.0.0
  28139. * @category String
  28140. * @param {string} [string=''] The string to trim.
  28141. * @param {string} [chars=whitespace] The characters to trim.
  28142. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28143. * @returns {string} Returns the trimmed string.
  28144. * @example
  28145. *
  28146. * _.trimStart(' abc ');
  28147. * // => 'abc '
  28148. *
  28149. * _.trimStart('-_-abc-_-', '_-');
  28150. * // => 'abc-_-'
  28151. */
  28152. function trimStart(string, chars, guard) {
  28153. string = toString(string);
  28154. if (string && (guard || chars === undefined)) {
  28155. return string.replace(reTrimStart, '');
  28156. }
  28157. if (!string || !(chars = baseToString(chars))) {
  28158. return string;
  28159. }
  28160. var strSymbols = stringToArray(string),
  28161. start = charsStartIndex(strSymbols, stringToArray(chars));
  28162. return castSlice(strSymbols, start).join('');
  28163. }
  28164. /**
  28165. * Truncates `string` if it's longer than the given maximum string length.
  28166. * The last characters of the truncated string are replaced with the omission
  28167. * string which defaults to "...".
  28168. *
  28169. * @static
  28170. * @memberOf _
  28171. * @since 4.0.0
  28172. * @category String
  28173. * @param {string} [string=''] The string to truncate.
  28174. * @param {Object} [options={}] The options object.
  28175. * @param {number} [options.length=30] The maximum string length.
  28176. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  28177. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  28178. * @returns {string} Returns the truncated string.
  28179. * @example
  28180. *
  28181. * _.truncate('hi-diddly-ho there, neighborino');
  28182. * // => 'hi-diddly-ho there, neighbo...'
  28183. *
  28184. * _.truncate('hi-diddly-ho there, neighborino', {
  28185. * 'length': 24,
  28186. * 'separator': ' '
  28187. * });
  28188. * // => 'hi-diddly-ho there,...'
  28189. *
  28190. * _.truncate('hi-diddly-ho there, neighborino', {
  28191. * 'length': 24,
  28192. * 'separator': /,? +/
  28193. * });
  28194. * // => 'hi-diddly-ho there...'
  28195. *
  28196. * _.truncate('hi-diddly-ho there, neighborino', {
  28197. * 'omission': ' [...]'
  28198. * });
  28199. * // => 'hi-diddly-ho there, neig [...]'
  28200. */
  28201. function truncate(string, options) {
  28202. var length = DEFAULT_TRUNC_LENGTH,
  28203. omission = DEFAULT_TRUNC_OMISSION;
  28204. if (isObject(options)) {
  28205. var separator = 'separator' in options ? options.separator : separator;
  28206. length = 'length' in options ? toInteger(options.length) : length;
  28207. omission = 'omission' in options ? baseToString(options.omission) : omission;
  28208. }
  28209. string = toString(string);
  28210. var strLength = string.length;
  28211. if (hasUnicode(string)) {
  28212. var strSymbols = stringToArray(string);
  28213. strLength = strSymbols.length;
  28214. }
  28215. if (length >= strLength) {
  28216. return string;
  28217. }
  28218. var end = length - stringSize(omission);
  28219. if (end < 1) {
  28220. return omission;
  28221. }
  28222. var result = strSymbols
  28223. ? castSlice(strSymbols, 0, end).join('')
  28224. : string.slice(0, end);
  28225. if (separator === undefined) {
  28226. return result + omission;
  28227. }
  28228. if (strSymbols) {
  28229. end += (result.length - end);
  28230. }
  28231. if (isRegExp(separator)) {
  28232. if (string.slice(end).search(separator)) {
  28233. var match,
  28234. substring = result;
  28235. if (!separator.global) {
  28236. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  28237. }
  28238. separator.lastIndex = 0;
  28239. while ((match = separator.exec(substring))) {
  28240. var newEnd = match.index;
  28241. }
  28242. result = result.slice(0, newEnd === undefined ? end : newEnd);
  28243. }
  28244. } else if (string.indexOf(baseToString(separator), end) != end) {
  28245. var index = result.lastIndexOf(separator);
  28246. if (index > -1) {
  28247. result = result.slice(0, index);
  28248. }
  28249. }
  28250. return result + omission;
  28251. }
  28252. /**
  28253. * The inverse of `_.escape`; this method converts the HTML entities
  28254. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  28255. * their corresponding characters.
  28256. *
  28257. * **Note:** No other HTML entities are unescaped. To unescape additional
  28258. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  28259. *
  28260. * @static
  28261. * @memberOf _
  28262. * @since 0.6.0
  28263. * @category String
  28264. * @param {string} [string=''] The string to unescape.
  28265. * @returns {string} Returns the unescaped string.
  28266. * @example
  28267. *
  28268. * _.unescape('fred, barney, &amp; pebbles');
  28269. * // => 'fred, barney, & pebbles'
  28270. */
  28271. function unescape(string) {
  28272. string = toString(string);
  28273. return (string && reHasEscapedHtml.test(string))
  28274. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  28275. : string;
  28276. }
  28277. /**
  28278. * Converts `string`, as space separated words, to upper case.
  28279. *
  28280. * @static
  28281. * @memberOf _
  28282. * @since 4.0.0
  28283. * @category String
  28284. * @param {string} [string=''] The string to convert.
  28285. * @returns {string} Returns the upper cased string.
  28286. * @example
  28287. *
  28288. * _.upperCase('--foo-bar');
  28289. * // => 'FOO BAR'
  28290. *
  28291. * _.upperCase('fooBar');
  28292. * // => 'FOO BAR'
  28293. *
  28294. * _.upperCase('__foo_bar__');
  28295. * // => 'FOO BAR'
  28296. */
  28297. var upperCase = createCompounder(function(result, word, index) {
  28298. return result + (index ? ' ' : '') + word.toUpperCase();
  28299. });
  28300. /**
  28301. * Converts the first character of `string` to upper case.
  28302. *
  28303. * @static
  28304. * @memberOf _
  28305. * @since 4.0.0
  28306. * @category String
  28307. * @param {string} [string=''] The string to convert.
  28308. * @returns {string} Returns the converted string.
  28309. * @example
  28310. *
  28311. * _.upperFirst('fred');
  28312. * // => 'Fred'
  28313. *
  28314. * _.upperFirst('FRED');
  28315. * // => 'FRED'
  28316. */
  28317. var upperFirst = createCaseFirst('toUpperCase');
  28318. /**
  28319. * Splits `string` into an array of its words.
  28320. *
  28321. * @static
  28322. * @memberOf _
  28323. * @since 3.0.0
  28324. * @category String
  28325. * @param {string} [string=''] The string to inspect.
  28326. * @param {RegExp|string} [pattern] The pattern to match words.
  28327. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28328. * @returns {Array} Returns the words of `string`.
  28329. * @example
  28330. *
  28331. * _.words('fred, barney, & pebbles');
  28332. * // => ['fred', 'barney', 'pebbles']
  28333. *
  28334. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  28335. * // => ['fred', 'barney', '&', 'pebbles']
  28336. */
  28337. function words(string, pattern, guard) {
  28338. string = toString(string);
  28339. pattern = guard ? undefined : pattern;
  28340. if (pattern === undefined) {
  28341. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  28342. }
  28343. return string.match(pattern) || [];
  28344. }
  28345. /*------------------------------------------------------------------------*/
  28346. /**
  28347. * Attempts to invoke `func`, returning either the result or the caught error
  28348. * object. Any additional arguments are provided to `func` when it's invoked.
  28349. *
  28350. * @static
  28351. * @memberOf _
  28352. * @since 3.0.0
  28353. * @category Util
  28354. * @param {Function} func The function to attempt.
  28355. * @param {...*} [args] The arguments to invoke `func` with.
  28356. * @returns {*} Returns the `func` result or error object.
  28357. * @example
  28358. *
  28359. * // Avoid throwing errors for invalid selectors.
  28360. * var elements = _.attempt(function(selector) {
  28361. * return document.querySelectorAll(selector);
  28362. * }, '>_>');
  28363. *
  28364. * if (_.isError(elements)) {
  28365. * elements = [];
  28366. * }
  28367. */
  28368. var attempt = baseRest(function(func, args) {
  28369. try {
  28370. return apply(func, undefined, args);
  28371. } catch (e) {
  28372. return isError(e) ? e : new Error(e);
  28373. }
  28374. });
  28375. /**
  28376. * Binds methods of an object to the object itself, overwriting the existing
  28377. * method.
  28378. *
  28379. * **Note:** This method doesn't set the "length" property of bound functions.
  28380. *
  28381. * @static
  28382. * @since 0.1.0
  28383. * @memberOf _
  28384. * @category Util
  28385. * @param {Object} object The object to bind and assign the bound methods to.
  28386. * @param {...(string|string[])} methodNames The object method names to bind.
  28387. * @returns {Object} Returns `object`.
  28388. * @example
  28389. *
  28390. * var view = {
  28391. * 'label': 'docs',
  28392. * 'click': function() {
  28393. * console.log('clicked ' + this.label);
  28394. * }
  28395. * };
  28396. *
  28397. * _.bindAll(view, ['click']);
  28398. * jQuery(element).on('click', view.click);
  28399. * // => Logs 'clicked docs' when clicked.
  28400. */
  28401. var bindAll = flatRest(function(object, methodNames) {
  28402. arrayEach(methodNames, function(key) {
  28403. key = toKey(key);
  28404. baseAssignValue(object, key, bind(object[key], object));
  28405. });
  28406. return object;
  28407. });
  28408. /**
  28409. * Creates a function that iterates over `pairs` and invokes the corresponding
  28410. * function of the first predicate to return truthy. The predicate-function
  28411. * pairs are invoked with the `this` binding and arguments of the created
  28412. * function.
  28413. *
  28414. * @static
  28415. * @memberOf _
  28416. * @since 4.0.0
  28417. * @category Util
  28418. * @param {Array} pairs The predicate-function pairs.
  28419. * @returns {Function} Returns the new composite function.
  28420. * @example
  28421. *
  28422. * var func = _.cond([
  28423. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  28424. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  28425. * [_.stubTrue, _.constant('no match')]
  28426. * ]);
  28427. *
  28428. * func({ 'a': 1, 'b': 2 });
  28429. * // => 'matches A'
  28430. *
  28431. * func({ 'a': 0, 'b': 1 });
  28432. * // => 'matches B'
  28433. *
  28434. * func({ 'a': '1', 'b': '2' });
  28435. * // => 'no match'
  28436. */
  28437. function cond(pairs) {
  28438. var length = pairs == null ? 0 : pairs.length,
  28439. toIteratee = getIteratee();
  28440. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  28441. if (typeof pair[1] != 'function') {
  28442. throw new TypeError(FUNC_ERROR_TEXT);
  28443. }
  28444. return [toIteratee(pair[0]), pair[1]];
  28445. });
  28446. return baseRest(function(args) {
  28447. var index = -1;
  28448. while (++index < length) {
  28449. var pair = pairs[index];
  28450. if (apply(pair[0], this, args)) {
  28451. return apply(pair[1], this, args);
  28452. }
  28453. }
  28454. });
  28455. }
  28456. /**
  28457. * Creates a function that invokes the predicate properties of `source` with
  28458. * the corresponding property values of a given object, returning `true` if
  28459. * all predicates return truthy, else `false`.
  28460. *
  28461. * **Note:** The created function is equivalent to `_.conformsTo` with
  28462. * `source` partially applied.
  28463. *
  28464. * @static
  28465. * @memberOf _
  28466. * @since 4.0.0
  28467. * @category Util
  28468. * @param {Object} source The object of property predicates to conform to.
  28469. * @returns {Function} Returns the new spec function.
  28470. * @example
  28471. *
  28472. * var objects = [
  28473. * { 'a': 2, 'b': 1 },
  28474. * { 'a': 1, 'b': 2 }
  28475. * ];
  28476. *
  28477. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  28478. * // => [{ 'a': 1, 'b': 2 }]
  28479. */
  28480. function conforms(source) {
  28481. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  28482. }
  28483. /**
  28484. * Creates a function that returns `value`.
  28485. *
  28486. * @static
  28487. * @memberOf _
  28488. * @since 2.4.0
  28489. * @category Util
  28490. * @param {*} value The value to return from the new function.
  28491. * @returns {Function} Returns the new constant function.
  28492. * @example
  28493. *
  28494. * var objects = _.times(2, _.constant({ 'a': 1 }));
  28495. *
  28496. * console.log(objects);
  28497. * // => [{ 'a': 1 }, { 'a': 1 }]
  28498. *
  28499. * console.log(objects[0] === objects[1]);
  28500. * // => true
  28501. */
  28502. function constant(value) {
  28503. return function() {
  28504. return value;
  28505. };
  28506. }
  28507. /**
  28508. * Checks `value` to determine whether a default value should be returned in
  28509. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  28510. * or `undefined`.
  28511. *
  28512. * @static
  28513. * @memberOf _
  28514. * @since 4.14.0
  28515. * @category Util
  28516. * @param {*} value The value to check.
  28517. * @param {*} defaultValue The default value.
  28518. * @returns {*} Returns the resolved value.
  28519. * @example
  28520. *
  28521. * _.defaultTo(1, 10);
  28522. * // => 1
  28523. *
  28524. * _.defaultTo(undefined, 10);
  28525. * // => 10
  28526. */
  28527. function defaultTo(value, defaultValue) {
  28528. return (value == null || value !== value) ? defaultValue : value;
  28529. }
  28530. /**
  28531. * Creates a function that returns the result of invoking the given functions
  28532. * with the `this` binding of the created function, where each successive
  28533. * invocation is supplied the return value of the previous.
  28534. *
  28535. * @static
  28536. * @memberOf _
  28537. * @since 3.0.0
  28538. * @category Util
  28539. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28540. * @returns {Function} Returns the new composite function.
  28541. * @see _.flowRight
  28542. * @example
  28543. *
  28544. * function square(n) {
  28545. * return n * n;
  28546. * }
  28547. *
  28548. * var addSquare = _.flow([_.add, square]);
  28549. * addSquare(1, 2);
  28550. * // => 9
  28551. */
  28552. var flow = createFlow();
  28553. /**
  28554. * This method is like `_.flow` except that it creates a function that
  28555. * invokes the given functions from right to left.
  28556. *
  28557. * @static
  28558. * @since 3.0.0
  28559. * @memberOf _
  28560. * @category Util
  28561. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28562. * @returns {Function} Returns the new composite function.
  28563. * @see _.flow
  28564. * @example
  28565. *
  28566. * function square(n) {
  28567. * return n * n;
  28568. * }
  28569. *
  28570. * var addSquare = _.flowRight([square, _.add]);
  28571. * addSquare(1, 2);
  28572. * // => 9
  28573. */
  28574. var flowRight = createFlow(true);
  28575. /**
  28576. * This method returns the first argument it receives.
  28577. *
  28578. * @static
  28579. * @since 0.1.0
  28580. * @memberOf _
  28581. * @category Util
  28582. * @param {*} value Any value.
  28583. * @returns {*} Returns `value`.
  28584. * @example
  28585. *
  28586. * var object = { 'a': 1 };
  28587. *
  28588. * console.log(_.identity(object) === object);
  28589. * // => true
  28590. */
  28591. function identity(value) {
  28592. return value;
  28593. }
  28594. /**
  28595. * Creates a function that invokes `func` with the arguments of the created
  28596. * function. If `func` is a property name, the created function returns the
  28597. * property value for a given element. If `func` is an array or object, the
  28598. * created function returns `true` for elements that contain the equivalent
  28599. * source properties, otherwise it returns `false`.
  28600. *
  28601. * @static
  28602. * @since 4.0.0
  28603. * @memberOf _
  28604. * @category Util
  28605. * @param {*} [func=_.identity] The value to convert to a callback.
  28606. * @returns {Function} Returns the callback.
  28607. * @example
  28608. *
  28609. * var users = [
  28610. * { 'user': 'barney', 'age': 36, 'active': true },
  28611. * { 'user': 'fred', 'age': 40, 'active': false }
  28612. * ];
  28613. *
  28614. * // The `_.matches` iteratee shorthand.
  28615. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  28616. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  28617. *
  28618. * // The `_.matchesProperty` iteratee shorthand.
  28619. * _.filter(users, _.iteratee(['user', 'fred']));
  28620. * // => [{ 'user': 'fred', 'age': 40 }]
  28621. *
  28622. * // The `_.property` iteratee shorthand.
  28623. * _.map(users, _.iteratee('user'));
  28624. * // => ['barney', 'fred']
  28625. *
  28626. * // Create custom iteratee shorthands.
  28627. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  28628. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  28629. * return func.test(string);
  28630. * };
  28631. * });
  28632. *
  28633. * _.filter(['abc', 'def'], /ef/);
  28634. * // => ['def']
  28635. */
  28636. function iteratee(func) {
  28637. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  28638. }
  28639. /**
  28640. * Creates a function that performs a partial deep comparison between a given
  28641. * object and `source`, returning `true` if the given object has equivalent
  28642. * property values, else `false`.
  28643. *
  28644. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  28645. * partially applied.
  28646. *
  28647. * Partial comparisons will match empty array and empty object `source`
  28648. * values against any array or object value, respectively. See `_.isEqual`
  28649. * for a list of supported value comparisons.
  28650. *
  28651. * @static
  28652. * @memberOf _
  28653. * @since 3.0.0
  28654. * @category Util
  28655. * @param {Object} source The object of property values to match.
  28656. * @returns {Function} Returns the new spec function.
  28657. * @example
  28658. *
  28659. * var objects = [
  28660. * { 'a': 1, 'b': 2, 'c': 3 },
  28661. * { 'a': 4, 'b': 5, 'c': 6 }
  28662. * ];
  28663. *
  28664. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  28665. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  28666. */
  28667. function matches(source) {
  28668. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  28669. }
  28670. /**
  28671. * Creates a function that performs a partial deep comparison between the
  28672. * value at `path` of a given object to `srcValue`, returning `true` if the
  28673. * object value is equivalent, else `false`.
  28674. *
  28675. * **Note:** Partial comparisons will match empty array and empty object
  28676. * `srcValue` values against any array or object value, respectively. See
  28677. * `_.isEqual` for a list of supported value comparisons.
  28678. *
  28679. * @static
  28680. * @memberOf _
  28681. * @since 3.2.0
  28682. * @category Util
  28683. * @param {Array|string} path The path of the property to get.
  28684. * @param {*} srcValue The value to match.
  28685. * @returns {Function} Returns the new spec function.
  28686. * @example
  28687. *
  28688. * var objects = [
  28689. * { 'a': 1, 'b': 2, 'c': 3 },
  28690. * { 'a': 4, 'b': 5, 'c': 6 }
  28691. * ];
  28692. *
  28693. * _.find(objects, _.matchesProperty('a', 4));
  28694. * // => { 'a': 4, 'b': 5, 'c': 6 }
  28695. */
  28696. function matchesProperty(path, srcValue) {
  28697. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  28698. }
  28699. /**
  28700. * Creates a function that invokes the method at `path` of a given object.
  28701. * Any additional arguments are provided to the invoked method.
  28702. *
  28703. * @static
  28704. * @memberOf _
  28705. * @since 3.7.0
  28706. * @category Util
  28707. * @param {Array|string} path The path of the method to invoke.
  28708. * @param {...*} [args] The arguments to invoke the method with.
  28709. * @returns {Function} Returns the new invoker function.
  28710. * @example
  28711. *
  28712. * var objects = [
  28713. * { 'a': { 'b': _.constant(2) } },
  28714. * { 'a': { 'b': _.constant(1) } }
  28715. * ];
  28716. *
  28717. * _.map(objects, _.method('a.b'));
  28718. * // => [2, 1]
  28719. *
  28720. * _.map(objects, _.method(['a', 'b']));
  28721. * // => [2, 1]
  28722. */
  28723. var method = baseRest(function(path, args) {
  28724. return function(object) {
  28725. return baseInvoke(object, path, args);
  28726. };
  28727. });
  28728. /**
  28729. * The opposite of `_.method`; this method creates a function that invokes
  28730. * the method at a given path of `object`. Any additional arguments are
  28731. * provided to the invoked method.
  28732. *
  28733. * @static
  28734. * @memberOf _
  28735. * @since 3.7.0
  28736. * @category Util
  28737. * @param {Object} object The object to query.
  28738. * @param {...*} [args] The arguments to invoke the method with.
  28739. * @returns {Function} Returns the new invoker function.
  28740. * @example
  28741. *
  28742. * var array = _.times(3, _.constant),
  28743. * object = { 'a': array, 'b': array, 'c': array };
  28744. *
  28745. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  28746. * // => [2, 0]
  28747. *
  28748. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  28749. * // => [2, 0]
  28750. */
  28751. var methodOf = baseRest(function(object, args) {
  28752. return function(path) {
  28753. return baseInvoke(object, path, args);
  28754. };
  28755. });
  28756. /**
  28757. * Adds all own enumerable string keyed function properties of a source
  28758. * object to the destination object. If `object` is a function, then methods
  28759. * are added to its prototype as well.
  28760. *
  28761. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  28762. * avoid conflicts caused by modifying the original.
  28763. *
  28764. * @static
  28765. * @since 0.1.0
  28766. * @memberOf _
  28767. * @category Util
  28768. * @param {Function|Object} [object=lodash] The destination object.
  28769. * @param {Object} source The object of functions to add.
  28770. * @param {Object} [options={}] The options object.
  28771. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  28772. * @returns {Function|Object} Returns `object`.
  28773. * @example
  28774. *
  28775. * function vowels(string) {
  28776. * return _.filter(string, function(v) {
  28777. * return /[aeiou]/i.test(v);
  28778. * });
  28779. * }
  28780. *
  28781. * _.mixin({ 'vowels': vowels });
  28782. * _.vowels('fred');
  28783. * // => ['e']
  28784. *
  28785. * _('fred').vowels().value();
  28786. * // => ['e']
  28787. *
  28788. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  28789. * _('fred').vowels();
  28790. * // => ['e']
  28791. */
  28792. function mixin(object, source, options) {
  28793. var props = keys(source),
  28794. methodNames = baseFunctions(source, props);
  28795. if (options == null &&
  28796. !(isObject(source) && (methodNames.length || !props.length))) {
  28797. options = source;
  28798. source = object;
  28799. object = this;
  28800. methodNames = baseFunctions(source, keys(source));
  28801. }
  28802. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  28803. isFunc = isFunction(object);
  28804. arrayEach(methodNames, function(methodName) {
  28805. var func = source[methodName];
  28806. object[methodName] = func;
  28807. if (isFunc) {
  28808. object.prototype[methodName] = function() {
  28809. var chainAll = this.__chain__;
  28810. if (chain || chainAll) {
  28811. var result = object(this.__wrapped__),
  28812. actions = result.__actions__ = copyArray(this.__actions__);
  28813. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  28814. result.__chain__ = chainAll;
  28815. return result;
  28816. }
  28817. return func.apply(object, arrayPush([this.value()], arguments));
  28818. };
  28819. }
  28820. });
  28821. return object;
  28822. }
  28823. /**
  28824. * Reverts the `_` variable to its previous value and returns a reference to
  28825. * the `lodash` function.
  28826. *
  28827. * @static
  28828. * @since 0.1.0
  28829. * @memberOf _
  28830. * @category Util
  28831. * @returns {Function} Returns the `lodash` function.
  28832. * @example
  28833. *
  28834. * var lodash = _.noConflict();
  28835. */
  28836. function noConflict() {
  28837. if (root._ === this) {
  28838. root._ = oldDash;
  28839. }
  28840. return this;
  28841. }
  28842. /**
  28843. * This method returns `undefined`.
  28844. *
  28845. * @static
  28846. * @memberOf _
  28847. * @since 2.3.0
  28848. * @category Util
  28849. * @example
  28850. *
  28851. * _.times(2, _.noop);
  28852. * // => [undefined, undefined]
  28853. */
  28854. function noop() {
  28855. // No operation performed.
  28856. }
  28857. /**
  28858. * Creates a function that gets the argument at index `n`. If `n` is negative,
  28859. * the nth argument from the end is returned.
  28860. *
  28861. * @static
  28862. * @memberOf _
  28863. * @since 4.0.0
  28864. * @category Util
  28865. * @param {number} [n=0] The index of the argument to return.
  28866. * @returns {Function} Returns the new pass-thru function.
  28867. * @example
  28868. *
  28869. * var func = _.nthArg(1);
  28870. * func('a', 'b', 'c', 'd');
  28871. * // => 'b'
  28872. *
  28873. * var func = _.nthArg(-2);
  28874. * func('a', 'b', 'c', 'd');
  28875. * // => 'c'
  28876. */
  28877. function nthArg(n) {
  28878. n = toInteger(n);
  28879. return baseRest(function(args) {
  28880. return baseNth(args, n);
  28881. });
  28882. }
  28883. /**
  28884. * Creates a function that invokes `iteratees` with the arguments it receives
  28885. * and returns their results.
  28886. *
  28887. * @static
  28888. * @memberOf _
  28889. * @since 4.0.0
  28890. * @category Util
  28891. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  28892. * The iteratees to invoke.
  28893. * @returns {Function} Returns the new function.
  28894. * @example
  28895. *
  28896. * var func = _.over([Math.max, Math.min]);
  28897. *
  28898. * func(1, 2, 3, 4);
  28899. * // => [4, 1]
  28900. */
  28901. var over = createOver(arrayMap);
  28902. /**
  28903. * Creates a function that checks if **all** of the `predicates` return
  28904. * truthy when invoked with the arguments it receives.
  28905. *
  28906. * @static
  28907. * @memberOf _
  28908. * @since 4.0.0
  28909. * @category Util
  28910. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28911. * The predicates to check.
  28912. * @returns {Function} Returns the new function.
  28913. * @example
  28914. *
  28915. * var func = _.overEvery([Boolean, isFinite]);
  28916. *
  28917. * func('1');
  28918. * // => true
  28919. *
  28920. * func(null);
  28921. * // => false
  28922. *
  28923. * func(NaN);
  28924. * // => false
  28925. */
  28926. var overEvery = createOver(arrayEvery);
  28927. /**
  28928. * Creates a function that checks if **any** of the `predicates` return
  28929. * truthy when invoked with the arguments it receives.
  28930. *
  28931. * @static
  28932. * @memberOf _
  28933. * @since 4.0.0
  28934. * @category Util
  28935. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28936. * The predicates to check.
  28937. * @returns {Function} Returns the new function.
  28938. * @example
  28939. *
  28940. * var func = _.overSome([Boolean, isFinite]);
  28941. *
  28942. * func('1');
  28943. * // => true
  28944. *
  28945. * func(null);
  28946. * // => true
  28947. *
  28948. * func(NaN);
  28949. * // => false
  28950. */
  28951. var overSome = createOver(arraySome);
  28952. /**
  28953. * Creates a function that returns the value at `path` of a given object.
  28954. *
  28955. * @static
  28956. * @memberOf _
  28957. * @since 2.4.0
  28958. * @category Util
  28959. * @param {Array|string} path The path of the property to get.
  28960. * @returns {Function} Returns the new accessor function.
  28961. * @example
  28962. *
  28963. * var objects = [
  28964. * { 'a': { 'b': 2 } },
  28965. * { 'a': { 'b': 1 } }
  28966. * ];
  28967. *
  28968. * _.map(objects, _.property('a.b'));
  28969. * // => [2, 1]
  28970. *
  28971. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  28972. * // => [1, 2]
  28973. */
  28974. function property(path) {
  28975. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  28976. }
  28977. /**
  28978. * The opposite of `_.property`; this method creates a function that returns
  28979. * the value at a given path of `object`.
  28980. *
  28981. * @static
  28982. * @memberOf _
  28983. * @since 3.0.0
  28984. * @category Util
  28985. * @param {Object} object The object to query.
  28986. * @returns {Function} Returns the new accessor function.
  28987. * @example
  28988. *
  28989. * var array = [0, 1, 2],
  28990. * object = { 'a': array, 'b': array, 'c': array };
  28991. *
  28992. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  28993. * // => [2, 0]
  28994. *
  28995. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  28996. * // => [2, 0]
  28997. */
  28998. function propertyOf(object) {
  28999. return function(path) {
  29000. return object == null ? undefined : baseGet(object, path);
  29001. };
  29002. }
  29003. /**
  29004. * Creates an array of numbers (positive and/or negative) progressing from
  29005. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  29006. * `start` is specified without an `end` or `step`. If `end` is not specified,
  29007. * it's set to `start` with `start` then set to `0`.
  29008. *
  29009. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  29010. * floating-point values which can produce unexpected results.
  29011. *
  29012. * @static
  29013. * @since 0.1.0
  29014. * @memberOf _
  29015. * @category Util
  29016. * @param {number} [start=0] The start of the range.
  29017. * @param {number} end The end of the range.
  29018. * @param {number} [step=1] The value to increment or decrement by.
  29019. * @returns {Array} Returns the range of numbers.
  29020. * @see _.inRange, _.rangeRight
  29021. * @example
  29022. *
  29023. * _.range(4);
  29024. * // => [0, 1, 2, 3]
  29025. *
  29026. * _.range(-4);
  29027. * // => [0, -1, -2, -3]
  29028. *
  29029. * _.range(1, 5);
  29030. * // => [1, 2, 3, 4]
  29031. *
  29032. * _.range(0, 20, 5);
  29033. * // => [0, 5, 10, 15]
  29034. *
  29035. * _.range(0, -4, -1);
  29036. * // => [0, -1, -2, -3]
  29037. *
  29038. * _.range(1, 4, 0);
  29039. * // => [1, 1, 1]
  29040. *
  29041. * _.range(0);
  29042. * // => []
  29043. */
  29044. var range = createRange();
  29045. /**
  29046. * This method is like `_.range` except that it populates values in
  29047. * descending order.
  29048. *
  29049. * @static
  29050. * @memberOf _
  29051. * @since 4.0.0
  29052. * @category Util
  29053. * @param {number} [start=0] The start of the range.
  29054. * @param {number} end The end of the range.
  29055. * @param {number} [step=1] The value to increment or decrement by.
  29056. * @returns {Array} Returns the range of numbers.
  29057. * @see _.inRange, _.range
  29058. * @example
  29059. *
  29060. * _.rangeRight(4);
  29061. * // => [3, 2, 1, 0]
  29062. *
  29063. * _.rangeRight(-4);
  29064. * // => [-3, -2, -1, 0]
  29065. *
  29066. * _.rangeRight(1, 5);
  29067. * // => [4, 3, 2, 1]
  29068. *
  29069. * _.rangeRight(0, 20, 5);
  29070. * // => [15, 10, 5, 0]
  29071. *
  29072. * _.rangeRight(0, -4, -1);
  29073. * // => [-3, -2, -1, 0]
  29074. *
  29075. * _.rangeRight(1, 4, 0);
  29076. * // => [1, 1, 1]
  29077. *
  29078. * _.rangeRight(0);
  29079. * // => []
  29080. */
  29081. var rangeRight = createRange(true);
  29082. /**
  29083. * This method returns a new empty array.
  29084. *
  29085. * @static
  29086. * @memberOf _
  29087. * @since 4.13.0
  29088. * @category Util
  29089. * @returns {Array} Returns the new empty array.
  29090. * @example
  29091. *
  29092. * var arrays = _.times(2, _.stubArray);
  29093. *
  29094. * console.log(arrays);
  29095. * // => [[], []]
  29096. *
  29097. * console.log(arrays[0] === arrays[1]);
  29098. * // => false
  29099. */
  29100. function stubArray() {
  29101. return [];
  29102. }
  29103. /**
  29104. * This method returns `false`.
  29105. *
  29106. * @static
  29107. * @memberOf _
  29108. * @since 4.13.0
  29109. * @category Util
  29110. * @returns {boolean} Returns `false`.
  29111. * @example
  29112. *
  29113. * _.times(2, _.stubFalse);
  29114. * // => [false, false]
  29115. */
  29116. function stubFalse() {
  29117. return false;
  29118. }
  29119. /**
  29120. * This method returns a new empty object.
  29121. *
  29122. * @static
  29123. * @memberOf _
  29124. * @since 4.13.0
  29125. * @category Util
  29126. * @returns {Object} Returns the new empty object.
  29127. * @example
  29128. *
  29129. * var objects = _.times(2, _.stubObject);
  29130. *
  29131. * console.log(objects);
  29132. * // => [{}, {}]
  29133. *
  29134. * console.log(objects[0] === objects[1]);
  29135. * // => false
  29136. */
  29137. function stubObject() {
  29138. return {};
  29139. }
  29140. /**
  29141. * This method returns an empty string.
  29142. *
  29143. * @static
  29144. * @memberOf _
  29145. * @since 4.13.0
  29146. * @category Util
  29147. * @returns {string} Returns the empty string.
  29148. * @example
  29149. *
  29150. * _.times(2, _.stubString);
  29151. * // => ['', '']
  29152. */
  29153. function stubString() {
  29154. return '';
  29155. }
  29156. /**
  29157. * This method returns `true`.
  29158. *
  29159. * @static
  29160. * @memberOf _
  29161. * @since 4.13.0
  29162. * @category Util
  29163. * @returns {boolean} Returns `true`.
  29164. * @example
  29165. *
  29166. * _.times(2, _.stubTrue);
  29167. * // => [true, true]
  29168. */
  29169. function stubTrue() {
  29170. return true;
  29171. }
  29172. /**
  29173. * Invokes the iteratee `n` times, returning an array of the results of
  29174. * each invocation. The iteratee is invoked with one argument; (index).
  29175. *
  29176. * @static
  29177. * @since 0.1.0
  29178. * @memberOf _
  29179. * @category Util
  29180. * @param {number} n The number of times to invoke `iteratee`.
  29181. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29182. * @returns {Array} Returns the array of results.
  29183. * @example
  29184. *
  29185. * _.times(3, String);
  29186. * // => ['0', '1', '2']
  29187. *
  29188. * _.times(4, _.constant(0));
  29189. * // => [0, 0, 0, 0]
  29190. */
  29191. function times(n, iteratee) {
  29192. n = toInteger(n);
  29193. if (n < 1 || n > MAX_SAFE_INTEGER) {
  29194. return [];
  29195. }
  29196. var index = MAX_ARRAY_LENGTH,
  29197. length = nativeMin(n, MAX_ARRAY_LENGTH);
  29198. iteratee = getIteratee(iteratee);
  29199. n -= MAX_ARRAY_LENGTH;
  29200. var result = baseTimes(length, iteratee);
  29201. while (++index < n) {
  29202. iteratee(index);
  29203. }
  29204. return result;
  29205. }
  29206. /**
  29207. * Converts `value` to a property path array.
  29208. *
  29209. * @static
  29210. * @memberOf _
  29211. * @since 4.0.0
  29212. * @category Util
  29213. * @param {*} value The value to convert.
  29214. * @returns {Array} Returns the new property path array.
  29215. * @example
  29216. *
  29217. * _.toPath('a.b.c');
  29218. * // => ['a', 'b', 'c']
  29219. *
  29220. * _.toPath('a[0].b.c');
  29221. * // => ['a', '0', 'b', 'c']
  29222. */
  29223. function toPath(value) {
  29224. if (isArray(value)) {
  29225. return arrayMap(value, toKey);
  29226. }
  29227. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  29228. }
  29229. /**
  29230. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  29231. *
  29232. * @static
  29233. * @since 0.1.0
  29234. * @memberOf _
  29235. * @category Util
  29236. * @param {string} [prefix=''] The value to prefix the ID with.
  29237. * @returns {string} Returns the unique ID.
  29238. * @example
  29239. *
  29240. * _.uniqueId('contact_');
  29241. * // => 'contact_104'
  29242. *
  29243. * _.uniqueId();
  29244. * // => '105'
  29245. */
  29246. function uniqueId(prefix) {
  29247. var id = ++idCounter;
  29248. return toString(prefix) + id;
  29249. }
  29250. /*------------------------------------------------------------------------*/
  29251. /**
  29252. * Adds two numbers.
  29253. *
  29254. * @static
  29255. * @memberOf _
  29256. * @since 3.4.0
  29257. * @category Math
  29258. * @param {number} augend The first number in an addition.
  29259. * @param {number} addend The second number in an addition.
  29260. * @returns {number} Returns the total.
  29261. * @example
  29262. *
  29263. * _.add(6, 4);
  29264. * // => 10
  29265. */
  29266. var add = createMathOperation(function(augend, addend) {
  29267. return augend + addend;
  29268. }, 0);
  29269. /**
  29270. * Computes `number` rounded up to `precision`.
  29271. *
  29272. * @static
  29273. * @memberOf _
  29274. * @since 3.10.0
  29275. * @category Math
  29276. * @param {number} number The number to round up.
  29277. * @param {number} [precision=0] The precision to round up to.
  29278. * @returns {number} Returns the rounded up number.
  29279. * @example
  29280. *
  29281. * _.ceil(4.006);
  29282. * // => 5
  29283. *
  29284. * _.ceil(6.004, 2);
  29285. * // => 6.01
  29286. *
  29287. * _.ceil(6040, -2);
  29288. * // => 6100
  29289. */
  29290. var ceil = createRound('ceil');
  29291. /**
  29292. * Divide two numbers.
  29293. *
  29294. * @static
  29295. * @memberOf _
  29296. * @since 4.7.0
  29297. * @category Math
  29298. * @param {number} dividend The first number in a division.
  29299. * @param {number} divisor The second number in a division.
  29300. * @returns {number} Returns the quotient.
  29301. * @example
  29302. *
  29303. * _.divide(6, 4);
  29304. * // => 1.5
  29305. */
  29306. var divide = createMathOperation(function(dividend, divisor) {
  29307. return dividend / divisor;
  29308. }, 1);
  29309. /**
  29310. * Computes `number` rounded down to `precision`.
  29311. *
  29312. * @static
  29313. * @memberOf _
  29314. * @since 3.10.0
  29315. * @category Math
  29316. * @param {number} number The number to round down.
  29317. * @param {number} [precision=0] The precision to round down to.
  29318. * @returns {number} Returns the rounded down number.
  29319. * @example
  29320. *
  29321. * _.floor(4.006);
  29322. * // => 4
  29323. *
  29324. * _.floor(0.046, 2);
  29325. * // => 0.04
  29326. *
  29327. * _.floor(4060, -2);
  29328. * // => 4000
  29329. */
  29330. var floor = createRound('floor');
  29331. /**
  29332. * Computes the maximum value of `array`. If `array` is empty or falsey,
  29333. * `undefined` is returned.
  29334. *
  29335. * @static
  29336. * @since 0.1.0
  29337. * @memberOf _
  29338. * @category Math
  29339. * @param {Array} array The array to iterate over.
  29340. * @returns {*} Returns the maximum value.
  29341. * @example
  29342. *
  29343. * _.max([4, 2, 8, 6]);
  29344. * // => 8
  29345. *
  29346. * _.max([]);
  29347. * // => undefined
  29348. */
  29349. function max(array) {
  29350. return (array && array.length)
  29351. ? baseExtremum(array, identity, baseGt)
  29352. : undefined;
  29353. }
  29354. /**
  29355. * This method is like `_.max` except that it accepts `iteratee` which is
  29356. * invoked for each element in `array` to generate the criterion by which
  29357. * the value is ranked. The iteratee is invoked with one argument: (value).
  29358. *
  29359. * @static
  29360. * @memberOf _
  29361. * @since 4.0.0
  29362. * @category Math
  29363. * @param {Array} array The array to iterate over.
  29364. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29365. * @returns {*} Returns the maximum value.
  29366. * @example
  29367. *
  29368. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29369. *
  29370. * _.maxBy(objects, function(o) { return o.n; });
  29371. * // => { 'n': 2 }
  29372. *
  29373. * // The `_.property` iteratee shorthand.
  29374. * _.maxBy(objects, 'n');
  29375. * // => { 'n': 2 }
  29376. */
  29377. function maxBy(array, iteratee) {
  29378. return (array && array.length)
  29379. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  29380. : undefined;
  29381. }
  29382. /**
  29383. * Computes the mean of the values in `array`.
  29384. *
  29385. * @static
  29386. * @memberOf _
  29387. * @since 4.0.0
  29388. * @category Math
  29389. * @param {Array} array The array to iterate over.
  29390. * @returns {number} Returns the mean.
  29391. * @example
  29392. *
  29393. * _.mean([4, 2, 8, 6]);
  29394. * // => 5
  29395. */
  29396. function mean(array) {
  29397. return baseMean(array, identity);
  29398. }
  29399. /**
  29400. * This method is like `_.mean` except that it accepts `iteratee` which is
  29401. * invoked for each element in `array` to generate the value to be averaged.
  29402. * The iteratee is invoked with one argument: (value).
  29403. *
  29404. * @static
  29405. * @memberOf _
  29406. * @since 4.7.0
  29407. * @category Math
  29408. * @param {Array} array The array to iterate over.
  29409. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29410. * @returns {number} Returns the mean.
  29411. * @example
  29412. *
  29413. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29414. *
  29415. * _.meanBy(objects, function(o) { return o.n; });
  29416. * // => 5
  29417. *
  29418. * // The `_.property` iteratee shorthand.
  29419. * _.meanBy(objects, 'n');
  29420. * // => 5
  29421. */
  29422. function meanBy(array, iteratee) {
  29423. return baseMean(array, getIteratee(iteratee, 2));
  29424. }
  29425. /**
  29426. * Computes the minimum value of `array`. If `array` is empty or falsey,
  29427. * `undefined` is returned.
  29428. *
  29429. * @static
  29430. * @since 0.1.0
  29431. * @memberOf _
  29432. * @category Math
  29433. * @param {Array} array The array to iterate over.
  29434. * @returns {*} Returns the minimum value.
  29435. * @example
  29436. *
  29437. * _.min([4, 2, 8, 6]);
  29438. * // => 2
  29439. *
  29440. * _.min([]);
  29441. * // => undefined
  29442. */
  29443. function min(array) {
  29444. return (array && array.length)
  29445. ? baseExtremum(array, identity, baseLt)
  29446. : undefined;
  29447. }
  29448. /**
  29449. * This method is like `_.min` except that it accepts `iteratee` which is
  29450. * invoked for each element in `array` to generate the criterion by which
  29451. * the value is ranked. The iteratee is invoked with one argument: (value).
  29452. *
  29453. * @static
  29454. * @memberOf _
  29455. * @since 4.0.0
  29456. * @category Math
  29457. * @param {Array} array The array to iterate over.
  29458. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29459. * @returns {*} Returns the minimum value.
  29460. * @example
  29461. *
  29462. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29463. *
  29464. * _.minBy(objects, function(o) { return o.n; });
  29465. * // => { 'n': 1 }
  29466. *
  29467. * // The `_.property` iteratee shorthand.
  29468. * _.minBy(objects, 'n');
  29469. * // => { 'n': 1 }
  29470. */
  29471. function minBy(array, iteratee) {
  29472. return (array && array.length)
  29473. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  29474. : undefined;
  29475. }
  29476. /**
  29477. * Multiply two numbers.
  29478. *
  29479. * @static
  29480. * @memberOf _
  29481. * @since 4.7.0
  29482. * @category Math
  29483. * @param {number} multiplier The first number in a multiplication.
  29484. * @param {number} multiplicand The second number in a multiplication.
  29485. * @returns {number} Returns the product.
  29486. * @example
  29487. *
  29488. * _.multiply(6, 4);
  29489. * // => 24
  29490. */
  29491. var multiply = createMathOperation(function(multiplier, multiplicand) {
  29492. return multiplier * multiplicand;
  29493. }, 1);
  29494. /**
  29495. * Computes `number` rounded to `precision`.
  29496. *
  29497. * @static
  29498. * @memberOf _
  29499. * @since 3.10.0
  29500. * @category Math
  29501. * @param {number} number The number to round.
  29502. * @param {number} [precision=0] The precision to round to.
  29503. * @returns {number} Returns the rounded number.
  29504. * @example
  29505. *
  29506. * _.round(4.006);
  29507. * // => 4
  29508. *
  29509. * _.round(4.006, 2);
  29510. * // => 4.01
  29511. *
  29512. * _.round(4060, -2);
  29513. * // => 4100
  29514. */
  29515. var round = createRound('round');
  29516. /**
  29517. * Subtract two numbers.
  29518. *
  29519. * @static
  29520. * @memberOf _
  29521. * @since 4.0.0
  29522. * @category Math
  29523. * @param {number} minuend The first number in a subtraction.
  29524. * @param {number} subtrahend The second number in a subtraction.
  29525. * @returns {number} Returns the difference.
  29526. * @example
  29527. *
  29528. * _.subtract(6, 4);
  29529. * // => 2
  29530. */
  29531. var subtract = createMathOperation(function(minuend, subtrahend) {
  29532. return minuend - subtrahend;
  29533. }, 0);
  29534. /**
  29535. * Computes the sum of the values in `array`.
  29536. *
  29537. * @static
  29538. * @memberOf _
  29539. * @since 3.4.0
  29540. * @category Math
  29541. * @param {Array} array The array to iterate over.
  29542. * @returns {number} Returns the sum.
  29543. * @example
  29544. *
  29545. * _.sum([4, 2, 8, 6]);
  29546. * // => 20
  29547. */
  29548. function sum(array) {
  29549. return (array && array.length)
  29550. ? baseSum(array, identity)
  29551. : 0;
  29552. }
  29553. /**
  29554. * This method is like `_.sum` except that it accepts `iteratee` which is
  29555. * invoked for each element in `array` to generate the value to be summed.
  29556. * The iteratee is invoked with one argument: (value).
  29557. *
  29558. * @static
  29559. * @memberOf _
  29560. * @since 4.0.0
  29561. * @category Math
  29562. * @param {Array} array The array to iterate over.
  29563. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29564. * @returns {number} Returns the sum.
  29565. * @example
  29566. *
  29567. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29568. *
  29569. * _.sumBy(objects, function(o) { return o.n; });
  29570. * // => 20
  29571. *
  29572. * // The `_.property` iteratee shorthand.
  29573. * _.sumBy(objects, 'n');
  29574. * // => 20
  29575. */
  29576. function sumBy(array, iteratee) {
  29577. return (array && array.length)
  29578. ? baseSum(array, getIteratee(iteratee, 2))
  29579. : 0;
  29580. }
  29581. /*------------------------------------------------------------------------*/
  29582. // Add methods that return wrapped values in chain sequences.
  29583. lodash.after = after;
  29584. lodash.ary = ary;
  29585. lodash.assign = assign;
  29586. lodash.assignIn = assignIn;
  29587. lodash.assignInWith = assignInWith;
  29588. lodash.assignWith = assignWith;
  29589. lodash.at = at;
  29590. lodash.before = before;
  29591. lodash.bind = bind;
  29592. lodash.bindAll = bindAll;
  29593. lodash.bindKey = bindKey;
  29594. lodash.castArray = castArray;
  29595. lodash.chain = chain;
  29596. lodash.chunk = chunk;
  29597. lodash.compact = compact;
  29598. lodash.concat = concat;
  29599. lodash.cond = cond;
  29600. lodash.conforms = conforms;
  29601. lodash.constant = constant;
  29602. lodash.countBy = countBy;
  29603. lodash.create = create;
  29604. lodash.curry = curry;
  29605. lodash.curryRight = curryRight;
  29606. lodash.debounce = debounce;
  29607. lodash.defaults = defaults;
  29608. lodash.defaultsDeep = defaultsDeep;
  29609. lodash.defer = defer;
  29610. lodash.delay = delay;
  29611. lodash.difference = difference;
  29612. lodash.differenceBy = differenceBy;
  29613. lodash.differenceWith = differenceWith;
  29614. lodash.drop = drop;
  29615. lodash.dropRight = dropRight;
  29616. lodash.dropRightWhile = dropRightWhile;
  29617. lodash.dropWhile = dropWhile;
  29618. lodash.fill = fill;
  29619. lodash.filter = filter;
  29620. lodash.flatMap = flatMap;
  29621. lodash.flatMapDeep = flatMapDeep;
  29622. lodash.flatMapDepth = flatMapDepth;
  29623. lodash.flatten = flatten;
  29624. lodash.flattenDeep = flattenDeep;
  29625. lodash.flattenDepth = flattenDepth;
  29626. lodash.flip = flip;
  29627. lodash.flow = flow;
  29628. lodash.flowRight = flowRight;
  29629. lodash.fromPairs = fromPairs;
  29630. lodash.functions = functions;
  29631. lodash.functionsIn = functionsIn;
  29632. lodash.groupBy = groupBy;
  29633. lodash.initial = initial;
  29634. lodash.intersection = intersection;
  29635. lodash.intersectionBy = intersectionBy;
  29636. lodash.intersectionWith = intersectionWith;
  29637. lodash.invert = invert;
  29638. lodash.invertBy = invertBy;
  29639. lodash.invokeMap = invokeMap;
  29640. lodash.iteratee = iteratee;
  29641. lodash.keyBy = keyBy;
  29642. lodash.keys = keys;
  29643. lodash.keysIn = keysIn;
  29644. lodash.map = map;
  29645. lodash.mapKeys = mapKeys;
  29646. lodash.mapValues = mapValues;
  29647. lodash.matches = matches;
  29648. lodash.matchesProperty = matchesProperty;
  29649. lodash.memoize = memoize;
  29650. lodash.merge = merge;
  29651. lodash.mergeWith = mergeWith;
  29652. lodash.method = method;
  29653. lodash.methodOf = methodOf;
  29654. lodash.mixin = mixin;
  29655. lodash.negate = negate;
  29656. lodash.nthArg = nthArg;
  29657. lodash.omit = omit;
  29658. lodash.omitBy = omitBy;
  29659. lodash.once = once;
  29660. lodash.orderBy = orderBy;
  29661. lodash.over = over;
  29662. lodash.overArgs = overArgs;
  29663. lodash.overEvery = overEvery;
  29664. lodash.overSome = overSome;
  29665. lodash.partial = partial;
  29666. lodash.partialRight = partialRight;
  29667. lodash.partition = partition;
  29668. lodash.pick = pick;
  29669. lodash.pickBy = pickBy;
  29670. lodash.property = property;
  29671. lodash.propertyOf = propertyOf;
  29672. lodash.pull = pull;
  29673. lodash.pullAll = pullAll;
  29674. lodash.pullAllBy = pullAllBy;
  29675. lodash.pullAllWith = pullAllWith;
  29676. lodash.pullAt = pullAt;
  29677. lodash.range = range;
  29678. lodash.rangeRight = rangeRight;
  29679. lodash.rearg = rearg;
  29680. lodash.reject = reject;
  29681. lodash.remove = remove;
  29682. lodash.rest = rest;
  29683. lodash.reverse = reverse;
  29684. lodash.sampleSize = sampleSize;
  29685. lodash.set = set;
  29686. lodash.setWith = setWith;
  29687. lodash.shuffle = shuffle;
  29688. lodash.slice = slice;
  29689. lodash.sortBy = sortBy;
  29690. lodash.sortedUniq = sortedUniq;
  29691. lodash.sortedUniqBy = sortedUniqBy;
  29692. lodash.split = split;
  29693. lodash.spread = spread;
  29694. lodash.tail = tail;
  29695. lodash.take = take;
  29696. lodash.takeRight = takeRight;
  29697. lodash.takeRightWhile = takeRightWhile;
  29698. lodash.takeWhile = takeWhile;
  29699. lodash.tap = tap;
  29700. lodash.throttle = throttle;
  29701. lodash.thru = thru;
  29702. lodash.toArray = toArray;
  29703. lodash.toPairs = toPairs;
  29704. lodash.toPairsIn = toPairsIn;
  29705. lodash.toPath = toPath;
  29706. lodash.toPlainObject = toPlainObject;
  29707. lodash.transform = transform;
  29708. lodash.unary = unary;
  29709. lodash.union = union;
  29710. lodash.unionBy = unionBy;
  29711. lodash.unionWith = unionWith;
  29712. lodash.uniq = uniq;
  29713. lodash.uniqBy = uniqBy;
  29714. lodash.uniqWith = uniqWith;
  29715. lodash.unset = unset;
  29716. lodash.unzip = unzip;
  29717. lodash.unzipWith = unzipWith;
  29718. lodash.update = update;
  29719. lodash.updateWith = updateWith;
  29720. lodash.values = values;
  29721. lodash.valuesIn = valuesIn;
  29722. lodash.without = without;
  29723. lodash.words = words;
  29724. lodash.wrap = wrap;
  29725. lodash.xor = xor;
  29726. lodash.xorBy = xorBy;
  29727. lodash.xorWith = xorWith;
  29728. lodash.zip = zip;
  29729. lodash.zipObject = zipObject;
  29730. lodash.zipObjectDeep = zipObjectDeep;
  29731. lodash.zipWith = zipWith;
  29732. // Add aliases.
  29733. lodash.entries = toPairs;
  29734. lodash.entriesIn = toPairsIn;
  29735. lodash.extend = assignIn;
  29736. lodash.extendWith = assignInWith;
  29737. // Add methods to `lodash.prototype`.
  29738. mixin(lodash, lodash);
  29739. /*------------------------------------------------------------------------*/
  29740. // Add methods that return unwrapped values in chain sequences.
  29741. lodash.add = add;
  29742. lodash.attempt = attempt;
  29743. lodash.camelCase = camelCase;
  29744. lodash.capitalize = capitalize;
  29745. lodash.ceil = ceil;
  29746. lodash.clamp = clamp;
  29747. lodash.clone = clone;
  29748. lodash.cloneDeep = cloneDeep;
  29749. lodash.cloneDeepWith = cloneDeepWith;
  29750. lodash.cloneWith = cloneWith;
  29751. lodash.conformsTo = conformsTo;
  29752. lodash.deburr = deburr;
  29753. lodash.defaultTo = defaultTo;
  29754. lodash.divide = divide;
  29755. lodash.endsWith = endsWith;
  29756. lodash.eq = eq;
  29757. lodash.escape = escape;
  29758. lodash.escapeRegExp = escapeRegExp;
  29759. lodash.every = every;
  29760. lodash.find = find;
  29761. lodash.findIndex = findIndex;
  29762. lodash.findKey = findKey;
  29763. lodash.findLast = findLast;
  29764. lodash.findLastIndex = findLastIndex;
  29765. lodash.findLastKey = findLastKey;
  29766. lodash.floor = floor;
  29767. lodash.forEach = forEach;
  29768. lodash.forEachRight = forEachRight;
  29769. lodash.forIn = forIn;
  29770. lodash.forInRight = forInRight;
  29771. lodash.forOwn = forOwn;
  29772. lodash.forOwnRight = forOwnRight;
  29773. lodash.get = get;
  29774. lodash.gt = gt;
  29775. lodash.gte = gte;
  29776. lodash.has = has;
  29777. lodash.hasIn = hasIn;
  29778. lodash.head = head;
  29779. lodash.identity = identity;
  29780. lodash.includes = includes;
  29781. lodash.indexOf = indexOf;
  29782. lodash.inRange = inRange;
  29783. lodash.invoke = invoke;
  29784. lodash.isArguments = isArguments;
  29785. lodash.isArray = isArray;
  29786. lodash.isArrayBuffer = isArrayBuffer;
  29787. lodash.isArrayLike = isArrayLike;
  29788. lodash.isArrayLikeObject = isArrayLikeObject;
  29789. lodash.isBoolean = isBoolean;
  29790. lodash.isBuffer = isBuffer;
  29791. lodash.isDate = isDate;
  29792. lodash.isElement = isElement;
  29793. lodash.isEmpty = isEmpty;
  29794. lodash.isEqual = isEqual;
  29795. lodash.isEqualWith = isEqualWith;
  29796. lodash.isError = isError;
  29797. lodash.isFinite = isFinite;
  29798. lodash.isFunction = isFunction;
  29799. lodash.isInteger = isInteger;
  29800. lodash.isLength = isLength;
  29801. lodash.isMap = isMap;
  29802. lodash.isMatch = isMatch;
  29803. lodash.isMatchWith = isMatchWith;
  29804. lodash.isNaN = isNaN;
  29805. lodash.isNative = isNative;
  29806. lodash.isNil = isNil;
  29807. lodash.isNull = isNull;
  29808. lodash.isNumber = isNumber;
  29809. lodash.isObject = isObject;
  29810. lodash.isObjectLike = isObjectLike;
  29811. lodash.isPlainObject = isPlainObject;
  29812. lodash.isRegExp = isRegExp;
  29813. lodash.isSafeInteger = isSafeInteger;
  29814. lodash.isSet = isSet;
  29815. lodash.isString = isString;
  29816. lodash.isSymbol = isSymbol;
  29817. lodash.isTypedArray = isTypedArray;
  29818. lodash.isUndefined = isUndefined;
  29819. lodash.isWeakMap = isWeakMap;
  29820. lodash.isWeakSet = isWeakSet;
  29821. lodash.join = join;
  29822. lodash.kebabCase = kebabCase;
  29823. lodash.last = last;
  29824. lodash.lastIndexOf = lastIndexOf;
  29825. lodash.lowerCase = lowerCase;
  29826. lodash.lowerFirst = lowerFirst;
  29827. lodash.lt = lt;
  29828. lodash.lte = lte;
  29829. lodash.max = max;
  29830. lodash.maxBy = maxBy;
  29831. lodash.mean = mean;
  29832. lodash.meanBy = meanBy;
  29833. lodash.min = min;
  29834. lodash.minBy = minBy;
  29835. lodash.stubArray = stubArray;
  29836. lodash.stubFalse = stubFalse;
  29837. lodash.stubObject = stubObject;
  29838. lodash.stubString = stubString;
  29839. lodash.stubTrue = stubTrue;
  29840. lodash.multiply = multiply;
  29841. lodash.nth = nth;
  29842. lodash.noConflict = noConflict;
  29843. lodash.noop = noop;
  29844. lodash.now = now;
  29845. lodash.pad = pad;
  29846. lodash.padEnd = padEnd;
  29847. lodash.padStart = padStart;
  29848. lodash.parseInt = parseInt;
  29849. lodash.random = random;
  29850. lodash.reduce = reduce;
  29851. lodash.reduceRight = reduceRight;
  29852. lodash.repeat = repeat;
  29853. lodash.replace = replace;
  29854. lodash.result = result;
  29855. lodash.round = round;
  29856. lodash.runInContext = runInContext;
  29857. lodash.sample = sample;
  29858. lodash.size = size;
  29859. lodash.snakeCase = snakeCase;
  29860. lodash.some = some;
  29861. lodash.sortedIndex = sortedIndex;
  29862. lodash.sortedIndexBy = sortedIndexBy;
  29863. lodash.sortedIndexOf = sortedIndexOf;
  29864. lodash.sortedLastIndex = sortedLastIndex;
  29865. lodash.sortedLastIndexBy = sortedLastIndexBy;
  29866. lodash.sortedLastIndexOf = sortedLastIndexOf;
  29867. lodash.startCase = startCase;
  29868. lodash.startsWith = startsWith;
  29869. lodash.subtract = subtract;
  29870. lodash.sum = sum;
  29871. lodash.sumBy = sumBy;
  29872. lodash.template = template;
  29873. lodash.times = times;
  29874. lodash.toFinite = toFinite;
  29875. lodash.toInteger = toInteger;
  29876. lodash.toLength = toLength;
  29877. lodash.toLower = toLower;
  29878. lodash.toNumber = toNumber;
  29879. lodash.toSafeInteger = toSafeInteger;
  29880. lodash.toString = toString;
  29881. lodash.toUpper = toUpper;
  29882. lodash.trim = trim;
  29883. lodash.trimEnd = trimEnd;
  29884. lodash.trimStart = trimStart;
  29885. lodash.truncate = truncate;
  29886. lodash.unescape = unescape;
  29887. lodash.uniqueId = uniqueId;
  29888. lodash.upperCase = upperCase;
  29889. lodash.upperFirst = upperFirst;
  29890. // Add aliases.
  29891. lodash.each = forEach;
  29892. lodash.eachRight = forEachRight;
  29893. lodash.first = head;
  29894. mixin(lodash, (function() {
  29895. var source = {};
  29896. baseForOwn(lodash, function(func, methodName) {
  29897. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  29898. source[methodName] = func;
  29899. }
  29900. });
  29901. return source;
  29902. }()), { 'chain': false });
  29903. /*------------------------------------------------------------------------*/
  29904. /**
  29905. * The semantic version number.
  29906. *
  29907. * @static
  29908. * @memberOf _
  29909. * @type {string}
  29910. */
  29911. lodash.VERSION = VERSION;
  29912. // Assign default placeholders.
  29913. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  29914. lodash[methodName].placeholder = lodash;
  29915. });
  29916. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  29917. arrayEach(['drop', 'take'], function(methodName, index) {
  29918. LazyWrapper.prototype[methodName] = function(n) {
  29919. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  29920. var result = (this.__filtered__ && !index)
  29921. ? new LazyWrapper(this)
  29922. : this.clone();
  29923. if (result.__filtered__) {
  29924. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  29925. } else {
  29926. result.__views__.push({
  29927. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  29928. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  29929. });
  29930. }
  29931. return result;
  29932. };
  29933. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  29934. return this.reverse()[methodName](n).reverse();
  29935. };
  29936. });
  29937. // Add `LazyWrapper` methods that accept an `iteratee` value.
  29938. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  29939. var type = index + 1,
  29940. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  29941. LazyWrapper.prototype[methodName] = function(iteratee) {
  29942. var result = this.clone();
  29943. result.__iteratees__.push({
  29944. 'iteratee': getIteratee(iteratee, 3),
  29945. 'type': type
  29946. });
  29947. result.__filtered__ = result.__filtered__ || isFilter;
  29948. return result;
  29949. };
  29950. });
  29951. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  29952. arrayEach(['head', 'last'], function(methodName, index) {
  29953. var takeName = 'take' + (index ? 'Right' : '');
  29954. LazyWrapper.prototype[methodName] = function() {
  29955. return this[takeName](1).value()[0];
  29956. };
  29957. });
  29958. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  29959. arrayEach(['initial', 'tail'], function(methodName, index) {
  29960. var dropName = 'drop' + (index ? '' : 'Right');
  29961. LazyWrapper.prototype[methodName] = function() {
  29962. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  29963. };
  29964. });
  29965. LazyWrapper.prototype.compact = function() {
  29966. return this.filter(identity);
  29967. };
  29968. LazyWrapper.prototype.find = function(predicate) {
  29969. return this.filter(predicate).head();
  29970. };
  29971. LazyWrapper.prototype.findLast = function(predicate) {
  29972. return this.reverse().find(predicate);
  29973. };
  29974. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  29975. if (typeof path == 'function') {
  29976. return new LazyWrapper(this);
  29977. }
  29978. return this.map(function(value) {
  29979. return baseInvoke(value, path, args);
  29980. });
  29981. });
  29982. LazyWrapper.prototype.reject = function(predicate) {
  29983. return this.filter(negate(getIteratee(predicate)));
  29984. };
  29985. LazyWrapper.prototype.slice = function(start, end) {
  29986. start = toInteger(start);
  29987. var result = this;
  29988. if (result.__filtered__ && (start > 0 || end < 0)) {
  29989. return new LazyWrapper(result);
  29990. }
  29991. if (start < 0) {
  29992. result = result.takeRight(-start);
  29993. } else if (start) {
  29994. result = result.drop(start);
  29995. }
  29996. if (end !== undefined) {
  29997. end = toInteger(end);
  29998. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  29999. }
  30000. return result;
  30001. };
  30002. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  30003. return this.reverse().takeWhile(predicate).reverse();
  30004. };
  30005. LazyWrapper.prototype.toArray = function() {
  30006. return this.take(MAX_ARRAY_LENGTH);
  30007. };
  30008. // Add `LazyWrapper` methods to `lodash.prototype`.
  30009. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  30010. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  30011. isTaker = /^(?:head|last)$/.test(methodName),
  30012. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  30013. retUnwrapped = isTaker || /^find/.test(methodName);
  30014. if (!lodashFunc) {
  30015. return;
  30016. }
  30017. lodash.prototype[methodName] = function() {
  30018. var value = this.__wrapped__,
  30019. args = isTaker ? [1] : arguments,
  30020. isLazy = value instanceof LazyWrapper,
  30021. iteratee = args[0],
  30022. useLazy = isLazy || isArray(value);
  30023. var interceptor = function(value) {
  30024. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  30025. return (isTaker && chainAll) ? result[0] : result;
  30026. };
  30027. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  30028. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  30029. isLazy = useLazy = false;
  30030. }
  30031. var chainAll = this.__chain__,
  30032. isHybrid = !!this.__actions__.length,
  30033. isUnwrapped = retUnwrapped && !chainAll,
  30034. onlyLazy = isLazy && !isHybrid;
  30035. if (!retUnwrapped && useLazy) {
  30036. value = onlyLazy ? value : new LazyWrapper(this);
  30037. var result = func.apply(value, args);
  30038. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  30039. return new LodashWrapper(result, chainAll);
  30040. }
  30041. if (isUnwrapped && onlyLazy) {
  30042. return func.apply(this, args);
  30043. }
  30044. result = this.thru(interceptor);
  30045. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  30046. };
  30047. });
  30048. // Add `Array` methods to `lodash.prototype`.
  30049. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  30050. var func = arrayProto[methodName],
  30051. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  30052. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  30053. lodash.prototype[methodName] = function() {
  30054. var args = arguments;
  30055. if (retUnwrapped && !this.__chain__) {
  30056. var value = this.value();
  30057. return func.apply(isArray(value) ? value : [], args);
  30058. }
  30059. return this[chainName](function(value) {
  30060. return func.apply(isArray(value) ? value : [], args);
  30061. });
  30062. };
  30063. });
  30064. // Map minified method names to their real names.
  30065. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  30066. var lodashFunc = lodash[methodName];
  30067. if (lodashFunc) {
  30068. var key = lodashFunc.name + '';
  30069. if (!hasOwnProperty.call(realNames, key)) {
  30070. realNames[key] = [];
  30071. }
  30072. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  30073. }
  30074. });
  30075. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  30076. 'name': 'wrapper',
  30077. 'func': undefined
  30078. }];
  30079. // Add methods to `LazyWrapper`.
  30080. LazyWrapper.prototype.clone = lazyClone;
  30081. LazyWrapper.prototype.reverse = lazyReverse;
  30082. LazyWrapper.prototype.value = lazyValue;
  30083. // Add chain sequence methods to the `lodash` wrapper.
  30084. lodash.prototype.at = wrapperAt;
  30085. lodash.prototype.chain = wrapperChain;
  30086. lodash.prototype.commit = wrapperCommit;
  30087. lodash.prototype.next = wrapperNext;
  30088. lodash.prototype.plant = wrapperPlant;
  30089. lodash.prototype.reverse = wrapperReverse;
  30090. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  30091. // Add lazy aliases.
  30092. lodash.prototype.first = lodash.prototype.head;
  30093. if (symIterator) {
  30094. lodash.prototype[symIterator] = wrapperToIterator;
  30095. }
  30096. return lodash;
  30097. });
  30098. /*--------------------------------------------------------------------------*/
  30099. // Export lodash.
  30100. var _ = runInContext();
  30101. // Some AMD build optimizers, like r.js, check for condition patterns like:
  30102. if (true) {
  30103. // Expose Lodash on the global object to prevent errors when Lodash is
  30104. // loaded by a script tag in the presence of an AMD loader.
  30105. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  30106. // Use `_.noConflict` to remove Lodash from the global object.
  30107. root._ = _;
  30108. // Define as an anonymous module so, through path mapping, it can be
  30109. // referenced as the "underscore" module.
  30110. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  30111. return _;
  30112. }).call(exports, __webpack_require__, exports, module),
  30113. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  30114. }
  30115. // Check for `exports` after `define` in case a build optimizer adds it.
  30116. else {}
  30117. }.call(this));
  30118. /* 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)))
  30119. /***/ }),
  30120. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  30121. /*!***************************************************!*\
  30122. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  30123. \***************************************************/
  30124. /*! exports provided: default */
  30125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30126. "use strict";
  30127. __webpack_require__.r(__webpack_exports__);
  30128. /* WEBPACK VAR INJECTION */(function(global) {/**!
  30129. * @fileOverview Kickass library to create and place poppers near their reference elements.
  30130. * @version 1.16.1
  30131. * @license
  30132. * Copyright (c) 2016 Federico Zivolo and contributors
  30133. *
  30134. * Permission is hereby granted, free of charge, to any person obtaining a copy
  30135. * of this software and associated documentation files (the "Software"), to deal
  30136. * in the Software without restriction, including without limitation the rights
  30137. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  30138. * copies of the Software, and to permit persons to whom the Software is
  30139. * furnished to do so, subject to the following conditions:
  30140. *
  30141. * The above copyright notice and this permission notice shall be included in all
  30142. * copies or substantial portions of the Software.
  30143. *
  30144. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30145. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  30146. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  30147. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  30148. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  30149. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30150. * SOFTWARE.
  30151. */
  30152. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  30153. var timeoutDuration = function () {
  30154. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  30155. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  30156. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  30157. return 1;
  30158. }
  30159. }
  30160. return 0;
  30161. }();
  30162. function microtaskDebounce(fn) {
  30163. var called = false;
  30164. return function () {
  30165. if (called) {
  30166. return;
  30167. }
  30168. called = true;
  30169. window.Promise.resolve().then(function () {
  30170. called = false;
  30171. fn();
  30172. });
  30173. };
  30174. }
  30175. function taskDebounce(fn) {
  30176. var scheduled = false;
  30177. return function () {
  30178. if (!scheduled) {
  30179. scheduled = true;
  30180. setTimeout(function () {
  30181. scheduled = false;
  30182. fn();
  30183. }, timeoutDuration);
  30184. }
  30185. };
  30186. }
  30187. var supportsMicroTasks = isBrowser && window.Promise;
  30188. /**
  30189. * Create a debounced version of a method, that's asynchronously deferred
  30190. * but called in the minimum time possible.
  30191. *
  30192. * @method
  30193. * @memberof Popper.Utils
  30194. * @argument {Function} fn
  30195. * @returns {Function}
  30196. */
  30197. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  30198. /**
  30199. * Check if the given variable is a function
  30200. * @method
  30201. * @memberof Popper.Utils
  30202. * @argument {Any} functionToCheck - variable to check
  30203. * @returns {Boolean} answer to: is a function?
  30204. */
  30205. function isFunction(functionToCheck) {
  30206. var getType = {};
  30207. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  30208. }
  30209. /**
  30210. * Get CSS computed property of the given element
  30211. * @method
  30212. * @memberof Popper.Utils
  30213. * @argument {Eement} element
  30214. * @argument {String} property
  30215. */
  30216. function getStyleComputedProperty(element, property) {
  30217. if (element.nodeType !== 1) {
  30218. return [];
  30219. }
  30220. // NOTE: 1 DOM access here
  30221. var window = element.ownerDocument.defaultView;
  30222. var css = window.getComputedStyle(element, null);
  30223. return property ? css[property] : css;
  30224. }
  30225. /**
  30226. * Returns the parentNode or the host of the element
  30227. * @method
  30228. * @memberof Popper.Utils
  30229. * @argument {Element} element
  30230. * @returns {Element} parent
  30231. */
  30232. function getParentNode(element) {
  30233. if (element.nodeName === 'HTML') {
  30234. return element;
  30235. }
  30236. return element.parentNode || element.host;
  30237. }
  30238. /**
  30239. * Returns the scrolling parent of the given element
  30240. * @method
  30241. * @memberof Popper.Utils
  30242. * @argument {Element} element
  30243. * @returns {Element} scroll parent
  30244. */
  30245. function getScrollParent(element) {
  30246. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  30247. if (!element) {
  30248. return document.body;
  30249. }
  30250. switch (element.nodeName) {
  30251. case 'HTML':
  30252. case 'BODY':
  30253. return element.ownerDocument.body;
  30254. case '#document':
  30255. return element.body;
  30256. }
  30257. // Firefox want us to check `-x` and `-y` variations as well
  30258. var _getStyleComputedProp = getStyleComputedProperty(element),
  30259. overflow = _getStyleComputedProp.overflow,
  30260. overflowX = _getStyleComputedProp.overflowX,
  30261. overflowY = _getStyleComputedProp.overflowY;
  30262. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  30263. return element;
  30264. }
  30265. return getScrollParent(getParentNode(element));
  30266. }
  30267. /**
  30268. * Returns the reference node of the reference object, or the reference object itself.
  30269. * @method
  30270. * @memberof Popper.Utils
  30271. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  30272. * @returns {Element} parent
  30273. */
  30274. function getReferenceNode(reference) {
  30275. return reference && reference.referenceNode ? reference.referenceNode : reference;
  30276. }
  30277. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  30278. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  30279. /**
  30280. * Determines if the browser is Internet Explorer
  30281. * @method
  30282. * @memberof Popper.Utils
  30283. * @param {Number} version to check
  30284. * @returns {Boolean} isIE
  30285. */
  30286. function isIE(version) {
  30287. if (version === 11) {
  30288. return isIE11;
  30289. }
  30290. if (version === 10) {
  30291. return isIE10;
  30292. }
  30293. return isIE11 || isIE10;
  30294. }
  30295. /**
  30296. * Returns the offset parent of the given element
  30297. * @method
  30298. * @memberof Popper.Utils
  30299. * @argument {Element} element
  30300. * @returns {Element} offset parent
  30301. */
  30302. function getOffsetParent(element) {
  30303. if (!element) {
  30304. return document.documentElement;
  30305. }
  30306. var noOffsetParent = isIE(10) ? document.body : null;
  30307. // NOTE: 1 DOM access here
  30308. var offsetParent = element.offsetParent || null;
  30309. // Skip hidden elements which don't have an offsetParent
  30310. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  30311. offsetParent = (element = element.nextElementSibling).offsetParent;
  30312. }
  30313. var nodeName = offsetParent && offsetParent.nodeName;
  30314. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  30315. return element ? element.ownerDocument.documentElement : document.documentElement;
  30316. }
  30317. // .offsetParent will return the closest TH, TD or TABLE in case
  30318. // no offsetParent is present, I hate this job...
  30319. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  30320. return getOffsetParent(offsetParent);
  30321. }
  30322. return offsetParent;
  30323. }
  30324. function isOffsetContainer(element) {
  30325. var nodeName = element.nodeName;
  30326. if (nodeName === 'BODY') {
  30327. return false;
  30328. }
  30329. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  30330. }
  30331. /**
  30332. * Finds the root node (document, shadowDOM root) of the given element
  30333. * @method
  30334. * @memberof Popper.Utils
  30335. * @argument {Element} node
  30336. * @returns {Element} root node
  30337. */
  30338. function getRoot(node) {
  30339. if (node.parentNode !== null) {
  30340. return getRoot(node.parentNode);
  30341. }
  30342. return node;
  30343. }
  30344. /**
  30345. * Finds the offset parent common to the two provided nodes
  30346. * @method
  30347. * @memberof Popper.Utils
  30348. * @argument {Element} element1
  30349. * @argument {Element} element2
  30350. * @returns {Element} common offset parent
  30351. */
  30352. function findCommonOffsetParent(element1, element2) {
  30353. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30354. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  30355. return document.documentElement;
  30356. }
  30357. // Here we make sure to give as "start" the element that comes first in the DOM
  30358. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  30359. var start = order ? element1 : element2;
  30360. var end = order ? element2 : element1;
  30361. // Get common ancestor container
  30362. var range = document.createRange();
  30363. range.setStart(start, 0);
  30364. range.setEnd(end, 0);
  30365. var commonAncestorContainer = range.commonAncestorContainer;
  30366. // Both nodes are inside #document
  30367. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  30368. if (isOffsetContainer(commonAncestorContainer)) {
  30369. return commonAncestorContainer;
  30370. }
  30371. return getOffsetParent(commonAncestorContainer);
  30372. }
  30373. // one of the nodes is inside shadowDOM, find which one
  30374. var element1root = getRoot(element1);
  30375. if (element1root.host) {
  30376. return findCommonOffsetParent(element1root.host, element2);
  30377. } else {
  30378. return findCommonOffsetParent(element1, getRoot(element2).host);
  30379. }
  30380. }
  30381. /**
  30382. * Gets the scroll value of the given element in the given side (top and left)
  30383. * @method
  30384. * @memberof Popper.Utils
  30385. * @argument {Element} element
  30386. * @argument {String} side `top` or `left`
  30387. * @returns {number} amount of scrolled pixels
  30388. */
  30389. function getScroll(element) {
  30390. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  30391. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  30392. var nodeName = element.nodeName;
  30393. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30394. var html = element.ownerDocument.documentElement;
  30395. var scrollingElement = element.ownerDocument.scrollingElement || html;
  30396. return scrollingElement[upperSide];
  30397. }
  30398. return element[upperSide];
  30399. }
  30400. /*
  30401. * Sum or subtract the element scroll values (left and top) from a given rect object
  30402. * @method
  30403. * @memberof Popper.Utils
  30404. * @param {Object} rect - Rect object you want to change
  30405. * @param {HTMLElement} element - The element from the function reads the scroll values
  30406. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  30407. * @return {Object} rect - The modifier rect object
  30408. */
  30409. function includeScroll(rect, element) {
  30410. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30411. var scrollTop = getScroll(element, 'top');
  30412. var scrollLeft = getScroll(element, 'left');
  30413. var modifier = subtract ? -1 : 1;
  30414. rect.top += scrollTop * modifier;
  30415. rect.bottom += scrollTop * modifier;
  30416. rect.left += scrollLeft * modifier;
  30417. rect.right += scrollLeft * modifier;
  30418. return rect;
  30419. }
  30420. /*
  30421. * Helper to detect borders of a given element
  30422. * @method
  30423. * @memberof Popper.Utils
  30424. * @param {CSSStyleDeclaration} styles
  30425. * Result of `getStyleComputedProperty` on the given element
  30426. * @param {String} axis - `x` or `y`
  30427. * @return {number} borders - The borders size of the given axis
  30428. */
  30429. function getBordersSize(styles, axis) {
  30430. var sideA = axis === 'x' ? 'Left' : 'Top';
  30431. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  30432. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  30433. }
  30434. function getSize(axis, body, html, computedStyle) {
  30435. 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);
  30436. }
  30437. function getWindowSizes(document) {
  30438. var body = document.body;
  30439. var html = document.documentElement;
  30440. var computedStyle = isIE(10) && getComputedStyle(html);
  30441. return {
  30442. height: getSize('Height', body, html, computedStyle),
  30443. width: getSize('Width', body, html, computedStyle)
  30444. };
  30445. }
  30446. var classCallCheck = function (instance, Constructor) {
  30447. if (!(instance instanceof Constructor)) {
  30448. throw new TypeError("Cannot call a class as a function");
  30449. }
  30450. };
  30451. var createClass = function () {
  30452. function defineProperties(target, props) {
  30453. for (var i = 0; i < props.length; i++) {
  30454. var descriptor = props[i];
  30455. descriptor.enumerable = descriptor.enumerable || false;
  30456. descriptor.configurable = true;
  30457. if ("value" in descriptor) descriptor.writable = true;
  30458. Object.defineProperty(target, descriptor.key, descriptor);
  30459. }
  30460. }
  30461. return function (Constructor, protoProps, staticProps) {
  30462. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  30463. if (staticProps) defineProperties(Constructor, staticProps);
  30464. return Constructor;
  30465. };
  30466. }();
  30467. var defineProperty = function (obj, key, value) {
  30468. if (key in obj) {
  30469. Object.defineProperty(obj, key, {
  30470. value: value,
  30471. enumerable: true,
  30472. configurable: true,
  30473. writable: true
  30474. });
  30475. } else {
  30476. obj[key] = value;
  30477. }
  30478. return obj;
  30479. };
  30480. var _extends = Object.assign || function (target) {
  30481. for (var i = 1; i < arguments.length; i++) {
  30482. var source = arguments[i];
  30483. for (var key in source) {
  30484. if (Object.prototype.hasOwnProperty.call(source, key)) {
  30485. target[key] = source[key];
  30486. }
  30487. }
  30488. }
  30489. return target;
  30490. };
  30491. /**
  30492. * Given element offsets, generate an output similar to getBoundingClientRect
  30493. * @method
  30494. * @memberof Popper.Utils
  30495. * @argument {Object} offsets
  30496. * @returns {Object} ClientRect like output
  30497. */
  30498. function getClientRect(offsets) {
  30499. return _extends({}, offsets, {
  30500. right: offsets.left + offsets.width,
  30501. bottom: offsets.top + offsets.height
  30502. });
  30503. }
  30504. /**
  30505. * Get bounding client rect of given element
  30506. * @method
  30507. * @memberof Popper.Utils
  30508. * @param {HTMLElement} element
  30509. * @return {Object} client rect
  30510. */
  30511. function getBoundingClientRect(element) {
  30512. var rect = {};
  30513. // IE10 10 FIX: Please, don't ask, the element isn't
  30514. // considered in DOM in some circumstances...
  30515. // This isn't reproducible in IE10 compatibility mode of IE11
  30516. try {
  30517. if (isIE(10)) {
  30518. rect = element.getBoundingClientRect();
  30519. var scrollTop = getScroll(element, 'top');
  30520. var scrollLeft = getScroll(element, 'left');
  30521. rect.top += scrollTop;
  30522. rect.left += scrollLeft;
  30523. rect.bottom += scrollTop;
  30524. rect.right += scrollLeft;
  30525. } else {
  30526. rect = element.getBoundingClientRect();
  30527. }
  30528. } catch (e) {}
  30529. var result = {
  30530. left: rect.left,
  30531. top: rect.top,
  30532. width: rect.right - rect.left,
  30533. height: rect.bottom - rect.top
  30534. };
  30535. // subtract scrollbar size from sizes
  30536. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  30537. var width = sizes.width || element.clientWidth || result.width;
  30538. var height = sizes.height || element.clientHeight || result.height;
  30539. var horizScrollbar = element.offsetWidth - width;
  30540. var vertScrollbar = element.offsetHeight - height;
  30541. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  30542. // we make this check conditional for performance reasons
  30543. if (horizScrollbar || vertScrollbar) {
  30544. var styles = getStyleComputedProperty(element);
  30545. horizScrollbar -= getBordersSize(styles, 'x');
  30546. vertScrollbar -= getBordersSize(styles, 'y');
  30547. result.width -= horizScrollbar;
  30548. result.height -= vertScrollbar;
  30549. }
  30550. return getClientRect(result);
  30551. }
  30552. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  30553. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30554. var isIE10 = isIE(10);
  30555. var isHTML = parent.nodeName === 'HTML';
  30556. var childrenRect = getBoundingClientRect(children);
  30557. var parentRect = getBoundingClientRect(parent);
  30558. var scrollParent = getScrollParent(children);
  30559. var styles = getStyleComputedProperty(parent);
  30560. var borderTopWidth = parseFloat(styles.borderTopWidth);
  30561. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  30562. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  30563. if (fixedPosition && isHTML) {
  30564. parentRect.top = Math.max(parentRect.top, 0);
  30565. parentRect.left = Math.max(parentRect.left, 0);
  30566. }
  30567. var offsets = getClientRect({
  30568. top: childrenRect.top - parentRect.top - borderTopWidth,
  30569. left: childrenRect.left - parentRect.left - borderLeftWidth,
  30570. width: childrenRect.width,
  30571. height: childrenRect.height
  30572. });
  30573. offsets.marginTop = 0;
  30574. offsets.marginLeft = 0;
  30575. // Subtract margins of documentElement in case it's being used as parent
  30576. // we do this only on HTML because it's the only element that behaves
  30577. // differently when margins are applied to it. The margins are included in
  30578. // the box of the documentElement, in the other cases not.
  30579. if (!isIE10 && isHTML) {
  30580. var marginTop = parseFloat(styles.marginTop);
  30581. var marginLeft = parseFloat(styles.marginLeft);
  30582. offsets.top -= borderTopWidth - marginTop;
  30583. offsets.bottom -= borderTopWidth - marginTop;
  30584. offsets.left -= borderLeftWidth - marginLeft;
  30585. offsets.right -= borderLeftWidth - marginLeft;
  30586. // Attach marginTop and marginLeft because in some circumstances we may need them
  30587. offsets.marginTop = marginTop;
  30588. offsets.marginLeft = marginLeft;
  30589. }
  30590. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  30591. offsets = includeScroll(offsets, parent);
  30592. }
  30593. return offsets;
  30594. }
  30595. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  30596. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  30597. var html = element.ownerDocument.documentElement;
  30598. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  30599. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  30600. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  30601. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  30602. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  30603. var offset = {
  30604. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  30605. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  30606. width: width,
  30607. height: height
  30608. };
  30609. return getClientRect(offset);
  30610. }
  30611. /**
  30612. * Check if the given element is fixed or is inside a fixed parent
  30613. * @method
  30614. * @memberof Popper.Utils
  30615. * @argument {Element} element
  30616. * @argument {Element} customContainer
  30617. * @returns {Boolean} answer to "isFixed?"
  30618. */
  30619. function isFixed(element) {
  30620. var nodeName = element.nodeName;
  30621. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30622. return false;
  30623. }
  30624. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  30625. return true;
  30626. }
  30627. var parentNode = getParentNode(element);
  30628. if (!parentNode) {
  30629. return false;
  30630. }
  30631. return isFixed(parentNode);
  30632. }
  30633. /**
  30634. * Finds the first parent of an element that has a transformed property defined
  30635. * @method
  30636. * @memberof Popper.Utils
  30637. * @argument {Element} element
  30638. * @returns {Element} first transformed parent or documentElement
  30639. */
  30640. function getFixedPositionOffsetParent(element) {
  30641. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30642. if (!element || !element.parentElement || isIE()) {
  30643. return document.documentElement;
  30644. }
  30645. var el = element.parentElement;
  30646. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  30647. el = el.parentElement;
  30648. }
  30649. return el || document.documentElement;
  30650. }
  30651. /**
  30652. * Computed the boundaries limits and return them
  30653. * @method
  30654. * @memberof Popper.Utils
  30655. * @param {HTMLElement} popper
  30656. * @param {HTMLElement} reference
  30657. * @param {number} padding
  30658. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  30659. * @param {Boolean} fixedPosition - Is in fixed position mode
  30660. * @returns {Object} Coordinates of the boundaries
  30661. */
  30662. function getBoundaries(popper, reference, padding, boundariesElement) {
  30663. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  30664. // NOTE: 1 DOM access here
  30665. var boundaries = { top: 0, left: 0 };
  30666. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30667. // Handle viewport case
  30668. if (boundariesElement === 'viewport') {
  30669. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  30670. } else {
  30671. // Handle other cases based on DOM element used as boundaries
  30672. var boundariesNode = void 0;
  30673. if (boundariesElement === 'scrollParent') {
  30674. boundariesNode = getScrollParent(getParentNode(reference));
  30675. if (boundariesNode.nodeName === 'BODY') {
  30676. boundariesNode = popper.ownerDocument.documentElement;
  30677. }
  30678. } else if (boundariesElement === 'window') {
  30679. boundariesNode = popper.ownerDocument.documentElement;
  30680. } else {
  30681. boundariesNode = boundariesElement;
  30682. }
  30683. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  30684. // In case of HTML, we need a different computation
  30685. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  30686. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  30687. height = _getWindowSizes.height,
  30688. width = _getWindowSizes.width;
  30689. boundaries.top += offsets.top - offsets.marginTop;
  30690. boundaries.bottom = height + offsets.top;
  30691. boundaries.left += offsets.left - offsets.marginLeft;
  30692. boundaries.right = width + offsets.left;
  30693. } else {
  30694. // for all the other DOM elements, this one is good
  30695. boundaries = offsets;
  30696. }
  30697. }
  30698. // Add paddings
  30699. padding = padding || 0;
  30700. var isPaddingNumber = typeof padding === 'number';
  30701. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  30702. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  30703. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  30704. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  30705. return boundaries;
  30706. }
  30707. function getArea(_ref) {
  30708. var width = _ref.width,
  30709. height = _ref.height;
  30710. return width * height;
  30711. }
  30712. /**
  30713. * Utility used to transform the `auto` placement to the placement with more
  30714. * available space.
  30715. * @method
  30716. * @memberof Popper.Utils
  30717. * @argument {Object} data - The data object generated by update method
  30718. * @argument {Object} options - Modifiers configuration and options
  30719. * @returns {Object} The data object, properly modified
  30720. */
  30721. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  30722. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  30723. if (placement.indexOf('auto') === -1) {
  30724. return placement;
  30725. }
  30726. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  30727. var rects = {
  30728. top: {
  30729. width: boundaries.width,
  30730. height: refRect.top - boundaries.top
  30731. },
  30732. right: {
  30733. width: boundaries.right - refRect.right,
  30734. height: boundaries.height
  30735. },
  30736. bottom: {
  30737. width: boundaries.width,
  30738. height: boundaries.bottom - refRect.bottom
  30739. },
  30740. left: {
  30741. width: refRect.left - boundaries.left,
  30742. height: boundaries.height
  30743. }
  30744. };
  30745. var sortedAreas = Object.keys(rects).map(function (key) {
  30746. return _extends({
  30747. key: key
  30748. }, rects[key], {
  30749. area: getArea(rects[key])
  30750. });
  30751. }).sort(function (a, b) {
  30752. return b.area - a.area;
  30753. });
  30754. var filteredAreas = sortedAreas.filter(function (_ref2) {
  30755. var width = _ref2.width,
  30756. height = _ref2.height;
  30757. return width >= popper.clientWidth && height >= popper.clientHeight;
  30758. });
  30759. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  30760. var variation = placement.split('-')[1];
  30761. return computedPlacement + (variation ? '-' + variation : '');
  30762. }
  30763. /**
  30764. * Get offsets to the reference element
  30765. * @method
  30766. * @memberof Popper.Utils
  30767. * @param {Object} state
  30768. * @param {Element} popper - the popper element
  30769. * @param {Element} reference - the reference element (the popper will be relative to this)
  30770. * @param {Element} fixedPosition - is in fixed position mode
  30771. * @returns {Object} An object containing the offsets which will be applied to the popper
  30772. */
  30773. function getReferenceOffsets(state, popper, reference) {
  30774. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  30775. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30776. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  30777. }
  30778. /**
  30779. * Get the outer sizes of the given element (offset size + margins)
  30780. * @method
  30781. * @memberof Popper.Utils
  30782. * @argument {Element} element
  30783. * @returns {Object} object containing width and height properties
  30784. */
  30785. function getOuterSizes(element) {
  30786. var window = element.ownerDocument.defaultView;
  30787. var styles = window.getComputedStyle(element);
  30788. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  30789. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  30790. var result = {
  30791. width: element.offsetWidth + y,
  30792. height: element.offsetHeight + x
  30793. };
  30794. return result;
  30795. }
  30796. /**
  30797. * Get the opposite placement of the given one
  30798. * @method
  30799. * @memberof Popper.Utils
  30800. * @argument {String} placement
  30801. * @returns {String} flipped placement
  30802. */
  30803. function getOppositePlacement(placement) {
  30804. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  30805. return placement.replace(/left|right|bottom|top/g, function (matched) {
  30806. return hash[matched];
  30807. });
  30808. }
  30809. /**
  30810. * Get offsets to the popper
  30811. * @method
  30812. * @memberof Popper.Utils
  30813. * @param {Object} position - CSS position the Popper will get applied
  30814. * @param {HTMLElement} popper - the popper element
  30815. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  30816. * @param {String} placement - one of the valid placement options
  30817. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  30818. */
  30819. function getPopperOffsets(popper, referenceOffsets, placement) {
  30820. placement = placement.split('-')[0];
  30821. // Get popper node sizes
  30822. var popperRect = getOuterSizes(popper);
  30823. // Add position, width and height to our offsets object
  30824. var popperOffsets = {
  30825. width: popperRect.width,
  30826. height: popperRect.height
  30827. };
  30828. // depending by the popper placement we have to compute its offsets slightly differently
  30829. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  30830. var mainSide = isHoriz ? 'top' : 'left';
  30831. var secondarySide = isHoriz ? 'left' : 'top';
  30832. var measurement = isHoriz ? 'height' : 'width';
  30833. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  30834. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  30835. if (placement === secondarySide) {
  30836. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  30837. } else {
  30838. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  30839. }
  30840. return popperOffsets;
  30841. }
  30842. /**
  30843. * Mimics the `find` method of Array
  30844. * @method
  30845. * @memberof Popper.Utils
  30846. * @argument {Array} arr
  30847. * @argument prop
  30848. * @argument value
  30849. * @returns index or -1
  30850. */
  30851. function find(arr, check) {
  30852. // use native find if supported
  30853. if (Array.prototype.find) {
  30854. return arr.find(check);
  30855. }
  30856. // use `filter` to obtain the same behavior of `find`
  30857. return arr.filter(check)[0];
  30858. }
  30859. /**
  30860. * Return the index of the matching object
  30861. * @method
  30862. * @memberof Popper.Utils
  30863. * @argument {Array} arr
  30864. * @argument prop
  30865. * @argument value
  30866. * @returns index or -1
  30867. */
  30868. function findIndex(arr, prop, value) {
  30869. // use native findIndex if supported
  30870. if (Array.prototype.findIndex) {
  30871. return arr.findIndex(function (cur) {
  30872. return cur[prop] === value;
  30873. });
  30874. }
  30875. // use `find` + `indexOf` if `findIndex` isn't supported
  30876. var match = find(arr, function (obj) {
  30877. return obj[prop] === value;
  30878. });
  30879. return arr.indexOf(match);
  30880. }
  30881. /**
  30882. * Loop trough the list of modifiers and run them in order,
  30883. * each of them will then edit the data object.
  30884. * @method
  30885. * @memberof Popper.Utils
  30886. * @param {dataObject} data
  30887. * @param {Array} modifiers
  30888. * @param {String} ends - Optional modifier name used as stopper
  30889. * @returns {dataObject}
  30890. */
  30891. function runModifiers(modifiers, data, ends) {
  30892. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  30893. modifiersToRun.forEach(function (modifier) {
  30894. if (modifier['function']) {
  30895. // eslint-disable-line dot-notation
  30896. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  30897. }
  30898. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  30899. if (modifier.enabled && isFunction(fn)) {
  30900. // Add properties to offsets to make them a complete clientRect object
  30901. // we do this before each modifier to make sure the previous one doesn't
  30902. // mess with these values
  30903. data.offsets.popper = getClientRect(data.offsets.popper);
  30904. data.offsets.reference = getClientRect(data.offsets.reference);
  30905. data = fn(data, modifier);
  30906. }
  30907. });
  30908. return data;
  30909. }
  30910. /**
  30911. * Updates the position of the popper, computing the new offsets and applying
  30912. * the new style.<br />
  30913. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  30914. * @method
  30915. * @memberof Popper
  30916. */
  30917. function update() {
  30918. // if popper is destroyed, don't perform any further update
  30919. if (this.state.isDestroyed) {
  30920. return;
  30921. }
  30922. var data = {
  30923. instance: this,
  30924. styles: {},
  30925. arrowStyles: {},
  30926. attributes: {},
  30927. flipped: false,
  30928. offsets: {}
  30929. };
  30930. // compute reference element offsets
  30931. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  30932. // compute auto placement, store placement inside the data object,
  30933. // modifiers will be able to edit `placement` if needed
  30934. // and refer to originalPlacement to know the original value
  30935. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  30936. // store the computed placement inside `originalPlacement`
  30937. data.originalPlacement = data.placement;
  30938. data.positionFixed = this.options.positionFixed;
  30939. // compute the popper offsets
  30940. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  30941. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  30942. // run the modifiers
  30943. data = runModifiers(this.modifiers, data);
  30944. // the first `update` will call `onCreate` callback
  30945. // the other ones will call `onUpdate` callback
  30946. if (!this.state.isCreated) {
  30947. this.state.isCreated = true;
  30948. this.options.onCreate(data);
  30949. } else {
  30950. this.options.onUpdate(data);
  30951. }
  30952. }
  30953. /**
  30954. * Helper used to know if the given modifier is enabled.
  30955. * @method
  30956. * @memberof Popper.Utils
  30957. * @returns {Boolean}
  30958. */
  30959. function isModifierEnabled(modifiers, modifierName) {
  30960. return modifiers.some(function (_ref) {
  30961. var name = _ref.name,
  30962. enabled = _ref.enabled;
  30963. return enabled && name === modifierName;
  30964. });
  30965. }
  30966. /**
  30967. * Get the prefixed supported property name
  30968. * @method
  30969. * @memberof Popper.Utils
  30970. * @argument {String} property (camelCase)
  30971. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  30972. */
  30973. function getSupportedPropertyName(property) {
  30974. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  30975. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  30976. for (var i = 0; i < prefixes.length; i++) {
  30977. var prefix = prefixes[i];
  30978. var toCheck = prefix ? '' + prefix + upperProp : property;
  30979. if (typeof document.body.style[toCheck] !== 'undefined') {
  30980. return toCheck;
  30981. }
  30982. }
  30983. return null;
  30984. }
  30985. /**
  30986. * Destroys the popper.
  30987. * @method
  30988. * @memberof Popper
  30989. */
  30990. function destroy() {
  30991. this.state.isDestroyed = true;
  30992. // touch DOM only if `applyStyle` modifier is enabled
  30993. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  30994. this.popper.removeAttribute('x-placement');
  30995. this.popper.style.position = '';
  30996. this.popper.style.top = '';
  30997. this.popper.style.left = '';
  30998. this.popper.style.right = '';
  30999. this.popper.style.bottom = '';
  31000. this.popper.style.willChange = '';
  31001. this.popper.style[getSupportedPropertyName('transform')] = '';
  31002. }
  31003. this.disableEventListeners();
  31004. // remove the popper if user explicitly asked for the deletion on destroy
  31005. // do not use `remove` because IE11 doesn't support it
  31006. if (this.options.removeOnDestroy) {
  31007. this.popper.parentNode.removeChild(this.popper);
  31008. }
  31009. return this;
  31010. }
  31011. /**
  31012. * Get the window associated with the element
  31013. * @argument {Element} element
  31014. * @returns {Window}
  31015. */
  31016. function getWindow(element) {
  31017. var ownerDocument = element.ownerDocument;
  31018. return ownerDocument ? ownerDocument.defaultView : window;
  31019. }
  31020. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  31021. var isBody = scrollParent.nodeName === 'BODY';
  31022. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  31023. target.addEventListener(event, callback, { passive: true });
  31024. if (!isBody) {
  31025. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  31026. }
  31027. scrollParents.push(target);
  31028. }
  31029. /**
  31030. * Setup needed event listeners used to update the popper position
  31031. * @method
  31032. * @memberof Popper.Utils
  31033. * @private
  31034. */
  31035. function setupEventListeners(reference, options, state, updateBound) {
  31036. // Resize event listener on window
  31037. state.updateBound = updateBound;
  31038. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  31039. // Scroll event listener on scroll parents
  31040. var scrollElement = getScrollParent(reference);
  31041. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  31042. state.scrollElement = scrollElement;
  31043. state.eventsEnabled = true;
  31044. return state;
  31045. }
  31046. /**
  31047. * It will add resize/scroll events and start recalculating
  31048. * position of the popper element when they are triggered.
  31049. * @method
  31050. * @memberof Popper
  31051. */
  31052. function enableEventListeners() {
  31053. if (!this.state.eventsEnabled) {
  31054. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  31055. }
  31056. }
  31057. /**
  31058. * Remove event listeners used to update the popper position
  31059. * @method
  31060. * @memberof Popper.Utils
  31061. * @private
  31062. */
  31063. function removeEventListeners(reference, state) {
  31064. // Remove resize event listener on window
  31065. getWindow(reference).removeEventListener('resize', state.updateBound);
  31066. // Remove scroll event listener on scroll parents
  31067. state.scrollParents.forEach(function (target) {
  31068. target.removeEventListener('scroll', state.updateBound);
  31069. });
  31070. // Reset state
  31071. state.updateBound = null;
  31072. state.scrollParents = [];
  31073. state.scrollElement = null;
  31074. state.eventsEnabled = false;
  31075. return state;
  31076. }
  31077. /**
  31078. * It will remove resize/scroll events and won't recalculate popper position
  31079. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  31080. * unless you call `update` method manually.
  31081. * @method
  31082. * @memberof Popper
  31083. */
  31084. function disableEventListeners() {
  31085. if (this.state.eventsEnabled) {
  31086. cancelAnimationFrame(this.scheduleUpdate);
  31087. this.state = removeEventListeners(this.reference, this.state);
  31088. }
  31089. }
  31090. /**
  31091. * Tells if a given input is a number
  31092. * @method
  31093. * @memberof Popper.Utils
  31094. * @param {*} input to check
  31095. * @return {Boolean}
  31096. */
  31097. function isNumeric(n) {
  31098. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  31099. }
  31100. /**
  31101. * Set the style to the given popper
  31102. * @method
  31103. * @memberof Popper.Utils
  31104. * @argument {Element} element - Element to apply the style to
  31105. * @argument {Object} styles
  31106. * Object with a list of properties and values which will be applied to the element
  31107. */
  31108. function setStyles(element, styles) {
  31109. Object.keys(styles).forEach(function (prop) {
  31110. var unit = '';
  31111. // add unit if the value is numeric and is one of the following
  31112. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  31113. unit = 'px';
  31114. }
  31115. element.style[prop] = styles[prop] + unit;
  31116. });
  31117. }
  31118. /**
  31119. * Set the attributes to the given popper
  31120. * @method
  31121. * @memberof Popper.Utils
  31122. * @argument {Element} element - Element to apply the attributes to
  31123. * @argument {Object} styles
  31124. * Object with a list of properties and values which will be applied to the element
  31125. */
  31126. function setAttributes(element, attributes) {
  31127. Object.keys(attributes).forEach(function (prop) {
  31128. var value = attributes[prop];
  31129. if (value !== false) {
  31130. element.setAttribute(prop, attributes[prop]);
  31131. } else {
  31132. element.removeAttribute(prop);
  31133. }
  31134. });
  31135. }
  31136. /**
  31137. * @function
  31138. * @memberof Modifiers
  31139. * @argument {Object} data - The data object generated by `update` method
  31140. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  31141. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  31142. * @argument {Object} options - Modifiers configuration and options
  31143. * @returns {Object} The same data object
  31144. */
  31145. function applyStyle(data) {
  31146. // any property present in `data.styles` will be applied to the popper,
  31147. // in this way we can make the 3rd party modifiers add custom styles to it
  31148. // Be aware, modifiers could override the properties defined in the previous
  31149. // lines of this modifier!
  31150. setStyles(data.instance.popper, data.styles);
  31151. // any property present in `data.attributes` will be applied to the popper,
  31152. // they will be set as HTML attributes of the element
  31153. setAttributes(data.instance.popper, data.attributes);
  31154. // if arrowElement is defined and arrowStyles has some properties
  31155. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  31156. setStyles(data.arrowElement, data.arrowStyles);
  31157. }
  31158. return data;
  31159. }
  31160. /**
  31161. * Set the x-placement attribute before everything else because it could be used
  31162. * to add margins to the popper margins needs to be calculated to get the
  31163. * correct popper offsets.
  31164. * @method
  31165. * @memberof Popper.modifiers
  31166. * @param {HTMLElement} reference - The reference element used to position the popper
  31167. * @param {HTMLElement} popper - The HTML element used as popper
  31168. * @param {Object} options - Popper.js options
  31169. */
  31170. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  31171. // compute reference element offsets
  31172. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  31173. // compute auto placement, store placement inside the data object,
  31174. // modifiers will be able to edit `placement` if needed
  31175. // and refer to originalPlacement to know the original value
  31176. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  31177. popper.setAttribute('x-placement', placement);
  31178. // Apply `position` to popper before anything else because
  31179. // without the position applied we can't guarantee correct computations
  31180. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  31181. return options;
  31182. }
  31183. /**
  31184. * @function
  31185. * @memberof Popper.Utils
  31186. * @argument {Object} data - The data object generated by `update` method
  31187. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  31188. * @returns {Object} The popper's position offsets rounded
  31189. *
  31190. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  31191. * good as it can be within reason.
  31192. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  31193. *
  31194. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  31195. * as well on High DPI screens).
  31196. *
  31197. * Firefox prefers no rounding for positioning and does not have blurriness on
  31198. * high DPI screens.
  31199. *
  31200. * Only horizontal placement and left/right values need to be considered.
  31201. */
  31202. function getRoundedOffsets(data, shouldRound) {
  31203. var _data$offsets = data.offsets,
  31204. popper = _data$offsets.popper,
  31205. reference = _data$offsets.reference;
  31206. var round = Math.round,
  31207. floor = Math.floor;
  31208. var noRound = function noRound(v) {
  31209. return v;
  31210. };
  31211. var referenceWidth = round(reference.width);
  31212. var popperWidth = round(popper.width);
  31213. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  31214. var isVariation = data.placement.indexOf('-') !== -1;
  31215. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  31216. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  31217. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  31218. var verticalToInteger = !shouldRound ? noRound : round;
  31219. return {
  31220. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  31221. top: verticalToInteger(popper.top),
  31222. bottom: verticalToInteger(popper.bottom),
  31223. right: horizontalToInteger(popper.right)
  31224. };
  31225. }
  31226. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  31227. /**
  31228. * @function
  31229. * @memberof Modifiers
  31230. * @argument {Object} data - The data object generated by `update` method
  31231. * @argument {Object} options - Modifiers configuration and options
  31232. * @returns {Object} The data object, properly modified
  31233. */
  31234. function computeStyle(data, options) {
  31235. var x = options.x,
  31236. y = options.y;
  31237. var popper = data.offsets.popper;
  31238. // Remove this legacy support in Popper.js v2
  31239. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  31240. return modifier.name === 'applyStyle';
  31241. }).gpuAcceleration;
  31242. if (legacyGpuAccelerationOption !== undefined) {
  31243. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  31244. }
  31245. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  31246. var offsetParent = getOffsetParent(data.instance.popper);
  31247. var offsetParentRect = getBoundingClientRect(offsetParent);
  31248. // Styles
  31249. var styles = {
  31250. position: popper.position
  31251. };
  31252. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  31253. var sideA = x === 'bottom' ? 'top' : 'bottom';
  31254. var sideB = y === 'right' ? 'left' : 'right';
  31255. // if gpuAcceleration is set to `true` and transform is supported,
  31256. // we use `translate3d` to apply the position to the popper we
  31257. // automatically use the supported prefixed version if needed
  31258. var prefixedProperty = getSupportedPropertyName('transform');
  31259. // now, let's make a step back and look at this code closely (wtf?)
  31260. // If the content of the popper grows once it's been positioned, it
  31261. // may happen that the popper gets misplaced because of the new content
  31262. // overflowing its reference element
  31263. // To avoid this problem, we provide two options (x and y), which allow
  31264. // the consumer to define the offset origin.
  31265. // If we position a popper on top of a reference element, we can set
  31266. // `x` to `top` to make the popper grow towards its top instead of
  31267. // its bottom.
  31268. var left = void 0,
  31269. top = void 0;
  31270. if (sideA === 'bottom') {
  31271. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  31272. // and not the bottom of the html element
  31273. if (offsetParent.nodeName === 'HTML') {
  31274. top = -offsetParent.clientHeight + offsets.bottom;
  31275. } else {
  31276. top = -offsetParentRect.height + offsets.bottom;
  31277. }
  31278. } else {
  31279. top = offsets.top;
  31280. }
  31281. if (sideB === 'right') {
  31282. if (offsetParent.nodeName === 'HTML') {
  31283. left = -offsetParent.clientWidth + offsets.right;
  31284. } else {
  31285. left = -offsetParentRect.width + offsets.right;
  31286. }
  31287. } else {
  31288. left = offsets.left;
  31289. }
  31290. if (gpuAcceleration && prefixedProperty) {
  31291. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  31292. styles[sideA] = 0;
  31293. styles[sideB] = 0;
  31294. styles.willChange = 'transform';
  31295. } else {
  31296. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  31297. var invertTop = sideA === 'bottom' ? -1 : 1;
  31298. var invertLeft = sideB === 'right' ? -1 : 1;
  31299. styles[sideA] = top * invertTop;
  31300. styles[sideB] = left * invertLeft;
  31301. styles.willChange = sideA + ', ' + sideB;
  31302. }
  31303. // Attributes
  31304. var attributes = {
  31305. 'x-placement': data.placement
  31306. };
  31307. // Update `data` attributes, styles and arrowStyles
  31308. data.attributes = _extends({}, attributes, data.attributes);
  31309. data.styles = _extends({}, styles, data.styles);
  31310. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  31311. return data;
  31312. }
  31313. /**
  31314. * Helper used to know if the given modifier depends from another one.<br />
  31315. * It checks if the needed modifier is listed and enabled.
  31316. * @method
  31317. * @memberof Popper.Utils
  31318. * @param {Array} modifiers - list of modifiers
  31319. * @param {String} requestingName - name of requesting modifier
  31320. * @param {String} requestedName - name of requested modifier
  31321. * @returns {Boolean}
  31322. */
  31323. function isModifierRequired(modifiers, requestingName, requestedName) {
  31324. var requesting = find(modifiers, function (_ref) {
  31325. var name = _ref.name;
  31326. return name === requestingName;
  31327. });
  31328. var isRequired = !!requesting && modifiers.some(function (modifier) {
  31329. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  31330. });
  31331. if (!isRequired) {
  31332. var _requesting = '`' + requestingName + '`';
  31333. var requested = '`' + requestedName + '`';
  31334. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  31335. }
  31336. return isRequired;
  31337. }
  31338. /**
  31339. * @function
  31340. * @memberof Modifiers
  31341. * @argument {Object} data - The data object generated by update method
  31342. * @argument {Object} options - Modifiers configuration and options
  31343. * @returns {Object} The data object, properly modified
  31344. */
  31345. function arrow(data, options) {
  31346. var _data$offsets$arrow;
  31347. // arrow depends on keepTogether in order to work
  31348. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  31349. return data;
  31350. }
  31351. var arrowElement = options.element;
  31352. // if arrowElement is a string, suppose it's a CSS selector
  31353. if (typeof arrowElement === 'string') {
  31354. arrowElement = data.instance.popper.querySelector(arrowElement);
  31355. // if arrowElement is not found, don't run the modifier
  31356. if (!arrowElement) {
  31357. return data;
  31358. }
  31359. } else {
  31360. // if the arrowElement isn't a query selector we must check that the
  31361. // provided DOM node is child of its popper node
  31362. if (!data.instance.popper.contains(arrowElement)) {
  31363. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  31364. return data;
  31365. }
  31366. }
  31367. var placement = data.placement.split('-')[0];
  31368. var _data$offsets = data.offsets,
  31369. popper = _data$offsets.popper,
  31370. reference = _data$offsets.reference;
  31371. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  31372. var len = isVertical ? 'height' : 'width';
  31373. var sideCapitalized = isVertical ? 'Top' : 'Left';
  31374. var side = sideCapitalized.toLowerCase();
  31375. var altSide = isVertical ? 'left' : 'top';
  31376. var opSide = isVertical ? 'bottom' : 'right';
  31377. var arrowElementSize = getOuterSizes(arrowElement)[len];
  31378. //
  31379. // extends keepTogether behavior making sure the popper and its
  31380. // reference have enough pixels in conjunction
  31381. //
  31382. // top/left side
  31383. if (reference[opSide] - arrowElementSize < popper[side]) {
  31384. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  31385. }
  31386. // bottom/right side
  31387. if (reference[side] + arrowElementSize > popper[opSide]) {
  31388. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  31389. }
  31390. data.offsets.popper = getClientRect(data.offsets.popper);
  31391. // compute center of the popper
  31392. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  31393. // Compute the sideValue using the updated popper offsets
  31394. // take popper margin in account because we don't have this info available
  31395. var css = getStyleComputedProperty(data.instance.popper);
  31396. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  31397. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  31398. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  31399. // prevent arrowElement from being placed not contiguously to its popper
  31400. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  31401. data.arrowElement = arrowElement;
  31402. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  31403. return data;
  31404. }
  31405. /**
  31406. * Get the opposite placement variation of the given one
  31407. * @method
  31408. * @memberof Popper.Utils
  31409. * @argument {String} placement variation
  31410. * @returns {String} flipped placement variation
  31411. */
  31412. function getOppositeVariation(variation) {
  31413. if (variation === 'end') {
  31414. return 'start';
  31415. } else if (variation === 'start') {
  31416. return 'end';
  31417. }
  31418. return variation;
  31419. }
  31420. /**
  31421. * List of accepted placements to use as values of the `placement` option.<br />
  31422. * Valid placements are:
  31423. * - `auto`
  31424. * - `top`
  31425. * - `right`
  31426. * - `bottom`
  31427. * - `left`
  31428. *
  31429. * Each placement can have a variation from this list:
  31430. * - `-start`
  31431. * - `-end`
  31432. *
  31433. * Variations are interpreted easily if you think of them as the left to right
  31434. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  31435. * is right.<br />
  31436. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  31437. *
  31438. * Some valid examples are:
  31439. * - `top-end` (on top of reference, right aligned)
  31440. * - `right-start` (on right of reference, top aligned)
  31441. * - `bottom` (on bottom, centered)
  31442. * - `auto-end` (on the side with more space available, alignment depends by placement)
  31443. *
  31444. * @static
  31445. * @type {Array}
  31446. * @enum {String}
  31447. * @readonly
  31448. * @method placements
  31449. * @memberof Popper
  31450. */
  31451. 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'];
  31452. // Get rid of `auto` `auto-start` and `auto-end`
  31453. var validPlacements = placements.slice(3);
  31454. /**
  31455. * Given an initial placement, returns all the subsequent placements
  31456. * clockwise (or counter-clockwise).
  31457. *
  31458. * @method
  31459. * @memberof Popper.Utils
  31460. * @argument {String} placement - A valid placement (it accepts variations)
  31461. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  31462. * @returns {Array} placements including their variations
  31463. */
  31464. function clockwise(placement) {
  31465. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  31466. var index = validPlacements.indexOf(placement);
  31467. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  31468. return counter ? arr.reverse() : arr;
  31469. }
  31470. var BEHAVIORS = {
  31471. FLIP: 'flip',
  31472. CLOCKWISE: 'clockwise',
  31473. COUNTERCLOCKWISE: 'counterclockwise'
  31474. };
  31475. /**
  31476. * @function
  31477. * @memberof Modifiers
  31478. * @argument {Object} data - The data object generated by update method
  31479. * @argument {Object} options - Modifiers configuration and options
  31480. * @returns {Object} The data object, properly modified
  31481. */
  31482. function flip(data, options) {
  31483. // if `inner` modifier is enabled, we can't use the `flip` modifier
  31484. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  31485. return data;
  31486. }
  31487. if (data.flipped && data.placement === data.originalPlacement) {
  31488. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  31489. return data;
  31490. }
  31491. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  31492. var placement = data.placement.split('-')[0];
  31493. var placementOpposite = getOppositePlacement(placement);
  31494. var variation = data.placement.split('-')[1] || '';
  31495. var flipOrder = [];
  31496. switch (options.behavior) {
  31497. case BEHAVIORS.FLIP:
  31498. flipOrder = [placement, placementOpposite];
  31499. break;
  31500. case BEHAVIORS.CLOCKWISE:
  31501. flipOrder = clockwise(placement);
  31502. break;
  31503. case BEHAVIORS.COUNTERCLOCKWISE:
  31504. flipOrder = clockwise(placement, true);
  31505. break;
  31506. default:
  31507. flipOrder = options.behavior;
  31508. }
  31509. flipOrder.forEach(function (step, index) {
  31510. if (placement !== step || flipOrder.length === index + 1) {
  31511. return data;
  31512. }
  31513. placement = data.placement.split('-')[0];
  31514. placementOpposite = getOppositePlacement(placement);
  31515. var popperOffsets = data.offsets.popper;
  31516. var refOffsets = data.offsets.reference;
  31517. // using floor because the reference offsets may contain decimals we are not going to consider here
  31518. var floor = Math.floor;
  31519. 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);
  31520. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  31521. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  31522. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  31523. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  31524. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  31525. // flip the variation if required
  31526. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31527. // flips variation if reference element overflows boundaries
  31528. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  31529. // flips variation if popper content overflows boundaries
  31530. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  31531. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  31532. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  31533. // this boolean to detect any flip loop
  31534. data.flipped = true;
  31535. if (overlapsRef || overflowsBoundaries) {
  31536. placement = flipOrder[index + 1];
  31537. }
  31538. if (flippedVariation) {
  31539. variation = getOppositeVariation(variation);
  31540. }
  31541. data.placement = placement + (variation ? '-' + variation : '');
  31542. // this object contains `position`, we want to preserve it along with
  31543. // any additional property we may add in the future
  31544. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  31545. data = runModifiers(data.instance.modifiers, data, 'flip');
  31546. }
  31547. });
  31548. return data;
  31549. }
  31550. /**
  31551. * @function
  31552. * @memberof Modifiers
  31553. * @argument {Object} data - The data object generated by update method
  31554. * @argument {Object} options - Modifiers configuration and options
  31555. * @returns {Object} The data object, properly modified
  31556. */
  31557. function keepTogether(data) {
  31558. var _data$offsets = data.offsets,
  31559. popper = _data$offsets.popper,
  31560. reference = _data$offsets.reference;
  31561. var placement = data.placement.split('-')[0];
  31562. var floor = Math.floor;
  31563. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31564. var side = isVertical ? 'right' : 'bottom';
  31565. var opSide = isVertical ? 'left' : 'top';
  31566. var measurement = isVertical ? 'width' : 'height';
  31567. if (popper[side] < floor(reference[opSide])) {
  31568. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  31569. }
  31570. if (popper[opSide] > floor(reference[side])) {
  31571. data.offsets.popper[opSide] = floor(reference[side]);
  31572. }
  31573. return data;
  31574. }
  31575. /**
  31576. * Converts a string containing value + unit into a px value number
  31577. * @function
  31578. * @memberof {modifiers~offset}
  31579. * @private
  31580. * @argument {String} str - Value + unit string
  31581. * @argument {String} measurement - `height` or `width`
  31582. * @argument {Object} popperOffsets
  31583. * @argument {Object} referenceOffsets
  31584. * @returns {Number|String}
  31585. * Value in pixels, or original string if no values were extracted
  31586. */
  31587. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  31588. // separate value from unit
  31589. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  31590. var value = +split[1];
  31591. var unit = split[2];
  31592. // If it's not a number it's an operator, I guess
  31593. if (!value) {
  31594. return str;
  31595. }
  31596. if (unit.indexOf('%') === 0) {
  31597. var element = void 0;
  31598. switch (unit) {
  31599. case '%p':
  31600. element = popperOffsets;
  31601. break;
  31602. case '%':
  31603. case '%r':
  31604. default:
  31605. element = referenceOffsets;
  31606. }
  31607. var rect = getClientRect(element);
  31608. return rect[measurement] / 100 * value;
  31609. } else if (unit === 'vh' || unit === 'vw') {
  31610. // if is a vh or vw, we calculate the size based on the viewport
  31611. var size = void 0;
  31612. if (unit === 'vh') {
  31613. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  31614. } else {
  31615. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  31616. }
  31617. return size / 100 * value;
  31618. } else {
  31619. // if is an explicit pixel unit, we get rid of the unit and keep the value
  31620. // if is an implicit unit, it's px, and we return just the value
  31621. return value;
  31622. }
  31623. }
  31624. /**
  31625. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  31626. * @function
  31627. * @memberof {modifiers~offset}
  31628. * @private
  31629. * @argument {String} offset
  31630. * @argument {Object} popperOffsets
  31631. * @argument {Object} referenceOffsets
  31632. * @argument {String} basePlacement
  31633. * @returns {Array} a two cells array with x and y offsets in numbers
  31634. */
  31635. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  31636. var offsets = [0, 0];
  31637. // Use height if placement is left or right and index is 0 otherwise use width
  31638. // in this way the first offset will use an axis and the second one
  31639. // will use the other one
  31640. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  31641. // Split the offset string to obtain a list of values and operands
  31642. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  31643. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  31644. return frag.trim();
  31645. });
  31646. // Detect if the offset string contains a pair of values or a single one
  31647. // they could be separated by comma or space
  31648. var divider = fragments.indexOf(find(fragments, function (frag) {
  31649. return frag.search(/,|\s/) !== -1;
  31650. }));
  31651. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  31652. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  31653. }
  31654. // If divider is found, we divide the list of values and operands to divide
  31655. // them by ofset X and Y.
  31656. var splitRegex = /\s*,\s*|\s+/;
  31657. 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];
  31658. // Convert the values with units to absolute pixels to allow our computations
  31659. ops = ops.map(function (op, index) {
  31660. // Most of the units rely on the orientation of the popper
  31661. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  31662. var mergeWithPrevious = false;
  31663. return op
  31664. // This aggregates any `+` or `-` sign that aren't considered operators
  31665. // e.g.: 10 + +5 => [10, +, +5]
  31666. .reduce(function (a, b) {
  31667. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  31668. a[a.length - 1] = b;
  31669. mergeWithPrevious = true;
  31670. return a;
  31671. } else if (mergeWithPrevious) {
  31672. a[a.length - 1] += b;
  31673. mergeWithPrevious = false;
  31674. return a;
  31675. } else {
  31676. return a.concat(b);
  31677. }
  31678. }, [])
  31679. // Here we convert the string values into number values (in px)
  31680. .map(function (str) {
  31681. return toValue(str, measurement, popperOffsets, referenceOffsets);
  31682. });
  31683. });
  31684. // Loop trough the offsets arrays and execute the operations
  31685. ops.forEach(function (op, index) {
  31686. op.forEach(function (frag, index2) {
  31687. if (isNumeric(frag)) {
  31688. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  31689. }
  31690. });
  31691. });
  31692. return offsets;
  31693. }
  31694. /**
  31695. * @function
  31696. * @memberof Modifiers
  31697. * @argument {Object} data - The data object generated by update method
  31698. * @argument {Object} options - Modifiers configuration and options
  31699. * @argument {Number|String} options.offset=0
  31700. * The offset value as described in the modifier description
  31701. * @returns {Object} The data object, properly modified
  31702. */
  31703. function offset(data, _ref) {
  31704. var offset = _ref.offset;
  31705. var placement = data.placement,
  31706. _data$offsets = data.offsets,
  31707. popper = _data$offsets.popper,
  31708. reference = _data$offsets.reference;
  31709. var basePlacement = placement.split('-')[0];
  31710. var offsets = void 0;
  31711. if (isNumeric(+offset)) {
  31712. offsets = [+offset, 0];
  31713. } else {
  31714. offsets = parseOffset(offset, popper, reference, basePlacement);
  31715. }
  31716. if (basePlacement === 'left') {
  31717. popper.top += offsets[0];
  31718. popper.left -= offsets[1];
  31719. } else if (basePlacement === 'right') {
  31720. popper.top += offsets[0];
  31721. popper.left += offsets[1];
  31722. } else if (basePlacement === 'top') {
  31723. popper.left += offsets[0];
  31724. popper.top -= offsets[1];
  31725. } else if (basePlacement === 'bottom') {
  31726. popper.left += offsets[0];
  31727. popper.top += offsets[1];
  31728. }
  31729. data.popper = popper;
  31730. return data;
  31731. }
  31732. /**
  31733. * @function
  31734. * @memberof Modifiers
  31735. * @argument {Object} data - The data object generated by `update` method
  31736. * @argument {Object} options - Modifiers configuration and options
  31737. * @returns {Object} The data object, properly modified
  31738. */
  31739. function preventOverflow(data, options) {
  31740. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  31741. // If offsetParent is the reference element, we really want to
  31742. // go one step up and use the next offsetParent as reference to
  31743. // avoid to make this modifier completely useless and look like broken
  31744. if (data.instance.reference === boundariesElement) {
  31745. boundariesElement = getOffsetParent(boundariesElement);
  31746. }
  31747. // NOTE: DOM access here
  31748. // resets the popper's position so that the document size can be calculated excluding
  31749. // the size of the popper element itself
  31750. var transformProp = getSupportedPropertyName('transform');
  31751. var popperStyles = data.instance.popper.style; // assignment to help minification
  31752. var top = popperStyles.top,
  31753. left = popperStyles.left,
  31754. transform = popperStyles[transformProp];
  31755. popperStyles.top = '';
  31756. popperStyles.left = '';
  31757. popperStyles[transformProp] = '';
  31758. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  31759. // NOTE: DOM access here
  31760. // restores the original style properties after the offsets have been computed
  31761. popperStyles.top = top;
  31762. popperStyles.left = left;
  31763. popperStyles[transformProp] = transform;
  31764. options.boundaries = boundaries;
  31765. var order = options.priority;
  31766. var popper = data.offsets.popper;
  31767. var check = {
  31768. primary: function primary(placement) {
  31769. var value = popper[placement];
  31770. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  31771. value = Math.max(popper[placement], boundaries[placement]);
  31772. }
  31773. return defineProperty({}, placement, value);
  31774. },
  31775. secondary: function secondary(placement) {
  31776. var mainSide = placement === 'right' ? 'left' : 'top';
  31777. var value = popper[mainSide];
  31778. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  31779. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  31780. }
  31781. return defineProperty({}, mainSide, value);
  31782. }
  31783. };
  31784. order.forEach(function (placement) {
  31785. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  31786. popper = _extends({}, popper, check[side](placement));
  31787. });
  31788. data.offsets.popper = popper;
  31789. return data;
  31790. }
  31791. /**
  31792. * @function
  31793. * @memberof Modifiers
  31794. * @argument {Object} data - The data object generated by `update` method
  31795. * @argument {Object} options - Modifiers configuration and options
  31796. * @returns {Object} The data object, properly modified
  31797. */
  31798. function shift(data) {
  31799. var placement = data.placement;
  31800. var basePlacement = placement.split('-')[0];
  31801. var shiftvariation = placement.split('-')[1];
  31802. // if shift shiftvariation is specified, run the modifier
  31803. if (shiftvariation) {
  31804. var _data$offsets = data.offsets,
  31805. reference = _data$offsets.reference,
  31806. popper = _data$offsets.popper;
  31807. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  31808. var side = isVertical ? 'left' : 'top';
  31809. var measurement = isVertical ? 'width' : 'height';
  31810. var shiftOffsets = {
  31811. start: defineProperty({}, side, reference[side]),
  31812. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  31813. };
  31814. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  31815. }
  31816. return data;
  31817. }
  31818. /**
  31819. * @function
  31820. * @memberof Modifiers
  31821. * @argument {Object} data - The data object generated by update method
  31822. * @argument {Object} options - Modifiers configuration and options
  31823. * @returns {Object} The data object, properly modified
  31824. */
  31825. function hide(data) {
  31826. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  31827. return data;
  31828. }
  31829. var refRect = data.offsets.reference;
  31830. var bound = find(data.instance.modifiers, function (modifier) {
  31831. return modifier.name === 'preventOverflow';
  31832. }).boundaries;
  31833. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  31834. // Avoid unnecessary DOM access if visibility hasn't changed
  31835. if (data.hide === true) {
  31836. return data;
  31837. }
  31838. data.hide = true;
  31839. data.attributes['x-out-of-boundaries'] = '';
  31840. } else {
  31841. // Avoid unnecessary DOM access if visibility hasn't changed
  31842. if (data.hide === false) {
  31843. return data;
  31844. }
  31845. data.hide = false;
  31846. data.attributes['x-out-of-boundaries'] = false;
  31847. }
  31848. return data;
  31849. }
  31850. /**
  31851. * @function
  31852. * @memberof Modifiers
  31853. * @argument {Object} data - The data object generated by `update` method
  31854. * @argument {Object} options - Modifiers configuration and options
  31855. * @returns {Object} The data object, properly modified
  31856. */
  31857. function inner(data) {
  31858. var placement = data.placement;
  31859. var basePlacement = placement.split('-')[0];
  31860. var _data$offsets = data.offsets,
  31861. popper = _data$offsets.popper,
  31862. reference = _data$offsets.reference;
  31863. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  31864. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  31865. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  31866. data.placement = getOppositePlacement(placement);
  31867. data.offsets.popper = getClientRect(popper);
  31868. return data;
  31869. }
  31870. /**
  31871. * Modifier function, each modifier can have a function of this type assigned
  31872. * to its `fn` property.<br />
  31873. * These functions will be called on each update, this means that you must
  31874. * make sure they are performant enough to avoid performance bottlenecks.
  31875. *
  31876. * @function ModifierFn
  31877. * @argument {dataObject} data - The data object generated by `update` method
  31878. * @argument {Object} options - Modifiers configuration and options
  31879. * @returns {dataObject} The data object, properly modified
  31880. */
  31881. /**
  31882. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  31883. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  31884. * needed by the library.
  31885. *
  31886. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  31887. * All the other properties are configurations that could be tweaked.
  31888. * @namespace modifiers
  31889. */
  31890. var modifiers = {
  31891. /**
  31892. * Modifier used to shift the popper on the start or end of its reference
  31893. * element.<br />
  31894. * It will read the variation of the `placement` property.<br />
  31895. * It can be one either `-end` or `-start`.
  31896. * @memberof modifiers
  31897. * @inner
  31898. */
  31899. shift: {
  31900. /** @prop {number} order=100 - Index used to define the order of execution */
  31901. order: 100,
  31902. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31903. enabled: true,
  31904. /** @prop {ModifierFn} */
  31905. fn: shift
  31906. },
  31907. /**
  31908. * The `offset` modifier can shift your popper on both its axis.
  31909. *
  31910. * It accepts the following units:
  31911. * - `px` or unit-less, interpreted as pixels
  31912. * - `%` or `%r`, percentage relative to the length of the reference element
  31913. * - `%p`, percentage relative to the length of the popper element
  31914. * - `vw`, CSS viewport width unit
  31915. * - `vh`, CSS viewport height unit
  31916. *
  31917. * For length is intended the main axis relative to the placement of the popper.<br />
  31918. * This means that if the placement is `top` or `bottom`, the length will be the
  31919. * `width`. In case of `left` or `right`, it will be the `height`.
  31920. *
  31921. * You can provide a single value (as `Number` or `String`), or a pair of values
  31922. * as `String` divided by a comma or one (or more) white spaces.<br />
  31923. * The latter is a deprecated method because it leads to confusion and will be
  31924. * removed in v2.<br />
  31925. * Additionally, it accepts additions and subtractions between different units.
  31926. * Note that multiplications and divisions aren't supported.
  31927. *
  31928. * Valid examples are:
  31929. * ```
  31930. * 10
  31931. * '10%'
  31932. * '10, 10'
  31933. * '10%, 10'
  31934. * '10 + 10%'
  31935. * '10 - 5vh + 3%'
  31936. * '-10px + 5vh, 5px - 6%'
  31937. * ```
  31938. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  31939. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  31940. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  31941. *
  31942. * @memberof modifiers
  31943. * @inner
  31944. */
  31945. offset: {
  31946. /** @prop {number} order=200 - Index used to define the order of execution */
  31947. order: 200,
  31948. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31949. enabled: true,
  31950. /** @prop {ModifierFn} */
  31951. fn: offset,
  31952. /** @prop {Number|String} offset=0
  31953. * The offset value as described in the modifier description
  31954. */
  31955. offset: 0
  31956. },
  31957. /**
  31958. * Modifier used to prevent the popper from being positioned outside the boundary.
  31959. *
  31960. * A scenario exists where the reference itself is not within the boundaries.<br />
  31961. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  31962. * In this case we need to decide whether the popper should either:
  31963. *
  31964. * - detach from the reference and remain "trapped" in the boundaries, or
  31965. * - if it should ignore the boundary and "escape with its reference"
  31966. *
  31967. * When `escapeWithReference` is set to`true` and reference is completely
  31968. * outside its boundaries, the popper will overflow (or completely leave)
  31969. * the boundaries in order to remain attached to the edge of the reference.
  31970. *
  31971. * @memberof modifiers
  31972. * @inner
  31973. */
  31974. preventOverflow: {
  31975. /** @prop {number} order=300 - Index used to define the order of execution */
  31976. order: 300,
  31977. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31978. enabled: true,
  31979. /** @prop {ModifierFn} */
  31980. fn: preventOverflow,
  31981. /**
  31982. * @prop {Array} [priority=['left','right','top','bottom']]
  31983. * Popper will try to prevent overflow following these priorities by default,
  31984. * then, it could overflow on the left and on top of the `boundariesElement`
  31985. */
  31986. priority: ['left', 'right', 'top', 'bottom'],
  31987. /**
  31988. * @prop {number} padding=5
  31989. * Amount of pixel used to define a minimum distance between the boundaries
  31990. * and the popper. This makes sure the popper always has a little padding
  31991. * between the edges of its container
  31992. */
  31993. padding: 5,
  31994. /**
  31995. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  31996. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  31997. * `viewport` or any DOM element.
  31998. */
  31999. boundariesElement: 'scrollParent'
  32000. },
  32001. /**
  32002. * Modifier used to make sure the reference and its popper stay near each other
  32003. * without leaving any gap between the two. Especially useful when the arrow is
  32004. * enabled and you want to ensure that it points to its reference element.
  32005. * It cares only about the first axis. You can still have poppers with margin
  32006. * between the popper and its reference element.
  32007. * @memberof modifiers
  32008. * @inner
  32009. */
  32010. keepTogether: {
  32011. /** @prop {number} order=400 - Index used to define the order of execution */
  32012. order: 400,
  32013. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32014. enabled: true,
  32015. /** @prop {ModifierFn} */
  32016. fn: keepTogether
  32017. },
  32018. /**
  32019. * This modifier is used to move the `arrowElement` of the popper to make
  32020. * sure it is positioned between the reference element and its popper element.
  32021. * It will read the outer size of the `arrowElement` node to detect how many
  32022. * pixels of conjunction are needed.
  32023. *
  32024. * It has no effect if no `arrowElement` is provided.
  32025. * @memberof modifiers
  32026. * @inner
  32027. */
  32028. arrow: {
  32029. /** @prop {number} order=500 - Index used to define the order of execution */
  32030. order: 500,
  32031. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32032. enabled: true,
  32033. /** @prop {ModifierFn} */
  32034. fn: arrow,
  32035. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  32036. element: '[x-arrow]'
  32037. },
  32038. /**
  32039. * Modifier used to flip the popper's placement when it starts to overlap its
  32040. * reference element.
  32041. *
  32042. * Requires the `preventOverflow` modifier before it in order to work.
  32043. *
  32044. * **NOTE:** this modifier will interrupt the current update cycle and will
  32045. * restart it if it detects the need to flip the placement.
  32046. * @memberof modifiers
  32047. * @inner
  32048. */
  32049. flip: {
  32050. /** @prop {number} order=600 - Index used to define the order of execution */
  32051. order: 600,
  32052. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32053. enabled: true,
  32054. /** @prop {ModifierFn} */
  32055. fn: flip,
  32056. /**
  32057. * @prop {String|Array} behavior='flip'
  32058. * The behavior used to change the popper's placement. It can be one of
  32059. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  32060. * placements (with optional variations)
  32061. */
  32062. behavior: 'flip',
  32063. /**
  32064. * @prop {number} padding=5
  32065. * The popper will flip if it hits the edges of the `boundariesElement`
  32066. */
  32067. padding: 5,
  32068. /**
  32069. * @prop {String|HTMLElement} boundariesElement='viewport'
  32070. * The element which will define the boundaries of the popper position.
  32071. * The popper will never be placed outside of the defined boundaries
  32072. * (except if `keepTogether` is enabled)
  32073. */
  32074. boundariesElement: 'viewport',
  32075. /**
  32076. * @prop {Boolean} flipVariations=false
  32077. * The popper will switch placement variation between `-start` and `-end` when
  32078. * the reference element overlaps its boundaries.
  32079. *
  32080. * The original placement should have a set variation.
  32081. */
  32082. flipVariations: false,
  32083. /**
  32084. * @prop {Boolean} flipVariationsByContent=false
  32085. * The popper will switch placement variation between `-start` and `-end` when
  32086. * the popper element overlaps its reference boundaries.
  32087. *
  32088. * The original placement should have a set variation.
  32089. */
  32090. flipVariationsByContent: false
  32091. },
  32092. /**
  32093. * Modifier used to make the popper flow toward the inner of the reference element.
  32094. * By default, when this modifier is disabled, the popper will be placed outside
  32095. * the reference element.
  32096. * @memberof modifiers
  32097. * @inner
  32098. */
  32099. inner: {
  32100. /** @prop {number} order=700 - Index used to define the order of execution */
  32101. order: 700,
  32102. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  32103. enabled: false,
  32104. /** @prop {ModifierFn} */
  32105. fn: inner
  32106. },
  32107. /**
  32108. * Modifier used to hide the popper when its reference element is outside of the
  32109. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  32110. * be used to hide with a CSS selector the popper when its reference is
  32111. * out of boundaries.
  32112. *
  32113. * Requires the `preventOverflow` modifier before it in order to work.
  32114. * @memberof modifiers
  32115. * @inner
  32116. */
  32117. hide: {
  32118. /** @prop {number} order=800 - Index used to define the order of execution */
  32119. order: 800,
  32120. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32121. enabled: true,
  32122. /** @prop {ModifierFn} */
  32123. fn: hide
  32124. },
  32125. /**
  32126. * Computes the style that will be applied to the popper element to gets
  32127. * properly positioned.
  32128. *
  32129. * Note that this modifier will not touch the DOM, it just prepares the styles
  32130. * so that `applyStyle` modifier can apply it. This separation is useful
  32131. * in case you need to replace `applyStyle` with a custom implementation.
  32132. *
  32133. * This modifier has `850` as `order` value to maintain backward compatibility
  32134. * with previous versions of Popper.js. Expect the modifiers ordering method
  32135. * to change in future major versions of the library.
  32136. *
  32137. * @memberof modifiers
  32138. * @inner
  32139. */
  32140. computeStyle: {
  32141. /** @prop {number} order=850 - Index used to define the order of execution */
  32142. order: 850,
  32143. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32144. enabled: true,
  32145. /** @prop {ModifierFn} */
  32146. fn: computeStyle,
  32147. /**
  32148. * @prop {Boolean} gpuAcceleration=true
  32149. * If true, it uses the CSS 3D transformation to position the popper.
  32150. * Otherwise, it will use the `top` and `left` properties
  32151. */
  32152. gpuAcceleration: true,
  32153. /**
  32154. * @prop {string} [x='bottom']
  32155. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  32156. * Change this if your popper should grow in a direction different from `bottom`
  32157. */
  32158. x: 'bottom',
  32159. /**
  32160. * @prop {string} [x='left']
  32161. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  32162. * Change this if your popper should grow in a direction different from `right`
  32163. */
  32164. y: 'right'
  32165. },
  32166. /**
  32167. * Applies the computed styles to the popper element.
  32168. *
  32169. * All the DOM manipulations are limited to this modifier. This is useful in case
  32170. * you want to integrate Popper.js inside a framework or view library and you
  32171. * want to delegate all the DOM manipulations to it.
  32172. *
  32173. * Note that if you disable this modifier, you must make sure the popper element
  32174. * has its position set to `absolute` before Popper.js can do its work!
  32175. *
  32176. * Just disable this modifier and define your own to achieve the desired effect.
  32177. *
  32178. * @memberof modifiers
  32179. * @inner
  32180. */
  32181. applyStyle: {
  32182. /** @prop {number} order=900 - Index used to define the order of execution */
  32183. order: 900,
  32184. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32185. enabled: true,
  32186. /** @prop {ModifierFn} */
  32187. fn: applyStyle,
  32188. /** @prop {Function} */
  32189. onLoad: applyStyleOnLoad,
  32190. /**
  32191. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  32192. * @prop {Boolean} gpuAcceleration=true
  32193. * If true, it uses the CSS 3D transformation to position the popper.
  32194. * Otherwise, it will use the `top` and `left` properties
  32195. */
  32196. gpuAcceleration: undefined
  32197. }
  32198. };
  32199. /**
  32200. * The `dataObject` is an object containing all the information used by Popper.js.
  32201. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  32202. * @name dataObject
  32203. * @property {Object} data.instance The Popper.js instance
  32204. * @property {String} data.placement Placement applied to popper
  32205. * @property {String} data.originalPlacement Placement originally defined on init
  32206. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  32207. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  32208. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  32209. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32210. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32211. * @property {Object} data.boundaries Offsets of the popper boundaries
  32212. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  32213. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  32214. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  32215. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  32216. */
  32217. /**
  32218. * Default options provided to Popper.js constructor.<br />
  32219. * These can be overridden using the `options` argument of Popper.js.<br />
  32220. * To override an option, simply pass an object with the same
  32221. * structure of the `options` object, as the 3rd argument. For example:
  32222. * ```
  32223. * new Popper(ref, pop, {
  32224. * modifiers: {
  32225. * preventOverflow: { enabled: false }
  32226. * }
  32227. * })
  32228. * ```
  32229. * @type {Object}
  32230. * @static
  32231. * @memberof Popper
  32232. */
  32233. var Defaults = {
  32234. /**
  32235. * Popper's placement.
  32236. * @prop {Popper.placements} placement='bottom'
  32237. */
  32238. placement: 'bottom',
  32239. /**
  32240. * Set this to true if you want popper to position it self in 'fixed' mode
  32241. * @prop {Boolean} positionFixed=false
  32242. */
  32243. positionFixed: false,
  32244. /**
  32245. * Whether events (resize, scroll) are initially enabled.
  32246. * @prop {Boolean} eventsEnabled=true
  32247. */
  32248. eventsEnabled: true,
  32249. /**
  32250. * Set to true if you want to automatically remove the popper when
  32251. * you call the `destroy` method.
  32252. * @prop {Boolean} removeOnDestroy=false
  32253. */
  32254. removeOnDestroy: false,
  32255. /**
  32256. * Callback called when the popper is created.<br />
  32257. * By default, it is set to no-op.<br />
  32258. * Access Popper.js instance with `data.instance`.
  32259. * @prop {onCreate}
  32260. */
  32261. onCreate: function onCreate() {},
  32262. /**
  32263. * Callback called when the popper is updated. This callback is not called
  32264. * on the initialization/creation of the popper, but only on subsequent
  32265. * updates.<br />
  32266. * By default, it is set to no-op.<br />
  32267. * Access Popper.js instance with `data.instance`.
  32268. * @prop {onUpdate}
  32269. */
  32270. onUpdate: function onUpdate() {},
  32271. /**
  32272. * List of modifiers used to modify the offsets before they are applied to the popper.
  32273. * They provide most of the functionalities of Popper.js.
  32274. * @prop {modifiers}
  32275. */
  32276. modifiers: modifiers
  32277. };
  32278. /**
  32279. * @callback onCreate
  32280. * @param {dataObject} data
  32281. */
  32282. /**
  32283. * @callback onUpdate
  32284. * @param {dataObject} data
  32285. */
  32286. // Utils
  32287. // Methods
  32288. var Popper = function () {
  32289. /**
  32290. * Creates a new Popper.js instance.
  32291. * @class Popper
  32292. * @param {Element|referenceObject} reference - The reference element used to position the popper
  32293. * @param {Element} popper - The HTML / XML element used as the popper
  32294. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  32295. * @return {Object} instance - The generated Popper.js instance
  32296. */
  32297. function Popper(reference, popper) {
  32298. var _this = this;
  32299. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  32300. classCallCheck(this, Popper);
  32301. this.scheduleUpdate = function () {
  32302. return requestAnimationFrame(_this.update);
  32303. };
  32304. // make update() debounced, so that it only runs at most once-per-tick
  32305. this.update = debounce(this.update.bind(this));
  32306. // with {} we create a new object with the options inside it
  32307. this.options = _extends({}, Popper.Defaults, options);
  32308. // init state
  32309. this.state = {
  32310. isDestroyed: false,
  32311. isCreated: false,
  32312. scrollParents: []
  32313. };
  32314. // get reference and popper elements (allow jQuery wrappers)
  32315. this.reference = reference && reference.jquery ? reference[0] : reference;
  32316. this.popper = popper && popper.jquery ? popper[0] : popper;
  32317. // Deep merge modifiers options
  32318. this.options.modifiers = {};
  32319. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  32320. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  32321. });
  32322. // Refactoring modifiers' list (Object => Array)
  32323. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  32324. return _extends({
  32325. name: name
  32326. }, _this.options.modifiers[name]);
  32327. })
  32328. // sort the modifiers by order
  32329. .sort(function (a, b) {
  32330. return a.order - b.order;
  32331. });
  32332. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  32333. // such code is executed in the same order of its modifier
  32334. // they could add new properties to their options configuration
  32335. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  32336. this.modifiers.forEach(function (modifierOptions) {
  32337. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  32338. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  32339. }
  32340. });
  32341. // fire the first update to position the popper in the right place
  32342. this.update();
  32343. var eventsEnabled = this.options.eventsEnabled;
  32344. if (eventsEnabled) {
  32345. // setup event listeners, they will take care of update the position in specific situations
  32346. this.enableEventListeners();
  32347. }
  32348. this.state.eventsEnabled = eventsEnabled;
  32349. }
  32350. // We can't use class properties because they don't get listed in the
  32351. // class prototype and break stuff like Sinon stubs
  32352. createClass(Popper, [{
  32353. key: 'update',
  32354. value: function update$$1() {
  32355. return update.call(this);
  32356. }
  32357. }, {
  32358. key: 'destroy',
  32359. value: function destroy$$1() {
  32360. return destroy.call(this);
  32361. }
  32362. }, {
  32363. key: 'enableEventListeners',
  32364. value: function enableEventListeners$$1() {
  32365. return enableEventListeners.call(this);
  32366. }
  32367. }, {
  32368. key: 'disableEventListeners',
  32369. value: function disableEventListeners$$1() {
  32370. return disableEventListeners.call(this);
  32371. }
  32372. /**
  32373. * Schedules an update. It will run on the next UI update available.
  32374. * @method scheduleUpdate
  32375. * @memberof Popper
  32376. */
  32377. /**
  32378. * Collection of utilities useful when writing custom modifiers.
  32379. * Starting from version 1.7, this method is available only if you
  32380. * include `popper-utils.js` before `popper.js`.
  32381. *
  32382. * **DEPRECATION**: This way to access PopperUtils is deprecated
  32383. * and will be removed in v2! Use the PopperUtils module directly instead.
  32384. * Due to the high instability of the methods contained in Utils, we can't
  32385. * guarantee them to follow semver. Use them at your own risk!
  32386. * @static
  32387. * @private
  32388. * @type {Object}
  32389. * @deprecated since version 1.8
  32390. * @member Utils
  32391. * @memberof Popper
  32392. */
  32393. }]);
  32394. return Popper;
  32395. }();
  32396. /**
  32397. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  32398. * and lets you use it as replacement of a real DOM node.<br />
  32399. * You can use this method to position a popper relatively to a set of coordinates
  32400. * in case you don't have a DOM node to use as reference.
  32401. *
  32402. * ```
  32403. * new Popper(referenceObject, popperNode);
  32404. * ```
  32405. *
  32406. * NB: This feature isn't supported in Internet Explorer 10.
  32407. * @name referenceObject
  32408. * @property {Function} data.getBoundingClientRect
  32409. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  32410. * @property {number} data.clientWidth
  32411. * An ES6 getter that will return the width of the virtual reference element.
  32412. * @property {number} data.clientHeight
  32413. * An ES6 getter that will return the height of the virtual reference element.
  32414. */
  32415. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  32416. Popper.placements = placements;
  32417. Popper.Defaults = Defaults;
  32418. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  32419. //# sourceMappingURL=popper.js.map
  32420. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  32421. /***/ }),
  32422. /***/ "./node_modules/process/browser.js":
  32423. /*!*****************************************!*\
  32424. !*** ./node_modules/process/browser.js ***!
  32425. \*****************************************/
  32426. /*! no static exports found */
  32427. /***/ (function(module, exports) {
  32428. // shim for using process in browser
  32429. var process = module.exports = {};
  32430. // cached from whatever global is present so that test runners that stub it
  32431. // don't break things. But we need to wrap it in a try catch in case it is
  32432. // wrapped in strict mode code which doesn't define any globals. It's inside a
  32433. // function because try/catches deoptimize in certain engines.
  32434. var cachedSetTimeout;
  32435. var cachedClearTimeout;
  32436. function defaultSetTimout() {
  32437. throw new Error('setTimeout has not been defined');
  32438. }
  32439. function defaultClearTimeout () {
  32440. throw new Error('clearTimeout has not been defined');
  32441. }
  32442. (function () {
  32443. try {
  32444. if (typeof setTimeout === 'function') {
  32445. cachedSetTimeout = setTimeout;
  32446. } else {
  32447. cachedSetTimeout = defaultSetTimout;
  32448. }
  32449. } catch (e) {
  32450. cachedSetTimeout = defaultSetTimout;
  32451. }
  32452. try {
  32453. if (typeof clearTimeout === 'function') {
  32454. cachedClearTimeout = clearTimeout;
  32455. } else {
  32456. cachedClearTimeout = defaultClearTimeout;
  32457. }
  32458. } catch (e) {
  32459. cachedClearTimeout = defaultClearTimeout;
  32460. }
  32461. } ())
  32462. function runTimeout(fun) {
  32463. if (cachedSetTimeout === setTimeout) {
  32464. //normal enviroments in sane situations
  32465. return setTimeout(fun, 0);
  32466. }
  32467. // if setTimeout wasn't available but was latter defined
  32468. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  32469. cachedSetTimeout = setTimeout;
  32470. return setTimeout(fun, 0);
  32471. }
  32472. try {
  32473. // when when somebody has screwed with setTimeout but no I.E. maddness
  32474. return cachedSetTimeout(fun, 0);
  32475. } catch(e){
  32476. try {
  32477. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32478. return cachedSetTimeout.call(null, fun, 0);
  32479. } catch(e){
  32480. // 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
  32481. return cachedSetTimeout.call(this, fun, 0);
  32482. }
  32483. }
  32484. }
  32485. function runClearTimeout(marker) {
  32486. if (cachedClearTimeout === clearTimeout) {
  32487. //normal enviroments in sane situations
  32488. return clearTimeout(marker);
  32489. }
  32490. // if clearTimeout wasn't available but was latter defined
  32491. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  32492. cachedClearTimeout = clearTimeout;
  32493. return clearTimeout(marker);
  32494. }
  32495. try {
  32496. // when when somebody has screwed with setTimeout but no I.E. maddness
  32497. return cachedClearTimeout(marker);
  32498. } catch (e){
  32499. try {
  32500. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32501. return cachedClearTimeout.call(null, marker);
  32502. } catch (e){
  32503. // 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.
  32504. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  32505. return cachedClearTimeout.call(this, marker);
  32506. }
  32507. }
  32508. }
  32509. var queue = [];
  32510. var draining = false;
  32511. var currentQueue;
  32512. var queueIndex = -1;
  32513. function cleanUpNextTick() {
  32514. if (!draining || !currentQueue) {
  32515. return;
  32516. }
  32517. draining = false;
  32518. if (currentQueue.length) {
  32519. queue = currentQueue.concat(queue);
  32520. } else {
  32521. queueIndex = -1;
  32522. }
  32523. if (queue.length) {
  32524. drainQueue();
  32525. }
  32526. }
  32527. function drainQueue() {
  32528. if (draining) {
  32529. return;
  32530. }
  32531. var timeout = runTimeout(cleanUpNextTick);
  32532. draining = true;
  32533. var len = queue.length;
  32534. while(len) {
  32535. currentQueue = queue;
  32536. queue = [];
  32537. while (++queueIndex < len) {
  32538. if (currentQueue) {
  32539. currentQueue[queueIndex].run();
  32540. }
  32541. }
  32542. queueIndex = -1;
  32543. len = queue.length;
  32544. }
  32545. currentQueue = null;
  32546. draining = false;
  32547. runClearTimeout(timeout);
  32548. }
  32549. process.nextTick = function (fun) {
  32550. var args = new Array(arguments.length - 1);
  32551. if (arguments.length > 1) {
  32552. for (var i = 1; i < arguments.length; i++) {
  32553. args[i - 1] = arguments[i];
  32554. }
  32555. }
  32556. queue.push(new Item(fun, args));
  32557. if (queue.length === 1 && !draining) {
  32558. runTimeout(drainQueue);
  32559. }
  32560. };
  32561. // v8 likes predictible objects
  32562. function Item(fun, array) {
  32563. this.fun = fun;
  32564. this.array = array;
  32565. }
  32566. Item.prototype.run = function () {
  32567. this.fun.apply(null, this.array);
  32568. };
  32569. process.title = 'browser';
  32570. process.browser = true;
  32571. process.env = {};
  32572. process.argv = [];
  32573. process.version = ''; // empty string to avoid regexp issues
  32574. process.versions = {};
  32575. function noop() {}
  32576. process.on = noop;
  32577. process.addListener = noop;
  32578. process.once = noop;
  32579. process.off = noop;
  32580. process.removeListener = noop;
  32581. process.removeAllListeners = noop;
  32582. process.emit = noop;
  32583. process.prependListener = noop;
  32584. process.prependOnceListener = noop;
  32585. process.listeners = function (name) { return [] }
  32586. process.binding = function (name) {
  32587. throw new Error('process.binding is not supported');
  32588. };
  32589. process.cwd = function () { return '/' };
  32590. process.chdir = function (dir) {
  32591. throw new Error('process.chdir is not supported');
  32592. };
  32593. process.umask = function() { return 0; };
  32594. /***/ }),
  32595. /***/ "./node_modules/webpack/buildin/global.js":
  32596. /*!***********************************!*\
  32597. !*** (webpack)/buildin/global.js ***!
  32598. \***********************************/
  32599. /*! no static exports found */
  32600. /***/ (function(module, exports) {
  32601. var g;
  32602. // This works in non-strict mode
  32603. g = (function() {
  32604. return this;
  32605. })();
  32606. try {
  32607. // This works if eval is allowed (see CSP)
  32608. g = g || new Function("return this")();
  32609. } catch (e) {
  32610. // This works if the window reference is available
  32611. if (typeof window === "object") g = window;
  32612. }
  32613. // g can still be undefined, but nothing to do about it...
  32614. // We return undefined, instead of nothing here, so it's
  32615. // easier to handle this case. if(!global) { ...}
  32616. module.exports = g;
  32617. /***/ }),
  32618. /***/ "./node_modules/webpack/buildin/module.js":
  32619. /*!***********************************!*\
  32620. !*** (webpack)/buildin/module.js ***!
  32621. \***********************************/
  32622. /*! no static exports found */
  32623. /***/ (function(module, exports) {
  32624. module.exports = function(module) {
  32625. if (!module.webpackPolyfill) {
  32626. module.deprecate = function() {};
  32627. module.paths = [];
  32628. // module.parent = undefined by default
  32629. if (!module.children) module.children = [];
  32630. Object.defineProperty(module, "loaded", {
  32631. enumerable: true,
  32632. get: function() {
  32633. return module.l;
  32634. }
  32635. });
  32636. Object.defineProperty(module, "id", {
  32637. enumerable: true,
  32638. get: function() {
  32639. return module.i;
  32640. }
  32641. });
  32642. module.webpackPolyfill = 1;
  32643. }
  32644. return module;
  32645. };
  32646. /***/ }),
  32647. /***/ "./public/js/myScript.js":
  32648. /*!*******************************!*\
  32649. !*** ./public/js/myScript.js ***!
  32650. \*******************************/
  32651. /*! no static exports found */
  32652. /***/ (function(module, exports) {
  32653. $(document).ready(function () {
  32654. // --------------------------------------
  32655. // Async data loading
  32656. function asyncSend(tUri) {
  32657. $.ajax({
  32658. method: "GET",
  32659. url: tUri,
  32660. data: {}
  32661. }).done(function (data) {
  32662. return true;
  32663. }).fail(function (jqXHR, textStatus) {
  32664. Console.error(textStatus);
  32665. return false;
  32666. });
  32667. } // --------------------------------------
  32668. // My Player logic
  32669. function btnIconSwitch(obj, dir) {
  32670. if (dir) {
  32671. obj.classList.remove('fa-play');
  32672. obj.classList.add('fa-pause');
  32673. } else {
  32674. obj.classList.remove('fa-pause');
  32675. obj.classList.add('fa-play');
  32676. }
  32677. } // Simple player dynamics
  32678. var players = document.getElementsByClassName('play_btn');
  32679. for (var i = 0; i < players.length; i++) {
  32680. players[i].onclick = function () {
  32681. // Finding UI elements
  32682. var audioID = this.getAttribute('audio_id');
  32683. var audio = document.getElementById('audio_object_' + audioID);
  32684. var btn = document.getElementById('play_ctrl_' + audioID);
  32685. var playBadge = document.getElementById('play_num_' + audioID); // Handling Events
  32686. audio.onended = function () {
  32687. btnIconSwitch(btn, false);
  32688. };
  32689. if (audio.paused) {
  32690. audio.play();
  32691. btnIconSwitch(btn, true);
  32692. var plays = Number(playBadge.innerText) + 1;
  32693. playBadge.innerText = plays;
  32694. asyncSend(this.getAttribute('route')); // Play event
  32695. } else {
  32696. audio.pause();
  32697. btnIconSwitch(btn, false);
  32698. }
  32699. };
  32700. } // Downloads dynamics
  32701. var downs = document.getElementsByClassName('dw_btn');
  32702. for (var i = 0; i < downs.length; i++) {
  32703. downs[i].onclick = function () {
  32704. var audioID = this.getAttribute('audio_id');
  32705. var dwBadge = document.getElementById('dw_num_' + audioID);
  32706. var dw = Number(dwBadge.innerText) + 1;
  32707. dwBadge.innerText = dw;
  32708. asyncSend(this.getAttribute('route')); // download event
  32709. };
  32710. }
  32711. });
  32712. /***/ }),
  32713. /***/ "./resources/js/app.js":
  32714. /*!*****************************!*\
  32715. !*** ./resources/js/app.js ***!
  32716. \*****************************/
  32717. /*! no static exports found */
  32718. /***/ (function(module, exports, __webpack_require__) {
  32719. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  32720. __webpack_require__(/*! ../../public/js/myScript */ "./public/js/myScript.js");
  32721. /***/ }),
  32722. /***/ "./resources/js/bootstrap.js":
  32723. /*!***********************************!*\
  32724. !*** ./resources/js/bootstrap.js ***!
  32725. \***********************************/
  32726. /*! no static exports found */
  32727. /***/ (function(module, exports, __webpack_require__) {
  32728. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  32729. /**
  32730. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  32731. * for JavaScript based Bootstrap features such as modals and tabs. This
  32732. * code may be modified to fit the specific needs of your application.
  32733. */
  32734. try {
  32735. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  32736. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  32737. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  32738. } catch (e) {}
  32739. /**
  32740. * We'll load the axios HTTP library which allows us to easily issue requests
  32741. * to our Laravel back-end. This library automatically handles sending the
  32742. * CSRF token as a header based on the value of the "XSRF" token cookie.
  32743. */
  32744. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  32745. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  32746. /**
  32747. * Echo exposes an expressive API for subscribing to channels and listening
  32748. * for events that are broadcast by Laravel. Echo and event broadcasting
  32749. * allows your team to easily build robust real-time web applications.
  32750. */
  32751. // import Echo from 'laravel-echo';
  32752. // window.Pusher = require('pusher-js');
  32753. // window.Echo = new Echo({
  32754. // broadcaster: 'pusher',
  32755. // key: process.env.MIX_PUSHER_APP_KEY,
  32756. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  32757. // encrypted: true
  32758. // });
  32759. /***/ }),
  32760. /***/ "./resources/sass/app.scss":
  32761. /*!*********************************!*\
  32762. !*** ./resources/sass/app.scss ***!
  32763. \*********************************/
  32764. /*! no static exports found */
  32765. /***/ (function(module, exports) {
  32766. // removed by extract-text-webpack-plugin
  32767. /***/ }),
  32768. /***/ 0:
  32769. /*!*************************************************************!*\
  32770. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  32771. \*************************************************************/
  32772. /*! no static exports found */
  32773. /***/ (function(module, exports, __webpack_require__) {
  32774. __webpack_require__(/*! C:\Works\Development\spasPortal\resources\js\app.js */"./resources/js/app.js");
  32775. module.exports = __webpack_require__(/*! C:\Works\Development\spasPortal\resources\sass\app.scss */"./resources/sass/app.scss");
  32776. /***/ })
  32777. /******/ });