app.js 695 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./node_modules/alpinejs/dist/module.esm.js":
  4. /*!**************************************************!*\
  5. !*** ./node_modules/alpinejs/dist/module.esm.js ***!
  6. \**************************************************/
  7. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  8. "use strict";
  9. __webpack_require__.r(__webpack_exports__);
  10. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  11. /* harmony export */ "default": () => (/* binding */ module_default)
  12. /* harmony export */ });
  13. // packages/alpinejs/src/scheduler.js
  14. var flushPending = false;
  15. var flushing = false;
  16. var queue = [];
  17. function scheduler(callback) {
  18. queueJob(callback);
  19. }
  20. function queueJob(job) {
  21. if (!queue.includes(job))
  22. queue.push(job);
  23. queueFlush();
  24. }
  25. function dequeueJob(job) {
  26. let index = queue.indexOf(job);
  27. if (index !== -1)
  28. queue.splice(index, 1);
  29. }
  30. function queueFlush() {
  31. if (!flushing && !flushPending) {
  32. flushPending = true;
  33. queueMicrotask(flushJobs);
  34. }
  35. }
  36. function flushJobs() {
  37. flushPending = false;
  38. flushing = true;
  39. for (let i = 0; i < queue.length; i++) {
  40. queue[i]();
  41. }
  42. queue.length = 0;
  43. flushing = false;
  44. }
  45. // packages/alpinejs/src/reactivity.js
  46. var reactive;
  47. var effect;
  48. var release;
  49. var raw;
  50. var shouldSchedule = true;
  51. function disableEffectScheduling(callback) {
  52. shouldSchedule = false;
  53. callback();
  54. shouldSchedule = true;
  55. }
  56. function setReactivityEngine(engine) {
  57. reactive = engine.reactive;
  58. release = engine.release;
  59. effect = (callback) => engine.effect(callback, {scheduler: (task) => {
  60. if (shouldSchedule) {
  61. scheduler(task);
  62. } else {
  63. task();
  64. }
  65. }});
  66. raw = engine.raw;
  67. }
  68. function overrideEffect(override) {
  69. effect = override;
  70. }
  71. function elementBoundEffect(el) {
  72. let cleanup2 = () => {
  73. };
  74. let wrappedEffect = (callback) => {
  75. let effectReference = effect(callback);
  76. if (!el._x_effects) {
  77. el._x_effects = new Set();
  78. el._x_runEffects = () => {
  79. el._x_effects.forEach((i) => i());
  80. };
  81. }
  82. el._x_effects.add(effectReference);
  83. cleanup2 = () => {
  84. if (effectReference === void 0)
  85. return;
  86. el._x_effects.delete(effectReference);
  87. release(effectReference);
  88. };
  89. return effectReference;
  90. };
  91. return [wrappedEffect, () => {
  92. cleanup2();
  93. }];
  94. }
  95. // packages/alpinejs/src/mutation.js
  96. var onAttributeAddeds = [];
  97. var onElRemoveds = [];
  98. var onElAddeds = [];
  99. function onElAdded(callback) {
  100. onElAddeds.push(callback);
  101. }
  102. function onElRemoved(el, callback) {
  103. if (typeof callback === "function") {
  104. if (!el._x_cleanups)
  105. el._x_cleanups = [];
  106. el._x_cleanups.push(callback);
  107. } else {
  108. callback = el;
  109. onElRemoveds.push(callback);
  110. }
  111. }
  112. function onAttributesAdded(callback) {
  113. onAttributeAddeds.push(callback);
  114. }
  115. function onAttributeRemoved(el, name, callback) {
  116. if (!el._x_attributeCleanups)
  117. el._x_attributeCleanups = {};
  118. if (!el._x_attributeCleanups[name])
  119. el._x_attributeCleanups[name] = [];
  120. el._x_attributeCleanups[name].push(callback);
  121. }
  122. function cleanupAttributes(el, names) {
  123. if (!el._x_attributeCleanups)
  124. return;
  125. Object.entries(el._x_attributeCleanups).forEach(([name, value]) => {
  126. if (names === void 0 || names.includes(name)) {
  127. value.forEach((i) => i());
  128. delete el._x_attributeCleanups[name];
  129. }
  130. });
  131. }
  132. var observer = new MutationObserver(onMutate);
  133. var currentlyObserving = false;
  134. function startObservingMutations() {
  135. observer.observe(document, {subtree: true, childList: true, attributes: true, attributeOldValue: true});
  136. currentlyObserving = true;
  137. }
  138. function stopObservingMutations() {
  139. flushObserver();
  140. observer.disconnect();
  141. currentlyObserving = false;
  142. }
  143. var recordQueue = [];
  144. var willProcessRecordQueue = false;
  145. function flushObserver() {
  146. recordQueue = recordQueue.concat(observer.takeRecords());
  147. if (recordQueue.length && !willProcessRecordQueue) {
  148. willProcessRecordQueue = true;
  149. queueMicrotask(() => {
  150. processRecordQueue();
  151. willProcessRecordQueue = false;
  152. });
  153. }
  154. }
  155. function processRecordQueue() {
  156. onMutate(recordQueue);
  157. recordQueue.length = 0;
  158. }
  159. function mutateDom(callback) {
  160. if (!currentlyObserving)
  161. return callback();
  162. stopObservingMutations();
  163. let result = callback();
  164. startObservingMutations();
  165. return result;
  166. }
  167. var isCollecting = false;
  168. var deferredMutations = [];
  169. function deferMutations() {
  170. isCollecting = true;
  171. }
  172. function flushAndStopDeferringMutations() {
  173. isCollecting = false;
  174. onMutate(deferredMutations);
  175. deferredMutations = [];
  176. }
  177. function onMutate(mutations) {
  178. if (isCollecting) {
  179. deferredMutations = deferredMutations.concat(mutations);
  180. return;
  181. }
  182. let addedNodes = [];
  183. let removedNodes = [];
  184. let addedAttributes = new Map();
  185. let removedAttributes = new Map();
  186. for (let i = 0; i < mutations.length; i++) {
  187. if (mutations[i].target._x_ignoreMutationObserver)
  188. continue;
  189. if (mutations[i].type === "childList") {
  190. mutations[i].addedNodes.forEach((node) => node.nodeType === 1 && addedNodes.push(node));
  191. mutations[i].removedNodes.forEach((node) => node.nodeType === 1 && removedNodes.push(node));
  192. }
  193. if (mutations[i].type === "attributes") {
  194. let el = mutations[i].target;
  195. let name = mutations[i].attributeName;
  196. let oldValue = mutations[i].oldValue;
  197. let add2 = () => {
  198. if (!addedAttributes.has(el))
  199. addedAttributes.set(el, []);
  200. addedAttributes.get(el).push({name, value: el.getAttribute(name)});
  201. };
  202. let remove = () => {
  203. if (!removedAttributes.has(el))
  204. removedAttributes.set(el, []);
  205. removedAttributes.get(el).push(name);
  206. };
  207. if (el.hasAttribute(name) && oldValue === null) {
  208. add2();
  209. } else if (el.hasAttribute(name)) {
  210. remove();
  211. add2();
  212. } else {
  213. remove();
  214. }
  215. }
  216. }
  217. removedAttributes.forEach((attrs, el) => {
  218. cleanupAttributes(el, attrs);
  219. });
  220. addedAttributes.forEach((attrs, el) => {
  221. onAttributeAddeds.forEach((i) => i(el, attrs));
  222. });
  223. for (let node of removedNodes) {
  224. if (addedNodes.includes(node))
  225. continue;
  226. onElRemoveds.forEach((i) => i(node));
  227. if (node._x_cleanups) {
  228. while (node._x_cleanups.length)
  229. node._x_cleanups.pop()();
  230. }
  231. }
  232. addedNodes.forEach((node) => {
  233. node._x_ignoreSelf = true;
  234. node._x_ignore = true;
  235. });
  236. for (let node of addedNodes) {
  237. if (removedNodes.includes(node))
  238. continue;
  239. if (!node.isConnected)
  240. continue;
  241. delete node._x_ignoreSelf;
  242. delete node._x_ignore;
  243. onElAddeds.forEach((i) => i(node));
  244. node._x_ignore = true;
  245. node._x_ignoreSelf = true;
  246. }
  247. addedNodes.forEach((node) => {
  248. delete node._x_ignoreSelf;
  249. delete node._x_ignore;
  250. });
  251. addedNodes = null;
  252. removedNodes = null;
  253. addedAttributes = null;
  254. removedAttributes = null;
  255. }
  256. // packages/alpinejs/src/scope.js
  257. function scope(node) {
  258. return mergeProxies(closestDataStack(node));
  259. }
  260. function addScopeToNode(node, data2, referenceNode) {
  261. node._x_dataStack = [data2, ...closestDataStack(referenceNode || node)];
  262. return () => {
  263. node._x_dataStack = node._x_dataStack.filter((i) => i !== data2);
  264. };
  265. }
  266. function refreshScope(element, scope2) {
  267. let existingScope = element._x_dataStack[0];
  268. Object.entries(scope2).forEach(([key, value]) => {
  269. existingScope[key] = value;
  270. });
  271. }
  272. function closestDataStack(node) {
  273. if (node._x_dataStack)
  274. return node._x_dataStack;
  275. if (typeof ShadowRoot === "function" && node instanceof ShadowRoot) {
  276. return closestDataStack(node.host);
  277. }
  278. if (!node.parentNode) {
  279. return [];
  280. }
  281. return closestDataStack(node.parentNode);
  282. }
  283. function mergeProxies(objects) {
  284. let thisProxy = new Proxy({}, {
  285. ownKeys: () => {
  286. return Array.from(new Set(objects.flatMap((i) => Object.keys(i))));
  287. },
  288. has: (target, name) => {
  289. return objects.some((obj) => obj.hasOwnProperty(name));
  290. },
  291. get: (target, name) => {
  292. return (objects.find((obj) => {
  293. if (obj.hasOwnProperty(name)) {
  294. let descriptor = Object.getOwnPropertyDescriptor(obj, name);
  295. if (descriptor.get && descriptor.get._x_alreadyBound || descriptor.set && descriptor.set._x_alreadyBound) {
  296. return true;
  297. }
  298. if ((descriptor.get || descriptor.set) && descriptor.enumerable) {
  299. let getter = descriptor.get;
  300. let setter = descriptor.set;
  301. let property = descriptor;
  302. getter = getter && getter.bind(thisProxy);
  303. setter = setter && setter.bind(thisProxy);
  304. if (getter)
  305. getter._x_alreadyBound = true;
  306. if (setter)
  307. setter._x_alreadyBound = true;
  308. Object.defineProperty(obj, name, {
  309. ...property,
  310. get: getter,
  311. set: setter
  312. });
  313. }
  314. return true;
  315. }
  316. return false;
  317. }) || {})[name];
  318. },
  319. set: (target, name, value) => {
  320. let closestObjectWithKey = objects.find((obj) => obj.hasOwnProperty(name));
  321. if (closestObjectWithKey) {
  322. closestObjectWithKey[name] = value;
  323. } else {
  324. objects[objects.length - 1][name] = value;
  325. }
  326. return true;
  327. }
  328. });
  329. return thisProxy;
  330. }
  331. // packages/alpinejs/src/interceptor.js
  332. function initInterceptors(data2) {
  333. let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null;
  334. let recurse = (obj, basePath = "") => {
  335. Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, {value, enumerable}]) => {
  336. if (enumerable === false || value === void 0)
  337. return;
  338. let path = basePath === "" ? key : `${basePath}.${key}`;
  339. if (typeof value === "object" && value !== null && value._x_interceptor) {
  340. obj[key] = value.initialize(data2, path, key);
  341. } else {
  342. if (isObject2(value) && value !== obj && !(value instanceof Element)) {
  343. recurse(value, path);
  344. }
  345. }
  346. });
  347. };
  348. return recurse(data2);
  349. }
  350. function interceptor(callback, mutateObj = () => {
  351. }) {
  352. let obj = {
  353. initialValue: void 0,
  354. _x_interceptor: true,
  355. initialize(data2, path, key) {
  356. return callback(this.initialValue, () => get(data2, path), (value) => set(data2, path, value), path, key);
  357. }
  358. };
  359. mutateObj(obj);
  360. return (initialValue) => {
  361. if (typeof initialValue === "object" && initialValue !== null && initialValue._x_interceptor) {
  362. let initialize = obj.initialize.bind(obj);
  363. obj.initialize = (data2, path, key) => {
  364. let innerValue = initialValue.initialize(data2, path, key);
  365. obj.initialValue = innerValue;
  366. return initialize(data2, path, key);
  367. };
  368. } else {
  369. obj.initialValue = initialValue;
  370. }
  371. return obj;
  372. };
  373. }
  374. function get(obj, path) {
  375. return path.split(".").reduce((carry, segment) => carry[segment], obj);
  376. }
  377. function set(obj, path, value) {
  378. if (typeof path === "string")
  379. path = path.split(".");
  380. if (path.length === 1)
  381. obj[path[0]] = value;
  382. else if (path.length === 0)
  383. throw error;
  384. else {
  385. if (obj[path[0]])
  386. return set(obj[path[0]], path.slice(1), value);
  387. else {
  388. obj[path[0]] = {};
  389. return set(obj[path[0]], path.slice(1), value);
  390. }
  391. }
  392. }
  393. // packages/alpinejs/src/magics.js
  394. var magics = {};
  395. function magic(name, callback) {
  396. magics[name] = callback;
  397. }
  398. function injectMagics(obj, el) {
  399. Object.entries(magics).forEach(([name, callback]) => {
  400. Object.defineProperty(obj, `$${name}`, {
  401. get() {
  402. let [utilities, cleanup2] = getElementBoundUtilities(el);
  403. utilities = {interceptor, ...utilities};
  404. onElRemoved(el, cleanup2);
  405. return callback(el, utilities);
  406. },
  407. enumerable: false
  408. });
  409. });
  410. return obj;
  411. }
  412. // packages/alpinejs/src/utils/error.js
  413. function tryCatch(el, expression, callback, ...args) {
  414. try {
  415. return callback(...args);
  416. } catch (e) {
  417. handleError(e, el, expression);
  418. }
  419. }
  420. function handleError(error2, el, expression = void 0) {
  421. Object.assign(error2, {el, expression});
  422. console.warn(`Alpine Expression Error: ${error2.message}
  423. ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el);
  424. setTimeout(() => {
  425. throw error2;
  426. }, 0);
  427. }
  428. // packages/alpinejs/src/evaluator.js
  429. function evaluate(el, expression, extras = {}) {
  430. let result;
  431. evaluateLater(el, expression)((value) => result = value, extras);
  432. return result;
  433. }
  434. function evaluateLater(...args) {
  435. return theEvaluatorFunction(...args);
  436. }
  437. var theEvaluatorFunction = normalEvaluator;
  438. function setEvaluator(newEvaluator) {
  439. theEvaluatorFunction = newEvaluator;
  440. }
  441. function normalEvaluator(el, expression) {
  442. let overriddenMagics = {};
  443. injectMagics(overriddenMagics, el);
  444. let dataStack = [overriddenMagics, ...closestDataStack(el)];
  445. if (typeof expression === "function") {
  446. return generateEvaluatorFromFunction(dataStack, expression);
  447. }
  448. let evaluator = generateEvaluatorFromString(dataStack, expression, el);
  449. return tryCatch.bind(null, el, expression, evaluator);
  450. }
  451. function generateEvaluatorFromFunction(dataStack, func) {
  452. return (receiver = () => {
  453. }, {scope: scope2 = {}, params = []} = {}) => {
  454. let result = func.apply(mergeProxies([scope2, ...dataStack]), params);
  455. runIfTypeOfFunction(receiver, result);
  456. };
  457. }
  458. var evaluatorMemo = {};
  459. function generateFunctionFromString(expression, el) {
  460. if (evaluatorMemo[expression]) {
  461. return evaluatorMemo[expression];
  462. }
  463. let AsyncFunction = Object.getPrototypeOf(async function() {
  464. }).constructor;
  465. let rightSideSafeExpression = /^[\n\s]*if.*\(.*\)/.test(expression) || /^(let|const)\s/.test(expression) ? `(() => { ${expression} })()` : expression;
  466. const safeAsyncFunction = () => {
  467. try {
  468. return new AsyncFunction(["__self", "scope"], `with (scope) { __self.result = ${rightSideSafeExpression} }; __self.finished = true; return __self.result;`);
  469. } catch (error2) {
  470. handleError(error2, el, expression);
  471. return Promise.resolve();
  472. }
  473. };
  474. let func = safeAsyncFunction();
  475. evaluatorMemo[expression] = func;
  476. return func;
  477. }
  478. function generateEvaluatorFromString(dataStack, expression, el) {
  479. let func = generateFunctionFromString(expression, el);
  480. return (receiver = () => {
  481. }, {scope: scope2 = {}, params = []} = {}) => {
  482. func.result = void 0;
  483. func.finished = false;
  484. let completeScope = mergeProxies([scope2, ...dataStack]);
  485. if (typeof func === "function") {
  486. let promise = func(func, completeScope).catch((error2) => handleError(error2, el, expression));
  487. if (func.finished) {
  488. runIfTypeOfFunction(receiver, func.result, completeScope, params, el);
  489. func.result = void 0;
  490. } else {
  491. promise.then((result) => {
  492. runIfTypeOfFunction(receiver, result, completeScope, params, el);
  493. }).catch((error2) => handleError(error2, el, expression)).finally(() => func.result = void 0);
  494. }
  495. }
  496. };
  497. }
  498. function runIfTypeOfFunction(receiver, value, scope2, params, el) {
  499. if (typeof value === "function") {
  500. let result = value.apply(scope2, params);
  501. if (result instanceof Promise) {
  502. result.then((i) => runIfTypeOfFunction(receiver, i, scope2, params)).catch((error2) => handleError(error2, el, value));
  503. } else {
  504. receiver(result);
  505. }
  506. } else {
  507. receiver(value);
  508. }
  509. }
  510. // packages/alpinejs/src/directives.js
  511. var prefixAsString = "x-";
  512. function prefix(subject = "") {
  513. return prefixAsString + subject;
  514. }
  515. function setPrefix(newPrefix) {
  516. prefixAsString = newPrefix;
  517. }
  518. var directiveHandlers = {};
  519. function directive(name, callback) {
  520. directiveHandlers[name] = callback;
  521. }
  522. function directives(el, attributes, originalAttributeOverride) {
  523. let transformedAttributeMap = {};
  524. let directives2 = Array.from(attributes).map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority);
  525. return directives2.map((directive2) => {
  526. return getDirectiveHandler(el, directive2);
  527. });
  528. }
  529. function attributesOnly(attributes) {
  530. return Array.from(attributes).map(toTransformedAttributes()).filter((attr) => !outNonAlpineAttributes(attr));
  531. }
  532. var isDeferringHandlers = false;
  533. var directiveHandlerStacks = new Map();
  534. var currentHandlerStackKey = Symbol();
  535. function deferHandlingDirectives(callback) {
  536. isDeferringHandlers = true;
  537. let key = Symbol();
  538. currentHandlerStackKey = key;
  539. directiveHandlerStacks.set(key, []);
  540. let flushHandlers = () => {
  541. while (directiveHandlerStacks.get(key).length)
  542. directiveHandlerStacks.get(key).shift()();
  543. directiveHandlerStacks.delete(key);
  544. };
  545. let stopDeferring = () => {
  546. isDeferringHandlers = false;
  547. flushHandlers();
  548. };
  549. callback(flushHandlers);
  550. stopDeferring();
  551. }
  552. function getElementBoundUtilities(el) {
  553. let cleanups = [];
  554. let cleanup2 = (callback) => cleanups.push(callback);
  555. let [effect3, cleanupEffect] = elementBoundEffect(el);
  556. cleanups.push(cleanupEffect);
  557. let utilities = {
  558. Alpine: alpine_default,
  559. effect: effect3,
  560. cleanup: cleanup2,
  561. evaluateLater: evaluateLater.bind(evaluateLater, el),
  562. evaluate: evaluate.bind(evaluate, el)
  563. };
  564. let doCleanup = () => cleanups.forEach((i) => i());
  565. return [utilities, doCleanup];
  566. }
  567. function getDirectiveHandler(el, directive2) {
  568. let noop = () => {
  569. };
  570. let handler3 = directiveHandlers[directive2.type] || noop;
  571. let [utilities, cleanup2] = getElementBoundUtilities(el);
  572. onAttributeRemoved(el, directive2.original, cleanup2);
  573. let fullHandler = () => {
  574. if (el._x_ignore || el._x_ignoreSelf)
  575. return;
  576. handler3.inline && handler3.inline(el, directive2, utilities);
  577. handler3 = handler3.bind(handler3, el, directive2, utilities);
  578. isDeferringHandlers ? directiveHandlerStacks.get(currentHandlerStackKey).push(handler3) : handler3();
  579. };
  580. fullHandler.runCleanups = cleanup2;
  581. return fullHandler;
  582. }
  583. var startingWith = (subject, replacement) => ({name, value}) => {
  584. if (name.startsWith(subject))
  585. name = name.replace(subject, replacement);
  586. return {name, value};
  587. };
  588. var into = (i) => i;
  589. function toTransformedAttributes(callback = () => {
  590. }) {
  591. return ({name, value}) => {
  592. let {name: newName, value: newValue} = attributeTransformers.reduce((carry, transform) => {
  593. return transform(carry);
  594. }, {name, value});
  595. if (newName !== name)
  596. callback(newName, name);
  597. return {name: newName, value: newValue};
  598. };
  599. }
  600. var attributeTransformers = [];
  601. function mapAttributes(callback) {
  602. attributeTransformers.push(callback);
  603. }
  604. function outNonAlpineAttributes({name}) {
  605. return alpineAttributeRegex().test(name);
  606. }
  607. var alpineAttributeRegex = () => new RegExp(`^${prefixAsString}([^:^.]+)\\b`);
  608. function toParsedDirectives(transformedAttributeMap, originalAttributeOverride) {
  609. return ({name, value}) => {
  610. let typeMatch = name.match(alpineAttributeRegex());
  611. let valueMatch = name.match(/:([a-zA-Z0-9\-:]+)/);
  612. let modifiers = name.match(/\.[^.\]]+(?=[^\]]*$)/g) || [];
  613. let original = originalAttributeOverride || transformedAttributeMap[name] || name;
  614. return {
  615. type: typeMatch ? typeMatch[1] : null,
  616. value: valueMatch ? valueMatch[1] : null,
  617. modifiers: modifiers.map((i) => i.replace(".", "")),
  618. expression: value,
  619. original
  620. };
  621. };
  622. }
  623. var DEFAULT = "DEFAULT";
  624. var directiveOrder = [
  625. "ignore",
  626. "ref",
  627. "data",
  628. "id",
  629. "bind",
  630. "init",
  631. "for",
  632. "model",
  633. "modelable",
  634. "transition",
  635. "show",
  636. "if",
  637. DEFAULT,
  638. "teleport",
  639. "element"
  640. ];
  641. function byPriority(a, b) {
  642. let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type;
  643. let typeB = directiveOrder.indexOf(b.type) === -1 ? DEFAULT : b.type;
  644. return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB);
  645. }
  646. // packages/alpinejs/src/utils/dispatch.js
  647. function dispatch(el, name, detail = {}) {
  648. el.dispatchEvent(new CustomEvent(name, {
  649. detail,
  650. bubbles: true,
  651. composed: true,
  652. cancelable: true
  653. }));
  654. }
  655. // packages/alpinejs/src/nextTick.js
  656. var tickStack = [];
  657. var isHolding = false;
  658. function nextTick(callback) {
  659. tickStack.push(callback);
  660. queueMicrotask(() => {
  661. isHolding || setTimeout(() => {
  662. releaseNextTicks();
  663. });
  664. });
  665. }
  666. function releaseNextTicks() {
  667. isHolding = false;
  668. while (tickStack.length)
  669. tickStack.shift()();
  670. }
  671. function holdNextTicks() {
  672. isHolding = true;
  673. }
  674. // packages/alpinejs/src/utils/walk.js
  675. function walk(el, callback) {
  676. if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) {
  677. Array.from(el.children).forEach((el2) => walk(el2, callback));
  678. return;
  679. }
  680. let skip = false;
  681. callback(el, () => skip = true);
  682. if (skip)
  683. return;
  684. let node = el.firstElementChild;
  685. while (node) {
  686. walk(node, callback, false);
  687. node = node.nextElementSibling;
  688. }
  689. }
  690. // packages/alpinejs/src/utils/warn.js
  691. function warn(message, ...args) {
  692. console.warn(`Alpine Warning: ${message}`, ...args);
  693. }
  694. // packages/alpinejs/src/lifecycle.js
  695. function start() {
  696. if (!document.body)
  697. warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?");
  698. dispatch(document, "alpine:init");
  699. dispatch(document, "alpine:initializing");
  700. startObservingMutations();
  701. onElAdded((el) => initTree(el, walk));
  702. onElRemoved((el) => destroyTree(el));
  703. onAttributesAdded((el, attrs) => {
  704. directives(el, attrs).forEach((handle) => handle());
  705. });
  706. let outNestedComponents = (el) => !closestRoot(el.parentElement, true);
  707. Array.from(document.querySelectorAll(allSelectors())).filter(outNestedComponents).forEach((el) => {
  708. initTree(el);
  709. });
  710. dispatch(document, "alpine:initialized");
  711. }
  712. var rootSelectorCallbacks = [];
  713. var initSelectorCallbacks = [];
  714. function rootSelectors() {
  715. return rootSelectorCallbacks.map((fn) => fn());
  716. }
  717. function allSelectors() {
  718. return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn());
  719. }
  720. function addRootSelector(selectorCallback) {
  721. rootSelectorCallbacks.push(selectorCallback);
  722. }
  723. function addInitSelector(selectorCallback) {
  724. initSelectorCallbacks.push(selectorCallback);
  725. }
  726. function closestRoot(el, includeInitSelectors = false) {
  727. return findClosest(el, (element) => {
  728. const selectors = includeInitSelectors ? allSelectors() : rootSelectors();
  729. if (selectors.some((selector) => element.matches(selector)))
  730. return true;
  731. });
  732. }
  733. function findClosest(el, callback) {
  734. if (!el)
  735. return;
  736. if (callback(el))
  737. return el;
  738. if (el._x_teleportBack)
  739. el = el._x_teleportBack;
  740. if (!el.parentElement)
  741. return;
  742. return findClosest(el.parentElement, callback);
  743. }
  744. function isRoot(el) {
  745. return rootSelectors().some((selector) => el.matches(selector));
  746. }
  747. function initTree(el, walker = walk) {
  748. deferHandlingDirectives(() => {
  749. walker(el, (el2, skip) => {
  750. directives(el2, el2.attributes).forEach((handle) => handle());
  751. el2._x_ignore && skip();
  752. });
  753. });
  754. }
  755. function destroyTree(root) {
  756. walk(root, (el) => cleanupAttributes(el));
  757. }
  758. // packages/alpinejs/src/utils/classes.js
  759. function setClasses(el, value) {
  760. if (Array.isArray(value)) {
  761. return setClassesFromString(el, value.join(" "));
  762. } else if (typeof value === "object" && value !== null) {
  763. return setClassesFromObject(el, value);
  764. } else if (typeof value === "function") {
  765. return setClasses(el, value());
  766. }
  767. return setClassesFromString(el, value);
  768. }
  769. function setClassesFromString(el, classString) {
  770. let split = (classString2) => classString2.split(" ").filter(Boolean);
  771. let missingClasses = (classString2) => classString2.split(" ").filter((i) => !el.classList.contains(i)).filter(Boolean);
  772. let addClassesAndReturnUndo = (classes) => {
  773. el.classList.add(...classes);
  774. return () => {
  775. el.classList.remove(...classes);
  776. };
  777. };
  778. classString = classString === true ? classString = "" : classString || "";
  779. return addClassesAndReturnUndo(missingClasses(classString));
  780. }
  781. function setClassesFromObject(el, classObject) {
  782. let split = (classString) => classString.split(" ").filter(Boolean);
  783. let forAdd = Object.entries(classObject).flatMap(([classString, bool]) => bool ? split(classString) : false).filter(Boolean);
  784. let forRemove = Object.entries(classObject).flatMap(([classString, bool]) => !bool ? split(classString) : false).filter(Boolean);
  785. let added = [];
  786. let removed = [];
  787. forRemove.forEach((i) => {
  788. if (el.classList.contains(i)) {
  789. el.classList.remove(i);
  790. removed.push(i);
  791. }
  792. });
  793. forAdd.forEach((i) => {
  794. if (!el.classList.contains(i)) {
  795. el.classList.add(i);
  796. added.push(i);
  797. }
  798. });
  799. return () => {
  800. removed.forEach((i) => el.classList.add(i));
  801. added.forEach((i) => el.classList.remove(i));
  802. };
  803. }
  804. // packages/alpinejs/src/utils/styles.js
  805. function setStyles(el, value) {
  806. if (typeof value === "object" && value !== null) {
  807. return setStylesFromObject(el, value);
  808. }
  809. return setStylesFromString(el, value);
  810. }
  811. function setStylesFromObject(el, value) {
  812. let previousStyles = {};
  813. Object.entries(value).forEach(([key, value2]) => {
  814. previousStyles[key] = el.style[key];
  815. if (!key.startsWith("--")) {
  816. key = kebabCase(key);
  817. }
  818. el.style.setProperty(key, value2);
  819. });
  820. setTimeout(() => {
  821. if (el.style.length === 0) {
  822. el.removeAttribute("style");
  823. }
  824. });
  825. return () => {
  826. setStyles(el, previousStyles);
  827. };
  828. }
  829. function setStylesFromString(el, value) {
  830. let cache = el.getAttribute("style", value);
  831. el.setAttribute("style", value);
  832. return () => {
  833. el.setAttribute("style", cache || "");
  834. };
  835. }
  836. function kebabCase(subject) {
  837. return subject.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
  838. }
  839. // packages/alpinejs/src/utils/once.js
  840. function once(callback, fallback = () => {
  841. }) {
  842. let called = false;
  843. return function() {
  844. if (!called) {
  845. called = true;
  846. callback.apply(this, arguments);
  847. } else {
  848. fallback.apply(this, arguments);
  849. }
  850. };
  851. }
  852. // packages/alpinejs/src/directives/x-transition.js
  853. directive("transition", (el, {value, modifiers, expression}, {evaluate: evaluate2}) => {
  854. if (typeof expression === "function")
  855. expression = evaluate2(expression);
  856. if (!expression) {
  857. registerTransitionsFromHelper(el, modifiers, value);
  858. } else {
  859. registerTransitionsFromClassString(el, expression, value);
  860. }
  861. });
  862. function registerTransitionsFromClassString(el, classString, stage) {
  863. registerTransitionObject(el, setClasses, "");
  864. let directiveStorageMap = {
  865. enter: (classes) => {
  866. el._x_transition.enter.during = classes;
  867. },
  868. "enter-start": (classes) => {
  869. el._x_transition.enter.start = classes;
  870. },
  871. "enter-end": (classes) => {
  872. el._x_transition.enter.end = classes;
  873. },
  874. leave: (classes) => {
  875. el._x_transition.leave.during = classes;
  876. },
  877. "leave-start": (classes) => {
  878. el._x_transition.leave.start = classes;
  879. },
  880. "leave-end": (classes) => {
  881. el._x_transition.leave.end = classes;
  882. }
  883. };
  884. directiveStorageMap[stage](classString);
  885. }
  886. function registerTransitionsFromHelper(el, modifiers, stage) {
  887. registerTransitionObject(el, setStyles);
  888. let doesntSpecify = !modifiers.includes("in") && !modifiers.includes("out") && !stage;
  889. let transitioningIn = doesntSpecify || modifiers.includes("in") || ["enter"].includes(stage);
  890. let transitioningOut = doesntSpecify || modifiers.includes("out") || ["leave"].includes(stage);
  891. if (modifiers.includes("in") && !doesntSpecify) {
  892. modifiers = modifiers.filter((i, index) => index < modifiers.indexOf("out"));
  893. }
  894. if (modifiers.includes("out") && !doesntSpecify) {
  895. modifiers = modifiers.filter((i, index) => index > modifiers.indexOf("out"));
  896. }
  897. let wantsAll = !modifiers.includes("opacity") && !modifiers.includes("scale");
  898. let wantsOpacity = wantsAll || modifiers.includes("opacity");
  899. let wantsScale = wantsAll || modifiers.includes("scale");
  900. let opacityValue = wantsOpacity ? 0 : 1;
  901. let scaleValue = wantsScale ? modifierValue(modifiers, "scale", 95) / 100 : 1;
  902. let delay = modifierValue(modifiers, "delay", 0);
  903. let origin = modifierValue(modifiers, "origin", "center");
  904. let property = "opacity, transform";
  905. let durationIn = modifierValue(modifiers, "duration", 150) / 1e3;
  906. let durationOut = modifierValue(modifiers, "duration", 75) / 1e3;
  907. let easing = `cubic-bezier(0.4, 0.0, 0.2, 1)`;
  908. if (transitioningIn) {
  909. el._x_transition.enter.during = {
  910. transformOrigin: origin,
  911. transitionDelay: delay,
  912. transitionProperty: property,
  913. transitionDuration: `${durationIn}s`,
  914. transitionTimingFunction: easing
  915. };
  916. el._x_transition.enter.start = {
  917. opacity: opacityValue,
  918. transform: `scale(${scaleValue})`
  919. };
  920. el._x_transition.enter.end = {
  921. opacity: 1,
  922. transform: `scale(1)`
  923. };
  924. }
  925. if (transitioningOut) {
  926. el._x_transition.leave.during = {
  927. transformOrigin: origin,
  928. transitionDelay: delay,
  929. transitionProperty: property,
  930. transitionDuration: `${durationOut}s`,
  931. transitionTimingFunction: easing
  932. };
  933. el._x_transition.leave.start = {
  934. opacity: 1,
  935. transform: `scale(1)`
  936. };
  937. el._x_transition.leave.end = {
  938. opacity: opacityValue,
  939. transform: `scale(${scaleValue})`
  940. };
  941. }
  942. }
  943. function registerTransitionObject(el, setFunction, defaultValue = {}) {
  944. if (!el._x_transition)
  945. el._x_transition = {
  946. enter: {during: defaultValue, start: defaultValue, end: defaultValue},
  947. leave: {during: defaultValue, start: defaultValue, end: defaultValue},
  948. in(before = () => {
  949. }, after = () => {
  950. }) {
  951. transition(el, setFunction, {
  952. during: this.enter.during,
  953. start: this.enter.start,
  954. end: this.enter.end
  955. }, before, after);
  956. },
  957. out(before = () => {
  958. }, after = () => {
  959. }) {
  960. transition(el, setFunction, {
  961. during: this.leave.during,
  962. start: this.leave.start,
  963. end: this.leave.end
  964. }, before, after);
  965. }
  966. };
  967. }
  968. window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) {
  969. let clickAwayCompatibleShow = () => {
  970. document.visibilityState === "visible" ? requestAnimationFrame(show) : setTimeout(show);
  971. };
  972. if (value) {
  973. if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) {
  974. el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow();
  975. } else {
  976. el._x_transition ? el._x_transition.in(show) : clickAwayCompatibleShow();
  977. }
  978. return;
  979. }
  980. el._x_hidePromise = el._x_transition ? new Promise((resolve, reject) => {
  981. el._x_transition.out(() => {
  982. }, () => resolve(hide));
  983. el._x_transitioning.beforeCancel(() => reject({isFromCancelledTransition: true}));
  984. }) : Promise.resolve(hide);
  985. queueMicrotask(() => {
  986. let closest = closestHide(el);
  987. if (closest) {
  988. if (!closest._x_hideChildren)
  989. closest._x_hideChildren = [];
  990. closest._x_hideChildren.push(el);
  991. } else {
  992. queueMicrotask(() => {
  993. let hideAfterChildren = (el2) => {
  994. let carry = Promise.all([
  995. el2._x_hidePromise,
  996. ...(el2._x_hideChildren || []).map(hideAfterChildren)
  997. ]).then(([i]) => i());
  998. delete el2._x_hidePromise;
  999. delete el2._x_hideChildren;
  1000. return carry;
  1001. };
  1002. hideAfterChildren(el).catch((e) => {
  1003. if (!e.isFromCancelledTransition)
  1004. throw e;
  1005. });
  1006. });
  1007. }
  1008. });
  1009. };
  1010. function closestHide(el) {
  1011. let parent = el.parentNode;
  1012. if (!parent)
  1013. return;
  1014. return parent._x_hidePromise ? parent : closestHide(parent);
  1015. }
  1016. function transition(el, setFunction, {during, start: start2, end} = {}, before = () => {
  1017. }, after = () => {
  1018. }) {
  1019. if (el._x_transitioning)
  1020. el._x_transitioning.cancel();
  1021. if (Object.keys(during).length === 0 && Object.keys(start2).length === 0 && Object.keys(end).length === 0) {
  1022. before();
  1023. after();
  1024. return;
  1025. }
  1026. let undoStart, undoDuring, undoEnd;
  1027. performTransition(el, {
  1028. start() {
  1029. undoStart = setFunction(el, start2);
  1030. },
  1031. during() {
  1032. undoDuring = setFunction(el, during);
  1033. },
  1034. before,
  1035. end() {
  1036. undoStart();
  1037. undoEnd = setFunction(el, end);
  1038. },
  1039. after,
  1040. cleanup() {
  1041. undoDuring();
  1042. undoEnd();
  1043. }
  1044. });
  1045. }
  1046. function performTransition(el, stages) {
  1047. let interrupted, reachedBefore, reachedEnd;
  1048. let finish = once(() => {
  1049. mutateDom(() => {
  1050. interrupted = true;
  1051. if (!reachedBefore)
  1052. stages.before();
  1053. if (!reachedEnd) {
  1054. stages.end();
  1055. releaseNextTicks();
  1056. }
  1057. stages.after();
  1058. if (el.isConnected)
  1059. stages.cleanup();
  1060. delete el._x_transitioning;
  1061. });
  1062. });
  1063. el._x_transitioning = {
  1064. beforeCancels: [],
  1065. beforeCancel(callback) {
  1066. this.beforeCancels.push(callback);
  1067. },
  1068. cancel: once(function() {
  1069. while (this.beforeCancels.length) {
  1070. this.beforeCancels.shift()();
  1071. }
  1072. ;
  1073. finish();
  1074. }),
  1075. finish
  1076. };
  1077. mutateDom(() => {
  1078. stages.start();
  1079. stages.during();
  1080. });
  1081. holdNextTicks();
  1082. requestAnimationFrame(() => {
  1083. if (interrupted)
  1084. return;
  1085. let duration = Number(getComputedStyle(el).transitionDuration.replace(/,.*/, "").replace("s", "")) * 1e3;
  1086. let delay = Number(getComputedStyle(el).transitionDelay.replace(/,.*/, "").replace("s", "")) * 1e3;
  1087. if (duration === 0)
  1088. duration = Number(getComputedStyle(el).animationDuration.replace("s", "")) * 1e3;
  1089. mutateDom(() => {
  1090. stages.before();
  1091. });
  1092. reachedBefore = true;
  1093. requestAnimationFrame(() => {
  1094. if (interrupted)
  1095. return;
  1096. mutateDom(() => {
  1097. stages.end();
  1098. });
  1099. releaseNextTicks();
  1100. setTimeout(el._x_transitioning.finish, duration + delay);
  1101. reachedEnd = true;
  1102. });
  1103. });
  1104. }
  1105. function modifierValue(modifiers, key, fallback) {
  1106. if (modifiers.indexOf(key) === -1)
  1107. return fallback;
  1108. const rawValue = modifiers[modifiers.indexOf(key) + 1];
  1109. if (!rawValue)
  1110. return fallback;
  1111. if (key === "scale") {
  1112. if (isNaN(rawValue))
  1113. return fallback;
  1114. }
  1115. if (key === "duration") {
  1116. let match = rawValue.match(/([0-9]+)ms/);
  1117. if (match)
  1118. return match[1];
  1119. }
  1120. if (key === "origin") {
  1121. if (["top", "right", "left", "center", "bottom"].includes(modifiers[modifiers.indexOf(key) + 2])) {
  1122. return [rawValue, modifiers[modifiers.indexOf(key) + 2]].join(" ");
  1123. }
  1124. }
  1125. return rawValue;
  1126. }
  1127. // packages/alpinejs/src/clone.js
  1128. var isCloning = false;
  1129. function skipDuringClone(callback, fallback = () => {
  1130. }) {
  1131. return (...args) => isCloning ? fallback(...args) : callback(...args);
  1132. }
  1133. function clone(oldEl, newEl) {
  1134. if (!newEl._x_dataStack)
  1135. newEl._x_dataStack = oldEl._x_dataStack;
  1136. isCloning = true;
  1137. dontRegisterReactiveSideEffects(() => {
  1138. cloneTree(newEl);
  1139. });
  1140. isCloning = false;
  1141. }
  1142. function cloneTree(el) {
  1143. let hasRunThroughFirstEl = false;
  1144. let shallowWalker = (el2, callback) => {
  1145. walk(el2, (el3, skip) => {
  1146. if (hasRunThroughFirstEl && isRoot(el3))
  1147. return skip();
  1148. hasRunThroughFirstEl = true;
  1149. callback(el3, skip);
  1150. });
  1151. };
  1152. initTree(el, shallowWalker);
  1153. }
  1154. function dontRegisterReactiveSideEffects(callback) {
  1155. let cache = effect;
  1156. overrideEffect((callback2, el) => {
  1157. let storedEffect = cache(callback2);
  1158. release(storedEffect);
  1159. return () => {
  1160. };
  1161. });
  1162. callback();
  1163. overrideEffect(cache);
  1164. }
  1165. // packages/alpinejs/src/utils/bind.js
  1166. function bind(el, name, value, modifiers = []) {
  1167. if (!el._x_bindings)
  1168. el._x_bindings = reactive({});
  1169. el._x_bindings[name] = value;
  1170. name = modifiers.includes("camel") ? camelCase(name) : name;
  1171. switch (name) {
  1172. case "value":
  1173. bindInputValue(el, value);
  1174. break;
  1175. case "style":
  1176. bindStyles(el, value);
  1177. break;
  1178. case "class":
  1179. bindClasses(el, value);
  1180. break;
  1181. default:
  1182. bindAttribute(el, name, value);
  1183. break;
  1184. }
  1185. }
  1186. function bindInputValue(el, value) {
  1187. if (el.type === "radio") {
  1188. if (el.attributes.value === void 0) {
  1189. el.value = value;
  1190. }
  1191. if (window.fromModel) {
  1192. el.checked = checkedAttrLooseCompare(el.value, value);
  1193. }
  1194. } else if (el.type === "checkbox") {
  1195. if (Number.isInteger(value)) {
  1196. el.value = value;
  1197. } else if (!Number.isInteger(value) && !Array.isArray(value) && typeof value !== "boolean" && ![null, void 0].includes(value)) {
  1198. el.value = String(value);
  1199. } else {
  1200. if (Array.isArray(value)) {
  1201. el.checked = value.some((val) => checkedAttrLooseCompare(val, el.value));
  1202. } else {
  1203. el.checked = !!value;
  1204. }
  1205. }
  1206. } else if (el.tagName === "SELECT") {
  1207. updateSelect(el, value);
  1208. } else {
  1209. if (el.value === value)
  1210. return;
  1211. el.value = value;
  1212. }
  1213. }
  1214. function bindClasses(el, value) {
  1215. if (el._x_undoAddedClasses)
  1216. el._x_undoAddedClasses();
  1217. el._x_undoAddedClasses = setClasses(el, value);
  1218. }
  1219. function bindStyles(el, value) {
  1220. if (el._x_undoAddedStyles)
  1221. el._x_undoAddedStyles();
  1222. el._x_undoAddedStyles = setStyles(el, value);
  1223. }
  1224. function bindAttribute(el, name, value) {
  1225. if ([null, void 0, false].includes(value) && attributeShouldntBePreservedIfFalsy(name)) {
  1226. el.removeAttribute(name);
  1227. } else {
  1228. if (isBooleanAttr(name))
  1229. value = name;
  1230. setIfChanged(el, name, value);
  1231. }
  1232. }
  1233. function setIfChanged(el, attrName, value) {
  1234. if (el.getAttribute(attrName) != value) {
  1235. el.setAttribute(attrName, value);
  1236. }
  1237. }
  1238. function updateSelect(el, value) {
  1239. const arrayWrappedValue = [].concat(value).map((value2) => {
  1240. return value2 + "";
  1241. });
  1242. Array.from(el.options).forEach((option) => {
  1243. option.selected = arrayWrappedValue.includes(option.value);
  1244. });
  1245. }
  1246. function camelCase(subject) {
  1247. return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase());
  1248. }
  1249. function checkedAttrLooseCompare(valueA, valueB) {
  1250. return valueA == valueB;
  1251. }
  1252. function isBooleanAttr(attrName) {
  1253. const booleanAttributes = [
  1254. "disabled",
  1255. "checked",
  1256. "required",
  1257. "readonly",
  1258. "hidden",
  1259. "open",
  1260. "selected",
  1261. "autofocus",
  1262. "itemscope",
  1263. "multiple",
  1264. "novalidate",
  1265. "allowfullscreen",
  1266. "allowpaymentrequest",
  1267. "formnovalidate",
  1268. "autoplay",
  1269. "controls",
  1270. "loop",
  1271. "muted",
  1272. "playsinline",
  1273. "default",
  1274. "ismap",
  1275. "reversed",
  1276. "async",
  1277. "defer",
  1278. "nomodule"
  1279. ];
  1280. return booleanAttributes.includes(attrName);
  1281. }
  1282. function attributeShouldntBePreservedIfFalsy(name) {
  1283. return !["aria-pressed", "aria-checked", "aria-expanded", "aria-selected"].includes(name);
  1284. }
  1285. function getBinding(el, name, fallback) {
  1286. if (el._x_bindings && el._x_bindings[name] !== void 0)
  1287. return el._x_bindings[name];
  1288. let attr = el.getAttribute(name);
  1289. if (attr === null)
  1290. return typeof fallback === "function" ? fallback() : fallback;
  1291. if (isBooleanAttr(name)) {
  1292. return !![name, "true"].includes(attr);
  1293. }
  1294. if (attr === "")
  1295. return true;
  1296. return attr;
  1297. }
  1298. // packages/alpinejs/src/utils/debounce.js
  1299. function debounce(func, wait) {
  1300. var timeout;
  1301. return function() {
  1302. var context = this, args = arguments;
  1303. var later = function() {
  1304. timeout = null;
  1305. func.apply(context, args);
  1306. };
  1307. clearTimeout(timeout);
  1308. timeout = setTimeout(later, wait);
  1309. };
  1310. }
  1311. // packages/alpinejs/src/utils/throttle.js
  1312. function throttle(func, limit) {
  1313. let inThrottle;
  1314. return function() {
  1315. let context = this, args = arguments;
  1316. if (!inThrottle) {
  1317. func.apply(context, args);
  1318. inThrottle = true;
  1319. setTimeout(() => inThrottle = false, limit);
  1320. }
  1321. };
  1322. }
  1323. // packages/alpinejs/src/plugin.js
  1324. function plugin(callback) {
  1325. callback(alpine_default);
  1326. }
  1327. // packages/alpinejs/src/store.js
  1328. var stores = {};
  1329. var isReactive = false;
  1330. function store(name, value) {
  1331. if (!isReactive) {
  1332. stores = reactive(stores);
  1333. isReactive = true;
  1334. }
  1335. if (value === void 0) {
  1336. return stores[name];
  1337. }
  1338. stores[name] = value;
  1339. if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") {
  1340. stores[name].init();
  1341. }
  1342. initInterceptors(stores[name]);
  1343. }
  1344. function getStores() {
  1345. return stores;
  1346. }
  1347. // packages/alpinejs/src/binds.js
  1348. var binds = {};
  1349. function bind2(name, object) {
  1350. binds[name] = typeof object !== "function" ? () => object : object;
  1351. }
  1352. function injectBindingProviders(obj) {
  1353. Object.entries(binds).forEach(([name, callback]) => {
  1354. Object.defineProperty(obj, name, {
  1355. get() {
  1356. return (...args) => {
  1357. return callback(...args);
  1358. };
  1359. }
  1360. });
  1361. });
  1362. return obj;
  1363. }
  1364. // packages/alpinejs/src/datas.js
  1365. var datas = {};
  1366. function data(name, callback) {
  1367. datas[name] = callback;
  1368. }
  1369. function injectDataProviders(obj, context) {
  1370. Object.entries(datas).forEach(([name, callback]) => {
  1371. Object.defineProperty(obj, name, {
  1372. get() {
  1373. return (...args) => {
  1374. return callback.bind(context)(...args);
  1375. };
  1376. },
  1377. enumerable: false
  1378. });
  1379. });
  1380. return obj;
  1381. }
  1382. // packages/alpinejs/src/alpine.js
  1383. var Alpine = {
  1384. get reactive() {
  1385. return reactive;
  1386. },
  1387. get release() {
  1388. return release;
  1389. },
  1390. get effect() {
  1391. return effect;
  1392. },
  1393. get raw() {
  1394. return raw;
  1395. },
  1396. version: "3.9.6",
  1397. flushAndStopDeferringMutations,
  1398. disableEffectScheduling,
  1399. setReactivityEngine,
  1400. closestDataStack,
  1401. skipDuringClone,
  1402. addRootSelector,
  1403. addInitSelector,
  1404. addScopeToNode,
  1405. deferMutations,
  1406. mapAttributes,
  1407. evaluateLater,
  1408. setEvaluator,
  1409. mergeProxies,
  1410. findClosest,
  1411. closestRoot,
  1412. interceptor,
  1413. transition,
  1414. setStyles,
  1415. mutateDom,
  1416. directive,
  1417. throttle,
  1418. debounce,
  1419. evaluate,
  1420. initTree,
  1421. nextTick,
  1422. prefixed: prefix,
  1423. prefix: setPrefix,
  1424. plugin,
  1425. magic,
  1426. store,
  1427. start,
  1428. clone,
  1429. bound: getBinding,
  1430. $data: scope,
  1431. data,
  1432. bind: bind2
  1433. };
  1434. var alpine_default = Alpine;
  1435. // node_modules/@vue/shared/dist/shared.esm-bundler.js
  1436. function makeMap(str, expectsLowerCase) {
  1437. const map = Object.create(null);
  1438. const list = str.split(",");
  1439. for (let i = 0; i < list.length; i++) {
  1440. map[list[i]] = true;
  1441. }
  1442. return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
  1443. }
  1444. var PatchFlagNames = {
  1445. [1]: `TEXT`,
  1446. [2]: `CLASS`,
  1447. [4]: `STYLE`,
  1448. [8]: `PROPS`,
  1449. [16]: `FULL_PROPS`,
  1450. [32]: `HYDRATE_EVENTS`,
  1451. [64]: `STABLE_FRAGMENT`,
  1452. [128]: `KEYED_FRAGMENT`,
  1453. [256]: `UNKEYED_FRAGMENT`,
  1454. [512]: `NEED_PATCH`,
  1455. [1024]: `DYNAMIC_SLOTS`,
  1456. [2048]: `DEV_ROOT_FRAGMENT`,
  1457. [-1]: `HOISTED`,
  1458. [-2]: `BAIL`
  1459. };
  1460. var slotFlagsText = {
  1461. [1]: "STABLE",
  1462. [2]: "DYNAMIC",
  1463. [3]: "FORWARDED"
  1464. };
  1465. var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  1466. var isBooleanAttr2 = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
  1467. var EMPTY_OBJ = true ? Object.freeze({}) : 0;
  1468. var EMPTY_ARR = true ? Object.freeze([]) : 0;
  1469. var extend = Object.assign;
  1470. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1471. var hasOwn = (val, key) => hasOwnProperty.call(val, key);
  1472. var isArray = Array.isArray;
  1473. var isMap = (val) => toTypeString(val) === "[object Map]";
  1474. var isString = (val) => typeof val === "string";
  1475. var isSymbol = (val) => typeof val === "symbol";
  1476. var isObject = (val) => val !== null && typeof val === "object";
  1477. var objectToString = Object.prototype.toString;
  1478. var toTypeString = (value) => objectToString.call(value);
  1479. var toRawType = (value) => {
  1480. return toTypeString(value).slice(8, -1);
  1481. };
  1482. var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  1483. var cacheStringFunction = (fn) => {
  1484. const cache = Object.create(null);
  1485. return (str) => {
  1486. const hit = cache[str];
  1487. return hit || (cache[str] = fn(str));
  1488. };
  1489. };
  1490. var camelizeRE = /-(\w)/g;
  1491. var camelize = cacheStringFunction((str) => {
  1492. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  1493. });
  1494. var hyphenateRE = /\B([A-Z])/g;
  1495. var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
  1496. var capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  1497. var toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  1498. var hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
  1499. // node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
  1500. var targetMap = new WeakMap();
  1501. var effectStack = [];
  1502. var activeEffect;
  1503. var ITERATE_KEY = Symbol( true ? "iterate" : 0);
  1504. var MAP_KEY_ITERATE_KEY = Symbol( true ? "Map key iterate" : 0);
  1505. function isEffect(fn) {
  1506. return fn && fn._isEffect === true;
  1507. }
  1508. function effect2(fn, options = EMPTY_OBJ) {
  1509. if (isEffect(fn)) {
  1510. fn = fn.raw;
  1511. }
  1512. const effect3 = createReactiveEffect(fn, options);
  1513. if (!options.lazy) {
  1514. effect3();
  1515. }
  1516. return effect3;
  1517. }
  1518. function stop(effect3) {
  1519. if (effect3.active) {
  1520. cleanup(effect3);
  1521. if (effect3.options.onStop) {
  1522. effect3.options.onStop();
  1523. }
  1524. effect3.active = false;
  1525. }
  1526. }
  1527. var uid = 0;
  1528. function createReactiveEffect(fn, options) {
  1529. const effect3 = function reactiveEffect() {
  1530. if (!effect3.active) {
  1531. return fn();
  1532. }
  1533. if (!effectStack.includes(effect3)) {
  1534. cleanup(effect3);
  1535. try {
  1536. enableTracking();
  1537. effectStack.push(effect3);
  1538. activeEffect = effect3;
  1539. return fn();
  1540. } finally {
  1541. effectStack.pop();
  1542. resetTracking();
  1543. activeEffect = effectStack[effectStack.length - 1];
  1544. }
  1545. }
  1546. };
  1547. effect3.id = uid++;
  1548. effect3.allowRecurse = !!options.allowRecurse;
  1549. effect3._isEffect = true;
  1550. effect3.active = true;
  1551. effect3.raw = fn;
  1552. effect3.deps = [];
  1553. effect3.options = options;
  1554. return effect3;
  1555. }
  1556. function cleanup(effect3) {
  1557. const {deps} = effect3;
  1558. if (deps.length) {
  1559. for (let i = 0; i < deps.length; i++) {
  1560. deps[i].delete(effect3);
  1561. }
  1562. deps.length = 0;
  1563. }
  1564. }
  1565. var shouldTrack = true;
  1566. var trackStack = [];
  1567. function pauseTracking() {
  1568. trackStack.push(shouldTrack);
  1569. shouldTrack = false;
  1570. }
  1571. function enableTracking() {
  1572. trackStack.push(shouldTrack);
  1573. shouldTrack = true;
  1574. }
  1575. function resetTracking() {
  1576. const last = trackStack.pop();
  1577. shouldTrack = last === void 0 ? true : last;
  1578. }
  1579. function track(target, type, key) {
  1580. if (!shouldTrack || activeEffect === void 0) {
  1581. return;
  1582. }
  1583. let depsMap = targetMap.get(target);
  1584. if (!depsMap) {
  1585. targetMap.set(target, depsMap = new Map());
  1586. }
  1587. let dep = depsMap.get(key);
  1588. if (!dep) {
  1589. depsMap.set(key, dep = new Set());
  1590. }
  1591. if (!dep.has(activeEffect)) {
  1592. dep.add(activeEffect);
  1593. activeEffect.deps.push(dep);
  1594. if (activeEffect.options.onTrack) {
  1595. activeEffect.options.onTrack({
  1596. effect: activeEffect,
  1597. target,
  1598. type,
  1599. key
  1600. });
  1601. }
  1602. }
  1603. }
  1604. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  1605. const depsMap = targetMap.get(target);
  1606. if (!depsMap) {
  1607. return;
  1608. }
  1609. const effects = new Set();
  1610. const add2 = (effectsToAdd) => {
  1611. if (effectsToAdd) {
  1612. effectsToAdd.forEach((effect3) => {
  1613. if (effect3 !== activeEffect || effect3.allowRecurse) {
  1614. effects.add(effect3);
  1615. }
  1616. });
  1617. }
  1618. };
  1619. if (type === "clear") {
  1620. depsMap.forEach(add2);
  1621. } else if (key === "length" && isArray(target)) {
  1622. depsMap.forEach((dep, key2) => {
  1623. if (key2 === "length" || key2 >= newValue) {
  1624. add2(dep);
  1625. }
  1626. });
  1627. } else {
  1628. if (key !== void 0) {
  1629. add2(depsMap.get(key));
  1630. }
  1631. switch (type) {
  1632. case "add":
  1633. if (!isArray(target)) {
  1634. add2(depsMap.get(ITERATE_KEY));
  1635. if (isMap(target)) {
  1636. add2(depsMap.get(MAP_KEY_ITERATE_KEY));
  1637. }
  1638. } else if (isIntegerKey(key)) {
  1639. add2(depsMap.get("length"));
  1640. }
  1641. break;
  1642. case "delete":
  1643. if (!isArray(target)) {
  1644. add2(depsMap.get(ITERATE_KEY));
  1645. if (isMap(target)) {
  1646. add2(depsMap.get(MAP_KEY_ITERATE_KEY));
  1647. }
  1648. }
  1649. break;
  1650. case "set":
  1651. if (isMap(target)) {
  1652. add2(depsMap.get(ITERATE_KEY));
  1653. }
  1654. break;
  1655. }
  1656. }
  1657. const run = (effect3) => {
  1658. if (effect3.options.onTrigger) {
  1659. effect3.options.onTrigger({
  1660. effect: effect3,
  1661. target,
  1662. key,
  1663. type,
  1664. newValue,
  1665. oldValue,
  1666. oldTarget
  1667. });
  1668. }
  1669. if (effect3.options.scheduler) {
  1670. effect3.options.scheduler(effect3);
  1671. } else {
  1672. effect3();
  1673. }
  1674. };
  1675. effects.forEach(run);
  1676. }
  1677. var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  1678. var builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol));
  1679. var get2 = /* @__PURE__ */ createGetter();
  1680. var shallowGet = /* @__PURE__ */ createGetter(false, true);
  1681. var readonlyGet = /* @__PURE__ */ createGetter(true);
  1682. var shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
  1683. var arrayInstrumentations = {};
  1684. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  1685. const method = Array.prototype[key];
  1686. arrayInstrumentations[key] = function(...args) {
  1687. const arr = toRaw(this);
  1688. for (let i = 0, l = this.length; i < l; i++) {
  1689. track(arr, "get", i + "");
  1690. }
  1691. const res = method.apply(arr, args);
  1692. if (res === -1 || res === false) {
  1693. return method.apply(arr, args.map(toRaw));
  1694. } else {
  1695. return res;
  1696. }
  1697. };
  1698. });
  1699. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  1700. const method = Array.prototype[key];
  1701. arrayInstrumentations[key] = function(...args) {
  1702. pauseTracking();
  1703. const res = method.apply(this, args);
  1704. resetTracking();
  1705. return res;
  1706. };
  1707. });
  1708. function createGetter(isReadonly = false, shallow = false) {
  1709. return function get3(target, key, receiver) {
  1710. if (key === "__v_isReactive") {
  1711. return !isReadonly;
  1712. } else if (key === "__v_isReadonly") {
  1713. return isReadonly;
  1714. } else if (key === "__v_raw" && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
  1715. return target;
  1716. }
  1717. const targetIsArray = isArray(target);
  1718. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  1719. return Reflect.get(arrayInstrumentations, key, receiver);
  1720. }
  1721. const res = Reflect.get(target, key, receiver);
  1722. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  1723. return res;
  1724. }
  1725. if (!isReadonly) {
  1726. track(target, "get", key);
  1727. }
  1728. if (shallow) {
  1729. return res;
  1730. }
  1731. if (isRef(res)) {
  1732. const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
  1733. return shouldUnwrap ? res.value : res;
  1734. }
  1735. if (isObject(res)) {
  1736. return isReadonly ? readonly(res) : reactive2(res);
  1737. }
  1738. return res;
  1739. };
  1740. }
  1741. var set2 = /* @__PURE__ */ createSetter();
  1742. var shallowSet = /* @__PURE__ */ createSetter(true);
  1743. function createSetter(shallow = false) {
  1744. return function set3(target, key, value, receiver) {
  1745. let oldValue = target[key];
  1746. if (!shallow) {
  1747. value = toRaw(value);
  1748. oldValue = toRaw(oldValue);
  1749. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  1750. oldValue.value = value;
  1751. return true;
  1752. }
  1753. }
  1754. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  1755. const result = Reflect.set(target, key, value, receiver);
  1756. if (target === toRaw(receiver)) {
  1757. if (!hadKey) {
  1758. trigger(target, "add", key, value);
  1759. } else if (hasChanged(value, oldValue)) {
  1760. trigger(target, "set", key, value, oldValue);
  1761. }
  1762. }
  1763. return result;
  1764. };
  1765. }
  1766. function deleteProperty(target, key) {
  1767. const hadKey = hasOwn(target, key);
  1768. const oldValue = target[key];
  1769. const result = Reflect.deleteProperty(target, key);
  1770. if (result && hadKey) {
  1771. trigger(target, "delete", key, void 0, oldValue);
  1772. }
  1773. return result;
  1774. }
  1775. function has(target, key) {
  1776. const result = Reflect.has(target, key);
  1777. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  1778. track(target, "has", key);
  1779. }
  1780. return result;
  1781. }
  1782. function ownKeys(target) {
  1783. track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
  1784. return Reflect.ownKeys(target);
  1785. }
  1786. var mutableHandlers = {
  1787. get: get2,
  1788. set: set2,
  1789. deleteProperty,
  1790. has,
  1791. ownKeys
  1792. };
  1793. var readonlyHandlers = {
  1794. get: readonlyGet,
  1795. set(target, key) {
  1796. if (true) {
  1797. console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  1798. }
  1799. return true;
  1800. },
  1801. deleteProperty(target, key) {
  1802. if (true) {
  1803. console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  1804. }
  1805. return true;
  1806. }
  1807. };
  1808. var shallowReactiveHandlers = extend({}, mutableHandlers, {
  1809. get: shallowGet,
  1810. set: shallowSet
  1811. });
  1812. var shallowReadonlyHandlers = extend({}, readonlyHandlers, {
  1813. get: shallowReadonlyGet
  1814. });
  1815. var toReactive = (value) => isObject(value) ? reactive2(value) : value;
  1816. var toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1817. var toShallow = (value) => value;
  1818. var getProto = (v) => Reflect.getPrototypeOf(v);
  1819. function get$1(target, key, isReadonly = false, isShallow = false) {
  1820. target = target["__v_raw"];
  1821. const rawTarget = toRaw(target);
  1822. const rawKey = toRaw(key);
  1823. if (key !== rawKey) {
  1824. !isReadonly && track(rawTarget, "get", key);
  1825. }
  1826. !isReadonly && track(rawTarget, "get", rawKey);
  1827. const {has: has2} = getProto(rawTarget);
  1828. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1829. if (has2.call(rawTarget, key)) {
  1830. return wrap(target.get(key));
  1831. } else if (has2.call(rawTarget, rawKey)) {
  1832. return wrap(target.get(rawKey));
  1833. } else if (target !== rawTarget) {
  1834. target.get(key);
  1835. }
  1836. }
  1837. function has$1(key, isReadonly = false) {
  1838. const target = this["__v_raw"];
  1839. const rawTarget = toRaw(target);
  1840. const rawKey = toRaw(key);
  1841. if (key !== rawKey) {
  1842. !isReadonly && track(rawTarget, "has", key);
  1843. }
  1844. !isReadonly && track(rawTarget, "has", rawKey);
  1845. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  1846. }
  1847. function size(target, isReadonly = false) {
  1848. target = target["__v_raw"];
  1849. !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
  1850. return Reflect.get(target, "size", target);
  1851. }
  1852. function add(value) {
  1853. value = toRaw(value);
  1854. const target = toRaw(this);
  1855. const proto = getProto(target);
  1856. const hadKey = proto.has.call(target, value);
  1857. if (!hadKey) {
  1858. target.add(value);
  1859. trigger(target, "add", value, value);
  1860. }
  1861. return this;
  1862. }
  1863. function set$1(key, value) {
  1864. value = toRaw(value);
  1865. const target = toRaw(this);
  1866. const {has: has2, get: get3} = getProto(target);
  1867. let hadKey = has2.call(target, key);
  1868. if (!hadKey) {
  1869. key = toRaw(key);
  1870. hadKey = has2.call(target, key);
  1871. } else if (true) {
  1872. checkIdentityKeys(target, has2, key);
  1873. }
  1874. const oldValue = get3.call(target, key);
  1875. target.set(key, value);
  1876. if (!hadKey) {
  1877. trigger(target, "add", key, value);
  1878. } else if (hasChanged(value, oldValue)) {
  1879. trigger(target, "set", key, value, oldValue);
  1880. }
  1881. return this;
  1882. }
  1883. function deleteEntry(key) {
  1884. const target = toRaw(this);
  1885. const {has: has2, get: get3} = getProto(target);
  1886. let hadKey = has2.call(target, key);
  1887. if (!hadKey) {
  1888. key = toRaw(key);
  1889. hadKey = has2.call(target, key);
  1890. } else if (true) {
  1891. checkIdentityKeys(target, has2, key);
  1892. }
  1893. const oldValue = get3 ? get3.call(target, key) : void 0;
  1894. const result = target.delete(key);
  1895. if (hadKey) {
  1896. trigger(target, "delete", key, void 0, oldValue);
  1897. }
  1898. return result;
  1899. }
  1900. function clear() {
  1901. const target = toRaw(this);
  1902. const hadItems = target.size !== 0;
  1903. const oldTarget = true ? isMap(target) ? new Map(target) : new Set(target) : 0;
  1904. const result = target.clear();
  1905. if (hadItems) {
  1906. trigger(target, "clear", void 0, void 0, oldTarget);
  1907. }
  1908. return result;
  1909. }
  1910. function createForEach(isReadonly, isShallow) {
  1911. return function forEach(callback, thisArg) {
  1912. const observed = this;
  1913. const target = observed["__v_raw"];
  1914. const rawTarget = toRaw(target);
  1915. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1916. !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
  1917. return target.forEach((value, key) => {
  1918. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1919. });
  1920. };
  1921. }
  1922. function createIterableMethod(method, isReadonly, isShallow) {
  1923. return function(...args) {
  1924. const target = this["__v_raw"];
  1925. const rawTarget = toRaw(target);
  1926. const targetIsMap = isMap(rawTarget);
  1927. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  1928. const isKeyOnly = method === "keys" && targetIsMap;
  1929. const innerIterator = target[method](...args);
  1930. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1931. !isReadonly && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1932. return {
  1933. next() {
  1934. const {value, done} = innerIterator.next();
  1935. return done ? {value, done} : {
  1936. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1937. done
  1938. };
  1939. },
  1940. [Symbol.iterator]() {
  1941. return this;
  1942. }
  1943. };
  1944. };
  1945. }
  1946. function createReadonlyMethod(type) {
  1947. return function(...args) {
  1948. if (true) {
  1949. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1950. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1951. }
  1952. return type === "delete" ? false : this;
  1953. };
  1954. }
  1955. var mutableInstrumentations = {
  1956. get(key) {
  1957. return get$1(this, key);
  1958. },
  1959. get size() {
  1960. return size(this);
  1961. },
  1962. has: has$1,
  1963. add,
  1964. set: set$1,
  1965. delete: deleteEntry,
  1966. clear,
  1967. forEach: createForEach(false, false)
  1968. };
  1969. var shallowInstrumentations = {
  1970. get(key) {
  1971. return get$1(this, key, false, true);
  1972. },
  1973. get size() {
  1974. return size(this);
  1975. },
  1976. has: has$1,
  1977. add,
  1978. set: set$1,
  1979. delete: deleteEntry,
  1980. clear,
  1981. forEach: createForEach(false, true)
  1982. };
  1983. var readonlyInstrumentations = {
  1984. get(key) {
  1985. return get$1(this, key, true);
  1986. },
  1987. get size() {
  1988. return size(this, true);
  1989. },
  1990. has(key) {
  1991. return has$1.call(this, key, true);
  1992. },
  1993. add: createReadonlyMethod("add"),
  1994. set: createReadonlyMethod("set"),
  1995. delete: createReadonlyMethod("delete"),
  1996. clear: createReadonlyMethod("clear"),
  1997. forEach: createForEach(true, false)
  1998. };
  1999. var shallowReadonlyInstrumentations = {
  2000. get(key) {
  2001. return get$1(this, key, true, true);
  2002. },
  2003. get size() {
  2004. return size(this, true);
  2005. },
  2006. has(key) {
  2007. return has$1.call(this, key, true);
  2008. },
  2009. add: createReadonlyMethod("add"),
  2010. set: createReadonlyMethod("set"),
  2011. delete: createReadonlyMethod("delete"),
  2012. clear: createReadonlyMethod("clear"),
  2013. forEach: createForEach(true, true)
  2014. };
  2015. var iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
  2016. iteratorMethods.forEach((method) => {
  2017. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  2018. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  2019. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  2020. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  2021. });
  2022. function createInstrumentationGetter(isReadonly, shallow) {
  2023. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
  2024. return (target, key, receiver) => {
  2025. if (key === "__v_isReactive") {
  2026. return !isReadonly;
  2027. } else if (key === "__v_isReadonly") {
  2028. return isReadonly;
  2029. } else if (key === "__v_raw") {
  2030. return target;
  2031. }
  2032. return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
  2033. };
  2034. }
  2035. var mutableCollectionHandlers = {
  2036. get: createInstrumentationGetter(false, false)
  2037. };
  2038. var shallowCollectionHandlers = {
  2039. get: createInstrumentationGetter(false, true)
  2040. };
  2041. var readonlyCollectionHandlers = {
  2042. get: createInstrumentationGetter(true, false)
  2043. };
  2044. var shallowReadonlyCollectionHandlers = {
  2045. get: createInstrumentationGetter(true, true)
  2046. };
  2047. function checkIdentityKeys(target, has2, key) {
  2048. const rawKey = toRaw(key);
  2049. if (rawKey !== key && has2.call(target, rawKey)) {
  2050. const type = toRawType(target);
  2051. console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
  2052. }
  2053. }
  2054. var reactiveMap = new WeakMap();
  2055. var shallowReactiveMap = new WeakMap();
  2056. var readonlyMap = new WeakMap();
  2057. var shallowReadonlyMap = new WeakMap();
  2058. function targetTypeMap(rawType) {
  2059. switch (rawType) {
  2060. case "Object":
  2061. case "Array":
  2062. return 1;
  2063. case "Map":
  2064. case "Set":
  2065. case "WeakMap":
  2066. case "WeakSet":
  2067. return 2;
  2068. default:
  2069. return 0;
  2070. }
  2071. }
  2072. function getTargetType(value) {
  2073. return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
  2074. }
  2075. function reactive2(target) {
  2076. if (target && target["__v_isReadonly"]) {
  2077. return target;
  2078. }
  2079. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  2080. }
  2081. function readonly(target) {
  2082. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  2083. }
  2084. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  2085. if (!isObject(target)) {
  2086. if (true) {
  2087. console.warn(`value cannot be made reactive: ${String(target)}`);
  2088. }
  2089. return target;
  2090. }
  2091. if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) {
  2092. return target;
  2093. }
  2094. const existingProxy = proxyMap.get(target);
  2095. if (existingProxy) {
  2096. return existingProxy;
  2097. }
  2098. const targetType = getTargetType(target);
  2099. if (targetType === 0) {
  2100. return target;
  2101. }
  2102. const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
  2103. proxyMap.set(target, proxy);
  2104. return proxy;
  2105. }
  2106. function toRaw(observed) {
  2107. return observed && toRaw(observed["__v_raw"]) || observed;
  2108. }
  2109. function isRef(r) {
  2110. return Boolean(r && r.__v_isRef === true);
  2111. }
  2112. // packages/alpinejs/src/magics/$nextTick.js
  2113. magic("nextTick", () => nextTick);
  2114. // packages/alpinejs/src/magics/$dispatch.js
  2115. magic("dispatch", (el) => dispatch.bind(dispatch, el));
  2116. // packages/alpinejs/src/magics/$watch.js
  2117. magic("watch", (el, {evaluateLater: evaluateLater2, effect: effect3}) => (key, callback) => {
  2118. let evaluate2 = evaluateLater2(key);
  2119. let firstTime = true;
  2120. let oldValue;
  2121. let effectReference = effect3(() => evaluate2((value) => {
  2122. JSON.stringify(value);
  2123. if (!firstTime) {
  2124. queueMicrotask(() => {
  2125. callback(value, oldValue);
  2126. oldValue = value;
  2127. });
  2128. } else {
  2129. oldValue = value;
  2130. }
  2131. firstTime = false;
  2132. }));
  2133. el._x_effects.delete(effectReference);
  2134. });
  2135. // packages/alpinejs/src/magics/$store.js
  2136. magic("store", getStores);
  2137. // packages/alpinejs/src/magics/$data.js
  2138. magic("data", (el) => scope(el));
  2139. // packages/alpinejs/src/magics/$root.js
  2140. magic("root", (el) => closestRoot(el));
  2141. // packages/alpinejs/src/magics/$refs.js
  2142. magic("refs", (el) => {
  2143. if (el._x_refs_proxy)
  2144. return el._x_refs_proxy;
  2145. el._x_refs_proxy = mergeProxies(getArrayOfRefObject(el));
  2146. return el._x_refs_proxy;
  2147. });
  2148. function getArrayOfRefObject(el) {
  2149. let refObjects = [];
  2150. let currentEl = el;
  2151. while (currentEl) {
  2152. if (currentEl._x_refs)
  2153. refObjects.push(currentEl._x_refs);
  2154. currentEl = currentEl.parentNode;
  2155. }
  2156. return refObjects;
  2157. }
  2158. // packages/alpinejs/src/ids.js
  2159. var globalIdMemo = {};
  2160. function findAndIncrementId(name) {
  2161. if (!globalIdMemo[name])
  2162. globalIdMemo[name] = 0;
  2163. return ++globalIdMemo[name];
  2164. }
  2165. function closestIdRoot(el, name) {
  2166. return findClosest(el, (element) => {
  2167. if (element._x_ids && element._x_ids[name])
  2168. return true;
  2169. });
  2170. }
  2171. function setIdRoot(el, name) {
  2172. if (!el._x_ids)
  2173. el._x_ids = {};
  2174. if (!el._x_ids[name])
  2175. el._x_ids[name] = findAndIncrementId(name);
  2176. }
  2177. // packages/alpinejs/src/magics/$id.js
  2178. magic("id", (el) => (name, key = null) => {
  2179. let root = closestIdRoot(el, name);
  2180. let id = root ? root._x_ids[name] : findAndIncrementId(name);
  2181. return key ? `${name}-${id}-${key}` : `${name}-${id}`;
  2182. });
  2183. // packages/alpinejs/src/magics/$el.js
  2184. magic("el", (el) => el);
  2185. // packages/alpinejs/src/magics/index.js
  2186. warnMissingPluginMagic("Focus", "focus", "focus");
  2187. warnMissingPluginMagic("Persist", "persist", "persist");
  2188. function warnMissingPluginMagic(name, magicName, slug) {
  2189. magic(magicName, (el) => warn(`You can't use [$${directiveName}] without first installing the "${name}" plugin here: https://alpine.dev/plugins/${slug}`, el));
  2190. }
  2191. // packages/alpinejs/src/directives/x-modelable.js
  2192. directive("modelable", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => {
  2193. let func = evaluateLater2(expression);
  2194. let innerGet = () => {
  2195. let result;
  2196. func((i) => result = i);
  2197. return result;
  2198. };
  2199. let evaluateInnerSet = evaluateLater2(`${expression} = __placeholder`);
  2200. let innerSet = (val) => evaluateInnerSet(() => {
  2201. }, {scope: {__placeholder: val}});
  2202. let initialValue = innerGet();
  2203. innerSet(initialValue);
  2204. queueMicrotask(() => {
  2205. if (!el._x_model)
  2206. return;
  2207. el._x_removeModelListeners["default"]();
  2208. let outerGet = el._x_model.get;
  2209. let outerSet = el._x_model.set;
  2210. effect3(() => innerSet(outerGet()));
  2211. effect3(() => outerSet(innerGet()));
  2212. });
  2213. });
  2214. // packages/alpinejs/src/directives/x-teleport.js
  2215. directive("teleport", (el, {expression}, {cleanup: cleanup2}) => {
  2216. if (el.tagName.toLowerCase() !== "template")
  2217. warn("x-teleport can only be used on a <template> tag", el);
  2218. let target = document.querySelector(expression);
  2219. if (!target)
  2220. warn(`Cannot find x-teleport element for selector: "${expression}"`);
  2221. let clone2 = el.content.cloneNode(true).firstElementChild;
  2222. el._x_teleport = clone2;
  2223. clone2._x_teleportBack = el;
  2224. if (el._x_forwardEvents) {
  2225. el._x_forwardEvents.forEach((eventName) => {
  2226. clone2.addEventListener(eventName, (e) => {
  2227. e.stopPropagation();
  2228. el.dispatchEvent(new e.constructor(e.type, e));
  2229. });
  2230. });
  2231. }
  2232. addScopeToNode(clone2, {}, el);
  2233. mutateDom(() => {
  2234. target.appendChild(clone2);
  2235. initTree(clone2);
  2236. clone2._x_ignore = true;
  2237. });
  2238. cleanup2(() => clone2.remove());
  2239. });
  2240. // packages/alpinejs/src/directives/x-ignore.js
  2241. var handler = () => {
  2242. };
  2243. handler.inline = (el, {modifiers}, {cleanup: cleanup2}) => {
  2244. modifiers.includes("self") ? el._x_ignoreSelf = true : el._x_ignore = true;
  2245. cleanup2(() => {
  2246. modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore;
  2247. });
  2248. };
  2249. directive("ignore", handler);
  2250. // packages/alpinejs/src/directives/x-effect.js
  2251. directive("effect", (el, {expression}, {effect: effect3}) => effect3(evaluateLater(el, expression)));
  2252. // packages/alpinejs/src/utils/on.js
  2253. function on(el, event, modifiers, callback) {
  2254. let listenerTarget = el;
  2255. let handler3 = (e) => callback(e);
  2256. let options = {};
  2257. let wrapHandler = (callback2, wrapper) => (e) => wrapper(callback2, e);
  2258. if (modifiers.includes("dot"))
  2259. event = dotSyntax(event);
  2260. if (modifiers.includes("camel"))
  2261. event = camelCase2(event);
  2262. if (modifiers.includes("passive"))
  2263. options.passive = true;
  2264. if (modifiers.includes("capture"))
  2265. options.capture = true;
  2266. if (modifiers.includes("window"))
  2267. listenerTarget = window;
  2268. if (modifiers.includes("document"))
  2269. listenerTarget = document;
  2270. if (modifiers.includes("prevent"))
  2271. handler3 = wrapHandler(handler3, (next, e) => {
  2272. e.preventDefault();
  2273. next(e);
  2274. });
  2275. if (modifiers.includes("stop"))
  2276. handler3 = wrapHandler(handler3, (next, e) => {
  2277. e.stopPropagation();
  2278. next(e);
  2279. });
  2280. if (modifiers.includes("self"))
  2281. handler3 = wrapHandler(handler3, (next, e) => {
  2282. e.target === el && next(e);
  2283. });
  2284. if (modifiers.includes("away") || modifiers.includes("outside")) {
  2285. listenerTarget = document;
  2286. handler3 = wrapHandler(handler3, (next, e) => {
  2287. if (el.contains(e.target))
  2288. return;
  2289. if (e.target.isConnected === false)
  2290. return;
  2291. if (el.offsetWidth < 1 && el.offsetHeight < 1)
  2292. return;
  2293. if (el._x_isShown === false)
  2294. return;
  2295. next(e);
  2296. });
  2297. }
  2298. if (modifiers.includes("once")) {
  2299. handler3 = wrapHandler(handler3, (next, e) => {
  2300. next(e);
  2301. listenerTarget.removeEventListener(event, handler3, options);
  2302. });
  2303. }
  2304. handler3 = wrapHandler(handler3, (next, e) => {
  2305. if (isKeyEvent(event)) {
  2306. if (isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers)) {
  2307. return;
  2308. }
  2309. }
  2310. next(e);
  2311. });
  2312. if (modifiers.includes("debounce")) {
  2313. let nextModifier = modifiers[modifiers.indexOf("debounce") + 1] || "invalid-wait";
  2314. let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250;
  2315. handler3 = debounce(handler3, wait);
  2316. }
  2317. if (modifiers.includes("throttle")) {
  2318. let nextModifier = modifiers[modifiers.indexOf("throttle") + 1] || "invalid-wait";
  2319. let wait = isNumeric(nextModifier.split("ms")[0]) ? Number(nextModifier.split("ms")[0]) : 250;
  2320. handler3 = throttle(handler3, wait);
  2321. }
  2322. listenerTarget.addEventListener(event, handler3, options);
  2323. return () => {
  2324. listenerTarget.removeEventListener(event, handler3, options);
  2325. };
  2326. }
  2327. function dotSyntax(subject) {
  2328. return subject.replace(/-/g, ".");
  2329. }
  2330. function camelCase2(subject) {
  2331. return subject.toLowerCase().replace(/-(\w)/g, (match, char) => char.toUpperCase());
  2332. }
  2333. function isNumeric(subject) {
  2334. return !Array.isArray(subject) && !isNaN(subject);
  2335. }
  2336. function kebabCase2(subject) {
  2337. return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase();
  2338. }
  2339. function isKeyEvent(event) {
  2340. return ["keydown", "keyup"].includes(event);
  2341. }
  2342. function isListeningForASpecificKeyThatHasntBeenPressed(e, modifiers) {
  2343. let keyModifiers = modifiers.filter((i) => {
  2344. return !["window", "document", "prevent", "stop", "once"].includes(i);
  2345. });
  2346. if (keyModifiers.includes("debounce")) {
  2347. let debounceIndex = keyModifiers.indexOf("debounce");
  2348. keyModifiers.splice(debounceIndex, isNumeric((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1);
  2349. }
  2350. if (keyModifiers.length === 0)
  2351. return false;
  2352. if (keyModifiers.length === 1 && keyToModifiers(e.key).includes(keyModifiers[0]))
  2353. return false;
  2354. const systemKeyModifiers = ["ctrl", "shift", "alt", "meta", "cmd", "super"];
  2355. const selectedSystemKeyModifiers = systemKeyModifiers.filter((modifier) => keyModifiers.includes(modifier));
  2356. keyModifiers = keyModifiers.filter((i) => !selectedSystemKeyModifiers.includes(i));
  2357. if (selectedSystemKeyModifiers.length > 0) {
  2358. const activelyPressedKeyModifiers = selectedSystemKeyModifiers.filter((modifier) => {
  2359. if (modifier === "cmd" || modifier === "super")
  2360. modifier = "meta";
  2361. return e[`${modifier}Key`];
  2362. });
  2363. if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) {
  2364. if (keyToModifiers(e.key).includes(keyModifiers[0]))
  2365. return false;
  2366. }
  2367. }
  2368. return true;
  2369. }
  2370. function keyToModifiers(key) {
  2371. if (!key)
  2372. return [];
  2373. key = kebabCase2(key);
  2374. let modifierToKeyMap = {
  2375. ctrl: "control",
  2376. slash: "/",
  2377. space: "-",
  2378. spacebar: "-",
  2379. cmd: "meta",
  2380. esc: "escape",
  2381. up: "arrow-up",
  2382. down: "arrow-down",
  2383. left: "arrow-left",
  2384. right: "arrow-right",
  2385. period: ".",
  2386. equal: "="
  2387. };
  2388. modifierToKeyMap[key] = key;
  2389. return Object.keys(modifierToKeyMap).map((modifier) => {
  2390. if (modifierToKeyMap[modifier] === key)
  2391. return modifier;
  2392. }).filter((modifier) => modifier);
  2393. }
  2394. // packages/alpinejs/src/directives/x-model.js
  2395. directive("model", (el, {modifiers, expression}, {effect: effect3, cleanup: cleanup2}) => {
  2396. let evaluate2 = evaluateLater(el, expression);
  2397. let assignmentExpression = `${expression} = rightSideOfExpression($event, ${expression})`;
  2398. let evaluateAssignment = evaluateLater(el, assignmentExpression);
  2399. var event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input";
  2400. let assigmentFunction = generateAssignmentFunction(el, modifiers, expression);
  2401. let removeListener = on(el, event, modifiers, (e) => {
  2402. evaluateAssignment(() => {
  2403. }, {scope: {
  2404. $event: e,
  2405. rightSideOfExpression: assigmentFunction
  2406. }});
  2407. });
  2408. if (!el._x_removeModelListeners)
  2409. el._x_removeModelListeners = {};
  2410. el._x_removeModelListeners["default"] = removeListener;
  2411. cleanup2(() => el._x_removeModelListeners["default"]());
  2412. let evaluateSetModel = evaluateLater(el, `${expression} = __placeholder`);
  2413. el._x_model = {
  2414. get() {
  2415. let result;
  2416. evaluate2((value) => result = value);
  2417. return result;
  2418. },
  2419. set(value) {
  2420. evaluateSetModel(() => {
  2421. }, {scope: {__placeholder: value}});
  2422. }
  2423. };
  2424. el._x_forceModelUpdate = () => {
  2425. evaluate2((value) => {
  2426. if (value === void 0 && expression.match(/\./))
  2427. value = "";
  2428. window.fromModel = true;
  2429. mutateDom(() => bind(el, "value", value));
  2430. delete window.fromModel;
  2431. });
  2432. };
  2433. effect3(() => {
  2434. if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el))
  2435. return;
  2436. el._x_forceModelUpdate();
  2437. });
  2438. });
  2439. function generateAssignmentFunction(el, modifiers, expression) {
  2440. if (el.type === "radio") {
  2441. mutateDom(() => {
  2442. if (!el.hasAttribute("name"))
  2443. el.setAttribute("name", expression);
  2444. });
  2445. }
  2446. return (event, currentValue) => {
  2447. return mutateDom(() => {
  2448. if (event instanceof CustomEvent && event.detail !== void 0) {
  2449. return event.detail || event.target.value;
  2450. } else if (el.type === "checkbox") {
  2451. if (Array.isArray(currentValue)) {
  2452. let newValue = modifiers.includes("number") ? safeParseNumber(event.target.value) : event.target.value;
  2453. return event.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue));
  2454. } else {
  2455. return event.target.checked;
  2456. }
  2457. } else if (el.tagName.toLowerCase() === "select" && el.multiple) {
  2458. return modifiers.includes("number") ? Array.from(event.target.selectedOptions).map((option) => {
  2459. let rawValue = option.value || option.text;
  2460. return safeParseNumber(rawValue);
  2461. }) : Array.from(event.target.selectedOptions).map((option) => {
  2462. return option.value || option.text;
  2463. });
  2464. } else {
  2465. let rawValue = event.target.value;
  2466. return modifiers.includes("number") ? safeParseNumber(rawValue) : modifiers.includes("trim") ? rawValue.trim() : rawValue;
  2467. }
  2468. });
  2469. };
  2470. }
  2471. function safeParseNumber(rawValue) {
  2472. let number = rawValue ? parseFloat(rawValue) : null;
  2473. return isNumeric2(number) ? number : rawValue;
  2474. }
  2475. function checkedAttrLooseCompare2(valueA, valueB) {
  2476. return valueA == valueB;
  2477. }
  2478. function isNumeric2(subject) {
  2479. return !Array.isArray(subject) && !isNaN(subject);
  2480. }
  2481. // packages/alpinejs/src/directives/x-cloak.js
  2482. directive("cloak", (el) => queueMicrotask(() => mutateDom(() => el.removeAttribute(prefix("cloak")))));
  2483. // packages/alpinejs/src/directives/x-init.js
  2484. addInitSelector(() => `[${prefix("init")}]`);
  2485. directive("init", skipDuringClone((el, {expression}, {evaluate: evaluate2}) => {
  2486. if (typeof expression === "string") {
  2487. return !!expression.trim() && evaluate2(expression, {}, false);
  2488. }
  2489. return evaluate2(expression, {}, false);
  2490. }));
  2491. // packages/alpinejs/src/directives/x-text.js
  2492. directive("text", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => {
  2493. let evaluate2 = evaluateLater2(expression);
  2494. effect3(() => {
  2495. evaluate2((value) => {
  2496. mutateDom(() => {
  2497. el.textContent = value;
  2498. });
  2499. });
  2500. });
  2501. });
  2502. // packages/alpinejs/src/directives/x-html.js
  2503. directive("html", (el, {expression}, {effect: effect3, evaluateLater: evaluateLater2}) => {
  2504. let evaluate2 = evaluateLater2(expression);
  2505. effect3(() => {
  2506. evaluate2((value) => {
  2507. mutateDom(() => {
  2508. el.innerHTML = value;
  2509. el._x_ignoreSelf = true;
  2510. initTree(el);
  2511. delete el._x_ignoreSelf;
  2512. });
  2513. });
  2514. });
  2515. });
  2516. // packages/alpinejs/src/directives/x-bind.js
  2517. mapAttributes(startingWith(":", into(prefix("bind:"))));
  2518. directive("bind", (el, {value, modifiers, expression, original}, {effect: effect3}) => {
  2519. if (!value) {
  2520. return applyBindingsObject(el, expression, original, effect3);
  2521. }
  2522. if (value === "key")
  2523. return storeKeyForXFor(el, expression);
  2524. let evaluate2 = evaluateLater(el, expression);
  2525. effect3(() => evaluate2((result) => {
  2526. if (result === void 0 && expression.match(/\./))
  2527. result = "";
  2528. mutateDom(() => bind(el, value, result, modifiers));
  2529. }));
  2530. });
  2531. function applyBindingsObject(el, expression, original, effect3) {
  2532. let bindingProviders = {};
  2533. injectBindingProviders(bindingProviders);
  2534. let getBindings = evaluateLater(el, expression);
  2535. let cleanupRunners = [];
  2536. while (cleanupRunners.length)
  2537. cleanupRunners.pop()();
  2538. getBindings((bindings) => {
  2539. let attributes = Object.entries(bindings).map(([name, value]) => ({name, value}));
  2540. let staticAttributes = attributesOnly(attributes);
  2541. attributes = attributes.map((attribute) => {
  2542. if (staticAttributes.find((attr) => attr.name === attribute.name)) {
  2543. return {
  2544. name: `x-bind:${attribute.name}`,
  2545. value: `"${attribute.value}"`
  2546. };
  2547. }
  2548. return attribute;
  2549. });
  2550. directives(el, attributes, original).map((handle) => {
  2551. cleanupRunners.push(handle.runCleanups);
  2552. handle();
  2553. });
  2554. }, {scope: bindingProviders});
  2555. }
  2556. function storeKeyForXFor(el, expression) {
  2557. el._x_keyExpression = expression;
  2558. }
  2559. // packages/alpinejs/src/directives/x-data.js
  2560. addRootSelector(() => `[${prefix("data")}]`);
  2561. directive("data", skipDuringClone((el, {expression}, {cleanup: cleanup2}) => {
  2562. expression = expression === "" ? "{}" : expression;
  2563. let magicContext = {};
  2564. injectMagics(magicContext, el);
  2565. let dataProviderContext = {};
  2566. injectDataProviders(dataProviderContext, magicContext);
  2567. let data2 = evaluate(el, expression, {scope: dataProviderContext});
  2568. if (data2 === void 0)
  2569. data2 = {};
  2570. injectMagics(data2, el);
  2571. let reactiveData = reactive(data2);
  2572. initInterceptors(reactiveData);
  2573. let undo = addScopeToNode(el, reactiveData);
  2574. reactiveData["init"] && evaluate(el, reactiveData["init"]);
  2575. cleanup2(() => {
  2576. reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]);
  2577. undo();
  2578. });
  2579. }));
  2580. // packages/alpinejs/src/directives/x-show.js
  2581. directive("show", (el, {modifiers, expression}, {effect: effect3}) => {
  2582. let evaluate2 = evaluateLater(el, expression);
  2583. if (!el._x_doHide)
  2584. el._x_doHide = () => {
  2585. mutateDom(() => el.style.display = "none");
  2586. };
  2587. if (!el._x_doShow)
  2588. el._x_doShow = () => {
  2589. mutateDom(() => {
  2590. if (el.style.length === 1 && el.style.display === "none") {
  2591. el.removeAttribute("style");
  2592. } else {
  2593. el.style.removeProperty("display");
  2594. }
  2595. });
  2596. };
  2597. let hide = () => {
  2598. el._x_doHide();
  2599. el._x_isShown = false;
  2600. };
  2601. let show = () => {
  2602. el._x_doShow();
  2603. el._x_isShown = true;
  2604. };
  2605. let clickAwayCompatibleShow = () => setTimeout(show);
  2606. let toggle = once((value) => value ? show() : hide(), (value) => {
  2607. if (typeof el._x_toggleAndCascadeWithTransitions === "function") {
  2608. el._x_toggleAndCascadeWithTransitions(el, value, show, hide);
  2609. } else {
  2610. value ? clickAwayCompatibleShow() : hide();
  2611. }
  2612. });
  2613. let oldValue;
  2614. let firstTime = true;
  2615. effect3(() => evaluate2((value) => {
  2616. if (!firstTime && value === oldValue)
  2617. return;
  2618. if (modifiers.includes("immediate"))
  2619. value ? clickAwayCompatibleShow() : hide();
  2620. toggle(value);
  2621. oldValue = value;
  2622. firstTime = false;
  2623. }));
  2624. });
  2625. // packages/alpinejs/src/directives/x-for.js
  2626. directive("for", (el, {expression}, {effect: effect3, cleanup: cleanup2}) => {
  2627. let iteratorNames = parseForExpression(expression);
  2628. let evaluateItems = evaluateLater(el, iteratorNames.items);
  2629. let evaluateKey = evaluateLater(el, el._x_keyExpression || "index");
  2630. el._x_prevKeys = [];
  2631. el._x_lookup = {};
  2632. effect3(() => loop(el, iteratorNames, evaluateItems, evaluateKey));
  2633. cleanup2(() => {
  2634. Object.values(el._x_lookup).forEach((el2) => el2.remove());
  2635. delete el._x_prevKeys;
  2636. delete el._x_lookup;
  2637. });
  2638. });
  2639. function loop(el, iteratorNames, evaluateItems, evaluateKey) {
  2640. let isObject2 = (i) => typeof i === "object" && !Array.isArray(i);
  2641. let templateEl = el;
  2642. evaluateItems((items) => {
  2643. if (isNumeric3(items) && items >= 0) {
  2644. items = Array.from(Array(items).keys(), (i) => i + 1);
  2645. }
  2646. if (items === void 0)
  2647. items = [];
  2648. let lookup = el._x_lookup;
  2649. let prevKeys = el._x_prevKeys;
  2650. let scopes = [];
  2651. let keys = [];
  2652. if (isObject2(items)) {
  2653. items = Object.entries(items).map(([key, value]) => {
  2654. let scope2 = getIterationScopeVariables(iteratorNames, value, key, items);
  2655. evaluateKey((value2) => keys.push(value2), {scope: {index: key, ...scope2}});
  2656. scopes.push(scope2);
  2657. });
  2658. } else {
  2659. for (let i = 0; i < items.length; i++) {
  2660. let scope2 = getIterationScopeVariables(iteratorNames, items[i], i, items);
  2661. evaluateKey((value) => keys.push(value), {scope: {index: i, ...scope2}});
  2662. scopes.push(scope2);
  2663. }
  2664. }
  2665. let adds = [];
  2666. let moves = [];
  2667. let removes = [];
  2668. let sames = [];
  2669. for (let i = 0; i < prevKeys.length; i++) {
  2670. let key = prevKeys[i];
  2671. if (keys.indexOf(key) === -1)
  2672. removes.push(key);
  2673. }
  2674. prevKeys = prevKeys.filter((key) => !removes.includes(key));
  2675. let lastKey = "template";
  2676. for (let i = 0; i < keys.length; i++) {
  2677. let key = keys[i];
  2678. let prevIndex = prevKeys.indexOf(key);
  2679. if (prevIndex === -1) {
  2680. prevKeys.splice(i, 0, key);
  2681. adds.push([lastKey, i]);
  2682. } else if (prevIndex !== i) {
  2683. let keyInSpot = prevKeys.splice(i, 1)[0];
  2684. let keyForSpot = prevKeys.splice(prevIndex - 1, 1)[0];
  2685. prevKeys.splice(i, 0, keyForSpot);
  2686. prevKeys.splice(prevIndex, 0, keyInSpot);
  2687. moves.push([keyInSpot, keyForSpot]);
  2688. } else {
  2689. sames.push(key);
  2690. }
  2691. lastKey = key;
  2692. }
  2693. for (let i = 0; i < removes.length; i++) {
  2694. let key = removes[i];
  2695. if (!!lookup[key]._x_effects) {
  2696. lookup[key]._x_effects.forEach(dequeueJob);
  2697. }
  2698. lookup[key].remove();
  2699. lookup[key] = null;
  2700. delete lookup[key];
  2701. }
  2702. for (let i = 0; i < moves.length; i++) {
  2703. let [keyInSpot, keyForSpot] = moves[i];
  2704. let elInSpot = lookup[keyInSpot];
  2705. let elForSpot = lookup[keyForSpot];
  2706. let marker = document.createElement("div");
  2707. mutateDom(() => {
  2708. elForSpot.after(marker);
  2709. elInSpot.after(elForSpot);
  2710. elForSpot._x_currentIfEl && elForSpot.after(elForSpot._x_currentIfEl);
  2711. marker.before(elInSpot);
  2712. elInSpot._x_currentIfEl && elInSpot.after(elInSpot._x_currentIfEl);
  2713. marker.remove();
  2714. });
  2715. refreshScope(elForSpot, scopes[keys.indexOf(keyForSpot)]);
  2716. }
  2717. for (let i = 0; i < adds.length; i++) {
  2718. let [lastKey2, index] = adds[i];
  2719. let lastEl = lastKey2 === "template" ? templateEl : lookup[lastKey2];
  2720. if (lastEl._x_currentIfEl)
  2721. lastEl = lastEl._x_currentIfEl;
  2722. let scope2 = scopes[index];
  2723. let key = keys[index];
  2724. let clone2 = document.importNode(templateEl.content, true).firstElementChild;
  2725. addScopeToNode(clone2, reactive(scope2), templateEl);
  2726. mutateDom(() => {
  2727. lastEl.after(clone2);
  2728. initTree(clone2);
  2729. });
  2730. if (typeof key === "object") {
  2731. warn("x-for key cannot be an object, it must be a string or an integer", templateEl);
  2732. }
  2733. lookup[key] = clone2;
  2734. }
  2735. for (let i = 0; i < sames.length; i++) {
  2736. refreshScope(lookup[sames[i]], scopes[keys.indexOf(sames[i])]);
  2737. }
  2738. templateEl._x_prevKeys = keys;
  2739. });
  2740. }
  2741. function parseForExpression(expression) {
  2742. let forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  2743. let stripParensRE = /^\s*\(|\)\s*$/g;
  2744. let forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  2745. let inMatch = expression.match(forAliasRE);
  2746. if (!inMatch)
  2747. return;
  2748. let res = {};
  2749. res.items = inMatch[2].trim();
  2750. let item = inMatch[1].replace(stripParensRE, "").trim();
  2751. let iteratorMatch = item.match(forIteratorRE);
  2752. if (iteratorMatch) {
  2753. res.item = item.replace(forIteratorRE, "").trim();
  2754. res.index = iteratorMatch[1].trim();
  2755. if (iteratorMatch[2]) {
  2756. res.collection = iteratorMatch[2].trim();
  2757. }
  2758. } else {
  2759. res.item = item;
  2760. }
  2761. return res;
  2762. }
  2763. function getIterationScopeVariables(iteratorNames, item, index, items) {
  2764. let scopeVariables = {};
  2765. if (/^\[.*\]$/.test(iteratorNames.item) && Array.isArray(item)) {
  2766. let names = iteratorNames.item.replace("[", "").replace("]", "").split(",").map((i) => i.trim());
  2767. names.forEach((name, i) => {
  2768. scopeVariables[name] = item[i];
  2769. });
  2770. } else if (/^\{.*\}$/.test(iteratorNames.item) && !Array.isArray(item) && typeof item === "object") {
  2771. let names = iteratorNames.item.replace("{", "").replace("}", "").split(",").map((i) => i.trim());
  2772. names.forEach((name) => {
  2773. scopeVariables[name] = item[name];
  2774. });
  2775. } else {
  2776. scopeVariables[iteratorNames.item] = item;
  2777. }
  2778. if (iteratorNames.index)
  2779. scopeVariables[iteratorNames.index] = index;
  2780. if (iteratorNames.collection)
  2781. scopeVariables[iteratorNames.collection] = items;
  2782. return scopeVariables;
  2783. }
  2784. function isNumeric3(subject) {
  2785. return !Array.isArray(subject) && !isNaN(subject);
  2786. }
  2787. // packages/alpinejs/src/directives/x-ref.js
  2788. function handler2() {
  2789. }
  2790. handler2.inline = (el, {expression}, {cleanup: cleanup2}) => {
  2791. let root = closestRoot(el);
  2792. if (!root._x_refs)
  2793. root._x_refs = {};
  2794. root._x_refs[expression] = el;
  2795. cleanup2(() => delete root._x_refs[expression]);
  2796. };
  2797. directive("ref", handler2);
  2798. // packages/alpinejs/src/directives/x-if.js
  2799. directive("if", (el, {expression}, {effect: effect3, cleanup: cleanup2}) => {
  2800. let evaluate2 = evaluateLater(el, expression);
  2801. let show = () => {
  2802. if (el._x_currentIfEl)
  2803. return el._x_currentIfEl;
  2804. let clone2 = el.content.cloneNode(true).firstElementChild;
  2805. addScopeToNode(clone2, {}, el);
  2806. mutateDom(() => {
  2807. el.after(clone2);
  2808. initTree(clone2);
  2809. });
  2810. el._x_currentIfEl = clone2;
  2811. el._x_undoIf = () => {
  2812. walk(clone2, (node) => {
  2813. if (!!node._x_effects) {
  2814. node._x_effects.forEach(dequeueJob);
  2815. }
  2816. });
  2817. clone2.remove();
  2818. delete el._x_currentIfEl;
  2819. };
  2820. return clone2;
  2821. };
  2822. let hide = () => {
  2823. if (!el._x_undoIf)
  2824. return;
  2825. el._x_undoIf();
  2826. delete el._x_undoIf;
  2827. };
  2828. effect3(() => evaluate2((value) => {
  2829. value ? show() : hide();
  2830. }));
  2831. cleanup2(() => el._x_undoIf && el._x_undoIf());
  2832. });
  2833. // packages/alpinejs/src/directives/x-id.js
  2834. directive("id", (el, {expression}, {evaluate: evaluate2}) => {
  2835. let names = evaluate2(expression);
  2836. names.forEach((name) => setIdRoot(el, name));
  2837. });
  2838. // packages/alpinejs/src/directives/x-on.js
  2839. mapAttributes(startingWith("@", into(prefix("on:"))));
  2840. directive("on", skipDuringClone((el, {value, modifiers, expression}, {cleanup: cleanup2}) => {
  2841. let evaluate2 = expression ? evaluateLater(el, expression) : () => {
  2842. };
  2843. if (el.tagName.toLowerCase() === "template") {
  2844. if (!el._x_forwardEvents)
  2845. el._x_forwardEvents = [];
  2846. if (!el._x_forwardEvents.includes(value))
  2847. el._x_forwardEvents.push(value);
  2848. }
  2849. let removeListener = on(el, value, modifiers, (e) => {
  2850. evaluate2(() => {
  2851. }, {scope: {$event: e}, params: [e]});
  2852. });
  2853. cleanup2(() => removeListener());
  2854. }));
  2855. // packages/alpinejs/src/directives/index.js
  2856. warnMissingPluginDirective("Collapse", "collapse", "collapse");
  2857. warnMissingPluginDirective("Intersect", "intersect", "intersect");
  2858. warnMissingPluginDirective("Focus", "trap", "focus");
  2859. function warnMissingPluginDirective(name, directiveName2, slug) {
  2860. directive(directiveName2, (el) => warn(`You can't use [x-${directiveName2}] without first installing the "${name}" plugin here: https://alpine.dev/plugins/${slug}`, el));
  2861. }
  2862. // packages/alpinejs/src/index.js
  2863. alpine_default.setEvaluator(normalEvaluator);
  2864. alpine_default.setReactivityEngine({reactive: reactive2, effect: effect2, release: stop, raw: toRaw});
  2865. var src_default = alpine_default;
  2866. // packages/alpinejs/builds/module.js
  2867. var module_default = src_default;
  2868. /***/ }),
  2869. /***/ "./node_modules/axios/index.js":
  2870. /*!*************************************!*\
  2871. !*** ./node_modules/axios/index.js ***!
  2872. \*************************************/
  2873. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2874. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  2875. /***/ }),
  2876. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  2877. /*!************************************************!*\
  2878. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  2879. \************************************************/
  2880. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2881. "use strict";
  2882. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  2883. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  2884. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  2885. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  2886. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  2887. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  2888. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  2889. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  2890. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  2891. var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  2892. module.exports = function xhrAdapter(config) {
  2893. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2894. var requestData = config.data;
  2895. var requestHeaders = config.headers;
  2896. var responseType = config.responseType;
  2897. var onCanceled;
  2898. function done() {
  2899. if (config.cancelToken) {
  2900. config.cancelToken.unsubscribe(onCanceled);
  2901. }
  2902. if (config.signal) {
  2903. config.signal.removeEventListener('abort', onCanceled);
  2904. }
  2905. }
  2906. if (utils.isFormData(requestData)) {
  2907. delete requestHeaders['Content-Type']; // Let the browser set it
  2908. }
  2909. var request = new XMLHttpRequest();
  2910. // HTTP basic authentication
  2911. if (config.auth) {
  2912. var username = config.auth.username || '';
  2913. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  2914. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  2915. }
  2916. var fullPath = buildFullPath(config.baseURL, config.url);
  2917. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  2918. // Set the request timeout in MS
  2919. request.timeout = config.timeout;
  2920. function onloadend() {
  2921. if (!request) {
  2922. return;
  2923. }
  2924. // Prepare the response
  2925. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  2926. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  2927. request.responseText : request.response;
  2928. var response = {
  2929. data: responseData,
  2930. status: request.status,
  2931. statusText: request.statusText,
  2932. headers: responseHeaders,
  2933. config: config,
  2934. request: request
  2935. };
  2936. settle(function _resolve(value) {
  2937. resolve(value);
  2938. done();
  2939. }, function _reject(err) {
  2940. reject(err);
  2941. done();
  2942. }, response);
  2943. // Clean up request
  2944. request = null;
  2945. }
  2946. if ('onloadend' in request) {
  2947. // Use onloadend if available
  2948. request.onloadend = onloadend;
  2949. } else {
  2950. // Listen for ready state to emulate onloadend
  2951. request.onreadystatechange = function handleLoad() {
  2952. if (!request || request.readyState !== 4) {
  2953. return;
  2954. }
  2955. // The request errored out and we didn't get a response, this will be
  2956. // handled by onerror instead
  2957. // With one exception: request that using file: protocol, most browsers
  2958. // will return status as 0 even though it's a successful request
  2959. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2960. return;
  2961. }
  2962. // readystate handler is calling before onerror or ontimeout handlers,
  2963. // so we should call onloadend on the next 'tick'
  2964. setTimeout(onloadend);
  2965. };
  2966. }
  2967. // Handle browser request cancellation (as opposed to a manual cancellation)
  2968. request.onabort = function handleAbort() {
  2969. if (!request) {
  2970. return;
  2971. }
  2972. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  2973. // Clean up request
  2974. request = null;
  2975. };
  2976. // Handle low level network errors
  2977. request.onerror = function handleError() {
  2978. // Real errors are hidden from us by the browser
  2979. // onerror should only fire if it's a network error
  2980. reject(createError('Network Error', config, null, request));
  2981. // Clean up request
  2982. request = null;
  2983. };
  2984. // Handle timeout
  2985. request.ontimeout = function handleTimeout() {
  2986. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  2987. var transitional = config.transitional || defaults.transitional;
  2988. if (config.timeoutErrorMessage) {
  2989. timeoutErrorMessage = config.timeoutErrorMessage;
  2990. }
  2991. reject(createError(
  2992. timeoutErrorMessage,
  2993. config,
  2994. transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  2995. request));
  2996. // Clean up request
  2997. request = null;
  2998. };
  2999. // Add xsrf header
  3000. // This is only done if running in a standard browser environment.
  3001. // Specifically not if we're in a web worker, or react-native.
  3002. if (utils.isStandardBrowserEnv()) {
  3003. // Add xsrf header
  3004. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  3005. cookies.read(config.xsrfCookieName) :
  3006. undefined;
  3007. if (xsrfValue) {
  3008. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  3009. }
  3010. }
  3011. // Add headers to the request
  3012. if ('setRequestHeader' in request) {
  3013. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  3014. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  3015. // Remove Content-Type if data is undefined
  3016. delete requestHeaders[key];
  3017. } else {
  3018. // Otherwise add header to the request
  3019. request.setRequestHeader(key, val);
  3020. }
  3021. });
  3022. }
  3023. // Add withCredentials to request if needed
  3024. if (!utils.isUndefined(config.withCredentials)) {
  3025. request.withCredentials = !!config.withCredentials;
  3026. }
  3027. // Add responseType to request if needed
  3028. if (responseType && responseType !== 'json') {
  3029. request.responseType = config.responseType;
  3030. }
  3031. // Handle progress if needed
  3032. if (typeof config.onDownloadProgress === 'function') {
  3033. request.addEventListener('progress', config.onDownloadProgress);
  3034. }
  3035. // Not all browsers support upload events
  3036. if (typeof config.onUploadProgress === 'function' && request.upload) {
  3037. request.upload.addEventListener('progress', config.onUploadProgress);
  3038. }
  3039. if (config.cancelToken || config.signal) {
  3040. // Handle cancellation
  3041. // eslint-disable-next-line func-names
  3042. onCanceled = function(cancel) {
  3043. if (!request) {
  3044. return;
  3045. }
  3046. reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
  3047. request.abort();
  3048. request = null;
  3049. };
  3050. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  3051. if (config.signal) {
  3052. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  3053. }
  3054. }
  3055. if (!requestData) {
  3056. requestData = null;
  3057. }
  3058. // Send the request
  3059. request.send(requestData);
  3060. });
  3061. };
  3062. /***/ }),
  3063. /***/ "./node_modules/axios/lib/axios.js":
  3064. /*!*****************************************!*\
  3065. !*** ./node_modules/axios/lib/axios.js ***!
  3066. \*****************************************/
  3067. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3068. "use strict";
  3069. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  3070. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  3071. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  3072. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  3073. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  3074. /**
  3075. * Create an instance of Axios
  3076. *
  3077. * @param {Object} defaultConfig The default config for the instance
  3078. * @return {Axios} A new instance of Axios
  3079. */
  3080. function createInstance(defaultConfig) {
  3081. var context = new Axios(defaultConfig);
  3082. var instance = bind(Axios.prototype.request, context);
  3083. // Copy axios.prototype to instance
  3084. utils.extend(instance, Axios.prototype, context);
  3085. // Copy context to instance
  3086. utils.extend(instance, context);
  3087. // Factory for creating new instances
  3088. instance.create = function create(instanceConfig) {
  3089. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  3090. };
  3091. return instance;
  3092. }
  3093. // Create the default instance to be exported
  3094. var axios = createInstance(defaults);
  3095. // Expose Axios class to allow class inheritance
  3096. axios.Axios = Axios;
  3097. // Expose Cancel & CancelToken
  3098. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  3099. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  3100. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  3101. axios.VERSION = (__webpack_require__(/*! ./env/data */ "./node_modules/axios/lib/env/data.js").version);
  3102. // Expose all/spread
  3103. axios.all = function all(promises) {
  3104. return Promise.all(promises);
  3105. };
  3106. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  3107. // Expose isAxiosError
  3108. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  3109. module.exports = axios;
  3110. // Allow use of default import syntax in TypeScript
  3111. module.exports["default"] = axios;
  3112. /***/ }),
  3113. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  3114. /*!*************************************************!*\
  3115. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  3116. \*************************************************/
  3117. /***/ ((module) => {
  3118. "use strict";
  3119. /**
  3120. * A `Cancel` is an object that is thrown when an operation is canceled.
  3121. *
  3122. * @class
  3123. * @param {string=} message The message.
  3124. */
  3125. function Cancel(message) {
  3126. this.message = message;
  3127. }
  3128. Cancel.prototype.toString = function toString() {
  3129. return 'Cancel' + (this.message ? ': ' + this.message : '');
  3130. };
  3131. Cancel.prototype.__CANCEL__ = true;
  3132. module.exports = Cancel;
  3133. /***/ }),
  3134. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  3135. /*!******************************************************!*\
  3136. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  3137. \******************************************************/
  3138. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3139. "use strict";
  3140. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  3141. /**
  3142. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  3143. *
  3144. * @class
  3145. * @param {Function} executor The executor function.
  3146. */
  3147. function CancelToken(executor) {
  3148. if (typeof executor !== 'function') {
  3149. throw new TypeError('executor must be a function.');
  3150. }
  3151. var resolvePromise;
  3152. this.promise = new Promise(function promiseExecutor(resolve) {
  3153. resolvePromise = resolve;
  3154. });
  3155. var token = this;
  3156. // eslint-disable-next-line func-names
  3157. this.promise.then(function(cancel) {
  3158. if (!token._listeners) return;
  3159. var i;
  3160. var l = token._listeners.length;
  3161. for (i = 0; i < l; i++) {
  3162. token._listeners[i](cancel);
  3163. }
  3164. token._listeners = null;
  3165. });
  3166. // eslint-disable-next-line func-names
  3167. this.promise.then = function(onfulfilled) {
  3168. var _resolve;
  3169. // eslint-disable-next-line func-names
  3170. var promise = new Promise(function(resolve) {
  3171. token.subscribe(resolve);
  3172. _resolve = resolve;
  3173. }).then(onfulfilled);
  3174. promise.cancel = function reject() {
  3175. token.unsubscribe(_resolve);
  3176. };
  3177. return promise;
  3178. };
  3179. executor(function cancel(message) {
  3180. if (token.reason) {
  3181. // Cancellation has already been requested
  3182. return;
  3183. }
  3184. token.reason = new Cancel(message);
  3185. resolvePromise(token.reason);
  3186. });
  3187. }
  3188. /**
  3189. * Throws a `Cancel` if cancellation has been requested.
  3190. */
  3191. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  3192. if (this.reason) {
  3193. throw this.reason;
  3194. }
  3195. };
  3196. /**
  3197. * Subscribe to the cancel signal
  3198. */
  3199. CancelToken.prototype.subscribe = function subscribe(listener) {
  3200. if (this.reason) {
  3201. listener(this.reason);
  3202. return;
  3203. }
  3204. if (this._listeners) {
  3205. this._listeners.push(listener);
  3206. } else {
  3207. this._listeners = [listener];
  3208. }
  3209. };
  3210. /**
  3211. * Unsubscribe from the cancel signal
  3212. */
  3213. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  3214. if (!this._listeners) {
  3215. return;
  3216. }
  3217. var index = this._listeners.indexOf(listener);
  3218. if (index !== -1) {
  3219. this._listeners.splice(index, 1);
  3220. }
  3221. };
  3222. /**
  3223. * Returns an object that contains a new `CancelToken` and a function that, when called,
  3224. * cancels the `CancelToken`.
  3225. */
  3226. CancelToken.source = function source() {
  3227. var cancel;
  3228. var token = new CancelToken(function executor(c) {
  3229. cancel = c;
  3230. });
  3231. return {
  3232. token: token,
  3233. cancel: cancel
  3234. };
  3235. };
  3236. module.exports = CancelToken;
  3237. /***/ }),
  3238. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  3239. /*!***************************************************!*\
  3240. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  3241. \***************************************************/
  3242. /***/ ((module) => {
  3243. "use strict";
  3244. module.exports = function isCancel(value) {
  3245. return !!(value && value.__CANCEL__);
  3246. };
  3247. /***/ }),
  3248. /***/ "./node_modules/axios/lib/core/Axios.js":
  3249. /*!**********************************************!*\
  3250. !*** ./node_modules/axios/lib/core/Axios.js ***!
  3251. \**********************************************/
  3252. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3253. "use strict";
  3254. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3255. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  3256. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  3257. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  3258. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  3259. var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js");
  3260. var validators = validator.validators;
  3261. /**
  3262. * Create a new instance of Axios
  3263. *
  3264. * @param {Object} instanceConfig The default config for the instance
  3265. */
  3266. function Axios(instanceConfig) {
  3267. this.defaults = instanceConfig;
  3268. this.interceptors = {
  3269. request: new InterceptorManager(),
  3270. response: new InterceptorManager()
  3271. };
  3272. }
  3273. /**
  3274. * Dispatch a request
  3275. *
  3276. * @param {Object} config The config specific for this request (merged with this.defaults)
  3277. */
  3278. Axios.prototype.request = function request(configOrUrl, config) {
  3279. /*eslint no-param-reassign:0*/
  3280. // Allow for axios('example/url'[, config]) a la fetch API
  3281. if (typeof configOrUrl === 'string') {
  3282. config = config || {};
  3283. config.url = configOrUrl;
  3284. } else {
  3285. config = configOrUrl || {};
  3286. }
  3287. if (!config.url) {
  3288. throw new Error('Provided config url is not valid');
  3289. }
  3290. config = mergeConfig(this.defaults, config);
  3291. // Set config.method
  3292. if (config.method) {
  3293. config.method = config.method.toLowerCase();
  3294. } else if (this.defaults.method) {
  3295. config.method = this.defaults.method.toLowerCase();
  3296. } else {
  3297. config.method = 'get';
  3298. }
  3299. var transitional = config.transitional;
  3300. if (transitional !== undefined) {
  3301. validator.assertOptions(transitional, {
  3302. silentJSONParsing: validators.transitional(validators.boolean),
  3303. forcedJSONParsing: validators.transitional(validators.boolean),
  3304. clarifyTimeoutError: validators.transitional(validators.boolean)
  3305. }, false);
  3306. }
  3307. // filter out skipped interceptors
  3308. var requestInterceptorChain = [];
  3309. var synchronousRequestInterceptors = true;
  3310. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  3311. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  3312. return;
  3313. }
  3314. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  3315. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  3316. });
  3317. var responseInterceptorChain = [];
  3318. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  3319. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  3320. });
  3321. var promise;
  3322. if (!synchronousRequestInterceptors) {
  3323. var chain = [dispatchRequest, undefined];
  3324. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  3325. chain = chain.concat(responseInterceptorChain);
  3326. promise = Promise.resolve(config);
  3327. while (chain.length) {
  3328. promise = promise.then(chain.shift(), chain.shift());
  3329. }
  3330. return promise;
  3331. }
  3332. var newConfig = config;
  3333. while (requestInterceptorChain.length) {
  3334. var onFulfilled = requestInterceptorChain.shift();
  3335. var onRejected = requestInterceptorChain.shift();
  3336. try {
  3337. newConfig = onFulfilled(newConfig);
  3338. } catch (error) {
  3339. onRejected(error);
  3340. break;
  3341. }
  3342. }
  3343. try {
  3344. promise = dispatchRequest(newConfig);
  3345. } catch (error) {
  3346. return Promise.reject(error);
  3347. }
  3348. while (responseInterceptorChain.length) {
  3349. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  3350. }
  3351. return promise;
  3352. };
  3353. Axios.prototype.getUri = function getUri(config) {
  3354. if (!config.url) {
  3355. throw new Error('Provided config url is not valid');
  3356. }
  3357. config = mergeConfig(this.defaults, config);
  3358. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  3359. };
  3360. // Provide aliases for supported request methods
  3361. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  3362. /*eslint func-names:0*/
  3363. Axios.prototype[method] = function(url, config) {
  3364. return this.request(mergeConfig(config || {}, {
  3365. method: method,
  3366. url: url,
  3367. data: (config || {}).data
  3368. }));
  3369. };
  3370. });
  3371. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  3372. /*eslint func-names:0*/
  3373. Axios.prototype[method] = function(url, data, config) {
  3374. return this.request(mergeConfig(config || {}, {
  3375. method: method,
  3376. url: url,
  3377. data: data
  3378. }));
  3379. };
  3380. });
  3381. module.exports = Axios;
  3382. /***/ }),
  3383. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  3384. /*!***********************************************************!*\
  3385. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  3386. \***********************************************************/
  3387. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3388. "use strict";
  3389. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3390. function InterceptorManager() {
  3391. this.handlers = [];
  3392. }
  3393. /**
  3394. * Add a new interceptor to the stack
  3395. *
  3396. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  3397. * @param {Function} rejected The function to handle `reject` for a `Promise`
  3398. *
  3399. * @return {Number} An ID used to remove interceptor later
  3400. */
  3401. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  3402. this.handlers.push({
  3403. fulfilled: fulfilled,
  3404. rejected: rejected,
  3405. synchronous: options ? options.synchronous : false,
  3406. runWhen: options ? options.runWhen : null
  3407. });
  3408. return this.handlers.length - 1;
  3409. };
  3410. /**
  3411. * Remove an interceptor from the stack
  3412. *
  3413. * @param {Number} id The ID that was returned by `use`
  3414. */
  3415. InterceptorManager.prototype.eject = function eject(id) {
  3416. if (this.handlers[id]) {
  3417. this.handlers[id] = null;
  3418. }
  3419. };
  3420. /**
  3421. * Iterate over all the registered interceptors
  3422. *
  3423. * This method is particularly useful for skipping over any
  3424. * interceptors that may have become `null` calling `eject`.
  3425. *
  3426. * @param {Function} fn The function to call for each interceptor
  3427. */
  3428. InterceptorManager.prototype.forEach = function forEach(fn) {
  3429. utils.forEach(this.handlers, function forEachHandler(h) {
  3430. if (h !== null) {
  3431. fn(h);
  3432. }
  3433. });
  3434. };
  3435. module.exports = InterceptorManager;
  3436. /***/ }),
  3437. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  3438. /*!******************************************************!*\
  3439. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  3440. \******************************************************/
  3441. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3442. "use strict";
  3443. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  3444. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  3445. /**
  3446. * Creates a new URL by combining the baseURL with the requestedURL,
  3447. * only when the requestedURL is not already an absolute URL.
  3448. * If the requestURL is absolute, this function returns the requestedURL untouched.
  3449. *
  3450. * @param {string} baseURL The base URL
  3451. * @param {string} requestedURL Absolute or relative URL to combine
  3452. * @returns {string} The combined full path
  3453. */
  3454. module.exports = function buildFullPath(baseURL, requestedURL) {
  3455. if (baseURL && !isAbsoluteURL(requestedURL)) {
  3456. return combineURLs(baseURL, requestedURL);
  3457. }
  3458. return requestedURL;
  3459. };
  3460. /***/ }),
  3461. /***/ "./node_modules/axios/lib/core/createError.js":
  3462. /*!****************************************************!*\
  3463. !*** ./node_modules/axios/lib/core/createError.js ***!
  3464. \****************************************************/
  3465. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3466. "use strict";
  3467. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  3468. /**
  3469. * Create an Error with the specified message, config, error code, request and response.
  3470. *
  3471. * @param {string} message The error message.
  3472. * @param {Object} config The config.
  3473. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  3474. * @param {Object} [request] The request.
  3475. * @param {Object} [response] The response.
  3476. * @returns {Error} The created error.
  3477. */
  3478. module.exports = function createError(message, config, code, request, response) {
  3479. var error = new Error(message);
  3480. return enhanceError(error, config, code, request, response);
  3481. };
  3482. /***/ }),
  3483. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  3484. /*!********************************************************!*\
  3485. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  3486. \********************************************************/
  3487. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3488. "use strict";
  3489. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3490. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  3491. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  3492. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  3493. var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  3494. /**
  3495. * Throws a `Cancel` if cancellation has been requested.
  3496. */
  3497. function throwIfCancellationRequested(config) {
  3498. if (config.cancelToken) {
  3499. config.cancelToken.throwIfRequested();
  3500. }
  3501. if (config.signal && config.signal.aborted) {
  3502. throw new Cancel('canceled');
  3503. }
  3504. }
  3505. /**
  3506. * Dispatch a request to the server using the configured adapter.
  3507. *
  3508. * @param {object} config The config that is to be used for the request
  3509. * @returns {Promise} The Promise to be fulfilled
  3510. */
  3511. module.exports = function dispatchRequest(config) {
  3512. throwIfCancellationRequested(config);
  3513. // Ensure headers exist
  3514. config.headers = config.headers || {};
  3515. // Transform request data
  3516. config.data = transformData.call(
  3517. config,
  3518. config.data,
  3519. config.headers,
  3520. config.transformRequest
  3521. );
  3522. // Flatten headers
  3523. config.headers = utils.merge(
  3524. config.headers.common || {},
  3525. config.headers[config.method] || {},
  3526. config.headers
  3527. );
  3528. utils.forEach(
  3529. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  3530. function cleanHeaderConfig(method) {
  3531. delete config.headers[method];
  3532. }
  3533. );
  3534. var adapter = config.adapter || defaults.adapter;
  3535. return adapter(config).then(function onAdapterResolution(response) {
  3536. throwIfCancellationRequested(config);
  3537. // Transform response data
  3538. response.data = transformData.call(
  3539. config,
  3540. response.data,
  3541. response.headers,
  3542. config.transformResponse
  3543. );
  3544. return response;
  3545. }, function onAdapterRejection(reason) {
  3546. if (!isCancel(reason)) {
  3547. throwIfCancellationRequested(config);
  3548. // Transform response data
  3549. if (reason && reason.response) {
  3550. reason.response.data = transformData.call(
  3551. config,
  3552. reason.response.data,
  3553. reason.response.headers,
  3554. config.transformResponse
  3555. );
  3556. }
  3557. }
  3558. return Promise.reject(reason);
  3559. });
  3560. };
  3561. /***/ }),
  3562. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  3563. /*!*****************************************************!*\
  3564. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  3565. \*****************************************************/
  3566. /***/ ((module) => {
  3567. "use strict";
  3568. /**
  3569. * Update an Error with the specified config, error code, and response.
  3570. *
  3571. * @param {Error} error The error to update.
  3572. * @param {Object} config The config.
  3573. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  3574. * @param {Object} [request] The request.
  3575. * @param {Object} [response] The response.
  3576. * @returns {Error} The error.
  3577. */
  3578. module.exports = function enhanceError(error, config, code, request, response) {
  3579. error.config = config;
  3580. if (code) {
  3581. error.code = code;
  3582. }
  3583. error.request = request;
  3584. error.response = response;
  3585. error.isAxiosError = true;
  3586. error.toJSON = function toJSON() {
  3587. return {
  3588. // Standard
  3589. message: this.message,
  3590. name: this.name,
  3591. // Microsoft
  3592. description: this.description,
  3593. number: this.number,
  3594. // Mozilla
  3595. fileName: this.fileName,
  3596. lineNumber: this.lineNumber,
  3597. columnNumber: this.columnNumber,
  3598. stack: this.stack,
  3599. // Axios
  3600. config: this.config,
  3601. code: this.code,
  3602. status: this.response && this.response.status ? this.response.status : null
  3603. };
  3604. };
  3605. return error;
  3606. };
  3607. /***/ }),
  3608. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  3609. /*!****************************************************!*\
  3610. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  3611. \****************************************************/
  3612. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3613. "use strict";
  3614. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  3615. /**
  3616. * Config-specific merge-function which creates a new config-object
  3617. * by merging two configuration objects together.
  3618. *
  3619. * @param {Object} config1
  3620. * @param {Object} config2
  3621. * @returns {Object} New object resulting from merging config2 to config1
  3622. */
  3623. module.exports = function mergeConfig(config1, config2) {
  3624. // eslint-disable-next-line no-param-reassign
  3625. config2 = config2 || {};
  3626. var config = {};
  3627. function getMergedValue(target, source) {
  3628. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  3629. return utils.merge(target, source);
  3630. } else if (utils.isPlainObject(source)) {
  3631. return utils.merge({}, source);
  3632. } else if (utils.isArray(source)) {
  3633. return source.slice();
  3634. }
  3635. return source;
  3636. }
  3637. // eslint-disable-next-line consistent-return
  3638. function mergeDeepProperties(prop) {
  3639. if (!utils.isUndefined(config2[prop])) {
  3640. return getMergedValue(config1[prop], config2[prop]);
  3641. } else if (!utils.isUndefined(config1[prop])) {
  3642. return getMergedValue(undefined, config1[prop]);
  3643. }
  3644. }
  3645. // eslint-disable-next-line consistent-return
  3646. function valueFromConfig2(prop) {
  3647. if (!utils.isUndefined(config2[prop])) {
  3648. return getMergedValue(undefined, config2[prop]);
  3649. }
  3650. }
  3651. // eslint-disable-next-line consistent-return
  3652. function defaultToConfig2(prop) {
  3653. if (!utils.isUndefined(config2[prop])) {
  3654. return getMergedValue(undefined, config2[prop]);
  3655. } else if (!utils.isUndefined(config1[prop])) {
  3656. return getMergedValue(undefined, config1[prop]);
  3657. }
  3658. }
  3659. // eslint-disable-next-line consistent-return
  3660. function mergeDirectKeys(prop) {
  3661. if (prop in config2) {
  3662. return getMergedValue(config1[prop], config2[prop]);
  3663. } else if (prop in config1) {
  3664. return getMergedValue(undefined, config1[prop]);
  3665. }
  3666. }
  3667. var mergeMap = {
  3668. 'url': valueFromConfig2,
  3669. 'method': valueFromConfig2,
  3670. 'data': valueFromConfig2,
  3671. 'baseURL': defaultToConfig2,
  3672. 'transformRequest': defaultToConfig2,
  3673. 'transformResponse': defaultToConfig2,
  3674. 'paramsSerializer': defaultToConfig2,
  3675. 'timeout': defaultToConfig2,
  3676. 'timeoutMessage': defaultToConfig2,
  3677. 'withCredentials': defaultToConfig2,
  3678. 'adapter': defaultToConfig2,
  3679. 'responseType': defaultToConfig2,
  3680. 'xsrfCookieName': defaultToConfig2,
  3681. 'xsrfHeaderName': defaultToConfig2,
  3682. 'onUploadProgress': defaultToConfig2,
  3683. 'onDownloadProgress': defaultToConfig2,
  3684. 'decompress': defaultToConfig2,
  3685. 'maxContentLength': defaultToConfig2,
  3686. 'maxBodyLength': defaultToConfig2,
  3687. 'transport': defaultToConfig2,
  3688. 'httpAgent': defaultToConfig2,
  3689. 'httpsAgent': defaultToConfig2,
  3690. 'cancelToken': defaultToConfig2,
  3691. 'socketPath': defaultToConfig2,
  3692. 'responseEncoding': defaultToConfig2,
  3693. 'validateStatus': mergeDirectKeys
  3694. };
  3695. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  3696. var merge = mergeMap[prop] || mergeDeepProperties;
  3697. var configValue = merge(prop);
  3698. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  3699. });
  3700. return config;
  3701. };
  3702. /***/ }),
  3703. /***/ "./node_modules/axios/lib/core/settle.js":
  3704. /*!***********************************************!*\
  3705. !*** ./node_modules/axios/lib/core/settle.js ***!
  3706. \***********************************************/
  3707. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3708. "use strict";
  3709. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  3710. /**
  3711. * Resolve or reject a Promise based on response status.
  3712. *
  3713. * @param {Function} resolve A function that resolves the promise.
  3714. * @param {Function} reject A function that rejects the promise.
  3715. * @param {object} response The response.
  3716. */
  3717. module.exports = function settle(resolve, reject, response) {
  3718. var validateStatus = response.config.validateStatus;
  3719. if (!response.status || !validateStatus || validateStatus(response.status)) {
  3720. resolve(response);
  3721. } else {
  3722. reject(createError(
  3723. 'Request failed with status code ' + response.status,
  3724. response.config,
  3725. null,
  3726. response.request,
  3727. response
  3728. ));
  3729. }
  3730. };
  3731. /***/ }),
  3732. /***/ "./node_modules/axios/lib/core/transformData.js":
  3733. /*!******************************************************!*\
  3734. !*** ./node_modules/axios/lib/core/transformData.js ***!
  3735. \******************************************************/
  3736. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3737. "use strict";
  3738. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3739. var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js");
  3740. /**
  3741. * Transform the data for a request or a response
  3742. *
  3743. * @param {Object|String} data The data to be transformed
  3744. * @param {Array} headers The headers for the request or response
  3745. * @param {Array|Function} fns A single function or Array of functions
  3746. * @returns {*} The resulting transformed data
  3747. */
  3748. module.exports = function transformData(data, headers, fns) {
  3749. var context = this || defaults;
  3750. /*eslint no-param-reassign:0*/
  3751. utils.forEach(fns, function transform(fn) {
  3752. data = fn.call(context, data, headers);
  3753. });
  3754. return data;
  3755. };
  3756. /***/ }),
  3757. /***/ "./node_modules/axios/lib/defaults.js":
  3758. /*!********************************************!*\
  3759. !*** ./node_modules/axios/lib/defaults.js ***!
  3760. \********************************************/
  3761. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3762. "use strict";
  3763. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  3764. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  3765. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  3766. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  3767. var DEFAULT_CONTENT_TYPE = {
  3768. 'Content-Type': 'application/x-www-form-urlencoded'
  3769. };
  3770. function setContentTypeIfUnset(headers, value) {
  3771. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  3772. headers['Content-Type'] = value;
  3773. }
  3774. }
  3775. function getDefaultAdapter() {
  3776. var adapter;
  3777. if (typeof XMLHttpRequest !== 'undefined') {
  3778. // For browsers use XHR adapter
  3779. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  3780. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  3781. // For node use HTTP adapter
  3782. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  3783. }
  3784. return adapter;
  3785. }
  3786. function stringifySafely(rawValue, parser, encoder) {
  3787. if (utils.isString(rawValue)) {
  3788. try {
  3789. (parser || JSON.parse)(rawValue);
  3790. return utils.trim(rawValue);
  3791. } catch (e) {
  3792. if (e.name !== 'SyntaxError') {
  3793. throw e;
  3794. }
  3795. }
  3796. }
  3797. return (encoder || JSON.stringify)(rawValue);
  3798. }
  3799. var defaults = {
  3800. transitional: {
  3801. silentJSONParsing: true,
  3802. forcedJSONParsing: true,
  3803. clarifyTimeoutError: false
  3804. },
  3805. adapter: getDefaultAdapter(),
  3806. transformRequest: [function transformRequest(data, headers) {
  3807. normalizeHeaderName(headers, 'Accept');
  3808. normalizeHeaderName(headers, 'Content-Type');
  3809. if (utils.isFormData(data) ||
  3810. utils.isArrayBuffer(data) ||
  3811. utils.isBuffer(data) ||
  3812. utils.isStream(data) ||
  3813. utils.isFile(data) ||
  3814. utils.isBlob(data)
  3815. ) {
  3816. return data;
  3817. }
  3818. if (utils.isArrayBufferView(data)) {
  3819. return data.buffer;
  3820. }
  3821. if (utils.isURLSearchParams(data)) {
  3822. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  3823. return data.toString();
  3824. }
  3825. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  3826. setContentTypeIfUnset(headers, 'application/json');
  3827. return stringifySafely(data);
  3828. }
  3829. return data;
  3830. }],
  3831. transformResponse: [function transformResponse(data) {
  3832. var transitional = this.transitional || defaults.transitional;
  3833. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  3834. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  3835. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  3836. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  3837. try {
  3838. return JSON.parse(data);
  3839. } catch (e) {
  3840. if (strictJSONParsing) {
  3841. if (e.name === 'SyntaxError') {
  3842. throw enhanceError(e, this, 'E_JSON_PARSE');
  3843. }
  3844. throw e;
  3845. }
  3846. }
  3847. }
  3848. return data;
  3849. }],
  3850. /**
  3851. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  3852. * timeout is not created.
  3853. */
  3854. timeout: 0,
  3855. xsrfCookieName: 'XSRF-TOKEN',
  3856. xsrfHeaderName: 'X-XSRF-TOKEN',
  3857. maxContentLength: -1,
  3858. maxBodyLength: -1,
  3859. validateStatus: function validateStatus(status) {
  3860. return status >= 200 && status < 300;
  3861. },
  3862. headers: {
  3863. common: {
  3864. 'Accept': 'application/json, text/plain, */*'
  3865. }
  3866. }
  3867. };
  3868. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  3869. defaults.headers[method] = {};
  3870. });
  3871. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  3872. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  3873. });
  3874. module.exports = defaults;
  3875. /***/ }),
  3876. /***/ "./node_modules/axios/lib/env/data.js":
  3877. /*!********************************************!*\
  3878. !*** ./node_modules/axios/lib/env/data.js ***!
  3879. \********************************************/
  3880. /***/ ((module) => {
  3881. module.exports = {
  3882. "version": "0.25.0"
  3883. };
  3884. /***/ }),
  3885. /***/ "./node_modules/axios/lib/helpers/bind.js":
  3886. /*!************************************************!*\
  3887. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  3888. \************************************************/
  3889. /***/ ((module) => {
  3890. "use strict";
  3891. module.exports = function bind(fn, thisArg) {
  3892. return function wrap() {
  3893. var args = new Array(arguments.length);
  3894. for (var i = 0; i < args.length; i++) {
  3895. args[i] = arguments[i];
  3896. }
  3897. return fn.apply(thisArg, args);
  3898. };
  3899. };
  3900. /***/ }),
  3901. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  3902. /*!****************************************************!*\
  3903. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  3904. \****************************************************/
  3905. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3906. "use strict";
  3907. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3908. function encode(val) {
  3909. return encodeURIComponent(val).
  3910. replace(/%3A/gi, ':').
  3911. replace(/%24/g, '$').
  3912. replace(/%2C/gi, ',').
  3913. replace(/%20/g, '+').
  3914. replace(/%5B/gi, '[').
  3915. replace(/%5D/gi, ']');
  3916. }
  3917. /**
  3918. * Build a URL by appending params to the end
  3919. *
  3920. * @param {string} url The base of the url (e.g., http://www.google.com)
  3921. * @param {object} [params] The params to be appended
  3922. * @returns {string} The formatted url
  3923. */
  3924. module.exports = function buildURL(url, params, paramsSerializer) {
  3925. /*eslint no-param-reassign:0*/
  3926. if (!params) {
  3927. return url;
  3928. }
  3929. var serializedParams;
  3930. if (paramsSerializer) {
  3931. serializedParams = paramsSerializer(params);
  3932. } else if (utils.isURLSearchParams(params)) {
  3933. serializedParams = params.toString();
  3934. } else {
  3935. var parts = [];
  3936. utils.forEach(params, function serialize(val, key) {
  3937. if (val === null || typeof val === 'undefined') {
  3938. return;
  3939. }
  3940. if (utils.isArray(val)) {
  3941. key = key + '[]';
  3942. } else {
  3943. val = [val];
  3944. }
  3945. utils.forEach(val, function parseValue(v) {
  3946. if (utils.isDate(v)) {
  3947. v = v.toISOString();
  3948. } else if (utils.isObject(v)) {
  3949. v = JSON.stringify(v);
  3950. }
  3951. parts.push(encode(key) + '=' + encode(v));
  3952. });
  3953. });
  3954. serializedParams = parts.join('&');
  3955. }
  3956. if (serializedParams) {
  3957. var hashmarkIndex = url.indexOf('#');
  3958. if (hashmarkIndex !== -1) {
  3959. url = url.slice(0, hashmarkIndex);
  3960. }
  3961. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  3962. }
  3963. return url;
  3964. };
  3965. /***/ }),
  3966. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  3967. /*!*******************************************************!*\
  3968. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  3969. \*******************************************************/
  3970. /***/ ((module) => {
  3971. "use strict";
  3972. /**
  3973. * Creates a new URL by combining the specified URLs
  3974. *
  3975. * @param {string} baseURL The base URL
  3976. * @param {string} relativeURL The relative URL
  3977. * @returns {string} The combined URL
  3978. */
  3979. module.exports = function combineURLs(baseURL, relativeURL) {
  3980. return relativeURL
  3981. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  3982. : baseURL;
  3983. };
  3984. /***/ }),
  3985. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  3986. /*!***************************************************!*\
  3987. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  3988. \***************************************************/
  3989. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3990. "use strict";
  3991. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  3992. module.exports = (
  3993. utils.isStandardBrowserEnv() ?
  3994. // Standard browser envs support document.cookie
  3995. (function standardBrowserEnv() {
  3996. return {
  3997. write: function write(name, value, expires, path, domain, secure) {
  3998. var cookie = [];
  3999. cookie.push(name + '=' + encodeURIComponent(value));
  4000. if (utils.isNumber(expires)) {
  4001. cookie.push('expires=' + new Date(expires).toGMTString());
  4002. }
  4003. if (utils.isString(path)) {
  4004. cookie.push('path=' + path);
  4005. }
  4006. if (utils.isString(domain)) {
  4007. cookie.push('domain=' + domain);
  4008. }
  4009. if (secure === true) {
  4010. cookie.push('secure');
  4011. }
  4012. document.cookie = cookie.join('; ');
  4013. },
  4014. read: function read(name) {
  4015. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  4016. return (match ? decodeURIComponent(match[3]) : null);
  4017. },
  4018. remove: function remove(name) {
  4019. this.write(name, '', Date.now() - 86400000);
  4020. }
  4021. };
  4022. })() :
  4023. // Non standard browser env (web workers, react-native) lack needed support.
  4024. (function nonStandardBrowserEnv() {
  4025. return {
  4026. write: function write() {},
  4027. read: function read() { return null; },
  4028. remove: function remove() {}
  4029. };
  4030. })()
  4031. );
  4032. /***/ }),
  4033. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  4034. /*!*********************************************************!*\
  4035. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  4036. \*********************************************************/
  4037. /***/ ((module) => {
  4038. "use strict";
  4039. /**
  4040. * Determines whether the specified URL is absolute
  4041. *
  4042. * @param {string} url The URL to test
  4043. * @returns {boolean} True if the specified URL is absolute, otherwise false
  4044. */
  4045. module.exports = function isAbsoluteURL(url) {
  4046. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  4047. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  4048. // by any combination of letters, digits, plus, period, or hyphen.
  4049. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  4050. };
  4051. /***/ }),
  4052. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  4053. /*!********************************************************!*\
  4054. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  4055. \********************************************************/
  4056. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4057. "use strict";
  4058. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  4059. /**
  4060. * Determines whether the payload is an error thrown by Axios
  4061. *
  4062. * @param {*} payload The value to test
  4063. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  4064. */
  4065. module.exports = function isAxiosError(payload) {
  4066. return utils.isObject(payload) && (payload.isAxiosError === true);
  4067. };
  4068. /***/ }),
  4069. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  4070. /*!***********************************************************!*\
  4071. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  4072. \***********************************************************/
  4073. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4074. "use strict";
  4075. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  4076. module.exports = (
  4077. utils.isStandardBrowserEnv() ?
  4078. // Standard browser envs have full support of the APIs needed to test
  4079. // whether the request URL is of the same origin as current location.
  4080. (function standardBrowserEnv() {
  4081. var msie = /(msie|trident)/i.test(navigator.userAgent);
  4082. var urlParsingNode = document.createElement('a');
  4083. var originURL;
  4084. /**
  4085. * Parse a URL to discover it's components
  4086. *
  4087. * @param {String} url The URL to be parsed
  4088. * @returns {Object}
  4089. */
  4090. function resolveURL(url) {
  4091. var href = url;
  4092. if (msie) {
  4093. // IE needs attribute set twice to normalize properties
  4094. urlParsingNode.setAttribute('href', href);
  4095. href = urlParsingNode.href;
  4096. }
  4097. urlParsingNode.setAttribute('href', href);
  4098. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  4099. return {
  4100. href: urlParsingNode.href,
  4101. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  4102. host: urlParsingNode.host,
  4103. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  4104. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  4105. hostname: urlParsingNode.hostname,
  4106. port: urlParsingNode.port,
  4107. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  4108. urlParsingNode.pathname :
  4109. '/' + urlParsingNode.pathname
  4110. };
  4111. }
  4112. originURL = resolveURL(window.location.href);
  4113. /**
  4114. * Determine if a URL shares the same origin as the current location
  4115. *
  4116. * @param {String} requestURL The URL to test
  4117. * @returns {boolean} True if URL shares the same origin, otherwise false
  4118. */
  4119. return function isURLSameOrigin(requestURL) {
  4120. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  4121. return (parsed.protocol === originURL.protocol &&
  4122. parsed.host === originURL.host);
  4123. };
  4124. })() :
  4125. // Non standard browser envs (web workers, react-native) lack needed support.
  4126. (function nonStandardBrowserEnv() {
  4127. return function isURLSameOrigin() {
  4128. return true;
  4129. };
  4130. })()
  4131. );
  4132. /***/ }),
  4133. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  4134. /*!***************************************************************!*\
  4135. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  4136. \***************************************************************/
  4137. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4138. "use strict";
  4139. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  4140. module.exports = function normalizeHeaderName(headers, normalizedName) {
  4141. utils.forEach(headers, function processHeader(value, name) {
  4142. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  4143. headers[normalizedName] = value;
  4144. delete headers[name];
  4145. }
  4146. });
  4147. };
  4148. /***/ }),
  4149. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  4150. /*!********************************************************!*\
  4151. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  4152. \********************************************************/
  4153. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4154. "use strict";
  4155. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  4156. // Headers whose duplicates are ignored by node
  4157. // c.f. https://nodejs.org/api/http.html#http_message_headers
  4158. var ignoreDuplicateOf = [
  4159. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  4160. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  4161. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  4162. 'referer', 'retry-after', 'user-agent'
  4163. ];
  4164. /**
  4165. * Parse headers into an object
  4166. *
  4167. * ```
  4168. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  4169. * Content-Type: application/json
  4170. * Connection: keep-alive
  4171. * Transfer-Encoding: chunked
  4172. * ```
  4173. *
  4174. * @param {String} headers Headers needing to be parsed
  4175. * @returns {Object} Headers parsed into an object
  4176. */
  4177. module.exports = function parseHeaders(headers) {
  4178. var parsed = {};
  4179. var key;
  4180. var val;
  4181. var i;
  4182. if (!headers) { return parsed; }
  4183. utils.forEach(headers.split('\n'), function parser(line) {
  4184. i = line.indexOf(':');
  4185. key = utils.trim(line.substr(0, i)).toLowerCase();
  4186. val = utils.trim(line.substr(i + 1));
  4187. if (key) {
  4188. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  4189. return;
  4190. }
  4191. if (key === 'set-cookie') {
  4192. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  4193. } else {
  4194. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  4195. }
  4196. }
  4197. });
  4198. return parsed;
  4199. };
  4200. /***/ }),
  4201. /***/ "./node_modules/axios/lib/helpers/spread.js":
  4202. /*!**************************************************!*\
  4203. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  4204. \**************************************************/
  4205. /***/ ((module) => {
  4206. "use strict";
  4207. /**
  4208. * Syntactic sugar for invoking a function and expanding an array for arguments.
  4209. *
  4210. * Common use case would be to use `Function.prototype.apply`.
  4211. *
  4212. * ```js
  4213. * function f(x, y, z) {}
  4214. * var args = [1, 2, 3];
  4215. * f.apply(null, args);
  4216. * ```
  4217. *
  4218. * With `spread` this example can be re-written.
  4219. *
  4220. * ```js
  4221. * spread(function(x, y, z) {})([1, 2, 3]);
  4222. * ```
  4223. *
  4224. * @param {Function} callback
  4225. * @returns {Function}
  4226. */
  4227. module.exports = function spread(callback) {
  4228. return function wrap(arr) {
  4229. return callback.apply(null, arr);
  4230. };
  4231. };
  4232. /***/ }),
  4233. /***/ "./node_modules/axios/lib/helpers/validator.js":
  4234. /*!*****************************************************!*\
  4235. !*** ./node_modules/axios/lib/helpers/validator.js ***!
  4236. \*****************************************************/
  4237. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4238. "use strict";
  4239. var VERSION = (__webpack_require__(/*! ../env/data */ "./node_modules/axios/lib/env/data.js").version);
  4240. var validators = {};
  4241. // eslint-disable-next-line func-names
  4242. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  4243. validators[type] = function validator(thing) {
  4244. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  4245. };
  4246. });
  4247. var deprecatedWarnings = {};
  4248. /**
  4249. * Transitional option validator
  4250. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  4251. * @param {string?} version - deprecated version / removed since version
  4252. * @param {string?} message - some message with additional info
  4253. * @returns {function}
  4254. */
  4255. validators.transitional = function transitional(validator, version, message) {
  4256. function formatMessage(opt, desc) {
  4257. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  4258. }
  4259. // eslint-disable-next-line func-names
  4260. return function(value, opt, opts) {
  4261. if (validator === false) {
  4262. throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
  4263. }
  4264. if (version && !deprecatedWarnings[opt]) {
  4265. deprecatedWarnings[opt] = true;
  4266. // eslint-disable-next-line no-console
  4267. console.warn(
  4268. formatMessage(
  4269. opt,
  4270. ' has been deprecated since v' + version + ' and will be removed in the near future'
  4271. )
  4272. );
  4273. }
  4274. return validator ? validator(value, opt, opts) : true;
  4275. };
  4276. };
  4277. /**
  4278. * Assert object's properties type
  4279. * @param {object} options
  4280. * @param {object} schema
  4281. * @param {boolean?} allowUnknown
  4282. */
  4283. function assertOptions(options, schema, allowUnknown) {
  4284. if (typeof options !== 'object') {
  4285. throw new TypeError('options must be an object');
  4286. }
  4287. var keys = Object.keys(options);
  4288. var i = keys.length;
  4289. while (i-- > 0) {
  4290. var opt = keys[i];
  4291. var validator = schema[opt];
  4292. if (validator) {
  4293. var value = options[opt];
  4294. var result = value === undefined || validator(value, opt, options);
  4295. if (result !== true) {
  4296. throw new TypeError('option ' + opt + ' must be ' + result);
  4297. }
  4298. continue;
  4299. }
  4300. if (allowUnknown !== true) {
  4301. throw Error('Unknown option ' + opt);
  4302. }
  4303. }
  4304. }
  4305. module.exports = {
  4306. assertOptions: assertOptions,
  4307. validators: validators
  4308. };
  4309. /***/ }),
  4310. /***/ "./node_modules/axios/lib/utils.js":
  4311. /*!*****************************************!*\
  4312. !*** ./node_modules/axios/lib/utils.js ***!
  4313. \*****************************************/
  4314. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4315. "use strict";
  4316. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  4317. // utils is a library of generic helper functions non-specific to axios
  4318. var toString = Object.prototype.toString;
  4319. /**
  4320. * Determine if a value is an Array
  4321. *
  4322. * @param {Object} val The value to test
  4323. * @returns {boolean} True if value is an Array, otherwise false
  4324. */
  4325. function isArray(val) {
  4326. return Array.isArray(val);
  4327. }
  4328. /**
  4329. * Determine if a value is undefined
  4330. *
  4331. * @param {Object} val The value to test
  4332. * @returns {boolean} True if the value is undefined, otherwise false
  4333. */
  4334. function isUndefined(val) {
  4335. return typeof val === 'undefined';
  4336. }
  4337. /**
  4338. * Determine if a value is a Buffer
  4339. *
  4340. * @param {Object} val The value to test
  4341. * @returns {boolean} True if value is a Buffer, otherwise false
  4342. */
  4343. function isBuffer(val) {
  4344. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  4345. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  4346. }
  4347. /**
  4348. * Determine if a value is an ArrayBuffer
  4349. *
  4350. * @param {Object} val The value to test
  4351. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  4352. */
  4353. function isArrayBuffer(val) {
  4354. return toString.call(val) === '[object ArrayBuffer]';
  4355. }
  4356. /**
  4357. * Determine if a value is a FormData
  4358. *
  4359. * @param {Object} val The value to test
  4360. * @returns {boolean} True if value is an FormData, otherwise false
  4361. */
  4362. function isFormData(val) {
  4363. return toString.call(val) === '[object FormData]';
  4364. }
  4365. /**
  4366. * Determine if a value is a view on an ArrayBuffer
  4367. *
  4368. * @param {Object} val The value to test
  4369. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  4370. */
  4371. function isArrayBufferView(val) {
  4372. var result;
  4373. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  4374. result = ArrayBuffer.isView(val);
  4375. } else {
  4376. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  4377. }
  4378. return result;
  4379. }
  4380. /**
  4381. * Determine if a value is a String
  4382. *
  4383. * @param {Object} val The value to test
  4384. * @returns {boolean} True if value is a String, otherwise false
  4385. */
  4386. function isString(val) {
  4387. return typeof val === 'string';
  4388. }
  4389. /**
  4390. * Determine if a value is a Number
  4391. *
  4392. * @param {Object} val The value to test
  4393. * @returns {boolean} True if value is a Number, otherwise false
  4394. */
  4395. function isNumber(val) {
  4396. return typeof val === 'number';
  4397. }
  4398. /**
  4399. * Determine if a value is an Object
  4400. *
  4401. * @param {Object} val The value to test
  4402. * @returns {boolean} True if value is an Object, otherwise false
  4403. */
  4404. function isObject(val) {
  4405. return val !== null && typeof val === 'object';
  4406. }
  4407. /**
  4408. * Determine if a value is a plain Object
  4409. *
  4410. * @param {Object} val The value to test
  4411. * @return {boolean} True if value is a plain Object, otherwise false
  4412. */
  4413. function isPlainObject(val) {
  4414. if (toString.call(val) !== '[object Object]') {
  4415. return false;
  4416. }
  4417. var prototype = Object.getPrototypeOf(val);
  4418. return prototype === null || prototype === Object.prototype;
  4419. }
  4420. /**
  4421. * Determine if a value is a Date
  4422. *
  4423. * @param {Object} val The value to test
  4424. * @returns {boolean} True if value is a Date, otherwise false
  4425. */
  4426. function isDate(val) {
  4427. return toString.call(val) === '[object Date]';
  4428. }
  4429. /**
  4430. * Determine if a value is a File
  4431. *
  4432. * @param {Object} val The value to test
  4433. * @returns {boolean} True if value is a File, otherwise false
  4434. */
  4435. function isFile(val) {
  4436. return toString.call(val) === '[object File]';
  4437. }
  4438. /**
  4439. * Determine if a value is a Blob
  4440. *
  4441. * @param {Object} val The value to test
  4442. * @returns {boolean} True if value is a Blob, otherwise false
  4443. */
  4444. function isBlob(val) {
  4445. return toString.call(val) === '[object Blob]';
  4446. }
  4447. /**
  4448. * Determine if a value is a Function
  4449. *
  4450. * @param {Object} val The value to test
  4451. * @returns {boolean} True if value is a Function, otherwise false
  4452. */
  4453. function isFunction(val) {
  4454. return toString.call(val) === '[object Function]';
  4455. }
  4456. /**
  4457. * Determine if a value is a Stream
  4458. *
  4459. * @param {Object} val The value to test
  4460. * @returns {boolean} True if value is a Stream, otherwise false
  4461. */
  4462. function isStream(val) {
  4463. return isObject(val) && isFunction(val.pipe);
  4464. }
  4465. /**
  4466. * Determine if a value is a URLSearchParams object
  4467. *
  4468. * @param {Object} val The value to test
  4469. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  4470. */
  4471. function isURLSearchParams(val) {
  4472. return toString.call(val) === '[object URLSearchParams]';
  4473. }
  4474. /**
  4475. * Trim excess whitespace off the beginning and end of a string
  4476. *
  4477. * @param {String} str The String to trim
  4478. * @returns {String} The String freed of excess whitespace
  4479. */
  4480. function trim(str) {
  4481. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  4482. }
  4483. /**
  4484. * Determine if we're running in a standard browser environment
  4485. *
  4486. * This allows axios to run in a web worker, and react-native.
  4487. * Both environments support XMLHttpRequest, but not fully standard globals.
  4488. *
  4489. * web workers:
  4490. * typeof window -> undefined
  4491. * typeof document -> undefined
  4492. *
  4493. * react-native:
  4494. * navigator.product -> 'ReactNative'
  4495. * nativescript
  4496. * navigator.product -> 'NativeScript' or 'NS'
  4497. */
  4498. function isStandardBrowserEnv() {
  4499. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  4500. navigator.product === 'NativeScript' ||
  4501. navigator.product === 'NS')) {
  4502. return false;
  4503. }
  4504. return (
  4505. typeof window !== 'undefined' &&
  4506. typeof document !== 'undefined'
  4507. );
  4508. }
  4509. /**
  4510. * Iterate over an Array or an Object invoking a function for each item.
  4511. *
  4512. * If `obj` is an Array callback will be called passing
  4513. * the value, index, and complete array for each item.
  4514. *
  4515. * If 'obj' is an Object callback will be called passing
  4516. * the value, key, and complete object for each property.
  4517. *
  4518. * @param {Object|Array} obj The object to iterate
  4519. * @param {Function} fn The callback to invoke for each item
  4520. */
  4521. function forEach(obj, fn) {
  4522. // Don't bother if no value provided
  4523. if (obj === null || typeof obj === 'undefined') {
  4524. return;
  4525. }
  4526. // Force an array if not already something iterable
  4527. if (typeof obj !== 'object') {
  4528. /*eslint no-param-reassign:0*/
  4529. obj = [obj];
  4530. }
  4531. if (isArray(obj)) {
  4532. // Iterate over array values
  4533. for (var i = 0, l = obj.length; i < l; i++) {
  4534. fn.call(null, obj[i], i, obj);
  4535. }
  4536. } else {
  4537. // Iterate over object keys
  4538. for (var key in obj) {
  4539. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  4540. fn.call(null, obj[key], key, obj);
  4541. }
  4542. }
  4543. }
  4544. }
  4545. /**
  4546. * Accepts varargs expecting each argument to be an object, then
  4547. * immutably merges the properties of each object and returns result.
  4548. *
  4549. * When multiple objects contain the same key the later object in
  4550. * the arguments list will take precedence.
  4551. *
  4552. * Example:
  4553. *
  4554. * ```js
  4555. * var result = merge({foo: 123}, {foo: 456});
  4556. * console.log(result.foo); // outputs 456
  4557. * ```
  4558. *
  4559. * @param {Object} obj1 Object to merge
  4560. * @returns {Object} Result of all merge properties
  4561. */
  4562. function merge(/* obj1, obj2, obj3, ... */) {
  4563. var result = {};
  4564. function assignValue(val, key) {
  4565. if (isPlainObject(result[key]) && isPlainObject(val)) {
  4566. result[key] = merge(result[key], val);
  4567. } else if (isPlainObject(val)) {
  4568. result[key] = merge({}, val);
  4569. } else if (isArray(val)) {
  4570. result[key] = val.slice();
  4571. } else {
  4572. result[key] = val;
  4573. }
  4574. }
  4575. for (var i = 0, l = arguments.length; i < l; i++) {
  4576. forEach(arguments[i], assignValue);
  4577. }
  4578. return result;
  4579. }
  4580. /**
  4581. * Extends object a by mutably adding to it the properties of object b.
  4582. *
  4583. * @param {Object} a The object to be extended
  4584. * @param {Object} b The object to copy properties from
  4585. * @param {Object} thisArg The object to bind function to
  4586. * @return {Object} The resulting value of object a
  4587. */
  4588. function extend(a, b, thisArg) {
  4589. forEach(b, function assignValue(val, key) {
  4590. if (thisArg && typeof val === 'function') {
  4591. a[key] = bind(val, thisArg);
  4592. } else {
  4593. a[key] = val;
  4594. }
  4595. });
  4596. return a;
  4597. }
  4598. /**
  4599. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  4600. *
  4601. * @param {string} content with BOM
  4602. * @return {string} content value without BOM
  4603. */
  4604. function stripBOM(content) {
  4605. if (content.charCodeAt(0) === 0xFEFF) {
  4606. content = content.slice(1);
  4607. }
  4608. return content;
  4609. }
  4610. module.exports = {
  4611. isArray: isArray,
  4612. isArrayBuffer: isArrayBuffer,
  4613. isBuffer: isBuffer,
  4614. isFormData: isFormData,
  4615. isArrayBufferView: isArrayBufferView,
  4616. isString: isString,
  4617. isNumber: isNumber,
  4618. isObject: isObject,
  4619. isPlainObject: isPlainObject,
  4620. isUndefined: isUndefined,
  4621. isDate: isDate,
  4622. isFile: isFile,
  4623. isBlob: isBlob,
  4624. isFunction: isFunction,
  4625. isStream: isStream,
  4626. isURLSearchParams: isURLSearchParams,
  4627. isStandardBrowserEnv: isStandardBrowserEnv,
  4628. forEach: forEach,
  4629. merge: merge,
  4630. extend: extend,
  4631. trim: trim,
  4632. stripBOM: stripBOM
  4633. };
  4634. /***/ }),
  4635. /***/ "./resources/js/app.js":
  4636. /*!*****************************!*\
  4637. !*** ./resources/js/app.js ***!
  4638. \*****************************/
  4639. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4640. "use strict";
  4641. __webpack_require__.r(__webpack_exports__);
  4642. /* harmony import */ var alpinejs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/module.esm.js");
  4643. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  4644. window.Alpine = alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"];
  4645. alpinejs__WEBPACK_IMPORTED_MODULE_0__["default"].start();
  4646. /***/ }),
  4647. /***/ "./resources/js/bootstrap.js":
  4648. /*!***********************************!*\
  4649. !*** ./resources/js/bootstrap.js ***!
  4650. \***********************************/
  4651. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  4652. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  4653. /**
  4654. * We'll load the axios HTTP library which allows us to easily issue requests
  4655. * to our Laravel back-end. This library automatically handles sending the
  4656. * CSRF token as a header based on the value of the "XSRF" token cookie.
  4657. */
  4658. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  4659. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  4660. /**
  4661. * Echo exposes an expressive API for subscribing to channels and listening
  4662. * for events that are broadcast by Laravel. Echo and event broadcasting
  4663. * allows your team to easily build robust real-time web applications.
  4664. */
  4665. // import Echo from 'laravel-echo';
  4666. // window.Pusher = require('pusher-js');
  4667. // window.Echo = new Echo({
  4668. // broadcaster: 'pusher',
  4669. // key: process.env.MIX_PUSHER_APP_KEY,
  4670. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  4671. // forceTLS: true
  4672. // });
  4673. /***/ }),
  4674. /***/ "./node_modules/lodash/lodash.js":
  4675. /*!***************************************!*\
  4676. !*** ./node_modules/lodash/lodash.js ***!
  4677. \***************************************/
  4678. /***/ (function(module, exports, __webpack_require__) {
  4679. /* module decorator */ module = __webpack_require__.nmd(module);
  4680. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  4681. * @license
  4682. * Lodash <https://lodash.com/>
  4683. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  4684. * Released under MIT license <https://lodash.com/license>
  4685. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4686. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4687. */
  4688. ;(function() {
  4689. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  4690. var undefined;
  4691. /** Used as the semantic version number. */
  4692. var VERSION = '4.17.21';
  4693. /** Used as the size to enable large array optimizations. */
  4694. var LARGE_ARRAY_SIZE = 200;
  4695. /** Error message constants. */
  4696. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  4697. FUNC_ERROR_TEXT = 'Expected a function',
  4698. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  4699. /** Used to stand-in for `undefined` hash values. */
  4700. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  4701. /** Used as the maximum memoize cache size. */
  4702. var MAX_MEMOIZE_SIZE = 500;
  4703. /** Used as the internal argument placeholder. */
  4704. var PLACEHOLDER = '__lodash_placeholder__';
  4705. /** Used to compose bitmasks for cloning. */
  4706. var CLONE_DEEP_FLAG = 1,
  4707. CLONE_FLAT_FLAG = 2,
  4708. CLONE_SYMBOLS_FLAG = 4;
  4709. /** Used to compose bitmasks for value comparisons. */
  4710. var COMPARE_PARTIAL_FLAG = 1,
  4711. COMPARE_UNORDERED_FLAG = 2;
  4712. /** Used to compose bitmasks for function metadata. */
  4713. var WRAP_BIND_FLAG = 1,
  4714. WRAP_BIND_KEY_FLAG = 2,
  4715. WRAP_CURRY_BOUND_FLAG = 4,
  4716. WRAP_CURRY_FLAG = 8,
  4717. WRAP_CURRY_RIGHT_FLAG = 16,
  4718. WRAP_PARTIAL_FLAG = 32,
  4719. WRAP_PARTIAL_RIGHT_FLAG = 64,
  4720. WRAP_ARY_FLAG = 128,
  4721. WRAP_REARG_FLAG = 256,
  4722. WRAP_FLIP_FLAG = 512;
  4723. /** Used as default options for `_.truncate`. */
  4724. var DEFAULT_TRUNC_LENGTH = 30,
  4725. DEFAULT_TRUNC_OMISSION = '...';
  4726. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  4727. var HOT_COUNT = 800,
  4728. HOT_SPAN = 16;
  4729. /** Used to indicate the type of lazy iteratees. */
  4730. var LAZY_FILTER_FLAG = 1,
  4731. LAZY_MAP_FLAG = 2,
  4732. LAZY_WHILE_FLAG = 3;
  4733. /** Used as references for various `Number` constants. */
  4734. var INFINITY = 1 / 0,
  4735. MAX_SAFE_INTEGER = 9007199254740991,
  4736. MAX_INTEGER = 1.7976931348623157e+308,
  4737. NAN = 0 / 0;
  4738. /** Used as references for the maximum length and index of an array. */
  4739. var MAX_ARRAY_LENGTH = 4294967295,
  4740. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  4741. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  4742. /** Used to associate wrap methods with their bit flags. */
  4743. var wrapFlags = [
  4744. ['ary', WRAP_ARY_FLAG],
  4745. ['bind', WRAP_BIND_FLAG],
  4746. ['bindKey', WRAP_BIND_KEY_FLAG],
  4747. ['curry', WRAP_CURRY_FLAG],
  4748. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  4749. ['flip', WRAP_FLIP_FLAG],
  4750. ['partial', WRAP_PARTIAL_FLAG],
  4751. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  4752. ['rearg', WRAP_REARG_FLAG]
  4753. ];
  4754. /** `Object#toString` result references. */
  4755. var argsTag = '[object Arguments]',
  4756. arrayTag = '[object Array]',
  4757. asyncTag = '[object AsyncFunction]',
  4758. boolTag = '[object Boolean]',
  4759. dateTag = '[object Date]',
  4760. domExcTag = '[object DOMException]',
  4761. errorTag = '[object Error]',
  4762. funcTag = '[object Function]',
  4763. genTag = '[object GeneratorFunction]',
  4764. mapTag = '[object Map]',
  4765. numberTag = '[object Number]',
  4766. nullTag = '[object Null]',
  4767. objectTag = '[object Object]',
  4768. promiseTag = '[object Promise]',
  4769. proxyTag = '[object Proxy]',
  4770. regexpTag = '[object RegExp]',
  4771. setTag = '[object Set]',
  4772. stringTag = '[object String]',
  4773. symbolTag = '[object Symbol]',
  4774. undefinedTag = '[object Undefined]',
  4775. weakMapTag = '[object WeakMap]',
  4776. weakSetTag = '[object WeakSet]';
  4777. var arrayBufferTag = '[object ArrayBuffer]',
  4778. dataViewTag = '[object DataView]',
  4779. float32Tag = '[object Float32Array]',
  4780. float64Tag = '[object Float64Array]',
  4781. int8Tag = '[object Int8Array]',
  4782. int16Tag = '[object Int16Array]',
  4783. int32Tag = '[object Int32Array]',
  4784. uint8Tag = '[object Uint8Array]',
  4785. uint8ClampedTag = '[object Uint8ClampedArray]',
  4786. uint16Tag = '[object Uint16Array]',
  4787. uint32Tag = '[object Uint32Array]';
  4788. /** Used to match empty string literals in compiled template source. */
  4789. var reEmptyStringLeading = /\b__p \+= '';/g,
  4790. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  4791. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  4792. /** Used to match HTML entities and HTML characters. */
  4793. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  4794. reUnescapedHtml = /[&<>"']/g,
  4795. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  4796. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  4797. /** Used to match template delimiters. */
  4798. var reEscape = /<%-([\s\S]+?)%>/g,
  4799. reEvaluate = /<%([\s\S]+?)%>/g,
  4800. reInterpolate = /<%=([\s\S]+?)%>/g;
  4801. /** Used to match property names within property paths. */
  4802. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  4803. reIsPlainProp = /^\w*$/,
  4804. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  4805. /**
  4806. * Used to match `RegExp`
  4807. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  4808. */
  4809. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  4810. reHasRegExpChar = RegExp(reRegExpChar.source);
  4811. /** Used to match leading whitespace. */
  4812. var reTrimStart = /^\s+/;
  4813. /** Used to match a single whitespace character. */
  4814. var reWhitespace = /\s/;
  4815. /** Used to match wrap detail comments. */
  4816. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  4817. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  4818. reSplitDetails = /,? & /;
  4819. /** Used to match words composed of alphanumeric characters. */
  4820. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  4821. /**
  4822. * Used to validate the `validate` option in `_.template` variable.
  4823. *
  4824. * Forbids characters which could potentially change the meaning of the function argument definition:
  4825. * - "()," (modification of function parameters)
  4826. * - "=" (default value)
  4827. * - "[]{}" (destructuring of function parameters)
  4828. * - "/" (beginning of a comment)
  4829. * - whitespace
  4830. */
  4831. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  4832. /** Used to match backslashes in property paths. */
  4833. var reEscapeChar = /\\(\\)?/g;
  4834. /**
  4835. * Used to match
  4836. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  4837. */
  4838. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  4839. /** Used to match `RegExp` flags from their coerced string values. */
  4840. var reFlags = /\w*$/;
  4841. /** Used to detect bad signed hexadecimal string values. */
  4842. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  4843. /** Used to detect binary string values. */
  4844. var reIsBinary = /^0b[01]+$/i;
  4845. /** Used to detect host constructors (Safari). */
  4846. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  4847. /** Used to detect octal string values. */
  4848. var reIsOctal = /^0o[0-7]+$/i;
  4849. /** Used to detect unsigned integer values. */
  4850. var reIsUint = /^(?:0|[1-9]\d*)$/;
  4851. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  4852. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  4853. /** Used to ensure capturing order of template delimiters. */
  4854. var reNoMatch = /($^)/;
  4855. /** Used to match unescaped characters in compiled string literals. */
  4856. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  4857. /** Used to compose unicode character classes. */
  4858. var rsAstralRange = '\\ud800-\\udfff',
  4859. rsComboMarksRange = '\\u0300-\\u036f',
  4860. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  4861. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  4862. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  4863. rsDingbatRange = '\\u2700-\\u27bf',
  4864. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  4865. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  4866. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  4867. rsPunctuationRange = '\\u2000-\\u206f',
  4868. 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',
  4869. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  4870. rsVarRange = '\\ufe0e\\ufe0f',
  4871. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  4872. /** Used to compose unicode capture groups. */
  4873. var rsApos = "['\u2019]",
  4874. rsAstral = '[' + rsAstralRange + ']',
  4875. rsBreak = '[' + rsBreakRange + ']',
  4876. rsCombo = '[' + rsComboRange + ']',
  4877. rsDigits = '\\d+',
  4878. rsDingbat = '[' + rsDingbatRange + ']',
  4879. rsLower = '[' + rsLowerRange + ']',
  4880. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  4881. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  4882. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  4883. rsNonAstral = '[^' + rsAstralRange + ']',
  4884. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  4885. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  4886. rsUpper = '[' + rsUpperRange + ']',
  4887. rsZWJ = '\\u200d';
  4888. /** Used to compose unicode regexes. */
  4889. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  4890. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  4891. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  4892. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  4893. reOptMod = rsModifier + '?',
  4894. rsOptVar = '[' + rsVarRange + ']?',
  4895. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  4896. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  4897. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  4898. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  4899. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  4900. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  4901. /** Used to match apostrophes. */
  4902. var reApos = RegExp(rsApos, 'g');
  4903. /**
  4904. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  4905. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  4906. */
  4907. var reComboMark = RegExp(rsCombo, 'g');
  4908. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  4909. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  4910. /** Used to match complex or compound words. */
  4911. var reUnicodeWord = RegExp([
  4912. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  4913. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  4914. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  4915. rsUpper + '+' + rsOptContrUpper,
  4916. rsOrdUpper,
  4917. rsOrdLower,
  4918. rsDigits,
  4919. rsEmoji
  4920. ].join('|'), 'g');
  4921. /** 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/). */
  4922. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  4923. /** Used to detect strings that need a more robust regexp to match words. */
  4924. 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 ]/;
  4925. /** Used to assign default `context` object properties. */
  4926. var contextProps = [
  4927. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  4928. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  4929. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  4930. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  4931. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  4932. ];
  4933. /** Used to make template sourceURLs easier to identify. */
  4934. var templateCounter = -1;
  4935. /** Used to identify `toStringTag` values of typed arrays. */
  4936. var typedArrayTags = {};
  4937. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  4938. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  4939. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  4940. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  4941. typedArrayTags[uint32Tag] = true;
  4942. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  4943. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  4944. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  4945. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  4946. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  4947. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  4948. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  4949. typedArrayTags[weakMapTag] = false;
  4950. /** Used to identify `toStringTag` values supported by `_.clone`. */
  4951. var cloneableTags = {};
  4952. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  4953. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  4954. cloneableTags[boolTag] = cloneableTags[dateTag] =
  4955. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  4956. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  4957. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  4958. cloneableTags[numberTag] = cloneableTags[objectTag] =
  4959. cloneableTags[regexpTag] = cloneableTags[setTag] =
  4960. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  4961. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  4962. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  4963. cloneableTags[errorTag] = cloneableTags[funcTag] =
  4964. cloneableTags[weakMapTag] = false;
  4965. /** Used to map Latin Unicode letters to basic Latin letters. */
  4966. var deburredLetters = {
  4967. // Latin-1 Supplement block.
  4968. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  4969. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  4970. '\xc7': 'C', '\xe7': 'c',
  4971. '\xd0': 'D', '\xf0': 'd',
  4972. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  4973. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  4974. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  4975. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  4976. '\xd1': 'N', '\xf1': 'n',
  4977. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  4978. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  4979. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  4980. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  4981. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  4982. '\xc6': 'Ae', '\xe6': 'ae',
  4983. '\xde': 'Th', '\xfe': 'th',
  4984. '\xdf': 'ss',
  4985. // Latin Extended-A block.
  4986. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  4987. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  4988. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  4989. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  4990. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  4991. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  4992. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  4993. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  4994. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  4995. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  4996. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  4997. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  4998. '\u0134': 'J', '\u0135': 'j',
  4999. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  5000. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  5001. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  5002. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  5003. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  5004. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  5005. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  5006. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  5007. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  5008. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  5009. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  5010. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  5011. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  5012. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  5013. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  5014. '\u0174': 'W', '\u0175': 'w',
  5015. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  5016. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  5017. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  5018. '\u0132': 'IJ', '\u0133': 'ij',
  5019. '\u0152': 'Oe', '\u0153': 'oe',
  5020. '\u0149': "'n", '\u017f': 's'
  5021. };
  5022. /** Used to map characters to HTML entities. */
  5023. var htmlEscapes = {
  5024. '&': '&amp;',
  5025. '<': '&lt;',
  5026. '>': '&gt;',
  5027. '"': '&quot;',
  5028. "'": '&#39;'
  5029. };
  5030. /** Used to map HTML entities to characters. */
  5031. var htmlUnescapes = {
  5032. '&amp;': '&',
  5033. '&lt;': '<',
  5034. '&gt;': '>',
  5035. '&quot;': '"',
  5036. '&#39;': "'"
  5037. };
  5038. /** Used to escape characters for inclusion in compiled string literals. */
  5039. var stringEscapes = {
  5040. '\\': '\\',
  5041. "'": "'",
  5042. '\n': 'n',
  5043. '\r': 'r',
  5044. '\u2028': 'u2028',
  5045. '\u2029': 'u2029'
  5046. };
  5047. /** Built-in method references without a dependency on `root`. */
  5048. var freeParseFloat = parseFloat,
  5049. freeParseInt = parseInt;
  5050. /** Detect free variable `global` from Node.js. */
  5051. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  5052. /** Detect free variable `self`. */
  5053. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  5054. /** Used as a reference to the global object. */
  5055. var root = freeGlobal || freeSelf || Function('return this')();
  5056. /** Detect free variable `exports`. */
  5057. var freeExports = true && exports && !exports.nodeType && exports;
  5058. /** Detect free variable `module`. */
  5059. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  5060. /** Detect the popular CommonJS extension `module.exports`. */
  5061. var moduleExports = freeModule && freeModule.exports === freeExports;
  5062. /** Detect free variable `process` from Node.js. */
  5063. var freeProcess = moduleExports && freeGlobal.process;
  5064. /** Used to access faster Node.js helpers. */
  5065. var nodeUtil = (function() {
  5066. try {
  5067. // Use `util.types` for Node.js 10+.
  5068. var types = freeModule && freeModule.require && freeModule.require('util').types;
  5069. if (types) {
  5070. return types;
  5071. }
  5072. // Legacy `process.binding('util')` for Node.js < 10.
  5073. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  5074. } catch (e) {}
  5075. }());
  5076. /* Node.js helper references. */
  5077. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  5078. nodeIsDate = nodeUtil && nodeUtil.isDate,
  5079. nodeIsMap = nodeUtil && nodeUtil.isMap,
  5080. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  5081. nodeIsSet = nodeUtil && nodeUtil.isSet,
  5082. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  5083. /*--------------------------------------------------------------------------*/
  5084. /**
  5085. * A faster alternative to `Function#apply`, this function invokes `func`
  5086. * with the `this` binding of `thisArg` and the arguments of `args`.
  5087. *
  5088. * @private
  5089. * @param {Function} func The function to invoke.
  5090. * @param {*} thisArg The `this` binding of `func`.
  5091. * @param {Array} args The arguments to invoke `func` with.
  5092. * @returns {*} Returns the result of `func`.
  5093. */
  5094. function apply(func, thisArg, args) {
  5095. switch (args.length) {
  5096. case 0: return func.call(thisArg);
  5097. case 1: return func.call(thisArg, args[0]);
  5098. case 2: return func.call(thisArg, args[0], args[1]);
  5099. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  5100. }
  5101. return func.apply(thisArg, args);
  5102. }
  5103. /**
  5104. * A specialized version of `baseAggregator` for arrays.
  5105. *
  5106. * @private
  5107. * @param {Array} [array] The array to iterate over.
  5108. * @param {Function} setter The function to set `accumulator` values.
  5109. * @param {Function} iteratee The iteratee to transform keys.
  5110. * @param {Object} accumulator The initial aggregated object.
  5111. * @returns {Function} Returns `accumulator`.
  5112. */
  5113. function arrayAggregator(array, setter, iteratee, accumulator) {
  5114. var index = -1,
  5115. length = array == null ? 0 : array.length;
  5116. while (++index < length) {
  5117. var value = array[index];
  5118. setter(accumulator, value, iteratee(value), array);
  5119. }
  5120. return accumulator;
  5121. }
  5122. /**
  5123. * A specialized version of `_.forEach` for arrays without support for
  5124. * iteratee shorthands.
  5125. *
  5126. * @private
  5127. * @param {Array} [array] The array to iterate over.
  5128. * @param {Function} iteratee The function invoked per iteration.
  5129. * @returns {Array} Returns `array`.
  5130. */
  5131. function arrayEach(array, iteratee) {
  5132. var index = -1,
  5133. length = array == null ? 0 : array.length;
  5134. while (++index < length) {
  5135. if (iteratee(array[index], index, array) === false) {
  5136. break;
  5137. }
  5138. }
  5139. return array;
  5140. }
  5141. /**
  5142. * A specialized version of `_.forEachRight` for arrays without support for
  5143. * iteratee shorthands.
  5144. *
  5145. * @private
  5146. * @param {Array} [array] The array to iterate over.
  5147. * @param {Function} iteratee The function invoked per iteration.
  5148. * @returns {Array} Returns `array`.
  5149. */
  5150. function arrayEachRight(array, iteratee) {
  5151. var length = array == null ? 0 : array.length;
  5152. while (length--) {
  5153. if (iteratee(array[length], length, array) === false) {
  5154. break;
  5155. }
  5156. }
  5157. return array;
  5158. }
  5159. /**
  5160. * A specialized version of `_.every` for arrays without support for
  5161. * iteratee shorthands.
  5162. *
  5163. * @private
  5164. * @param {Array} [array] The array to iterate over.
  5165. * @param {Function} predicate The function invoked per iteration.
  5166. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  5167. * else `false`.
  5168. */
  5169. function arrayEvery(array, predicate) {
  5170. var index = -1,
  5171. length = array == null ? 0 : array.length;
  5172. while (++index < length) {
  5173. if (!predicate(array[index], index, array)) {
  5174. return false;
  5175. }
  5176. }
  5177. return true;
  5178. }
  5179. /**
  5180. * A specialized version of `_.filter` for arrays without support for
  5181. * iteratee shorthands.
  5182. *
  5183. * @private
  5184. * @param {Array} [array] The array to iterate over.
  5185. * @param {Function} predicate The function invoked per iteration.
  5186. * @returns {Array} Returns the new filtered array.
  5187. */
  5188. function arrayFilter(array, predicate) {
  5189. var index = -1,
  5190. length = array == null ? 0 : array.length,
  5191. resIndex = 0,
  5192. result = [];
  5193. while (++index < length) {
  5194. var value = array[index];
  5195. if (predicate(value, index, array)) {
  5196. result[resIndex++] = value;
  5197. }
  5198. }
  5199. return result;
  5200. }
  5201. /**
  5202. * A specialized version of `_.includes` for arrays without support for
  5203. * specifying an index to search from.
  5204. *
  5205. * @private
  5206. * @param {Array} [array] The array to inspect.
  5207. * @param {*} target The value to search for.
  5208. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  5209. */
  5210. function arrayIncludes(array, value) {
  5211. var length = array == null ? 0 : array.length;
  5212. return !!length && baseIndexOf(array, value, 0) > -1;
  5213. }
  5214. /**
  5215. * This function is like `arrayIncludes` except that it accepts a comparator.
  5216. *
  5217. * @private
  5218. * @param {Array} [array] The array to inspect.
  5219. * @param {*} target The value to search for.
  5220. * @param {Function} comparator The comparator invoked per element.
  5221. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  5222. */
  5223. function arrayIncludesWith(array, value, comparator) {
  5224. var index = -1,
  5225. length = array == null ? 0 : array.length;
  5226. while (++index < length) {
  5227. if (comparator(value, array[index])) {
  5228. return true;
  5229. }
  5230. }
  5231. return false;
  5232. }
  5233. /**
  5234. * A specialized version of `_.map` for arrays without support for iteratee
  5235. * shorthands.
  5236. *
  5237. * @private
  5238. * @param {Array} [array] The array to iterate over.
  5239. * @param {Function} iteratee The function invoked per iteration.
  5240. * @returns {Array} Returns the new mapped array.
  5241. */
  5242. function arrayMap(array, iteratee) {
  5243. var index = -1,
  5244. length = array == null ? 0 : array.length,
  5245. result = Array(length);
  5246. while (++index < length) {
  5247. result[index] = iteratee(array[index], index, array);
  5248. }
  5249. return result;
  5250. }
  5251. /**
  5252. * Appends the elements of `values` to `array`.
  5253. *
  5254. * @private
  5255. * @param {Array} array The array to modify.
  5256. * @param {Array} values The values to append.
  5257. * @returns {Array} Returns `array`.
  5258. */
  5259. function arrayPush(array, values) {
  5260. var index = -1,
  5261. length = values.length,
  5262. offset = array.length;
  5263. while (++index < length) {
  5264. array[offset + index] = values[index];
  5265. }
  5266. return array;
  5267. }
  5268. /**
  5269. * A specialized version of `_.reduce` for arrays without support for
  5270. * iteratee shorthands.
  5271. *
  5272. * @private
  5273. * @param {Array} [array] The array to iterate over.
  5274. * @param {Function} iteratee The function invoked per iteration.
  5275. * @param {*} [accumulator] The initial value.
  5276. * @param {boolean} [initAccum] Specify using the first element of `array` as
  5277. * the initial value.
  5278. * @returns {*} Returns the accumulated value.
  5279. */
  5280. function arrayReduce(array, iteratee, accumulator, initAccum) {
  5281. var index = -1,
  5282. length = array == null ? 0 : array.length;
  5283. if (initAccum && length) {
  5284. accumulator = array[++index];
  5285. }
  5286. while (++index < length) {
  5287. accumulator = iteratee(accumulator, array[index], index, array);
  5288. }
  5289. return accumulator;
  5290. }
  5291. /**
  5292. * A specialized version of `_.reduceRight` for arrays without support for
  5293. * iteratee shorthands.
  5294. *
  5295. * @private
  5296. * @param {Array} [array] The array to iterate over.
  5297. * @param {Function} iteratee The function invoked per iteration.
  5298. * @param {*} [accumulator] The initial value.
  5299. * @param {boolean} [initAccum] Specify using the last element of `array` as
  5300. * the initial value.
  5301. * @returns {*} Returns the accumulated value.
  5302. */
  5303. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  5304. var length = array == null ? 0 : array.length;
  5305. if (initAccum && length) {
  5306. accumulator = array[--length];
  5307. }
  5308. while (length--) {
  5309. accumulator = iteratee(accumulator, array[length], length, array);
  5310. }
  5311. return accumulator;
  5312. }
  5313. /**
  5314. * A specialized version of `_.some` for arrays without support for iteratee
  5315. * shorthands.
  5316. *
  5317. * @private
  5318. * @param {Array} [array] The array to iterate over.
  5319. * @param {Function} predicate The function invoked per iteration.
  5320. * @returns {boolean} Returns `true` if any element passes the predicate check,
  5321. * else `false`.
  5322. */
  5323. function arraySome(array, predicate) {
  5324. var index = -1,
  5325. length = array == null ? 0 : array.length;
  5326. while (++index < length) {
  5327. if (predicate(array[index], index, array)) {
  5328. return true;
  5329. }
  5330. }
  5331. return false;
  5332. }
  5333. /**
  5334. * Gets the size of an ASCII `string`.
  5335. *
  5336. * @private
  5337. * @param {string} string The string inspect.
  5338. * @returns {number} Returns the string size.
  5339. */
  5340. var asciiSize = baseProperty('length');
  5341. /**
  5342. * Converts an ASCII `string` to an array.
  5343. *
  5344. * @private
  5345. * @param {string} string The string to convert.
  5346. * @returns {Array} Returns the converted array.
  5347. */
  5348. function asciiToArray(string) {
  5349. return string.split('');
  5350. }
  5351. /**
  5352. * Splits an ASCII `string` into an array of its words.
  5353. *
  5354. * @private
  5355. * @param {string} The string to inspect.
  5356. * @returns {Array} Returns the words of `string`.
  5357. */
  5358. function asciiWords(string) {
  5359. return string.match(reAsciiWord) || [];
  5360. }
  5361. /**
  5362. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  5363. * without support for iteratee shorthands, which iterates over `collection`
  5364. * using `eachFunc`.
  5365. *
  5366. * @private
  5367. * @param {Array|Object} collection The collection to inspect.
  5368. * @param {Function} predicate The function invoked per iteration.
  5369. * @param {Function} eachFunc The function to iterate over `collection`.
  5370. * @returns {*} Returns the found element or its key, else `undefined`.
  5371. */
  5372. function baseFindKey(collection, predicate, eachFunc) {
  5373. var result;
  5374. eachFunc(collection, function(value, key, collection) {
  5375. if (predicate(value, key, collection)) {
  5376. result = key;
  5377. return false;
  5378. }
  5379. });
  5380. return result;
  5381. }
  5382. /**
  5383. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  5384. * support for iteratee shorthands.
  5385. *
  5386. * @private
  5387. * @param {Array} array The array to inspect.
  5388. * @param {Function} predicate The function invoked per iteration.
  5389. * @param {number} fromIndex The index to search from.
  5390. * @param {boolean} [fromRight] Specify iterating from right to left.
  5391. * @returns {number} Returns the index of the matched value, else `-1`.
  5392. */
  5393. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  5394. var length = array.length,
  5395. index = fromIndex + (fromRight ? 1 : -1);
  5396. while ((fromRight ? index-- : ++index < length)) {
  5397. if (predicate(array[index], index, array)) {
  5398. return index;
  5399. }
  5400. }
  5401. return -1;
  5402. }
  5403. /**
  5404. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  5405. *
  5406. * @private
  5407. * @param {Array} array The array to inspect.
  5408. * @param {*} value The value to search for.
  5409. * @param {number} fromIndex The index to search from.
  5410. * @returns {number} Returns the index of the matched value, else `-1`.
  5411. */
  5412. function baseIndexOf(array, value, fromIndex) {
  5413. return value === value
  5414. ? strictIndexOf(array, value, fromIndex)
  5415. : baseFindIndex(array, baseIsNaN, fromIndex);
  5416. }
  5417. /**
  5418. * This function is like `baseIndexOf` except that it accepts a comparator.
  5419. *
  5420. * @private
  5421. * @param {Array} array The array to inspect.
  5422. * @param {*} value The value to search for.
  5423. * @param {number} fromIndex The index to search from.
  5424. * @param {Function} comparator The comparator invoked per element.
  5425. * @returns {number} Returns the index of the matched value, else `-1`.
  5426. */
  5427. function baseIndexOfWith(array, value, fromIndex, comparator) {
  5428. var index = fromIndex - 1,
  5429. length = array.length;
  5430. while (++index < length) {
  5431. if (comparator(array[index], value)) {
  5432. return index;
  5433. }
  5434. }
  5435. return -1;
  5436. }
  5437. /**
  5438. * The base implementation of `_.isNaN` without support for number objects.
  5439. *
  5440. * @private
  5441. * @param {*} value The value to check.
  5442. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  5443. */
  5444. function baseIsNaN(value) {
  5445. return value !== value;
  5446. }
  5447. /**
  5448. * The base implementation of `_.mean` and `_.meanBy` without support for
  5449. * iteratee shorthands.
  5450. *
  5451. * @private
  5452. * @param {Array} array The array to iterate over.
  5453. * @param {Function} iteratee The function invoked per iteration.
  5454. * @returns {number} Returns the mean.
  5455. */
  5456. function baseMean(array, iteratee) {
  5457. var length = array == null ? 0 : array.length;
  5458. return length ? (baseSum(array, iteratee) / length) : NAN;
  5459. }
  5460. /**
  5461. * The base implementation of `_.property` without support for deep paths.
  5462. *
  5463. * @private
  5464. * @param {string} key The key of the property to get.
  5465. * @returns {Function} Returns the new accessor function.
  5466. */
  5467. function baseProperty(key) {
  5468. return function(object) {
  5469. return object == null ? undefined : object[key];
  5470. };
  5471. }
  5472. /**
  5473. * The base implementation of `_.propertyOf` without support for deep paths.
  5474. *
  5475. * @private
  5476. * @param {Object} object The object to query.
  5477. * @returns {Function} Returns the new accessor function.
  5478. */
  5479. function basePropertyOf(object) {
  5480. return function(key) {
  5481. return object == null ? undefined : object[key];
  5482. };
  5483. }
  5484. /**
  5485. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  5486. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  5487. *
  5488. * @private
  5489. * @param {Array|Object} collection The collection to iterate over.
  5490. * @param {Function} iteratee The function invoked per iteration.
  5491. * @param {*} accumulator The initial value.
  5492. * @param {boolean} initAccum Specify using the first or last element of
  5493. * `collection` as the initial value.
  5494. * @param {Function} eachFunc The function to iterate over `collection`.
  5495. * @returns {*} Returns the accumulated value.
  5496. */
  5497. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  5498. eachFunc(collection, function(value, index, collection) {
  5499. accumulator = initAccum
  5500. ? (initAccum = false, value)
  5501. : iteratee(accumulator, value, index, collection);
  5502. });
  5503. return accumulator;
  5504. }
  5505. /**
  5506. * The base implementation of `_.sortBy` which uses `comparer` to define the
  5507. * sort order of `array` and replaces criteria objects with their corresponding
  5508. * values.
  5509. *
  5510. * @private
  5511. * @param {Array} array The array to sort.
  5512. * @param {Function} comparer The function to define sort order.
  5513. * @returns {Array} Returns `array`.
  5514. */
  5515. function baseSortBy(array, comparer) {
  5516. var length = array.length;
  5517. array.sort(comparer);
  5518. while (length--) {
  5519. array[length] = array[length].value;
  5520. }
  5521. return array;
  5522. }
  5523. /**
  5524. * The base implementation of `_.sum` and `_.sumBy` without support for
  5525. * iteratee shorthands.
  5526. *
  5527. * @private
  5528. * @param {Array} array The array to iterate over.
  5529. * @param {Function} iteratee The function invoked per iteration.
  5530. * @returns {number} Returns the sum.
  5531. */
  5532. function baseSum(array, iteratee) {
  5533. var result,
  5534. index = -1,
  5535. length = array.length;
  5536. while (++index < length) {
  5537. var current = iteratee(array[index]);
  5538. if (current !== undefined) {
  5539. result = result === undefined ? current : (result + current);
  5540. }
  5541. }
  5542. return result;
  5543. }
  5544. /**
  5545. * The base implementation of `_.times` without support for iteratee shorthands
  5546. * or max array length checks.
  5547. *
  5548. * @private
  5549. * @param {number} n The number of times to invoke `iteratee`.
  5550. * @param {Function} iteratee The function invoked per iteration.
  5551. * @returns {Array} Returns the array of results.
  5552. */
  5553. function baseTimes(n, iteratee) {
  5554. var index = -1,
  5555. result = Array(n);
  5556. while (++index < n) {
  5557. result[index] = iteratee(index);
  5558. }
  5559. return result;
  5560. }
  5561. /**
  5562. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  5563. * of key-value pairs for `object` corresponding to the property names of `props`.
  5564. *
  5565. * @private
  5566. * @param {Object} object The object to query.
  5567. * @param {Array} props The property names to get values for.
  5568. * @returns {Object} Returns the key-value pairs.
  5569. */
  5570. function baseToPairs(object, props) {
  5571. return arrayMap(props, function(key) {
  5572. return [key, object[key]];
  5573. });
  5574. }
  5575. /**
  5576. * The base implementation of `_.trim`.
  5577. *
  5578. * @private
  5579. * @param {string} string The string to trim.
  5580. * @returns {string} Returns the trimmed string.
  5581. */
  5582. function baseTrim(string) {
  5583. return string
  5584. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  5585. : string;
  5586. }
  5587. /**
  5588. * The base implementation of `_.unary` without support for storing metadata.
  5589. *
  5590. * @private
  5591. * @param {Function} func The function to cap arguments for.
  5592. * @returns {Function} Returns the new capped function.
  5593. */
  5594. function baseUnary(func) {
  5595. return function(value) {
  5596. return func(value);
  5597. };
  5598. }
  5599. /**
  5600. * The base implementation of `_.values` and `_.valuesIn` which creates an
  5601. * array of `object` property values corresponding to the property names
  5602. * of `props`.
  5603. *
  5604. * @private
  5605. * @param {Object} object The object to query.
  5606. * @param {Array} props The property names to get values for.
  5607. * @returns {Object} Returns the array of property values.
  5608. */
  5609. function baseValues(object, props) {
  5610. return arrayMap(props, function(key) {
  5611. return object[key];
  5612. });
  5613. }
  5614. /**
  5615. * Checks if a `cache` value for `key` exists.
  5616. *
  5617. * @private
  5618. * @param {Object} cache The cache to query.
  5619. * @param {string} key The key of the entry to check.
  5620. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  5621. */
  5622. function cacheHas(cache, key) {
  5623. return cache.has(key);
  5624. }
  5625. /**
  5626. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  5627. * that is not found in the character symbols.
  5628. *
  5629. * @private
  5630. * @param {Array} strSymbols The string symbols to inspect.
  5631. * @param {Array} chrSymbols The character symbols to find.
  5632. * @returns {number} Returns the index of the first unmatched string symbol.
  5633. */
  5634. function charsStartIndex(strSymbols, chrSymbols) {
  5635. var index = -1,
  5636. length = strSymbols.length;
  5637. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  5638. return index;
  5639. }
  5640. /**
  5641. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  5642. * that is not found in the character symbols.
  5643. *
  5644. * @private
  5645. * @param {Array} strSymbols The string symbols to inspect.
  5646. * @param {Array} chrSymbols The character symbols to find.
  5647. * @returns {number} Returns the index of the last unmatched string symbol.
  5648. */
  5649. function charsEndIndex(strSymbols, chrSymbols) {
  5650. var index = strSymbols.length;
  5651. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  5652. return index;
  5653. }
  5654. /**
  5655. * Gets the number of `placeholder` occurrences in `array`.
  5656. *
  5657. * @private
  5658. * @param {Array} array The array to inspect.
  5659. * @param {*} placeholder The placeholder to search for.
  5660. * @returns {number} Returns the placeholder count.
  5661. */
  5662. function countHolders(array, placeholder) {
  5663. var length = array.length,
  5664. result = 0;
  5665. while (length--) {
  5666. if (array[length] === placeholder) {
  5667. ++result;
  5668. }
  5669. }
  5670. return result;
  5671. }
  5672. /**
  5673. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  5674. * letters to basic Latin letters.
  5675. *
  5676. * @private
  5677. * @param {string} letter The matched letter to deburr.
  5678. * @returns {string} Returns the deburred letter.
  5679. */
  5680. var deburrLetter = basePropertyOf(deburredLetters);
  5681. /**
  5682. * Used by `_.escape` to convert characters to HTML entities.
  5683. *
  5684. * @private
  5685. * @param {string} chr The matched character to escape.
  5686. * @returns {string} Returns the escaped character.
  5687. */
  5688. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  5689. /**
  5690. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  5691. *
  5692. * @private
  5693. * @param {string} chr The matched character to escape.
  5694. * @returns {string} Returns the escaped character.
  5695. */
  5696. function escapeStringChar(chr) {
  5697. return '\\' + stringEscapes[chr];
  5698. }
  5699. /**
  5700. * Gets the value at `key` of `object`.
  5701. *
  5702. * @private
  5703. * @param {Object} [object] The object to query.
  5704. * @param {string} key The key of the property to get.
  5705. * @returns {*} Returns the property value.
  5706. */
  5707. function getValue(object, key) {
  5708. return object == null ? undefined : object[key];
  5709. }
  5710. /**
  5711. * Checks if `string` contains Unicode symbols.
  5712. *
  5713. * @private
  5714. * @param {string} string The string to inspect.
  5715. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  5716. */
  5717. function hasUnicode(string) {
  5718. return reHasUnicode.test(string);
  5719. }
  5720. /**
  5721. * Checks if `string` contains a word composed of Unicode symbols.
  5722. *
  5723. * @private
  5724. * @param {string} string The string to inspect.
  5725. * @returns {boolean} Returns `true` if a word is found, else `false`.
  5726. */
  5727. function hasUnicodeWord(string) {
  5728. return reHasUnicodeWord.test(string);
  5729. }
  5730. /**
  5731. * Converts `iterator` to an array.
  5732. *
  5733. * @private
  5734. * @param {Object} iterator The iterator to convert.
  5735. * @returns {Array} Returns the converted array.
  5736. */
  5737. function iteratorToArray(iterator) {
  5738. var data,
  5739. result = [];
  5740. while (!(data = iterator.next()).done) {
  5741. result.push(data.value);
  5742. }
  5743. return result;
  5744. }
  5745. /**
  5746. * Converts `map` to its key-value pairs.
  5747. *
  5748. * @private
  5749. * @param {Object} map The map to convert.
  5750. * @returns {Array} Returns the key-value pairs.
  5751. */
  5752. function mapToArray(map) {
  5753. var index = -1,
  5754. result = Array(map.size);
  5755. map.forEach(function(value, key) {
  5756. result[++index] = [key, value];
  5757. });
  5758. return result;
  5759. }
  5760. /**
  5761. * Creates a unary function that invokes `func` with its argument transformed.
  5762. *
  5763. * @private
  5764. * @param {Function} func The function to wrap.
  5765. * @param {Function} transform The argument transform.
  5766. * @returns {Function} Returns the new function.
  5767. */
  5768. function overArg(func, transform) {
  5769. return function(arg) {
  5770. return func(transform(arg));
  5771. };
  5772. }
  5773. /**
  5774. * Replaces all `placeholder` elements in `array` with an internal placeholder
  5775. * and returns an array of their indexes.
  5776. *
  5777. * @private
  5778. * @param {Array} array The array to modify.
  5779. * @param {*} placeholder The placeholder to replace.
  5780. * @returns {Array} Returns the new array of placeholder indexes.
  5781. */
  5782. function replaceHolders(array, placeholder) {
  5783. var index = -1,
  5784. length = array.length,
  5785. resIndex = 0,
  5786. result = [];
  5787. while (++index < length) {
  5788. var value = array[index];
  5789. if (value === placeholder || value === PLACEHOLDER) {
  5790. array[index] = PLACEHOLDER;
  5791. result[resIndex++] = index;
  5792. }
  5793. }
  5794. return result;
  5795. }
  5796. /**
  5797. * Converts `set` to an array of its values.
  5798. *
  5799. * @private
  5800. * @param {Object} set The set to convert.
  5801. * @returns {Array} Returns the values.
  5802. */
  5803. function setToArray(set) {
  5804. var index = -1,
  5805. result = Array(set.size);
  5806. set.forEach(function(value) {
  5807. result[++index] = value;
  5808. });
  5809. return result;
  5810. }
  5811. /**
  5812. * Converts `set` to its value-value pairs.
  5813. *
  5814. * @private
  5815. * @param {Object} set The set to convert.
  5816. * @returns {Array} Returns the value-value pairs.
  5817. */
  5818. function setToPairs(set) {
  5819. var index = -1,
  5820. result = Array(set.size);
  5821. set.forEach(function(value) {
  5822. result[++index] = [value, value];
  5823. });
  5824. return result;
  5825. }
  5826. /**
  5827. * A specialized version of `_.indexOf` which performs strict equality
  5828. * comparisons of values, i.e. `===`.
  5829. *
  5830. * @private
  5831. * @param {Array} array The array to inspect.
  5832. * @param {*} value The value to search for.
  5833. * @param {number} fromIndex The index to search from.
  5834. * @returns {number} Returns the index of the matched value, else `-1`.
  5835. */
  5836. function strictIndexOf(array, value, fromIndex) {
  5837. var index = fromIndex - 1,
  5838. length = array.length;
  5839. while (++index < length) {
  5840. if (array[index] === value) {
  5841. return index;
  5842. }
  5843. }
  5844. return -1;
  5845. }
  5846. /**
  5847. * A specialized version of `_.lastIndexOf` which performs strict equality
  5848. * comparisons of values, i.e. `===`.
  5849. *
  5850. * @private
  5851. * @param {Array} array The array to inspect.
  5852. * @param {*} value The value to search for.
  5853. * @param {number} fromIndex The index to search from.
  5854. * @returns {number} Returns the index of the matched value, else `-1`.
  5855. */
  5856. function strictLastIndexOf(array, value, fromIndex) {
  5857. var index = fromIndex + 1;
  5858. while (index--) {
  5859. if (array[index] === value) {
  5860. return index;
  5861. }
  5862. }
  5863. return index;
  5864. }
  5865. /**
  5866. * Gets the number of symbols in `string`.
  5867. *
  5868. * @private
  5869. * @param {string} string The string to inspect.
  5870. * @returns {number} Returns the string size.
  5871. */
  5872. function stringSize(string) {
  5873. return hasUnicode(string)
  5874. ? unicodeSize(string)
  5875. : asciiSize(string);
  5876. }
  5877. /**
  5878. * Converts `string` to an array.
  5879. *
  5880. * @private
  5881. * @param {string} string The string to convert.
  5882. * @returns {Array} Returns the converted array.
  5883. */
  5884. function stringToArray(string) {
  5885. return hasUnicode(string)
  5886. ? unicodeToArray(string)
  5887. : asciiToArray(string);
  5888. }
  5889. /**
  5890. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  5891. * character of `string`.
  5892. *
  5893. * @private
  5894. * @param {string} string The string to inspect.
  5895. * @returns {number} Returns the index of the last non-whitespace character.
  5896. */
  5897. function trimmedEndIndex(string) {
  5898. var index = string.length;
  5899. while (index-- && reWhitespace.test(string.charAt(index))) {}
  5900. return index;
  5901. }
  5902. /**
  5903. * Used by `_.unescape` to convert HTML entities to characters.
  5904. *
  5905. * @private
  5906. * @param {string} chr The matched character to unescape.
  5907. * @returns {string} Returns the unescaped character.
  5908. */
  5909. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  5910. /**
  5911. * Gets the size of a Unicode `string`.
  5912. *
  5913. * @private
  5914. * @param {string} string The string inspect.
  5915. * @returns {number} Returns the string size.
  5916. */
  5917. function unicodeSize(string) {
  5918. var result = reUnicode.lastIndex = 0;
  5919. while (reUnicode.test(string)) {
  5920. ++result;
  5921. }
  5922. return result;
  5923. }
  5924. /**
  5925. * Converts a Unicode `string` to an array.
  5926. *
  5927. * @private
  5928. * @param {string} string The string to convert.
  5929. * @returns {Array} Returns the converted array.
  5930. */
  5931. function unicodeToArray(string) {
  5932. return string.match(reUnicode) || [];
  5933. }
  5934. /**
  5935. * Splits a Unicode `string` into an array of its words.
  5936. *
  5937. * @private
  5938. * @param {string} The string to inspect.
  5939. * @returns {Array} Returns the words of `string`.
  5940. */
  5941. function unicodeWords(string) {
  5942. return string.match(reUnicodeWord) || [];
  5943. }
  5944. /*--------------------------------------------------------------------------*/
  5945. /**
  5946. * Create a new pristine `lodash` function using the `context` object.
  5947. *
  5948. * @static
  5949. * @memberOf _
  5950. * @since 1.1.0
  5951. * @category Util
  5952. * @param {Object} [context=root] The context object.
  5953. * @returns {Function} Returns a new `lodash` function.
  5954. * @example
  5955. *
  5956. * _.mixin({ 'foo': _.constant('foo') });
  5957. *
  5958. * var lodash = _.runInContext();
  5959. * lodash.mixin({ 'bar': lodash.constant('bar') });
  5960. *
  5961. * _.isFunction(_.foo);
  5962. * // => true
  5963. * _.isFunction(_.bar);
  5964. * // => false
  5965. *
  5966. * lodash.isFunction(lodash.foo);
  5967. * // => false
  5968. * lodash.isFunction(lodash.bar);
  5969. * // => true
  5970. *
  5971. * // Create a suped-up `defer` in Node.js.
  5972. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  5973. */
  5974. var runInContext = (function runInContext(context) {
  5975. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  5976. /** Built-in constructor references. */
  5977. var Array = context.Array,
  5978. Date = context.Date,
  5979. Error = context.Error,
  5980. Function = context.Function,
  5981. Math = context.Math,
  5982. Object = context.Object,
  5983. RegExp = context.RegExp,
  5984. String = context.String,
  5985. TypeError = context.TypeError;
  5986. /** Used for built-in method references. */
  5987. var arrayProto = Array.prototype,
  5988. funcProto = Function.prototype,
  5989. objectProto = Object.prototype;
  5990. /** Used to detect overreaching core-js shims. */
  5991. var coreJsData = context['__core-js_shared__'];
  5992. /** Used to resolve the decompiled source of functions. */
  5993. var funcToString = funcProto.toString;
  5994. /** Used to check objects for own properties. */
  5995. var hasOwnProperty = objectProto.hasOwnProperty;
  5996. /** Used to generate unique IDs. */
  5997. var idCounter = 0;
  5998. /** Used to detect methods masquerading as native. */
  5999. var maskSrcKey = (function() {
  6000. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  6001. return uid ? ('Symbol(src)_1.' + uid) : '';
  6002. }());
  6003. /**
  6004. * Used to resolve the
  6005. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  6006. * of values.
  6007. */
  6008. var nativeObjectToString = objectProto.toString;
  6009. /** Used to infer the `Object` constructor. */
  6010. var objectCtorString = funcToString.call(Object);
  6011. /** Used to restore the original `_` reference in `_.noConflict`. */
  6012. var oldDash = root._;
  6013. /** Used to detect if a method is native. */
  6014. var reIsNative = RegExp('^' +
  6015. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  6016. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  6017. );
  6018. /** Built-in value references. */
  6019. var Buffer = moduleExports ? context.Buffer : undefined,
  6020. Symbol = context.Symbol,
  6021. Uint8Array = context.Uint8Array,
  6022. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  6023. getPrototype = overArg(Object.getPrototypeOf, Object),
  6024. objectCreate = Object.create,
  6025. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  6026. splice = arrayProto.splice,
  6027. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  6028. symIterator = Symbol ? Symbol.iterator : undefined,
  6029. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  6030. var defineProperty = (function() {
  6031. try {
  6032. var func = getNative(Object, 'defineProperty');
  6033. func({}, '', {});
  6034. return func;
  6035. } catch (e) {}
  6036. }());
  6037. /** Mocked built-ins. */
  6038. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  6039. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  6040. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  6041. /* Built-in method references for those with the same name as other `lodash` methods. */
  6042. var nativeCeil = Math.ceil,
  6043. nativeFloor = Math.floor,
  6044. nativeGetSymbols = Object.getOwnPropertySymbols,
  6045. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  6046. nativeIsFinite = context.isFinite,
  6047. nativeJoin = arrayProto.join,
  6048. nativeKeys = overArg(Object.keys, Object),
  6049. nativeMax = Math.max,
  6050. nativeMin = Math.min,
  6051. nativeNow = Date.now,
  6052. nativeParseInt = context.parseInt,
  6053. nativeRandom = Math.random,
  6054. nativeReverse = arrayProto.reverse;
  6055. /* Built-in method references that are verified to be native. */
  6056. var DataView = getNative(context, 'DataView'),
  6057. Map = getNative(context, 'Map'),
  6058. Promise = getNative(context, 'Promise'),
  6059. Set = getNative(context, 'Set'),
  6060. WeakMap = getNative(context, 'WeakMap'),
  6061. nativeCreate = getNative(Object, 'create');
  6062. /** Used to store function metadata. */
  6063. var metaMap = WeakMap && new WeakMap;
  6064. /** Used to lookup unminified function names. */
  6065. var realNames = {};
  6066. /** Used to detect maps, sets, and weakmaps. */
  6067. var dataViewCtorString = toSource(DataView),
  6068. mapCtorString = toSource(Map),
  6069. promiseCtorString = toSource(Promise),
  6070. setCtorString = toSource(Set),
  6071. weakMapCtorString = toSource(WeakMap);
  6072. /** Used to convert symbols to primitives and strings. */
  6073. var symbolProto = Symbol ? Symbol.prototype : undefined,
  6074. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  6075. symbolToString = symbolProto ? symbolProto.toString : undefined;
  6076. /*------------------------------------------------------------------------*/
  6077. /**
  6078. * Creates a `lodash` object which wraps `value` to enable implicit method
  6079. * chain sequences. Methods that operate on and return arrays, collections,
  6080. * and functions can be chained together. Methods that retrieve a single value
  6081. * or may return a primitive value will automatically end the chain sequence
  6082. * and return the unwrapped value. Otherwise, the value must be unwrapped
  6083. * with `_#value`.
  6084. *
  6085. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  6086. * enabled using `_.chain`.
  6087. *
  6088. * The execution of chained methods is lazy, that is, it's deferred until
  6089. * `_#value` is implicitly or explicitly called.
  6090. *
  6091. * Lazy evaluation allows several methods to support shortcut fusion.
  6092. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  6093. * the creation of intermediate arrays and can greatly reduce the number of
  6094. * iteratee executions. Sections of a chain sequence qualify for shortcut
  6095. * fusion if the section is applied to an array and iteratees accept only
  6096. * one argument. The heuristic for whether a section qualifies for shortcut
  6097. * fusion is subject to change.
  6098. *
  6099. * Chaining is supported in custom builds as long as the `_#value` method is
  6100. * directly or indirectly included in the build.
  6101. *
  6102. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  6103. *
  6104. * The wrapper `Array` methods are:
  6105. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  6106. *
  6107. * The wrapper `String` methods are:
  6108. * `replace` and `split`
  6109. *
  6110. * The wrapper methods that support shortcut fusion are:
  6111. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  6112. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  6113. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  6114. *
  6115. * The chainable wrapper methods are:
  6116. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  6117. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  6118. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  6119. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  6120. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  6121. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  6122. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  6123. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  6124. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  6125. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  6126. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  6127. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  6128. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  6129. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  6130. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  6131. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  6132. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  6133. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  6134. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  6135. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  6136. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  6137. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  6138. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  6139. * `zipObject`, `zipObjectDeep`, and `zipWith`
  6140. *
  6141. * The wrapper methods that are **not** chainable by default are:
  6142. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  6143. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  6144. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  6145. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  6146. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  6147. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  6148. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  6149. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  6150. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  6151. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  6152. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  6153. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  6154. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  6155. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  6156. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  6157. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  6158. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  6159. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  6160. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  6161. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  6162. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  6163. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  6164. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  6165. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  6166. * `upperFirst`, `value`, and `words`
  6167. *
  6168. * @name _
  6169. * @constructor
  6170. * @category Seq
  6171. * @param {*} value The value to wrap in a `lodash` instance.
  6172. * @returns {Object} Returns the new `lodash` wrapper instance.
  6173. * @example
  6174. *
  6175. * function square(n) {
  6176. * return n * n;
  6177. * }
  6178. *
  6179. * var wrapped = _([1, 2, 3]);
  6180. *
  6181. * // Returns an unwrapped value.
  6182. * wrapped.reduce(_.add);
  6183. * // => 6
  6184. *
  6185. * // Returns a wrapped value.
  6186. * var squares = wrapped.map(square);
  6187. *
  6188. * _.isArray(squares);
  6189. * // => false
  6190. *
  6191. * _.isArray(squares.value());
  6192. * // => true
  6193. */
  6194. function lodash(value) {
  6195. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  6196. if (value instanceof LodashWrapper) {
  6197. return value;
  6198. }
  6199. if (hasOwnProperty.call(value, '__wrapped__')) {
  6200. return wrapperClone(value);
  6201. }
  6202. }
  6203. return new LodashWrapper(value);
  6204. }
  6205. /**
  6206. * The base implementation of `_.create` without support for assigning
  6207. * properties to the created object.
  6208. *
  6209. * @private
  6210. * @param {Object} proto The object to inherit from.
  6211. * @returns {Object} Returns the new object.
  6212. */
  6213. var baseCreate = (function() {
  6214. function object() {}
  6215. return function(proto) {
  6216. if (!isObject(proto)) {
  6217. return {};
  6218. }
  6219. if (objectCreate) {
  6220. return objectCreate(proto);
  6221. }
  6222. object.prototype = proto;
  6223. var result = new object;
  6224. object.prototype = undefined;
  6225. return result;
  6226. };
  6227. }());
  6228. /**
  6229. * The function whose prototype chain sequence wrappers inherit from.
  6230. *
  6231. * @private
  6232. */
  6233. function baseLodash() {
  6234. // No operation performed.
  6235. }
  6236. /**
  6237. * The base constructor for creating `lodash` wrapper objects.
  6238. *
  6239. * @private
  6240. * @param {*} value The value to wrap.
  6241. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  6242. */
  6243. function LodashWrapper(value, chainAll) {
  6244. this.__wrapped__ = value;
  6245. this.__actions__ = [];
  6246. this.__chain__ = !!chainAll;
  6247. this.__index__ = 0;
  6248. this.__values__ = undefined;
  6249. }
  6250. /**
  6251. * By default, the template delimiters used by lodash are like those in
  6252. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  6253. * following template settings to use alternative delimiters.
  6254. *
  6255. * @static
  6256. * @memberOf _
  6257. * @type {Object}
  6258. */
  6259. lodash.templateSettings = {
  6260. /**
  6261. * Used to detect `data` property values to be HTML-escaped.
  6262. *
  6263. * @memberOf _.templateSettings
  6264. * @type {RegExp}
  6265. */
  6266. 'escape': reEscape,
  6267. /**
  6268. * Used to detect code to be evaluated.
  6269. *
  6270. * @memberOf _.templateSettings
  6271. * @type {RegExp}
  6272. */
  6273. 'evaluate': reEvaluate,
  6274. /**
  6275. * Used to detect `data` property values to inject.
  6276. *
  6277. * @memberOf _.templateSettings
  6278. * @type {RegExp}
  6279. */
  6280. 'interpolate': reInterpolate,
  6281. /**
  6282. * Used to reference the data object in the template text.
  6283. *
  6284. * @memberOf _.templateSettings
  6285. * @type {string}
  6286. */
  6287. 'variable': '',
  6288. /**
  6289. * Used to import variables into the compiled template.
  6290. *
  6291. * @memberOf _.templateSettings
  6292. * @type {Object}
  6293. */
  6294. 'imports': {
  6295. /**
  6296. * A reference to the `lodash` function.
  6297. *
  6298. * @memberOf _.templateSettings.imports
  6299. * @type {Function}
  6300. */
  6301. '_': lodash
  6302. }
  6303. };
  6304. // Ensure wrappers are instances of `baseLodash`.
  6305. lodash.prototype = baseLodash.prototype;
  6306. lodash.prototype.constructor = lodash;
  6307. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  6308. LodashWrapper.prototype.constructor = LodashWrapper;
  6309. /*------------------------------------------------------------------------*/
  6310. /**
  6311. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  6312. *
  6313. * @private
  6314. * @constructor
  6315. * @param {*} value The value to wrap.
  6316. */
  6317. function LazyWrapper(value) {
  6318. this.__wrapped__ = value;
  6319. this.__actions__ = [];
  6320. this.__dir__ = 1;
  6321. this.__filtered__ = false;
  6322. this.__iteratees__ = [];
  6323. this.__takeCount__ = MAX_ARRAY_LENGTH;
  6324. this.__views__ = [];
  6325. }
  6326. /**
  6327. * Creates a clone of the lazy wrapper object.
  6328. *
  6329. * @private
  6330. * @name clone
  6331. * @memberOf LazyWrapper
  6332. * @returns {Object} Returns the cloned `LazyWrapper` object.
  6333. */
  6334. function lazyClone() {
  6335. var result = new LazyWrapper(this.__wrapped__);
  6336. result.__actions__ = copyArray(this.__actions__);
  6337. result.__dir__ = this.__dir__;
  6338. result.__filtered__ = this.__filtered__;
  6339. result.__iteratees__ = copyArray(this.__iteratees__);
  6340. result.__takeCount__ = this.__takeCount__;
  6341. result.__views__ = copyArray(this.__views__);
  6342. return result;
  6343. }
  6344. /**
  6345. * Reverses the direction of lazy iteration.
  6346. *
  6347. * @private
  6348. * @name reverse
  6349. * @memberOf LazyWrapper
  6350. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  6351. */
  6352. function lazyReverse() {
  6353. if (this.__filtered__) {
  6354. var result = new LazyWrapper(this);
  6355. result.__dir__ = -1;
  6356. result.__filtered__ = true;
  6357. } else {
  6358. result = this.clone();
  6359. result.__dir__ *= -1;
  6360. }
  6361. return result;
  6362. }
  6363. /**
  6364. * Extracts the unwrapped value from its lazy wrapper.
  6365. *
  6366. * @private
  6367. * @name value
  6368. * @memberOf LazyWrapper
  6369. * @returns {*} Returns the unwrapped value.
  6370. */
  6371. function lazyValue() {
  6372. var array = this.__wrapped__.value(),
  6373. dir = this.__dir__,
  6374. isArr = isArray(array),
  6375. isRight = dir < 0,
  6376. arrLength = isArr ? array.length : 0,
  6377. view = getView(0, arrLength, this.__views__),
  6378. start = view.start,
  6379. end = view.end,
  6380. length = end - start,
  6381. index = isRight ? end : (start - 1),
  6382. iteratees = this.__iteratees__,
  6383. iterLength = iteratees.length,
  6384. resIndex = 0,
  6385. takeCount = nativeMin(length, this.__takeCount__);
  6386. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  6387. return baseWrapperValue(array, this.__actions__);
  6388. }
  6389. var result = [];
  6390. outer:
  6391. while (length-- && resIndex < takeCount) {
  6392. index += dir;
  6393. var iterIndex = -1,
  6394. value = array[index];
  6395. while (++iterIndex < iterLength) {
  6396. var data = iteratees[iterIndex],
  6397. iteratee = data.iteratee,
  6398. type = data.type,
  6399. computed = iteratee(value);
  6400. if (type == LAZY_MAP_FLAG) {
  6401. value = computed;
  6402. } else if (!computed) {
  6403. if (type == LAZY_FILTER_FLAG) {
  6404. continue outer;
  6405. } else {
  6406. break outer;
  6407. }
  6408. }
  6409. }
  6410. result[resIndex++] = value;
  6411. }
  6412. return result;
  6413. }
  6414. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  6415. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  6416. LazyWrapper.prototype.constructor = LazyWrapper;
  6417. /*------------------------------------------------------------------------*/
  6418. /**
  6419. * Creates a hash object.
  6420. *
  6421. * @private
  6422. * @constructor
  6423. * @param {Array} [entries] The key-value pairs to cache.
  6424. */
  6425. function Hash(entries) {
  6426. var index = -1,
  6427. length = entries == null ? 0 : entries.length;
  6428. this.clear();
  6429. while (++index < length) {
  6430. var entry = entries[index];
  6431. this.set(entry[0], entry[1]);
  6432. }
  6433. }
  6434. /**
  6435. * Removes all key-value entries from the hash.
  6436. *
  6437. * @private
  6438. * @name clear
  6439. * @memberOf Hash
  6440. */
  6441. function hashClear() {
  6442. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  6443. this.size = 0;
  6444. }
  6445. /**
  6446. * Removes `key` and its value from the hash.
  6447. *
  6448. * @private
  6449. * @name delete
  6450. * @memberOf Hash
  6451. * @param {Object} hash The hash to modify.
  6452. * @param {string} key The key of the value to remove.
  6453. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6454. */
  6455. function hashDelete(key) {
  6456. var result = this.has(key) && delete this.__data__[key];
  6457. this.size -= result ? 1 : 0;
  6458. return result;
  6459. }
  6460. /**
  6461. * Gets the hash value for `key`.
  6462. *
  6463. * @private
  6464. * @name get
  6465. * @memberOf Hash
  6466. * @param {string} key The key of the value to get.
  6467. * @returns {*} Returns the entry value.
  6468. */
  6469. function hashGet(key) {
  6470. var data = this.__data__;
  6471. if (nativeCreate) {
  6472. var result = data[key];
  6473. return result === HASH_UNDEFINED ? undefined : result;
  6474. }
  6475. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  6476. }
  6477. /**
  6478. * Checks if a hash value for `key` exists.
  6479. *
  6480. * @private
  6481. * @name has
  6482. * @memberOf Hash
  6483. * @param {string} key The key of the entry to check.
  6484. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6485. */
  6486. function hashHas(key) {
  6487. var data = this.__data__;
  6488. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  6489. }
  6490. /**
  6491. * Sets the hash `key` to `value`.
  6492. *
  6493. * @private
  6494. * @name set
  6495. * @memberOf Hash
  6496. * @param {string} key The key of the value to set.
  6497. * @param {*} value The value to set.
  6498. * @returns {Object} Returns the hash instance.
  6499. */
  6500. function hashSet(key, value) {
  6501. var data = this.__data__;
  6502. this.size += this.has(key) ? 0 : 1;
  6503. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  6504. return this;
  6505. }
  6506. // Add methods to `Hash`.
  6507. Hash.prototype.clear = hashClear;
  6508. Hash.prototype['delete'] = hashDelete;
  6509. Hash.prototype.get = hashGet;
  6510. Hash.prototype.has = hashHas;
  6511. Hash.prototype.set = hashSet;
  6512. /*------------------------------------------------------------------------*/
  6513. /**
  6514. * Creates an list cache object.
  6515. *
  6516. * @private
  6517. * @constructor
  6518. * @param {Array} [entries] The key-value pairs to cache.
  6519. */
  6520. function ListCache(entries) {
  6521. var index = -1,
  6522. length = entries == null ? 0 : entries.length;
  6523. this.clear();
  6524. while (++index < length) {
  6525. var entry = entries[index];
  6526. this.set(entry[0], entry[1]);
  6527. }
  6528. }
  6529. /**
  6530. * Removes all key-value entries from the list cache.
  6531. *
  6532. * @private
  6533. * @name clear
  6534. * @memberOf ListCache
  6535. */
  6536. function listCacheClear() {
  6537. this.__data__ = [];
  6538. this.size = 0;
  6539. }
  6540. /**
  6541. * Removes `key` and its value from the list cache.
  6542. *
  6543. * @private
  6544. * @name delete
  6545. * @memberOf ListCache
  6546. * @param {string} key The key of the value to remove.
  6547. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6548. */
  6549. function listCacheDelete(key) {
  6550. var data = this.__data__,
  6551. index = assocIndexOf(data, key);
  6552. if (index < 0) {
  6553. return false;
  6554. }
  6555. var lastIndex = data.length - 1;
  6556. if (index == lastIndex) {
  6557. data.pop();
  6558. } else {
  6559. splice.call(data, index, 1);
  6560. }
  6561. --this.size;
  6562. return true;
  6563. }
  6564. /**
  6565. * Gets the list cache value for `key`.
  6566. *
  6567. * @private
  6568. * @name get
  6569. * @memberOf ListCache
  6570. * @param {string} key The key of the value to get.
  6571. * @returns {*} Returns the entry value.
  6572. */
  6573. function listCacheGet(key) {
  6574. var data = this.__data__,
  6575. index = assocIndexOf(data, key);
  6576. return index < 0 ? undefined : data[index][1];
  6577. }
  6578. /**
  6579. * Checks if a list cache value for `key` exists.
  6580. *
  6581. * @private
  6582. * @name has
  6583. * @memberOf ListCache
  6584. * @param {string} key The key of the entry to check.
  6585. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6586. */
  6587. function listCacheHas(key) {
  6588. return assocIndexOf(this.__data__, key) > -1;
  6589. }
  6590. /**
  6591. * Sets the list cache `key` to `value`.
  6592. *
  6593. * @private
  6594. * @name set
  6595. * @memberOf ListCache
  6596. * @param {string} key The key of the value to set.
  6597. * @param {*} value The value to set.
  6598. * @returns {Object} Returns the list cache instance.
  6599. */
  6600. function listCacheSet(key, value) {
  6601. var data = this.__data__,
  6602. index = assocIndexOf(data, key);
  6603. if (index < 0) {
  6604. ++this.size;
  6605. data.push([key, value]);
  6606. } else {
  6607. data[index][1] = value;
  6608. }
  6609. return this;
  6610. }
  6611. // Add methods to `ListCache`.
  6612. ListCache.prototype.clear = listCacheClear;
  6613. ListCache.prototype['delete'] = listCacheDelete;
  6614. ListCache.prototype.get = listCacheGet;
  6615. ListCache.prototype.has = listCacheHas;
  6616. ListCache.prototype.set = listCacheSet;
  6617. /*------------------------------------------------------------------------*/
  6618. /**
  6619. * Creates a map cache object to store key-value pairs.
  6620. *
  6621. * @private
  6622. * @constructor
  6623. * @param {Array} [entries] The key-value pairs to cache.
  6624. */
  6625. function MapCache(entries) {
  6626. var index = -1,
  6627. length = entries == null ? 0 : entries.length;
  6628. this.clear();
  6629. while (++index < length) {
  6630. var entry = entries[index];
  6631. this.set(entry[0], entry[1]);
  6632. }
  6633. }
  6634. /**
  6635. * Removes all key-value entries from the map.
  6636. *
  6637. * @private
  6638. * @name clear
  6639. * @memberOf MapCache
  6640. */
  6641. function mapCacheClear() {
  6642. this.size = 0;
  6643. this.__data__ = {
  6644. 'hash': new Hash,
  6645. 'map': new (Map || ListCache),
  6646. 'string': new Hash
  6647. };
  6648. }
  6649. /**
  6650. * Removes `key` and its value from the map.
  6651. *
  6652. * @private
  6653. * @name delete
  6654. * @memberOf MapCache
  6655. * @param {string} key The key of the value to remove.
  6656. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6657. */
  6658. function mapCacheDelete(key) {
  6659. var result = getMapData(this, key)['delete'](key);
  6660. this.size -= result ? 1 : 0;
  6661. return result;
  6662. }
  6663. /**
  6664. * Gets the map value for `key`.
  6665. *
  6666. * @private
  6667. * @name get
  6668. * @memberOf MapCache
  6669. * @param {string} key The key of the value to get.
  6670. * @returns {*} Returns the entry value.
  6671. */
  6672. function mapCacheGet(key) {
  6673. return getMapData(this, key).get(key);
  6674. }
  6675. /**
  6676. * Checks if a map value for `key` exists.
  6677. *
  6678. * @private
  6679. * @name has
  6680. * @memberOf MapCache
  6681. * @param {string} key The key of the entry to check.
  6682. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6683. */
  6684. function mapCacheHas(key) {
  6685. return getMapData(this, key).has(key);
  6686. }
  6687. /**
  6688. * Sets the map `key` to `value`.
  6689. *
  6690. * @private
  6691. * @name set
  6692. * @memberOf MapCache
  6693. * @param {string} key The key of the value to set.
  6694. * @param {*} value The value to set.
  6695. * @returns {Object} Returns the map cache instance.
  6696. */
  6697. function mapCacheSet(key, value) {
  6698. var data = getMapData(this, key),
  6699. size = data.size;
  6700. data.set(key, value);
  6701. this.size += data.size == size ? 0 : 1;
  6702. return this;
  6703. }
  6704. // Add methods to `MapCache`.
  6705. MapCache.prototype.clear = mapCacheClear;
  6706. MapCache.prototype['delete'] = mapCacheDelete;
  6707. MapCache.prototype.get = mapCacheGet;
  6708. MapCache.prototype.has = mapCacheHas;
  6709. MapCache.prototype.set = mapCacheSet;
  6710. /*------------------------------------------------------------------------*/
  6711. /**
  6712. *
  6713. * Creates an array cache object to store unique values.
  6714. *
  6715. * @private
  6716. * @constructor
  6717. * @param {Array} [values] The values to cache.
  6718. */
  6719. function SetCache(values) {
  6720. var index = -1,
  6721. length = values == null ? 0 : values.length;
  6722. this.__data__ = new MapCache;
  6723. while (++index < length) {
  6724. this.add(values[index]);
  6725. }
  6726. }
  6727. /**
  6728. * Adds `value` to the array cache.
  6729. *
  6730. * @private
  6731. * @name add
  6732. * @memberOf SetCache
  6733. * @alias push
  6734. * @param {*} value The value to cache.
  6735. * @returns {Object} Returns the cache instance.
  6736. */
  6737. function setCacheAdd(value) {
  6738. this.__data__.set(value, HASH_UNDEFINED);
  6739. return this;
  6740. }
  6741. /**
  6742. * Checks if `value` is in the array cache.
  6743. *
  6744. * @private
  6745. * @name has
  6746. * @memberOf SetCache
  6747. * @param {*} value The value to search for.
  6748. * @returns {number} Returns `true` if `value` is found, else `false`.
  6749. */
  6750. function setCacheHas(value) {
  6751. return this.__data__.has(value);
  6752. }
  6753. // Add methods to `SetCache`.
  6754. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  6755. SetCache.prototype.has = setCacheHas;
  6756. /*------------------------------------------------------------------------*/
  6757. /**
  6758. * Creates a stack cache object to store key-value pairs.
  6759. *
  6760. * @private
  6761. * @constructor
  6762. * @param {Array} [entries] The key-value pairs to cache.
  6763. */
  6764. function Stack(entries) {
  6765. var data = this.__data__ = new ListCache(entries);
  6766. this.size = data.size;
  6767. }
  6768. /**
  6769. * Removes all key-value entries from the stack.
  6770. *
  6771. * @private
  6772. * @name clear
  6773. * @memberOf Stack
  6774. */
  6775. function stackClear() {
  6776. this.__data__ = new ListCache;
  6777. this.size = 0;
  6778. }
  6779. /**
  6780. * Removes `key` and its value from the stack.
  6781. *
  6782. * @private
  6783. * @name delete
  6784. * @memberOf Stack
  6785. * @param {string} key The key of the value to remove.
  6786. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6787. */
  6788. function stackDelete(key) {
  6789. var data = this.__data__,
  6790. result = data['delete'](key);
  6791. this.size = data.size;
  6792. return result;
  6793. }
  6794. /**
  6795. * Gets the stack value for `key`.
  6796. *
  6797. * @private
  6798. * @name get
  6799. * @memberOf Stack
  6800. * @param {string} key The key of the value to get.
  6801. * @returns {*} Returns the entry value.
  6802. */
  6803. function stackGet(key) {
  6804. return this.__data__.get(key);
  6805. }
  6806. /**
  6807. * Checks if a stack value for `key` exists.
  6808. *
  6809. * @private
  6810. * @name has
  6811. * @memberOf Stack
  6812. * @param {string} key The key of the entry to check.
  6813. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6814. */
  6815. function stackHas(key) {
  6816. return this.__data__.has(key);
  6817. }
  6818. /**
  6819. * Sets the stack `key` to `value`.
  6820. *
  6821. * @private
  6822. * @name set
  6823. * @memberOf Stack
  6824. * @param {string} key The key of the value to set.
  6825. * @param {*} value The value to set.
  6826. * @returns {Object} Returns the stack cache instance.
  6827. */
  6828. function stackSet(key, value) {
  6829. var data = this.__data__;
  6830. if (data instanceof ListCache) {
  6831. var pairs = data.__data__;
  6832. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  6833. pairs.push([key, value]);
  6834. this.size = ++data.size;
  6835. return this;
  6836. }
  6837. data = this.__data__ = new MapCache(pairs);
  6838. }
  6839. data.set(key, value);
  6840. this.size = data.size;
  6841. return this;
  6842. }
  6843. // Add methods to `Stack`.
  6844. Stack.prototype.clear = stackClear;
  6845. Stack.prototype['delete'] = stackDelete;
  6846. Stack.prototype.get = stackGet;
  6847. Stack.prototype.has = stackHas;
  6848. Stack.prototype.set = stackSet;
  6849. /*------------------------------------------------------------------------*/
  6850. /**
  6851. * Creates an array of the enumerable property names of the array-like `value`.
  6852. *
  6853. * @private
  6854. * @param {*} value The value to query.
  6855. * @param {boolean} inherited Specify returning inherited property names.
  6856. * @returns {Array} Returns the array of property names.
  6857. */
  6858. function arrayLikeKeys(value, inherited) {
  6859. var isArr = isArray(value),
  6860. isArg = !isArr && isArguments(value),
  6861. isBuff = !isArr && !isArg && isBuffer(value),
  6862. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  6863. skipIndexes = isArr || isArg || isBuff || isType,
  6864. result = skipIndexes ? baseTimes(value.length, String) : [],
  6865. length = result.length;
  6866. for (var key in value) {
  6867. if ((inherited || hasOwnProperty.call(value, key)) &&
  6868. !(skipIndexes && (
  6869. // Safari 9 has enumerable `arguments.length` in strict mode.
  6870. key == 'length' ||
  6871. // Node.js 0.10 has enumerable non-index properties on buffers.
  6872. (isBuff && (key == 'offset' || key == 'parent')) ||
  6873. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  6874. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  6875. // Skip index properties.
  6876. isIndex(key, length)
  6877. ))) {
  6878. result.push(key);
  6879. }
  6880. }
  6881. return result;
  6882. }
  6883. /**
  6884. * A specialized version of `_.sample` for arrays.
  6885. *
  6886. * @private
  6887. * @param {Array} array The array to sample.
  6888. * @returns {*} Returns the random element.
  6889. */
  6890. function arraySample(array) {
  6891. var length = array.length;
  6892. return length ? array[baseRandom(0, length - 1)] : undefined;
  6893. }
  6894. /**
  6895. * A specialized version of `_.sampleSize` for arrays.
  6896. *
  6897. * @private
  6898. * @param {Array} array The array to sample.
  6899. * @param {number} n The number of elements to sample.
  6900. * @returns {Array} Returns the random elements.
  6901. */
  6902. function arraySampleSize(array, n) {
  6903. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  6904. }
  6905. /**
  6906. * A specialized version of `_.shuffle` for arrays.
  6907. *
  6908. * @private
  6909. * @param {Array} array The array to shuffle.
  6910. * @returns {Array} Returns the new shuffled array.
  6911. */
  6912. function arrayShuffle(array) {
  6913. return shuffleSelf(copyArray(array));
  6914. }
  6915. /**
  6916. * This function is like `assignValue` except that it doesn't assign
  6917. * `undefined` values.
  6918. *
  6919. * @private
  6920. * @param {Object} object The object to modify.
  6921. * @param {string} key The key of the property to assign.
  6922. * @param {*} value The value to assign.
  6923. */
  6924. function assignMergeValue(object, key, value) {
  6925. if ((value !== undefined && !eq(object[key], value)) ||
  6926. (value === undefined && !(key in object))) {
  6927. baseAssignValue(object, key, value);
  6928. }
  6929. }
  6930. /**
  6931. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  6932. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  6933. * for equality comparisons.
  6934. *
  6935. * @private
  6936. * @param {Object} object The object to modify.
  6937. * @param {string} key The key of the property to assign.
  6938. * @param {*} value The value to assign.
  6939. */
  6940. function assignValue(object, key, value) {
  6941. var objValue = object[key];
  6942. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  6943. (value === undefined && !(key in object))) {
  6944. baseAssignValue(object, key, value);
  6945. }
  6946. }
  6947. /**
  6948. * Gets the index at which the `key` is found in `array` of key-value pairs.
  6949. *
  6950. * @private
  6951. * @param {Array} array The array to inspect.
  6952. * @param {*} key The key to search for.
  6953. * @returns {number} Returns the index of the matched value, else `-1`.
  6954. */
  6955. function assocIndexOf(array, key) {
  6956. var length = array.length;
  6957. while (length--) {
  6958. if (eq(array[length][0], key)) {
  6959. return length;
  6960. }
  6961. }
  6962. return -1;
  6963. }
  6964. /**
  6965. * Aggregates elements of `collection` on `accumulator` with keys transformed
  6966. * by `iteratee` and values set by `setter`.
  6967. *
  6968. * @private
  6969. * @param {Array|Object} collection The collection to iterate over.
  6970. * @param {Function} setter The function to set `accumulator` values.
  6971. * @param {Function} iteratee The iteratee to transform keys.
  6972. * @param {Object} accumulator The initial aggregated object.
  6973. * @returns {Function} Returns `accumulator`.
  6974. */
  6975. function baseAggregator(collection, setter, iteratee, accumulator) {
  6976. baseEach(collection, function(value, key, collection) {
  6977. setter(accumulator, value, iteratee(value), collection);
  6978. });
  6979. return accumulator;
  6980. }
  6981. /**
  6982. * The base implementation of `_.assign` without support for multiple sources
  6983. * or `customizer` functions.
  6984. *
  6985. * @private
  6986. * @param {Object} object The destination object.
  6987. * @param {Object} source The source object.
  6988. * @returns {Object} Returns `object`.
  6989. */
  6990. function baseAssign(object, source) {
  6991. return object && copyObject(source, keys(source), object);
  6992. }
  6993. /**
  6994. * The base implementation of `_.assignIn` without support for multiple sources
  6995. * or `customizer` functions.
  6996. *
  6997. * @private
  6998. * @param {Object} object The destination object.
  6999. * @param {Object} source The source object.
  7000. * @returns {Object} Returns `object`.
  7001. */
  7002. function baseAssignIn(object, source) {
  7003. return object && copyObject(source, keysIn(source), object);
  7004. }
  7005. /**
  7006. * The base implementation of `assignValue` and `assignMergeValue` without
  7007. * value checks.
  7008. *
  7009. * @private
  7010. * @param {Object} object The object to modify.
  7011. * @param {string} key The key of the property to assign.
  7012. * @param {*} value The value to assign.
  7013. */
  7014. function baseAssignValue(object, key, value) {
  7015. if (key == '__proto__' && defineProperty) {
  7016. defineProperty(object, key, {
  7017. 'configurable': true,
  7018. 'enumerable': true,
  7019. 'value': value,
  7020. 'writable': true
  7021. });
  7022. } else {
  7023. object[key] = value;
  7024. }
  7025. }
  7026. /**
  7027. * The base implementation of `_.at` without support for individual paths.
  7028. *
  7029. * @private
  7030. * @param {Object} object The object to iterate over.
  7031. * @param {string[]} paths The property paths to pick.
  7032. * @returns {Array} Returns the picked elements.
  7033. */
  7034. function baseAt(object, paths) {
  7035. var index = -1,
  7036. length = paths.length,
  7037. result = Array(length),
  7038. skip = object == null;
  7039. while (++index < length) {
  7040. result[index] = skip ? undefined : get(object, paths[index]);
  7041. }
  7042. return result;
  7043. }
  7044. /**
  7045. * The base implementation of `_.clamp` which doesn't coerce arguments.
  7046. *
  7047. * @private
  7048. * @param {number} number The number to clamp.
  7049. * @param {number} [lower] The lower bound.
  7050. * @param {number} upper The upper bound.
  7051. * @returns {number} Returns the clamped number.
  7052. */
  7053. function baseClamp(number, lower, upper) {
  7054. if (number === number) {
  7055. if (upper !== undefined) {
  7056. number = number <= upper ? number : upper;
  7057. }
  7058. if (lower !== undefined) {
  7059. number = number >= lower ? number : lower;
  7060. }
  7061. }
  7062. return number;
  7063. }
  7064. /**
  7065. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  7066. * traversed objects.
  7067. *
  7068. * @private
  7069. * @param {*} value The value to clone.
  7070. * @param {boolean} bitmask The bitmask flags.
  7071. * 1 - Deep clone
  7072. * 2 - Flatten inherited properties
  7073. * 4 - Clone symbols
  7074. * @param {Function} [customizer] The function to customize cloning.
  7075. * @param {string} [key] The key of `value`.
  7076. * @param {Object} [object] The parent object of `value`.
  7077. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  7078. * @returns {*} Returns the cloned value.
  7079. */
  7080. function baseClone(value, bitmask, customizer, key, object, stack) {
  7081. var result,
  7082. isDeep = bitmask & CLONE_DEEP_FLAG,
  7083. isFlat = bitmask & CLONE_FLAT_FLAG,
  7084. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  7085. if (customizer) {
  7086. result = object ? customizer(value, key, object, stack) : customizer(value);
  7087. }
  7088. if (result !== undefined) {
  7089. return result;
  7090. }
  7091. if (!isObject(value)) {
  7092. return value;
  7093. }
  7094. var isArr = isArray(value);
  7095. if (isArr) {
  7096. result = initCloneArray(value);
  7097. if (!isDeep) {
  7098. return copyArray(value, result);
  7099. }
  7100. } else {
  7101. var tag = getTag(value),
  7102. isFunc = tag == funcTag || tag == genTag;
  7103. if (isBuffer(value)) {
  7104. return cloneBuffer(value, isDeep);
  7105. }
  7106. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  7107. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  7108. if (!isDeep) {
  7109. return isFlat
  7110. ? copySymbolsIn(value, baseAssignIn(result, value))
  7111. : copySymbols(value, baseAssign(result, value));
  7112. }
  7113. } else {
  7114. if (!cloneableTags[tag]) {
  7115. return object ? value : {};
  7116. }
  7117. result = initCloneByTag(value, tag, isDeep);
  7118. }
  7119. }
  7120. // Check for circular references and return its corresponding clone.
  7121. stack || (stack = new Stack);
  7122. var stacked = stack.get(value);
  7123. if (stacked) {
  7124. return stacked;
  7125. }
  7126. stack.set(value, result);
  7127. if (isSet(value)) {
  7128. value.forEach(function(subValue) {
  7129. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  7130. });
  7131. } else if (isMap(value)) {
  7132. value.forEach(function(subValue, key) {
  7133. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  7134. });
  7135. }
  7136. var keysFunc = isFull
  7137. ? (isFlat ? getAllKeysIn : getAllKeys)
  7138. : (isFlat ? keysIn : keys);
  7139. var props = isArr ? undefined : keysFunc(value);
  7140. arrayEach(props || value, function(subValue, key) {
  7141. if (props) {
  7142. key = subValue;
  7143. subValue = value[key];
  7144. }
  7145. // Recursively populate clone (susceptible to call stack limits).
  7146. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  7147. });
  7148. return result;
  7149. }
  7150. /**
  7151. * The base implementation of `_.conforms` which doesn't clone `source`.
  7152. *
  7153. * @private
  7154. * @param {Object} source The object of property predicates to conform to.
  7155. * @returns {Function} Returns the new spec function.
  7156. */
  7157. function baseConforms(source) {
  7158. var props = keys(source);
  7159. return function(object) {
  7160. return baseConformsTo(object, source, props);
  7161. };
  7162. }
  7163. /**
  7164. * The base implementation of `_.conformsTo` which accepts `props` to check.
  7165. *
  7166. * @private
  7167. * @param {Object} object The object to inspect.
  7168. * @param {Object} source The object of property predicates to conform to.
  7169. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  7170. */
  7171. function baseConformsTo(object, source, props) {
  7172. var length = props.length;
  7173. if (object == null) {
  7174. return !length;
  7175. }
  7176. object = Object(object);
  7177. while (length--) {
  7178. var key = props[length],
  7179. predicate = source[key],
  7180. value = object[key];
  7181. if ((value === undefined && !(key in object)) || !predicate(value)) {
  7182. return false;
  7183. }
  7184. }
  7185. return true;
  7186. }
  7187. /**
  7188. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  7189. * to provide to `func`.
  7190. *
  7191. * @private
  7192. * @param {Function} func The function to delay.
  7193. * @param {number} wait The number of milliseconds to delay invocation.
  7194. * @param {Array} args The arguments to provide to `func`.
  7195. * @returns {number|Object} Returns the timer id or timeout object.
  7196. */
  7197. function baseDelay(func, wait, args) {
  7198. if (typeof func != 'function') {
  7199. throw new TypeError(FUNC_ERROR_TEXT);
  7200. }
  7201. return setTimeout(function() { func.apply(undefined, args); }, wait);
  7202. }
  7203. /**
  7204. * The base implementation of methods like `_.difference` without support
  7205. * for excluding multiple arrays or iteratee shorthands.
  7206. *
  7207. * @private
  7208. * @param {Array} array The array to inspect.
  7209. * @param {Array} values The values to exclude.
  7210. * @param {Function} [iteratee] The iteratee invoked per element.
  7211. * @param {Function} [comparator] The comparator invoked per element.
  7212. * @returns {Array} Returns the new array of filtered values.
  7213. */
  7214. function baseDifference(array, values, iteratee, comparator) {
  7215. var index = -1,
  7216. includes = arrayIncludes,
  7217. isCommon = true,
  7218. length = array.length,
  7219. result = [],
  7220. valuesLength = values.length;
  7221. if (!length) {
  7222. return result;
  7223. }
  7224. if (iteratee) {
  7225. values = arrayMap(values, baseUnary(iteratee));
  7226. }
  7227. if (comparator) {
  7228. includes = arrayIncludesWith;
  7229. isCommon = false;
  7230. }
  7231. else if (values.length >= LARGE_ARRAY_SIZE) {
  7232. includes = cacheHas;
  7233. isCommon = false;
  7234. values = new SetCache(values);
  7235. }
  7236. outer:
  7237. while (++index < length) {
  7238. var value = array[index],
  7239. computed = iteratee == null ? value : iteratee(value);
  7240. value = (comparator || value !== 0) ? value : 0;
  7241. if (isCommon && computed === computed) {
  7242. var valuesIndex = valuesLength;
  7243. while (valuesIndex--) {
  7244. if (values[valuesIndex] === computed) {
  7245. continue outer;
  7246. }
  7247. }
  7248. result.push(value);
  7249. }
  7250. else if (!includes(values, computed, comparator)) {
  7251. result.push(value);
  7252. }
  7253. }
  7254. return result;
  7255. }
  7256. /**
  7257. * The base implementation of `_.forEach` without support for iteratee shorthands.
  7258. *
  7259. * @private
  7260. * @param {Array|Object} collection The collection to iterate over.
  7261. * @param {Function} iteratee The function invoked per iteration.
  7262. * @returns {Array|Object} Returns `collection`.
  7263. */
  7264. var baseEach = createBaseEach(baseForOwn);
  7265. /**
  7266. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  7267. *
  7268. * @private
  7269. * @param {Array|Object} collection The collection to iterate over.
  7270. * @param {Function} iteratee The function invoked per iteration.
  7271. * @returns {Array|Object} Returns `collection`.
  7272. */
  7273. var baseEachRight = createBaseEach(baseForOwnRight, true);
  7274. /**
  7275. * The base implementation of `_.every` without support for iteratee shorthands.
  7276. *
  7277. * @private
  7278. * @param {Array|Object} collection The collection to iterate over.
  7279. * @param {Function} predicate The function invoked per iteration.
  7280. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  7281. * else `false`
  7282. */
  7283. function baseEvery(collection, predicate) {
  7284. var result = true;
  7285. baseEach(collection, function(value, index, collection) {
  7286. result = !!predicate(value, index, collection);
  7287. return result;
  7288. });
  7289. return result;
  7290. }
  7291. /**
  7292. * The base implementation of methods like `_.max` and `_.min` which accepts a
  7293. * `comparator` to determine the extremum value.
  7294. *
  7295. * @private
  7296. * @param {Array} array The array to iterate over.
  7297. * @param {Function} iteratee The iteratee invoked per iteration.
  7298. * @param {Function} comparator The comparator used to compare values.
  7299. * @returns {*} Returns the extremum value.
  7300. */
  7301. function baseExtremum(array, iteratee, comparator) {
  7302. var index = -1,
  7303. length = array.length;
  7304. while (++index < length) {
  7305. var value = array[index],
  7306. current = iteratee(value);
  7307. if (current != null && (computed === undefined
  7308. ? (current === current && !isSymbol(current))
  7309. : comparator(current, computed)
  7310. )) {
  7311. var computed = current,
  7312. result = value;
  7313. }
  7314. }
  7315. return result;
  7316. }
  7317. /**
  7318. * The base implementation of `_.fill` without an iteratee call guard.
  7319. *
  7320. * @private
  7321. * @param {Array} array The array to fill.
  7322. * @param {*} value The value to fill `array` with.
  7323. * @param {number} [start=0] The start position.
  7324. * @param {number} [end=array.length] The end position.
  7325. * @returns {Array} Returns `array`.
  7326. */
  7327. function baseFill(array, value, start, end) {
  7328. var length = array.length;
  7329. start = toInteger(start);
  7330. if (start < 0) {
  7331. start = -start > length ? 0 : (length + start);
  7332. }
  7333. end = (end === undefined || end > length) ? length : toInteger(end);
  7334. if (end < 0) {
  7335. end += length;
  7336. }
  7337. end = start > end ? 0 : toLength(end);
  7338. while (start < end) {
  7339. array[start++] = value;
  7340. }
  7341. return array;
  7342. }
  7343. /**
  7344. * The base implementation of `_.filter` without support for iteratee shorthands.
  7345. *
  7346. * @private
  7347. * @param {Array|Object} collection The collection to iterate over.
  7348. * @param {Function} predicate The function invoked per iteration.
  7349. * @returns {Array} Returns the new filtered array.
  7350. */
  7351. function baseFilter(collection, predicate) {
  7352. var result = [];
  7353. baseEach(collection, function(value, index, collection) {
  7354. if (predicate(value, index, collection)) {
  7355. result.push(value);
  7356. }
  7357. });
  7358. return result;
  7359. }
  7360. /**
  7361. * The base implementation of `_.flatten` with support for restricting flattening.
  7362. *
  7363. * @private
  7364. * @param {Array} array The array to flatten.
  7365. * @param {number} depth The maximum recursion depth.
  7366. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  7367. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  7368. * @param {Array} [result=[]] The initial result value.
  7369. * @returns {Array} Returns the new flattened array.
  7370. */
  7371. function baseFlatten(array, depth, predicate, isStrict, result) {
  7372. var index = -1,
  7373. length = array.length;
  7374. predicate || (predicate = isFlattenable);
  7375. result || (result = []);
  7376. while (++index < length) {
  7377. var value = array[index];
  7378. if (depth > 0 && predicate(value)) {
  7379. if (depth > 1) {
  7380. // Recursively flatten arrays (susceptible to call stack limits).
  7381. baseFlatten(value, depth - 1, predicate, isStrict, result);
  7382. } else {
  7383. arrayPush(result, value);
  7384. }
  7385. } else if (!isStrict) {
  7386. result[result.length] = value;
  7387. }
  7388. }
  7389. return result;
  7390. }
  7391. /**
  7392. * The base implementation of `baseForOwn` which iterates over `object`
  7393. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  7394. * Iteratee functions may exit iteration early by explicitly returning `false`.
  7395. *
  7396. * @private
  7397. * @param {Object} object The object to iterate over.
  7398. * @param {Function} iteratee The function invoked per iteration.
  7399. * @param {Function} keysFunc The function to get the keys of `object`.
  7400. * @returns {Object} Returns `object`.
  7401. */
  7402. var baseFor = createBaseFor();
  7403. /**
  7404. * This function is like `baseFor` except that it iterates over properties
  7405. * in the opposite order.
  7406. *
  7407. * @private
  7408. * @param {Object} object The object to iterate over.
  7409. * @param {Function} iteratee The function invoked per iteration.
  7410. * @param {Function} keysFunc The function to get the keys of `object`.
  7411. * @returns {Object} Returns `object`.
  7412. */
  7413. var baseForRight = createBaseFor(true);
  7414. /**
  7415. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  7416. *
  7417. * @private
  7418. * @param {Object} object The object to iterate over.
  7419. * @param {Function} iteratee The function invoked per iteration.
  7420. * @returns {Object} Returns `object`.
  7421. */
  7422. function baseForOwn(object, iteratee) {
  7423. return object && baseFor(object, iteratee, keys);
  7424. }
  7425. /**
  7426. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  7427. *
  7428. * @private
  7429. * @param {Object} object The object to iterate over.
  7430. * @param {Function} iteratee The function invoked per iteration.
  7431. * @returns {Object} Returns `object`.
  7432. */
  7433. function baseForOwnRight(object, iteratee) {
  7434. return object && baseForRight(object, iteratee, keys);
  7435. }
  7436. /**
  7437. * The base implementation of `_.functions` which creates an array of
  7438. * `object` function property names filtered from `props`.
  7439. *
  7440. * @private
  7441. * @param {Object} object The object to inspect.
  7442. * @param {Array} props The property names to filter.
  7443. * @returns {Array} Returns the function names.
  7444. */
  7445. function baseFunctions(object, props) {
  7446. return arrayFilter(props, function(key) {
  7447. return isFunction(object[key]);
  7448. });
  7449. }
  7450. /**
  7451. * The base implementation of `_.get` without support for default values.
  7452. *
  7453. * @private
  7454. * @param {Object} object The object to query.
  7455. * @param {Array|string} path The path of the property to get.
  7456. * @returns {*} Returns the resolved value.
  7457. */
  7458. function baseGet(object, path) {
  7459. path = castPath(path, object);
  7460. var index = 0,
  7461. length = path.length;
  7462. while (object != null && index < length) {
  7463. object = object[toKey(path[index++])];
  7464. }
  7465. return (index && index == length) ? object : undefined;
  7466. }
  7467. /**
  7468. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  7469. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  7470. * symbols of `object`.
  7471. *
  7472. * @private
  7473. * @param {Object} object The object to query.
  7474. * @param {Function} keysFunc The function to get the keys of `object`.
  7475. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  7476. * @returns {Array} Returns the array of property names and symbols.
  7477. */
  7478. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  7479. var result = keysFunc(object);
  7480. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  7481. }
  7482. /**
  7483. * The base implementation of `getTag` without fallbacks for buggy environments.
  7484. *
  7485. * @private
  7486. * @param {*} value The value to query.
  7487. * @returns {string} Returns the `toStringTag`.
  7488. */
  7489. function baseGetTag(value) {
  7490. if (value == null) {
  7491. return value === undefined ? undefinedTag : nullTag;
  7492. }
  7493. return (symToStringTag && symToStringTag in Object(value))
  7494. ? getRawTag(value)
  7495. : objectToString(value);
  7496. }
  7497. /**
  7498. * The base implementation of `_.gt` which doesn't coerce arguments.
  7499. *
  7500. * @private
  7501. * @param {*} value The value to compare.
  7502. * @param {*} other The other value to compare.
  7503. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  7504. * else `false`.
  7505. */
  7506. function baseGt(value, other) {
  7507. return value > other;
  7508. }
  7509. /**
  7510. * The base implementation of `_.has` without support for deep paths.
  7511. *
  7512. * @private
  7513. * @param {Object} [object] The object to query.
  7514. * @param {Array|string} key The key to check.
  7515. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  7516. */
  7517. function baseHas(object, key) {
  7518. return object != null && hasOwnProperty.call(object, key);
  7519. }
  7520. /**
  7521. * The base implementation of `_.hasIn` without support for deep paths.
  7522. *
  7523. * @private
  7524. * @param {Object} [object] The object to query.
  7525. * @param {Array|string} key The key to check.
  7526. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  7527. */
  7528. function baseHasIn(object, key) {
  7529. return object != null && key in Object(object);
  7530. }
  7531. /**
  7532. * The base implementation of `_.inRange` which doesn't coerce arguments.
  7533. *
  7534. * @private
  7535. * @param {number} number The number to check.
  7536. * @param {number} start The start of the range.
  7537. * @param {number} end The end of the range.
  7538. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  7539. */
  7540. function baseInRange(number, start, end) {
  7541. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  7542. }
  7543. /**
  7544. * The base implementation of methods like `_.intersection`, without support
  7545. * for iteratee shorthands, that accepts an array of arrays to inspect.
  7546. *
  7547. * @private
  7548. * @param {Array} arrays The arrays to inspect.
  7549. * @param {Function} [iteratee] The iteratee invoked per element.
  7550. * @param {Function} [comparator] The comparator invoked per element.
  7551. * @returns {Array} Returns the new array of shared values.
  7552. */
  7553. function baseIntersection(arrays, iteratee, comparator) {
  7554. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  7555. length = arrays[0].length,
  7556. othLength = arrays.length,
  7557. othIndex = othLength,
  7558. caches = Array(othLength),
  7559. maxLength = Infinity,
  7560. result = [];
  7561. while (othIndex--) {
  7562. var array = arrays[othIndex];
  7563. if (othIndex && iteratee) {
  7564. array = arrayMap(array, baseUnary(iteratee));
  7565. }
  7566. maxLength = nativeMin(array.length, maxLength);
  7567. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  7568. ? new SetCache(othIndex && array)
  7569. : undefined;
  7570. }
  7571. array = arrays[0];
  7572. var index = -1,
  7573. seen = caches[0];
  7574. outer:
  7575. while (++index < length && result.length < maxLength) {
  7576. var value = array[index],
  7577. computed = iteratee ? iteratee(value) : value;
  7578. value = (comparator || value !== 0) ? value : 0;
  7579. if (!(seen
  7580. ? cacheHas(seen, computed)
  7581. : includes(result, computed, comparator)
  7582. )) {
  7583. othIndex = othLength;
  7584. while (--othIndex) {
  7585. var cache = caches[othIndex];
  7586. if (!(cache
  7587. ? cacheHas(cache, computed)
  7588. : includes(arrays[othIndex], computed, comparator))
  7589. ) {
  7590. continue outer;
  7591. }
  7592. }
  7593. if (seen) {
  7594. seen.push(computed);
  7595. }
  7596. result.push(value);
  7597. }
  7598. }
  7599. return result;
  7600. }
  7601. /**
  7602. * The base implementation of `_.invert` and `_.invertBy` which inverts
  7603. * `object` with values transformed by `iteratee` and set by `setter`.
  7604. *
  7605. * @private
  7606. * @param {Object} object The object to iterate over.
  7607. * @param {Function} setter The function to set `accumulator` values.
  7608. * @param {Function} iteratee The iteratee to transform values.
  7609. * @param {Object} accumulator The initial inverted object.
  7610. * @returns {Function} Returns `accumulator`.
  7611. */
  7612. function baseInverter(object, setter, iteratee, accumulator) {
  7613. baseForOwn(object, function(value, key, object) {
  7614. setter(accumulator, iteratee(value), key, object);
  7615. });
  7616. return accumulator;
  7617. }
  7618. /**
  7619. * The base implementation of `_.invoke` without support for individual
  7620. * method arguments.
  7621. *
  7622. * @private
  7623. * @param {Object} object The object to query.
  7624. * @param {Array|string} path The path of the method to invoke.
  7625. * @param {Array} args The arguments to invoke the method with.
  7626. * @returns {*} Returns the result of the invoked method.
  7627. */
  7628. function baseInvoke(object, path, args) {
  7629. path = castPath(path, object);
  7630. object = parent(object, path);
  7631. var func = object == null ? object : object[toKey(last(path))];
  7632. return func == null ? undefined : apply(func, object, args);
  7633. }
  7634. /**
  7635. * The base implementation of `_.isArguments`.
  7636. *
  7637. * @private
  7638. * @param {*} value The value to check.
  7639. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  7640. */
  7641. function baseIsArguments(value) {
  7642. return isObjectLike(value) && baseGetTag(value) == argsTag;
  7643. }
  7644. /**
  7645. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  7646. *
  7647. * @private
  7648. * @param {*} value The value to check.
  7649. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  7650. */
  7651. function baseIsArrayBuffer(value) {
  7652. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  7653. }
  7654. /**
  7655. * The base implementation of `_.isDate` without Node.js optimizations.
  7656. *
  7657. * @private
  7658. * @param {*} value The value to check.
  7659. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  7660. */
  7661. function baseIsDate(value) {
  7662. return isObjectLike(value) && baseGetTag(value) == dateTag;
  7663. }
  7664. /**
  7665. * The base implementation of `_.isEqual` which supports partial comparisons
  7666. * and tracks traversed objects.
  7667. *
  7668. * @private
  7669. * @param {*} value The value to compare.
  7670. * @param {*} other The other value to compare.
  7671. * @param {boolean} bitmask The bitmask flags.
  7672. * 1 - Unordered comparison
  7673. * 2 - Partial comparison
  7674. * @param {Function} [customizer] The function to customize comparisons.
  7675. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  7676. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  7677. */
  7678. function baseIsEqual(value, other, bitmask, customizer, stack) {
  7679. if (value === other) {
  7680. return true;
  7681. }
  7682. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  7683. return value !== value && other !== other;
  7684. }
  7685. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  7686. }
  7687. /**
  7688. * A specialized version of `baseIsEqual` for arrays and objects which performs
  7689. * deep comparisons and tracks traversed objects enabling objects with circular
  7690. * references to be compared.
  7691. *
  7692. * @private
  7693. * @param {Object} object The object to compare.
  7694. * @param {Object} other The other object to compare.
  7695. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7696. * @param {Function} customizer The function to customize comparisons.
  7697. * @param {Function} equalFunc The function to determine equivalents of values.
  7698. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  7699. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7700. */
  7701. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  7702. var objIsArr = isArray(object),
  7703. othIsArr = isArray(other),
  7704. objTag = objIsArr ? arrayTag : getTag(object),
  7705. othTag = othIsArr ? arrayTag : getTag(other);
  7706. objTag = objTag == argsTag ? objectTag : objTag;
  7707. othTag = othTag == argsTag ? objectTag : othTag;
  7708. var objIsObj = objTag == objectTag,
  7709. othIsObj = othTag == objectTag,
  7710. isSameTag = objTag == othTag;
  7711. if (isSameTag && isBuffer(object)) {
  7712. if (!isBuffer(other)) {
  7713. return false;
  7714. }
  7715. objIsArr = true;
  7716. objIsObj = false;
  7717. }
  7718. if (isSameTag && !objIsObj) {
  7719. stack || (stack = new Stack);
  7720. return (objIsArr || isTypedArray(object))
  7721. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  7722. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  7723. }
  7724. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  7725. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  7726. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  7727. if (objIsWrapped || othIsWrapped) {
  7728. var objUnwrapped = objIsWrapped ? object.value() : object,
  7729. othUnwrapped = othIsWrapped ? other.value() : other;
  7730. stack || (stack = new Stack);
  7731. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  7732. }
  7733. }
  7734. if (!isSameTag) {
  7735. return false;
  7736. }
  7737. stack || (stack = new Stack);
  7738. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  7739. }
  7740. /**
  7741. * The base implementation of `_.isMap` without Node.js optimizations.
  7742. *
  7743. * @private
  7744. * @param {*} value The value to check.
  7745. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  7746. */
  7747. function baseIsMap(value) {
  7748. return isObjectLike(value) && getTag(value) == mapTag;
  7749. }
  7750. /**
  7751. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  7752. *
  7753. * @private
  7754. * @param {Object} object The object to inspect.
  7755. * @param {Object} source The object of property values to match.
  7756. * @param {Array} matchData The property names, values, and compare flags to match.
  7757. * @param {Function} [customizer] The function to customize comparisons.
  7758. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  7759. */
  7760. function baseIsMatch(object, source, matchData, customizer) {
  7761. var index = matchData.length,
  7762. length = index,
  7763. noCustomizer = !customizer;
  7764. if (object == null) {
  7765. return !length;
  7766. }
  7767. object = Object(object);
  7768. while (index--) {
  7769. var data = matchData[index];
  7770. if ((noCustomizer && data[2])
  7771. ? data[1] !== object[data[0]]
  7772. : !(data[0] in object)
  7773. ) {
  7774. return false;
  7775. }
  7776. }
  7777. while (++index < length) {
  7778. data = matchData[index];
  7779. var key = data[0],
  7780. objValue = object[key],
  7781. srcValue = data[1];
  7782. if (noCustomizer && data[2]) {
  7783. if (objValue === undefined && !(key in object)) {
  7784. return false;
  7785. }
  7786. } else {
  7787. var stack = new Stack;
  7788. if (customizer) {
  7789. var result = customizer(objValue, srcValue, key, object, source, stack);
  7790. }
  7791. if (!(result === undefined
  7792. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  7793. : result
  7794. )) {
  7795. return false;
  7796. }
  7797. }
  7798. }
  7799. return true;
  7800. }
  7801. /**
  7802. * The base implementation of `_.isNative` without bad shim checks.
  7803. *
  7804. * @private
  7805. * @param {*} value The value to check.
  7806. * @returns {boolean} Returns `true` if `value` is a native function,
  7807. * else `false`.
  7808. */
  7809. function baseIsNative(value) {
  7810. if (!isObject(value) || isMasked(value)) {
  7811. return false;
  7812. }
  7813. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  7814. return pattern.test(toSource(value));
  7815. }
  7816. /**
  7817. * The base implementation of `_.isRegExp` without Node.js optimizations.
  7818. *
  7819. * @private
  7820. * @param {*} value The value to check.
  7821. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  7822. */
  7823. function baseIsRegExp(value) {
  7824. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  7825. }
  7826. /**
  7827. * The base implementation of `_.isSet` without Node.js optimizations.
  7828. *
  7829. * @private
  7830. * @param {*} value The value to check.
  7831. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  7832. */
  7833. function baseIsSet(value) {
  7834. return isObjectLike(value) && getTag(value) == setTag;
  7835. }
  7836. /**
  7837. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  7838. *
  7839. * @private
  7840. * @param {*} value The value to check.
  7841. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  7842. */
  7843. function baseIsTypedArray(value) {
  7844. return isObjectLike(value) &&
  7845. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  7846. }
  7847. /**
  7848. * The base implementation of `_.iteratee`.
  7849. *
  7850. * @private
  7851. * @param {*} [value=_.identity] The value to convert to an iteratee.
  7852. * @returns {Function} Returns the iteratee.
  7853. */
  7854. function baseIteratee(value) {
  7855. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  7856. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  7857. if (typeof value == 'function') {
  7858. return value;
  7859. }
  7860. if (value == null) {
  7861. return identity;
  7862. }
  7863. if (typeof value == 'object') {
  7864. return isArray(value)
  7865. ? baseMatchesProperty(value[0], value[1])
  7866. : baseMatches(value);
  7867. }
  7868. return property(value);
  7869. }
  7870. /**
  7871. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  7872. *
  7873. * @private
  7874. * @param {Object} object The object to query.
  7875. * @returns {Array} Returns the array of property names.
  7876. */
  7877. function baseKeys(object) {
  7878. if (!isPrototype(object)) {
  7879. return nativeKeys(object);
  7880. }
  7881. var result = [];
  7882. for (var key in Object(object)) {
  7883. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  7884. result.push(key);
  7885. }
  7886. }
  7887. return result;
  7888. }
  7889. /**
  7890. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  7891. *
  7892. * @private
  7893. * @param {Object} object The object to query.
  7894. * @returns {Array} Returns the array of property names.
  7895. */
  7896. function baseKeysIn(object) {
  7897. if (!isObject(object)) {
  7898. return nativeKeysIn(object);
  7899. }
  7900. var isProto = isPrototype(object),
  7901. result = [];
  7902. for (var key in object) {
  7903. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  7904. result.push(key);
  7905. }
  7906. }
  7907. return result;
  7908. }
  7909. /**
  7910. * The base implementation of `_.lt` which doesn't coerce arguments.
  7911. *
  7912. * @private
  7913. * @param {*} value The value to compare.
  7914. * @param {*} other The other value to compare.
  7915. * @returns {boolean} Returns `true` if `value` is less than `other`,
  7916. * else `false`.
  7917. */
  7918. function baseLt(value, other) {
  7919. return value < other;
  7920. }
  7921. /**
  7922. * The base implementation of `_.map` without support for iteratee shorthands.
  7923. *
  7924. * @private
  7925. * @param {Array|Object} collection The collection to iterate over.
  7926. * @param {Function} iteratee The function invoked per iteration.
  7927. * @returns {Array} Returns the new mapped array.
  7928. */
  7929. function baseMap(collection, iteratee) {
  7930. var index = -1,
  7931. result = isArrayLike(collection) ? Array(collection.length) : [];
  7932. baseEach(collection, function(value, key, collection) {
  7933. result[++index] = iteratee(value, key, collection);
  7934. });
  7935. return result;
  7936. }
  7937. /**
  7938. * The base implementation of `_.matches` which doesn't clone `source`.
  7939. *
  7940. * @private
  7941. * @param {Object} source The object of property values to match.
  7942. * @returns {Function} Returns the new spec function.
  7943. */
  7944. function baseMatches(source) {
  7945. var matchData = getMatchData(source);
  7946. if (matchData.length == 1 && matchData[0][2]) {
  7947. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  7948. }
  7949. return function(object) {
  7950. return object === source || baseIsMatch(object, source, matchData);
  7951. };
  7952. }
  7953. /**
  7954. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  7955. *
  7956. * @private
  7957. * @param {string} path The path of the property to get.
  7958. * @param {*} srcValue The value to match.
  7959. * @returns {Function} Returns the new spec function.
  7960. */
  7961. function baseMatchesProperty(path, srcValue) {
  7962. if (isKey(path) && isStrictComparable(srcValue)) {
  7963. return matchesStrictComparable(toKey(path), srcValue);
  7964. }
  7965. return function(object) {
  7966. var objValue = get(object, path);
  7967. return (objValue === undefined && objValue === srcValue)
  7968. ? hasIn(object, path)
  7969. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  7970. };
  7971. }
  7972. /**
  7973. * The base implementation of `_.merge` without support for multiple sources.
  7974. *
  7975. * @private
  7976. * @param {Object} object The destination object.
  7977. * @param {Object} source The source object.
  7978. * @param {number} srcIndex The index of `source`.
  7979. * @param {Function} [customizer] The function to customize merged values.
  7980. * @param {Object} [stack] Tracks traversed source values and their merged
  7981. * counterparts.
  7982. */
  7983. function baseMerge(object, source, srcIndex, customizer, stack) {
  7984. if (object === source) {
  7985. return;
  7986. }
  7987. baseFor(source, function(srcValue, key) {
  7988. stack || (stack = new Stack);
  7989. if (isObject(srcValue)) {
  7990. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  7991. }
  7992. else {
  7993. var newValue = customizer
  7994. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  7995. : undefined;
  7996. if (newValue === undefined) {
  7997. newValue = srcValue;
  7998. }
  7999. assignMergeValue(object, key, newValue);
  8000. }
  8001. }, keysIn);
  8002. }
  8003. /**
  8004. * A specialized version of `baseMerge` for arrays and objects which performs
  8005. * deep merges and tracks traversed objects enabling objects with circular
  8006. * references to be merged.
  8007. *
  8008. * @private
  8009. * @param {Object} object The destination object.
  8010. * @param {Object} source The source object.
  8011. * @param {string} key The key of the value to merge.
  8012. * @param {number} srcIndex The index of `source`.
  8013. * @param {Function} mergeFunc The function to merge values.
  8014. * @param {Function} [customizer] The function to customize assigned values.
  8015. * @param {Object} [stack] Tracks traversed source values and their merged
  8016. * counterparts.
  8017. */
  8018. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  8019. var objValue = safeGet(object, key),
  8020. srcValue = safeGet(source, key),
  8021. stacked = stack.get(srcValue);
  8022. if (stacked) {
  8023. assignMergeValue(object, key, stacked);
  8024. return;
  8025. }
  8026. var newValue = customizer
  8027. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  8028. : undefined;
  8029. var isCommon = newValue === undefined;
  8030. if (isCommon) {
  8031. var isArr = isArray(srcValue),
  8032. isBuff = !isArr && isBuffer(srcValue),
  8033. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  8034. newValue = srcValue;
  8035. if (isArr || isBuff || isTyped) {
  8036. if (isArray(objValue)) {
  8037. newValue = objValue;
  8038. }
  8039. else if (isArrayLikeObject(objValue)) {
  8040. newValue = copyArray(objValue);
  8041. }
  8042. else if (isBuff) {
  8043. isCommon = false;
  8044. newValue = cloneBuffer(srcValue, true);
  8045. }
  8046. else if (isTyped) {
  8047. isCommon = false;
  8048. newValue = cloneTypedArray(srcValue, true);
  8049. }
  8050. else {
  8051. newValue = [];
  8052. }
  8053. }
  8054. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  8055. newValue = objValue;
  8056. if (isArguments(objValue)) {
  8057. newValue = toPlainObject(objValue);
  8058. }
  8059. else if (!isObject(objValue) || isFunction(objValue)) {
  8060. newValue = initCloneObject(srcValue);
  8061. }
  8062. }
  8063. else {
  8064. isCommon = false;
  8065. }
  8066. }
  8067. if (isCommon) {
  8068. // Recursively merge objects and arrays (susceptible to call stack limits).
  8069. stack.set(srcValue, newValue);
  8070. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  8071. stack['delete'](srcValue);
  8072. }
  8073. assignMergeValue(object, key, newValue);
  8074. }
  8075. /**
  8076. * The base implementation of `_.nth` which doesn't coerce arguments.
  8077. *
  8078. * @private
  8079. * @param {Array} array The array to query.
  8080. * @param {number} n The index of the element to return.
  8081. * @returns {*} Returns the nth element of `array`.
  8082. */
  8083. function baseNth(array, n) {
  8084. var length = array.length;
  8085. if (!length) {
  8086. return;
  8087. }
  8088. n += n < 0 ? length : 0;
  8089. return isIndex(n, length) ? array[n] : undefined;
  8090. }
  8091. /**
  8092. * The base implementation of `_.orderBy` without param guards.
  8093. *
  8094. * @private
  8095. * @param {Array|Object} collection The collection to iterate over.
  8096. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  8097. * @param {string[]} orders The sort orders of `iteratees`.
  8098. * @returns {Array} Returns the new sorted array.
  8099. */
  8100. function baseOrderBy(collection, iteratees, orders) {
  8101. if (iteratees.length) {
  8102. iteratees = arrayMap(iteratees, function(iteratee) {
  8103. if (isArray(iteratee)) {
  8104. return function(value) {
  8105. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  8106. }
  8107. }
  8108. return iteratee;
  8109. });
  8110. } else {
  8111. iteratees = [identity];
  8112. }
  8113. var index = -1;
  8114. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  8115. var result = baseMap(collection, function(value, key, collection) {
  8116. var criteria = arrayMap(iteratees, function(iteratee) {
  8117. return iteratee(value);
  8118. });
  8119. return { 'criteria': criteria, 'index': ++index, 'value': value };
  8120. });
  8121. return baseSortBy(result, function(object, other) {
  8122. return compareMultiple(object, other, orders);
  8123. });
  8124. }
  8125. /**
  8126. * The base implementation of `_.pick` without support for individual
  8127. * property identifiers.
  8128. *
  8129. * @private
  8130. * @param {Object} object The source object.
  8131. * @param {string[]} paths The property paths to pick.
  8132. * @returns {Object} Returns the new object.
  8133. */
  8134. function basePick(object, paths) {
  8135. return basePickBy(object, paths, function(value, path) {
  8136. return hasIn(object, path);
  8137. });
  8138. }
  8139. /**
  8140. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  8141. *
  8142. * @private
  8143. * @param {Object} object The source object.
  8144. * @param {string[]} paths The property paths to pick.
  8145. * @param {Function} predicate The function invoked per property.
  8146. * @returns {Object} Returns the new object.
  8147. */
  8148. function basePickBy(object, paths, predicate) {
  8149. var index = -1,
  8150. length = paths.length,
  8151. result = {};
  8152. while (++index < length) {
  8153. var path = paths[index],
  8154. value = baseGet(object, path);
  8155. if (predicate(value, path)) {
  8156. baseSet(result, castPath(path, object), value);
  8157. }
  8158. }
  8159. return result;
  8160. }
  8161. /**
  8162. * A specialized version of `baseProperty` which supports deep paths.
  8163. *
  8164. * @private
  8165. * @param {Array|string} path The path of the property to get.
  8166. * @returns {Function} Returns the new accessor function.
  8167. */
  8168. function basePropertyDeep(path) {
  8169. return function(object) {
  8170. return baseGet(object, path);
  8171. };
  8172. }
  8173. /**
  8174. * The base implementation of `_.pullAllBy` without support for iteratee
  8175. * shorthands.
  8176. *
  8177. * @private
  8178. * @param {Array} array The array to modify.
  8179. * @param {Array} values The values to remove.
  8180. * @param {Function} [iteratee] The iteratee invoked per element.
  8181. * @param {Function} [comparator] The comparator invoked per element.
  8182. * @returns {Array} Returns `array`.
  8183. */
  8184. function basePullAll(array, values, iteratee, comparator) {
  8185. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  8186. index = -1,
  8187. length = values.length,
  8188. seen = array;
  8189. if (array === values) {
  8190. values = copyArray(values);
  8191. }
  8192. if (iteratee) {
  8193. seen = arrayMap(array, baseUnary(iteratee));
  8194. }
  8195. while (++index < length) {
  8196. var fromIndex = 0,
  8197. value = values[index],
  8198. computed = iteratee ? iteratee(value) : value;
  8199. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  8200. if (seen !== array) {
  8201. splice.call(seen, fromIndex, 1);
  8202. }
  8203. splice.call(array, fromIndex, 1);
  8204. }
  8205. }
  8206. return array;
  8207. }
  8208. /**
  8209. * The base implementation of `_.pullAt` without support for individual
  8210. * indexes or capturing the removed elements.
  8211. *
  8212. * @private
  8213. * @param {Array} array The array to modify.
  8214. * @param {number[]} indexes The indexes of elements to remove.
  8215. * @returns {Array} Returns `array`.
  8216. */
  8217. function basePullAt(array, indexes) {
  8218. var length = array ? indexes.length : 0,
  8219. lastIndex = length - 1;
  8220. while (length--) {
  8221. var index = indexes[length];
  8222. if (length == lastIndex || index !== previous) {
  8223. var previous = index;
  8224. if (isIndex(index)) {
  8225. splice.call(array, index, 1);
  8226. } else {
  8227. baseUnset(array, index);
  8228. }
  8229. }
  8230. }
  8231. return array;
  8232. }
  8233. /**
  8234. * The base implementation of `_.random` without support for returning
  8235. * floating-point numbers.
  8236. *
  8237. * @private
  8238. * @param {number} lower The lower bound.
  8239. * @param {number} upper The upper bound.
  8240. * @returns {number} Returns the random number.
  8241. */
  8242. function baseRandom(lower, upper) {
  8243. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  8244. }
  8245. /**
  8246. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  8247. * coerce arguments.
  8248. *
  8249. * @private
  8250. * @param {number} start The start of the range.
  8251. * @param {number} end The end of the range.
  8252. * @param {number} step The value to increment or decrement by.
  8253. * @param {boolean} [fromRight] Specify iterating from right to left.
  8254. * @returns {Array} Returns the range of numbers.
  8255. */
  8256. function baseRange(start, end, step, fromRight) {
  8257. var index = -1,
  8258. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  8259. result = Array(length);
  8260. while (length--) {
  8261. result[fromRight ? length : ++index] = start;
  8262. start += step;
  8263. }
  8264. return result;
  8265. }
  8266. /**
  8267. * The base implementation of `_.repeat` which doesn't coerce arguments.
  8268. *
  8269. * @private
  8270. * @param {string} string The string to repeat.
  8271. * @param {number} n The number of times to repeat the string.
  8272. * @returns {string} Returns the repeated string.
  8273. */
  8274. function baseRepeat(string, n) {
  8275. var result = '';
  8276. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  8277. return result;
  8278. }
  8279. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  8280. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  8281. do {
  8282. if (n % 2) {
  8283. result += string;
  8284. }
  8285. n = nativeFloor(n / 2);
  8286. if (n) {
  8287. string += string;
  8288. }
  8289. } while (n);
  8290. return result;
  8291. }
  8292. /**
  8293. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  8294. *
  8295. * @private
  8296. * @param {Function} func The function to apply a rest parameter to.
  8297. * @param {number} [start=func.length-1] The start position of the rest parameter.
  8298. * @returns {Function} Returns the new function.
  8299. */
  8300. function baseRest(func, start) {
  8301. return setToString(overRest(func, start, identity), func + '');
  8302. }
  8303. /**
  8304. * The base implementation of `_.sample`.
  8305. *
  8306. * @private
  8307. * @param {Array|Object} collection The collection to sample.
  8308. * @returns {*} Returns the random element.
  8309. */
  8310. function baseSample(collection) {
  8311. return arraySample(values(collection));
  8312. }
  8313. /**
  8314. * The base implementation of `_.sampleSize` without param guards.
  8315. *
  8316. * @private
  8317. * @param {Array|Object} collection The collection to sample.
  8318. * @param {number} n The number of elements to sample.
  8319. * @returns {Array} Returns the random elements.
  8320. */
  8321. function baseSampleSize(collection, n) {
  8322. var array = values(collection);
  8323. return shuffleSelf(array, baseClamp(n, 0, array.length));
  8324. }
  8325. /**
  8326. * The base implementation of `_.set`.
  8327. *
  8328. * @private
  8329. * @param {Object} object The object to modify.
  8330. * @param {Array|string} path The path of the property to set.
  8331. * @param {*} value The value to set.
  8332. * @param {Function} [customizer] The function to customize path creation.
  8333. * @returns {Object} Returns `object`.
  8334. */
  8335. function baseSet(object, path, value, customizer) {
  8336. if (!isObject(object)) {
  8337. return object;
  8338. }
  8339. path = castPath(path, object);
  8340. var index = -1,
  8341. length = path.length,
  8342. lastIndex = length - 1,
  8343. nested = object;
  8344. while (nested != null && ++index < length) {
  8345. var key = toKey(path[index]),
  8346. newValue = value;
  8347. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  8348. return object;
  8349. }
  8350. if (index != lastIndex) {
  8351. var objValue = nested[key];
  8352. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  8353. if (newValue === undefined) {
  8354. newValue = isObject(objValue)
  8355. ? objValue
  8356. : (isIndex(path[index + 1]) ? [] : {});
  8357. }
  8358. }
  8359. assignValue(nested, key, newValue);
  8360. nested = nested[key];
  8361. }
  8362. return object;
  8363. }
  8364. /**
  8365. * The base implementation of `setData` without support for hot loop shorting.
  8366. *
  8367. * @private
  8368. * @param {Function} func The function to associate metadata with.
  8369. * @param {*} data The metadata.
  8370. * @returns {Function} Returns `func`.
  8371. */
  8372. var baseSetData = !metaMap ? identity : function(func, data) {
  8373. metaMap.set(func, data);
  8374. return func;
  8375. };
  8376. /**
  8377. * The base implementation of `setToString` without support for hot loop shorting.
  8378. *
  8379. * @private
  8380. * @param {Function} func The function to modify.
  8381. * @param {Function} string The `toString` result.
  8382. * @returns {Function} Returns `func`.
  8383. */
  8384. var baseSetToString = !defineProperty ? identity : function(func, string) {
  8385. return defineProperty(func, 'toString', {
  8386. 'configurable': true,
  8387. 'enumerable': false,
  8388. 'value': constant(string),
  8389. 'writable': true
  8390. });
  8391. };
  8392. /**
  8393. * The base implementation of `_.shuffle`.
  8394. *
  8395. * @private
  8396. * @param {Array|Object} collection The collection to shuffle.
  8397. * @returns {Array} Returns the new shuffled array.
  8398. */
  8399. function baseShuffle(collection) {
  8400. return shuffleSelf(values(collection));
  8401. }
  8402. /**
  8403. * The base implementation of `_.slice` without an iteratee call guard.
  8404. *
  8405. * @private
  8406. * @param {Array} array The array to slice.
  8407. * @param {number} [start=0] The start position.
  8408. * @param {number} [end=array.length] The end position.
  8409. * @returns {Array} Returns the slice of `array`.
  8410. */
  8411. function baseSlice(array, start, end) {
  8412. var index = -1,
  8413. length = array.length;
  8414. if (start < 0) {
  8415. start = -start > length ? 0 : (length + start);
  8416. }
  8417. end = end > length ? length : end;
  8418. if (end < 0) {
  8419. end += length;
  8420. }
  8421. length = start > end ? 0 : ((end - start) >>> 0);
  8422. start >>>= 0;
  8423. var result = Array(length);
  8424. while (++index < length) {
  8425. result[index] = array[index + start];
  8426. }
  8427. return result;
  8428. }
  8429. /**
  8430. * The base implementation of `_.some` without support for iteratee shorthands.
  8431. *
  8432. * @private
  8433. * @param {Array|Object} collection The collection to iterate over.
  8434. * @param {Function} predicate The function invoked per iteration.
  8435. * @returns {boolean} Returns `true` if any element passes the predicate check,
  8436. * else `false`.
  8437. */
  8438. function baseSome(collection, predicate) {
  8439. var result;
  8440. baseEach(collection, function(value, index, collection) {
  8441. result = predicate(value, index, collection);
  8442. return !result;
  8443. });
  8444. return !!result;
  8445. }
  8446. /**
  8447. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  8448. * performs a binary search of `array` to determine the index at which `value`
  8449. * should be inserted into `array` in order to maintain its sort order.
  8450. *
  8451. * @private
  8452. * @param {Array} array The sorted array to inspect.
  8453. * @param {*} value The value to evaluate.
  8454. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  8455. * @returns {number} Returns the index at which `value` should be inserted
  8456. * into `array`.
  8457. */
  8458. function baseSortedIndex(array, value, retHighest) {
  8459. var low = 0,
  8460. high = array == null ? low : array.length;
  8461. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  8462. while (low < high) {
  8463. var mid = (low + high) >>> 1,
  8464. computed = array[mid];
  8465. if (computed !== null && !isSymbol(computed) &&
  8466. (retHighest ? (computed <= value) : (computed < value))) {
  8467. low = mid + 1;
  8468. } else {
  8469. high = mid;
  8470. }
  8471. }
  8472. return high;
  8473. }
  8474. return baseSortedIndexBy(array, value, identity, retHighest);
  8475. }
  8476. /**
  8477. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  8478. * which invokes `iteratee` for `value` and each element of `array` to compute
  8479. * their sort ranking. The iteratee is invoked with one argument; (value).
  8480. *
  8481. * @private
  8482. * @param {Array} array The sorted array to inspect.
  8483. * @param {*} value The value to evaluate.
  8484. * @param {Function} iteratee The iteratee invoked per element.
  8485. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  8486. * @returns {number} Returns the index at which `value` should be inserted
  8487. * into `array`.
  8488. */
  8489. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  8490. var low = 0,
  8491. high = array == null ? 0 : array.length;
  8492. if (high === 0) {
  8493. return 0;
  8494. }
  8495. value = iteratee(value);
  8496. var valIsNaN = value !== value,
  8497. valIsNull = value === null,
  8498. valIsSymbol = isSymbol(value),
  8499. valIsUndefined = value === undefined;
  8500. while (low < high) {
  8501. var mid = nativeFloor((low + high) / 2),
  8502. computed = iteratee(array[mid]),
  8503. othIsDefined = computed !== undefined,
  8504. othIsNull = computed === null,
  8505. othIsReflexive = computed === computed,
  8506. othIsSymbol = isSymbol(computed);
  8507. if (valIsNaN) {
  8508. var setLow = retHighest || othIsReflexive;
  8509. } else if (valIsUndefined) {
  8510. setLow = othIsReflexive && (retHighest || othIsDefined);
  8511. } else if (valIsNull) {
  8512. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  8513. } else if (valIsSymbol) {
  8514. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  8515. } else if (othIsNull || othIsSymbol) {
  8516. setLow = false;
  8517. } else {
  8518. setLow = retHighest ? (computed <= value) : (computed < value);
  8519. }
  8520. if (setLow) {
  8521. low = mid + 1;
  8522. } else {
  8523. high = mid;
  8524. }
  8525. }
  8526. return nativeMin(high, MAX_ARRAY_INDEX);
  8527. }
  8528. /**
  8529. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  8530. * support for iteratee shorthands.
  8531. *
  8532. * @private
  8533. * @param {Array} array The array to inspect.
  8534. * @param {Function} [iteratee] The iteratee invoked per element.
  8535. * @returns {Array} Returns the new duplicate free array.
  8536. */
  8537. function baseSortedUniq(array, iteratee) {
  8538. var index = -1,
  8539. length = array.length,
  8540. resIndex = 0,
  8541. result = [];
  8542. while (++index < length) {
  8543. var value = array[index],
  8544. computed = iteratee ? iteratee(value) : value;
  8545. if (!index || !eq(computed, seen)) {
  8546. var seen = computed;
  8547. result[resIndex++] = value === 0 ? 0 : value;
  8548. }
  8549. }
  8550. return result;
  8551. }
  8552. /**
  8553. * The base implementation of `_.toNumber` which doesn't ensure correct
  8554. * conversions of binary, hexadecimal, or octal string values.
  8555. *
  8556. * @private
  8557. * @param {*} value The value to process.
  8558. * @returns {number} Returns the number.
  8559. */
  8560. function baseToNumber(value) {
  8561. if (typeof value == 'number') {
  8562. return value;
  8563. }
  8564. if (isSymbol(value)) {
  8565. return NAN;
  8566. }
  8567. return +value;
  8568. }
  8569. /**
  8570. * The base implementation of `_.toString` which doesn't convert nullish
  8571. * values to empty strings.
  8572. *
  8573. * @private
  8574. * @param {*} value The value to process.
  8575. * @returns {string} Returns the string.
  8576. */
  8577. function baseToString(value) {
  8578. // Exit early for strings to avoid a performance hit in some environments.
  8579. if (typeof value == 'string') {
  8580. return value;
  8581. }
  8582. if (isArray(value)) {
  8583. // Recursively convert values (susceptible to call stack limits).
  8584. return arrayMap(value, baseToString) + '';
  8585. }
  8586. if (isSymbol(value)) {
  8587. return symbolToString ? symbolToString.call(value) : '';
  8588. }
  8589. var result = (value + '');
  8590. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  8591. }
  8592. /**
  8593. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  8594. *
  8595. * @private
  8596. * @param {Array} array The array to inspect.
  8597. * @param {Function} [iteratee] The iteratee invoked per element.
  8598. * @param {Function} [comparator] The comparator invoked per element.
  8599. * @returns {Array} Returns the new duplicate free array.
  8600. */
  8601. function baseUniq(array, iteratee, comparator) {
  8602. var index = -1,
  8603. includes = arrayIncludes,
  8604. length = array.length,
  8605. isCommon = true,
  8606. result = [],
  8607. seen = result;
  8608. if (comparator) {
  8609. isCommon = false;
  8610. includes = arrayIncludesWith;
  8611. }
  8612. else if (length >= LARGE_ARRAY_SIZE) {
  8613. var set = iteratee ? null : createSet(array);
  8614. if (set) {
  8615. return setToArray(set);
  8616. }
  8617. isCommon = false;
  8618. includes = cacheHas;
  8619. seen = new SetCache;
  8620. }
  8621. else {
  8622. seen = iteratee ? [] : result;
  8623. }
  8624. outer:
  8625. while (++index < length) {
  8626. var value = array[index],
  8627. computed = iteratee ? iteratee(value) : value;
  8628. value = (comparator || value !== 0) ? value : 0;
  8629. if (isCommon && computed === computed) {
  8630. var seenIndex = seen.length;
  8631. while (seenIndex--) {
  8632. if (seen[seenIndex] === computed) {
  8633. continue outer;
  8634. }
  8635. }
  8636. if (iteratee) {
  8637. seen.push(computed);
  8638. }
  8639. result.push(value);
  8640. }
  8641. else if (!includes(seen, computed, comparator)) {
  8642. if (seen !== result) {
  8643. seen.push(computed);
  8644. }
  8645. result.push(value);
  8646. }
  8647. }
  8648. return result;
  8649. }
  8650. /**
  8651. * The base implementation of `_.unset`.
  8652. *
  8653. * @private
  8654. * @param {Object} object The object to modify.
  8655. * @param {Array|string} path The property path to unset.
  8656. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  8657. */
  8658. function baseUnset(object, path) {
  8659. path = castPath(path, object);
  8660. object = parent(object, path);
  8661. return object == null || delete object[toKey(last(path))];
  8662. }
  8663. /**
  8664. * The base implementation of `_.update`.
  8665. *
  8666. * @private
  8667. * @param {Object} object The object to modify.
  8668. * @param {Array|string} path The path of the property to update.
  8669. * @param {Function} updater The function to produce the updated value.
  8670. * @param {Function} [customizer] The function to customize path creation.
  8671. * @returns {Object} Returns `object`.
  8672. */
  8673. function baseUpdate(object, path, updater, customizer) {
  8674. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  8675. }
  8676. /**
  8677. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  8678. * without support for iteratee shorthands.
  8679. *
  8680. * @private
  8681. * @param {Array} array The array to query.
  8682. * @param {Function} predicate The function invoked per iteration.
  8683. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  8684. * @param {boolean} [fromRight] Specify iterating from right to left.
  8685. * @returns {Array} Returns the slice of `array`.
  8686. */
  8687. function baseWhile(array, predicate, isDrop, fromRight) {
  8688. var length = array.length,
  8689. index = fromRight ? length : -1;
  8690. while ((fromRight ? index-- : ++index < length) &&
  8691. predicate(array[index], index, array)) {}
  8692. return isDrop
  8693. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  8694. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  8695. }
  8696. /**
  8697. * The base implementation of `wrapperValue` which returns the result of
  8698. * performing a sequence of actions on the unwrapped `value`, where each
  8699. * successive action is supplied the return value of the previous.
  8700. *
  8701. * @private
  8702. * @param {*} value The unwrapped value.
  8703. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  8704. * @returns {*} Returns the resolved value.
  8705. */
  8706. function baseWrapperValue(value, actions) {
  8707. var result = value;
  8708. if (result instanceof LazyWrapper) {
  8709. result = result.value();
  8710. }
  8711. return arrayReduce(actions, function(result, action) {
  8712. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  8713. }, result);
  8714. }
  8715. /**
  8716. * The base implementation of methods like `_.xor`, without support for
  8717. * iteratee shorthands, that accepts an array of arrays to inspect.
  8718. *
  8719. * @private
  8720. * @param {Array} arrays The arrays to inspect.
  8721. * @param {Function} [iteratee] The iteratee invoked per element.
  8722. * @param {Function} [comparator] The comparator invoked per element.
  8723. * @returns {Array} Returns the new array of values.
  8724. */
  8725. function baseXor(arrays, iteratee, comparator) {
  8726. var length = arrays.length;
  8727. if (length < 2) {
  8728. return length ? baseUniq(arrays[0]) : [];
  8729. }
  8730. var index = -1,
  8731. result = Array(length);
  8732. while (++index < length) {
  8733. var array = arrays[index],
  8734. othIndex = -1;
  8735. while (++othIndex < length) {
  8736. if (othIndex != index) {
  8737. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  8738. }
  8739. }
  8740. }
  8741. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  8742. }
  8743. /**
  8744. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  8745. *
  8746. * @private
  8747. * @param {Array} props The property identifiers.
  8748. * @param {Array} values The property values.
  8749. * @param {Function} assignFunc The function to assign values.
  8750. * @returns {Object} Returns the new object.
  8751. */
  8752. function baseZipObject(props, values, assignFunc) {
  8753. var index = -1,
  8754. length = props.length,
  8755. valsLength = values.length,
  8756. result = {};
  8757. while (++index < length) {
  8758. var value = index < valsLength ? values[index] : undefined;
  8759. assignFunc(result, props[index], value);
  8760. }
  8761. return result;
  8762. }
  8763. /**
  8764. * Casts `value` to an empty array if it's not an array like object.
  8765. *
  8766. * @private
  8767. * @param {*} value The value to inspect.
  8768. * @returns {Array|Object} Returns the cast array-like object.
  8769. */
  8770. function castArrayLikeObject(value) {
  8771. return isArrayLikeObject(value) ? value : [];
  8772. }
  8773. /**
  8774. * Casts `value` to `identity` if it's not a function.
  8775. *
  8776. * @private
  8777. * @param {*} value The value to inspect.
  8778. * @returns {Function} Returns cast function.
  8779. */
  8780. function castFunction(value) {
  8781. return typeof value == 'function' ? value : identity;
  8782. }
  8783. /**
  8784. * Casts `value` to a path array if it's not one.
  8785. *
  8786. * @private
  8787. * @param {*} value The value to inspect.
  8788. * @param {Object} [object] The object to query keys on.
  8789. * @returns {Array} Returns the cast property path array.
  8790. */
  8791. function castPath(value, object) {
  8792. if (isArray(value)) {
  8793. return value;
  8794. }
  8795. return isKey(value, object) ? [value] : stringToPath(toString(value));
  8796. }
  8797. /**
  8798. * A `baseRest` alias which can be replaced with `identity` by module
  8799. * replacement plugins.
  8800. *
  8801. * @private
  8802. * @type {Function}
  8803. * @param {Function} func The function to apply a rest parameter to.
  8804. * @returns {Function} Returns the new function.
  8805. */
  8806. var castRest = baseRest;
  8807. /**
  8808. * Casts `array` to a slice if it's needed.
  8809. *
  8810. * @private
  8811. * @param {Array} array The array to inspect.
  8812. * @param {number} start The start position.
  8813. * @param {number} [end=array.length] The end position.
  8814. * @returns {Array} Returns the cast slice.
  8815. */
  8816. function castSlice(array, start, end) {
  8817. var length = array.length;
  8818. end = end === undefined ? length : end;
  8819. return (!start && end >= length) ? array : baseSlice(array, start, end);
  8820. }
  8821. /**
  8822. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  8823. *
  8824. * @private
  8825. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  8826. */
  8827. var clearTimeout = ctxClearTimeout || function(id) {
  8828. return root.clearTimeout(id);
  8829. };
  8830. /**
  8831. * Creates a clone of `buffer`.
  8832. *
  8833. * @private
  8834. * @param {Buffer} buffer The buffer to clone.
  8835. * @param {boolean} [isDeep] Specify a deep clone.
  8836. * @returns {Buffer} Returns the cloned buffer.
  8837. */
  8838. function cloneBuffer(buffer, isDeep) {
  8839. if (isDeep) {
  8840. return buffer.slice();
  8841. }
  8842. var length = buffer.length,
  8843. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  8844. buffer.copy(result);
  8845. return result;
  8846. }
  8847. /**
  8848. * Creates a clone of `arrayBuffer`.
  8849. *
  8850. * @private
  8851. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  8852. * @returns {ArrayBuffer} Returns the cloned array buffer.
  8853. */
  8854. function cloneArrayBuffer(arrayBuffer) {
  8855. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  8856. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  8857. return result;
  8858. }
  8859. /**
  8860. * Creates a clone of `dataView`.
  8861. *
  8862. * @private
  8863. * @param {Object} dataView The data view to clone.
  8864. * @param {boolean} [isDeep] Specify a deep clone.
  8865. * @returns {Object} Returns the cloned data view.
  8866. */
  8867. function cloneDataView(dataView, isDeep) {
  8868. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  8869. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  8870. }
  8871. /**
  8872. * Creates a clone of `regexp`.
  8873. *
  8874. * @private
  8875. * @param {Object} regexp The regexp to clone.
  8876. * @returns {Object} Returns the cloned regexp.
  8877. */
  8878. function cloneRegExp(regexp) {
  8879. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  8880. result.lastIndex = regexp.lastIndex;
  8881. return result;
  8882. }
  8883. /**
  8884. * Creates a clone of the `symbol` object.
  8885. *
  8886. * @private
  8887. * @param {Object} symbol The symbol object to clone.
  8888. * @returns {Object} Returns the cloned symbol object.
  8889. */
  8890. function cloneSymbol(symbol) {
  8891. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  8892. }
  8893. /**
  8894. * Creates a clone of `typedArray`.
  8895. *
  8896. * @private
  8897. * @param {Object} typedArray The typed array to clone.
  8898. * @param {boolean} [isDeep] Specify a deep clone.
  8899. * @returns {Object} Returns the cloned typed array.
  8900. */
  8901. function cloneTypedArray(typedArray, isDeep) {
  8902. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  8903. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  8904. }
  8905. /**
  8906. * Compares values to sort them in ascending order.
  8907. *
  8908. * @private
  8909. * @param {*} value The value to compare.
  8910. * @param {*} other The other value to compare.
  8911. * @returns {number} Returns the sort order indicator for `value`.
  8912. */
  8913. function compareAscending(value, other) {
  8914. if (value !== other) {
  8915. var valIsDefined = value !== undefined,
  8916. valIsNull = value === null,
  8917. valIsReflexive = value === value,
  8918. valIsSymbol = isSymbol(value);
  8919. var othIsDefined = other !== undefined,
  8920. othIsNull = other === null,
  8921. othIsReflexive = other === other,
  8922. othIsSymbol = isSymbol(other);
  8923. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  8924. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  8925. (valIsNull && othIsDefined && othIsReflexive) ||
  8926. (!valIsDefined && othIsReflexive) ||
  8927. !valIsReflexive) {
  8928. return 1;
  8929. }
  8930. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  8931. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  8932. (othIsNull && valIsDefined && valIsReflexive) ||
  8933. (!othIsDefined && valIsReflexive) ||
  8934. !othIsReflexive) {
  8935. return -1;
  8936. }
  8937. }
  8938. return 0;
  8939. }
  8940. /**
  8941. * Used by `_.orderBy` to compare multiple properties of a value to another
  8942. * and stable sort them.
  8943. *
  8944. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  8945. * specify an order of "desc" for descending or "asc" for ascending sort order
  8946. * of corresponding values.
  8947. *
  8948. * @private
  8949. * @param {Object} object The object to compare.
  8950. * @param {Object} other The other object to compare.
  8951. * @param {boolean[]|string[]} orders The order to sort by for each property.
  8952. * @returns {number} Returns the sort order indicator for `object`.
  8953. */
  8954. function compareMultiple(object, other, orders) {
  8955. var index = -1,
  8956. objCriteria = object.criteria,
  8957. othCriteria = other.criteria,
  8958. length = objCriteria.length,
  8959. ordersLength = orders.length;
  8960. while (++index < length) {
  8961. var result = compareAscending(objCriteria[index], othCriteria[index]);
  8962. if (result) {
  8963. if (index >= ordersLength) {
  8964. return result;
  8965. }
  8966. var order = orders[index];
  8967. return result * (order == 'desc' ? -1 : 1);
  8968. }
  8969. }
  8970. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  8971. // that causes it, under certain circumstances, to provide the same value for
  8972. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  8973. // for more details.
  8974. //
  8975. // This also ensures a stable sort in V8 and other engines.
  8976. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  8977. return object.index - other.index;
  8978. }
  8979. /**
  8980. * Creates an array that is the composition of partially applied arguments,
  8981. * placeholders, and provided arguments into a single array of arguments.
  8982. *
  8983. * @private
  8984. * @param {Array} args The provided arguments.
  8985. * @param {Array} partials The arguments to prepend to those provided.
  8986. * @param {Array} holders The `partials` placeholder indexes.
  8987. * @params {boolean} [isCurried] Specify composing for a curried function.
  8988. * @returns {Array} Returns the new array of composed arguments.
  8989. */
  8990. function composeArgs(args, partials, holders, isCurried) {
  8991. var argsIndex = -1,
  8992. argsLength = args.length,
  8993. holdersLength = holders.length,
  8994. leftIndex = -1,
  8995. leftLength = partials.length,
  8996. rangeLength = nativeMax(argsLength - holdersLength, 0),
  8997. result = Array(leftLength + rangeLength),
  8998. isUncurried = !isCurried;
  8999. while (++leftIndex < leftLength) {
  9000. result[leftIndex] = partials[leftIndex];
  9001. }
  9002. while (++argsIndex < holdersLength) {
  9003. if (isUncurried || argsIndex < argsLength) {
  9004. result[holders[argsIndex]] = args[argsIndex];
  9005. }
  9006. }
  9007. while (rangeLength--) {
  9008. result[leftIndex++] = args[argsIndex++];
  9009. }
  9010. return result;
  9011. }
  9012. /**
  9013. * This function is like `composeArgs` except that the arguments composition
  9014. * is tailored for `_.partialRight`.
  9015. *
  9016. * @private
  9017. * @param {Array} args The provided arguments.
  9018. * @param {Array} partials The arguments to append to those provided.
  9019. * @param {Array} holders The `partials` placeholder indexes.
  9020. * @params {boolean} [isCurried] Specify composing for a curried function.
  9021. * @returns {Array} Returns the new array of composed arguments.
  9022. */
  9023. function composeArgsRight(args, partials, holders, isCurried) {
  9024. var argsIndex = -1,
  9025. argsLength = args.length,
  9026. holdersIndex = -1,
  9027. holdersLength = holders.length,
  9028. rightIndex = -1,
  9029. rightLength = partials.length,
  9030. rangeLength = nativeMax(argsLength - holdersLength, 0),
  9031. result = Array(rangeLength + rightLength),
  9032. isUncurried = !isCurried;
  9033. while (++argsIndex < rangeLength) {
  9034. result[argsIndex] = args[argsIndex];
  9035. }
  9036. var offset = argsIndex;
  9037. while (++rightIndex < rightLength) {
  9038. result[offset + rightIndex] = partials[rightIndex];
  9039. }
  9040. while (++holdersIndex < holdersLength) {
  9041. if (isUncurried || argsIndex < argsLength) {
  9042. result[offset + holders[holdersIndex]] = args[argsIndex++];
  9043. }
  9044. }
  9045. return result;
  9046. }
  9047. /**
  9048. * Copies the values of `source` to `array`.
  9049. *
  9050. * @private
  9051. * @param {Array} source The array to copy values from.
  9052. * @param {Array} [array=[]] The array to copy values to.
  9053. * @returns {Array} Returns `array`.
  9054. */
  9055. function copyArray(source, array) {
  9056. var index = -1,
  9057. length = source.length;
  9058. array || (array = Array(length));
  9059. while (++index < length) {
  9060. array[index] = source[index];
  9061. }
  9062. return array;
  9063. }
  9064. /**
  9065. * Copies properties of `source` to `object`.
  9066. *
  9067. * @private
  9068. * @param {Object} source The object to copy properties from.
  9069. * @param {Array} props The property identifiers to copy.
  9070. * @param {Object} [object={}] The object to copy properties to.
  9071. * @param {Function} [customizer] The function to customize copied values.
  9072. * @returns {Object} Returns `object`.
  9073. */
  9074. function copyObject(source, props, object, customizer) {
  9075. var isNew = !object;
  9076. object || (object = {});
  9077. var index = -1,
  9078. length = props.length;
  9079. while (++index < length) {
  9080. var key = props[index];
  9081. var newValue = customizer
  9082. ? customizer(object[key], source[key], key, object, source)
  9083. : undefined;
  9084. if (newValue === undefined) {
  9085. newValue = source[key];
  9086. }
  9087. if (isNew) {
  9088. baseAssignValue(object, key, newValue);
  9089. } else {
  9090. assignValue(object, key, newValue);
  9091. }
  9092. }
  9093. return object;
  9094. }
  9095. /**
  9096. * Copies own symbols of `source` to `object`.
  9097. *
  9098. * @private
  9099. * @param {Object} source The object to copy symbols from.
  9100. * @param {Object} [object={}] The object to copy symbols to.
  9101. * @returns {Object} Returns `object`.
  9102. */
  9103. function copySymbols(source, object) {
  9104. return copyObject(source, getSymbols(source), object);
  9105. }
  9106. /**
  9107. * Copies own and inherited symbols of `source` to `object`.
  9108. *
  9109. * @private
  9110. * @param {Object} source The object to copy symbols from.
  9111. * @param {Object} [object={}] The object to copy symbols to.
  9112. * @returns {Object} Returns `object`.
  9113. */
  9114. function copySymbolsIn(source, object) {
  9115. return copyObject(source, getSymbolsIn(source), object);
  9116. }
  9117. /**
  9118. * Creates a function like `_.groupBy`.
  9119. *
  9120. * @private
  9121. * @param {Function} setter The function to set accumulator values.
  9122. * @param {Function} [initializer] The accumulator object initializer.
  9123. * @returns {Function} Returns the new aggregator function.
  9124. */
  9125. function createAggregator(setter, initializer) {
  9126. return function(collection, iteratee) {
  9127. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  9128. accumulator = initializer ? initializer() : {};
  9129. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  9130. };
  9131. }
  9132. /**
  9133. * Creates a function like `_.assign`.
  9134. *
  9135. * @private
  9136. * @param {Function} assigner The function to assign values.
  9137. * @returns {Function} Returns the new assigner function.
  9138. */
  9139. function createAssigner(assigner) {
  9140. return baseRest(function(object, sources) {
  9141. var index = -1,
  9142. length = sources.length,
  9143. customizer = length > 1 ? sources[length - 1] : undefined,
  9144. guard = length > 2 ? sources[2] : undefined;
  9145. customizer = (assigner.length > 3 && typeof customizer == 'function')
  9146. ? (length--, customizer)
  9147. : undefined;
  9148. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  9149. customizer = length < 3 ? undefined : customizer;
  9150. length = 1;
  9151. }
  9152. object = Object(object);
  9153. while (++index < length) {
  9154. var source = sources[index];
  9155. if (source) {
  9156. assigner(object, source, index, customizer);
  9157. }
  9158. }
  9159. return object;
  9160. });
  9161. }
  9162. /**
  9163. * Creates a `baseEach` or `baseEachRight` function.
  9164. *
  9165. * @private
  9166. * @param {Function} eachFunc The function to iterate over a collection.
  9167. * @param {boolean} [fromRight] Specify iterating from right to left.
  9168. * @returns {Function} Returns the new base function.
  9169. */
  9170. function createBaseEach(eachFunc, fromRight) {
  9171. return function(collection, iteratee) {
  9172. if (collection == null) {
  9173. return collection;
  9174. }
  9175. if (!isArrayLike(collection)) {
  9176. return eachFunc(collection, iteratee);
  9177. }
  9178. var length = collection.length,
  9179. index = fromRight ? length : -1,
  9180. iterable = Object(collection);
  9181. while ((fromRight ? index-- : ++index < length)) {
  9182. if (iteratee(iterable[index], index, iterable) === false) {
  9183. break;
  9184. }
  9185. }
  9186. return collection;
  9187. };
  9188. }
  9189. /**
  9190. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  9191. *
  9192. * @private
  9193. * @param {boolean} [fromRight] Specify iterating from right to left.
  9194. * @returns {Function} Returns the new base function.
  9195. */
  9196. function createBaseFor(fromRight) {
  9197. return function(object, iteratee, keysFunc) {
  9198. var index = -1,
  9199. iterable = Object(object),
  9200. props = keysFunc(object),
  9201. length = props.length;
  9202. while (length--) {
  9203. var key = props[fromRight ? length : ++index];
  9204. if (iteratee(iterable[key], key, iterable) === false) {
  9205. break;
  9206. }
  9207. }
  9208. return object;
  9209. };
  9210. }
  9211. /**
  9212. * Creates a function that wraps `func` to invoke it with the optional `this`
  9213. * binding of `thisArg`.
  9214. *
  9215. * @private
  9216. * @param {Function} func The function to wrap.
  9217. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9218. * @param {*} [thisArg] The `this` binding of `func`.
  9219. * @returns {Function} Returns the new wrapped function.
  9220. */
  9221. function createBind(func, bitmask, thisArg) {
  9222. var isBind = bitmask & WRAP_BIND_FLAG,
  9223. Ctor = createCtor(func);
  9224. function wrapper() {
  9225. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9226. return fn.apply(isBind ? thisArg : this, arguments);
  9227. }
  9228. return wrapper;
  9229. }
  9230. /**
  9231. * Creates a function like `_.lowerFirst`.
  9232. *
  9233. * @private
  9234. * @param {string} methodName The name of the `String` case method to use.
  9235. * @returns {Function} Returns the new case function.
  9236. */
  9237. function createCaseFirst(methodName) {
  9238. return function(string) {
  9239. string = toString(string);
  9240. var strSymbols = hasUnicode(string)
  9241. ? stringToArray(string)
  9242. : undefined;
  9243. var chr = strSymbols
  9244. ? strSymbols[0]
  9245. : string.charAt(0);
  9246. var trailing = strSymbols
  9247. ? castSlice(strSymbols, 1).join('')
  9248. : string.slice(1);
  9249. return chr[methodName]() + trailing;
  9250. };
  9251. }
  9252. /**
  9253. * Creates a function like `_.camelCase`.
  9254. *
  9255. * @private
  9256. * @param {Function} callback The function to combine each word.
  9257. * @returns {Function} Returns the new compounder function.
  9258. */
  9259. function createCompounder(callback) {
  9260. return function(string) {
  9261. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  9262. };
  9263. }
  9264. /**
  9265. * Creates a function that produces an instance of `Ctor` regardless of
  9266. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  9267. *
  9268. * @private
  9269. * @param {Function} Ctor The constructor to wrap.
  9270. * @returns {Function} Returns the new wrapped function.
  9271. */
  9272. function createCtor(Ctor) {
  9273. return function() {
  9274. // Use a `switch` statement to work with class constructors. See
  9275. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  9276. // for more details.
  9277. var args = arguments;
  9278. switch (args.length) {
  9279. case 0: return new Ctor;
  9280. case 1: return new Ctor(args[0]);
  9281. case 2: return new Ctor(args[0], args[1]);
  9282. case 3: return new Ctor(args[0], args[1], args[2]);
  9283. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  9284. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  9285. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  9286. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  9287. }
  9288. var thisBinding = baseCreate(Ctor.prototype),
  9289. result = Ctor.apply(thisBinding, args);
  9290. // Mimic the constructor's `return` behavior.
  9291. // See https://es5.github.io/#x13.2.2 for more details.
  9292. return isObject(result) ? result : thisBinding;
  9293. };
  9294. }
  9295. /**
  9296. * Creates a function that wraps `func` to enable currying.
  9297. *
  9298. * @private
  9299. * @param {Function} func The function to wrap.
  9300. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9301. * @param {number} arity The arity of `func`.
  9302. * @returns {Function} Returns the new wrapped function.
  9303. */
  9304. function createCurry(func, bitmask, arity) {
  9305. var Ctor = createCtor(func);
  9306. function wrapper() {
  9307. var length = arguments.length,
  9308. args = Array(length),
  9309. index = length,
  9310. placeholder = getHolder(wrapper);
  9311. while (index--) {
  9312. args[index] = arguments[index];
  9313. }
  9314. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  9315. ? []
  9316. : replaceHolders(args, placeholder);
  9317. length -= holders.length;
  9318. if (length < arity) {
  9319. return createRecurry(
  9320. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  9321. args, holders, undefined, undefined, arity - length);
  9322. }
  9323. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9324. return apply(fn, this, args);
  9325. }
  9326. return wrapper;
  9327. }
  9328. /**
  9329. * Creates a `_.find` or `_.findLast` function.
  9330. *
  9331. * @private
  9332. * @param {Function} findIndexFunc The function to find the collection index.
  9333. * @returns {Function} Returns the new find function.
  9334. */
  9335. function createFind(findIndexFunc) {
  9336. return function(collection, predicate, fromIndex) {
  9337. var iterable = Object(collection);
  9338. if (!isArrayLike(collection)) {
  9339. var iteratee = getIteratee(predicate, 3);
  9340. collection = keys(collection);
  9341. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  9342. }
  9343. var index = findIndexFunc(collection, predicate, fromIndex);
  9344. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  9345. };
  9346. }
  9347. /**
  9348. * Creates a `_.flow` or `_.flowRight` function.
  9349. *
  9350. * @private
  9351. * @param {boolean} [fromRight] Specify iterating from right to left.
  9352. * @returns {Function} Returns the new flow function.
  9353. */
  9354. function createFlow(fromRight) {
  9355. return flatRest(function(funcs) {
  9356. var length = funcs.length,
  9357. index = length,
  9358. prereq = LodashWrapper.prototype.thru;
  9359. if (fromRight) {
  9360. funcs.reverse();
  9361. }
  9362. while (index--) {
  9363. var func = funcs[index];
  9364. if (typeof func != 'function') {
  9365. throw new TypeError(FUNC_ERROR_TEXT);
  9366. }
  9367. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  9368. var wrapper = new LodashWrapper([], true);
  9369. }
  9370. }
  9371. index = wrapper ? index : length;
  9372. while (++index < length) {
  9373. func = funcs[index];
  9374. var funcName = getFuncName(func),
  9375. data = funcName == 'wrapper' ? getData(func) : undefined;
  9376. if (data && isLaziable(data[0]) &&
  9377. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  9378. !data[4].length && data[9] == 1
  9379. ) {
  9380. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  9381. } else {
  9382. wrapper = (func.length == 1 && isLaziable(func))
  9383. ? wrapper[funcName]()
  9384. : wrapper.thru(func);
  9385. }
  9386. }
  9387. return function() {
  9388. var args = arguments,
  9389. value = args[0];
  9390. if (wrapper && args.length == 1 && isArray(value)) {
  9391. return wrapper.plant(value).value();
  9392. }
  9393. var index = 0,
  9394. result = length ? funcs[index].apply(this, args) : value;
  9395. while (++index < length) {
  9396. result = funcs[index].call(this, result);
  9397. }
  9398. return result;
  9399. };
  9400. });
  9401. }
  9402. /**
  9403. * Creates a function that wraps `func` to invoke it with optional `this`
  9404. * binding of `thisArg`, partial application, and currying.
  9405. *
  9406. * @private
  9407. * @param {Function|string} func The function or method name to wrap.
  9408. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9409. * @param {*} [thisArg] The `this` binding of `func`.
  9410. * @param {Array} [partials] The arguments to prepend to those provided to
  9411. * the new function.
  9412. * @param {Array} [holders] The `partials` placeholder indexes.
  9413. * @param {Array} [partialsRight] The arguments to append to those provided
  9414. * to the new function.
  9415. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  9416. * @param {Array} [argPos] The argument positions of the new function.
  9417. * @param {number} [ary] The arity cap of `func`.
  9418. * @param {number} [arity] The arity of `func`.
  9419. * @returns {Function} Returns the new wrapped function.
  9420. */
  9421. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  9422. var isAry = bitmask & WRAP_ARY_FLAG,
  9423. isBind = bitmask & WRAP_BIND_FLAG,
  9424. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  9425. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  9426. isFlip = bitmask & WRAP_FLIP_FLAG,
  9427. Ctor = isBindKey ? undefined : createCtor(func);
  9428. function wrapper() {
  9429. var length = arguments.length,
  9430. args = Array(length),
  9431. index = length;
  9432. while (index--) {
  9433. args[index] = arguments[index];
  9434. }
  9435. if (isCurried) {
  9436. var placeholder = getHolder(wrapper),
  9437. holdersCount = countHolders(args, placeholder);
  9438. }
  9439. if (partials) {
  9440. args = composeArgs(args, partials, holders, isCurried);
  9441. }
  9442. if (partialsRight) {
  9443. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  9444. }
  9445. length -= holdersCount;
  9446. if (isCurried && length < arity) {
  9447. var newHolders = replaceHolders(args, placeholder);
  9448. return createRecurry(
  9449. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  9450. args, newHolders, argPos, ary, arity - length
  9451. );
  9452. }
  9453. var thisBinding = isBind ? thisArg : this,
  9454. fn = isBindKey ? thisBinding[func] : func;
  9455. length = args.length;
  9456. if (argPos) {
  9457. args = reorder(args, argPos);
  9458. } else if (isFlip && length > 1) {
  9459. args.reverse();
  9460. }
  9461. if (isAry && ary < length) {
  9462. args.length = ary;
  9463. }
  9464. if (this && this !== root && this instanceof wrapper) {
  9465. fn = Ctor || createCtor(fn);
  9466. }
  9467. return fn.apply(thisBinding, args);
  9468. }
  9469. return wrapper;
  9470. }
  9471. /**
  9472. * Creates a function like `_.invertBy`.
  9473. *
  9474. * @private
  9475. * @param {Function} setter The function to set accumulator values.
  9476. * @param {Function} toIteratee The function to resolve iteratees.
  9477. * @returns {Function} Returns the new inverter function.
  9478. */
  9479. function createInverter(setter, toIteratee) {
  9480. return function(object, iteratee) {
  9481. return baseInverter(object, setter, toIteratee(iteratee), {});
  9482. };
  9483. }
  9484. /**
  9485. * Creates a function that performs a mathematical operation on two values.
  9486. *
  9487. * @private
  9488. * @param {Function} operator The function to perform the operation.
  9489. * @param {number} [defaultValue] The value used for `undefined` arguments.
  9490. * @returns {Function} Returns the new mathematical operation function.
  9491. */
  9492. function createMathOperation(operator, defaultValue) {
  9493. return function(value, other) {
  9494. var result;
  9495. if (value === undefined && other === undefined) {
  9496. return defaultValue;
  9497. }
  9498. if (value !== undefined) {
  9499. result = value;
  9500. }
  9501. if (other !== undefined) {
  9502. if (result === undefined) {
  9503. return other;
  9504. }
  9505. if (typeof value == 'string' || typeof other == 'string') {
  9506. value = baseToString(value);
  9507. other = baseToString(other);
  9508. } else {
  9509. value = baseToNumber(value);
  9510. other = baseToNumber(other);
  9511. }
  9512. result = operator(value, other);
  9513. }
  9514. return result;
  9515. };
  9516. }
  9517. /**
  9518. * Creates a function like `_.over`.
  9519. *
  9520. * @private
  9521. * @param {Function} arrayFunc The function to iterate over iteratees.
  9522. * @returns {Function} Returns the new over function.
  9523. */
  9524. function createOver(arrayFunc) {
  9525. return flatRest(function(iteratees) {
  9526. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  9527. return baseRest(function(args) {
  9528. var thisArg = this;
  9529. return arrayFunc(iteratees, function(iteratee) {
  9530. return apply(iteratee, thisArg, args);
  9531. });
  9532. });
  9533. });
  9534. }
  9535. /**
  9536. * Creates the padding for `string` based on `length`. The `chars` string
  9537. * is truncated if the number of characters exceeds `length`.
  9538. *
  9539. * @private
  9540. * @param {number} length The padding length.
  9541. * @param {string} [chars=' '] The string used as padding.
  9542. * @returns {string} Returns the padding for `string`.
  9543. */
  9544. function createPadding(length, chars) {
  9545. chars = chars === undefined ? ' ' : baseToString(chars);
  9546. var charsLength = chars.length;
  9547. if (charsLength < 2) {
  9548. return charsLength ? baseRepeat(chars, length) : chars;
  9549. }
  9550. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  9551. return hasUnicode(chars)
  9552. ? castSlice(stringToArray(result), 0, length).join('')
  9553. : result.slice(0, length);
  9554. }
  9555. /**
  9556. * Creates a function that wraps `func` to invoke it with the `this` binding
  9557. * of `thisArg` and `partials` prepended to the arguments it receives.
  9558. *
  9559. * @private
  9560. * @param {Function} func The function to wrap.
  9561. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9562. * @param {*} thisArg The `this` binding of `func`.
  9563. * @param {Array} partials The arguments to prepend to those provided to
  9564. * the new function.
  9565. * @returns {Function} Returns the new wrapped function.
  9566. */
  9567. function createPartial(func, bitmask, thisArg, partials) {
  9568. var isBind = bitmask & WRAP_BIND_FLAG,
  9569. Ctor = createCtor(func);
  9570. function wrapper() {
  9571. var argsIndex = -1,
  9572. argsLength = arguments.length,
  9573. leftIndex = -1,
  9574. leftLength = partials.length,
  9575. args = Array(leftLength + argsLength),
  9576. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9577. while (++leftIndex < leftLength) {
  9578. args[leftIndex] = partials[leftIndex];
  9579. }
  9580. while (argsLength--) {
  9581. args[leftIndex++] = arguments[++argsIndex];
  9582. }
  9583. return apply(fn, isBind ? thisArg : this, args);
  9584. }
  9585. return wrapper;
  9586. }
  9587. /**
  9588. * Creates a `_.range` or `_.rangeRight` function.
  9589. *
  9590. * @private
  9591. * @param {boolean} [fromRight] Specify iterating from right to left.
  9592. * @returns {Function} Returns the new range function.
  9593. */
  9594. function createRange(fromRight) {
  9595. return function(start, end, step) {
  9596. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  9597. end = step = undefined;
  9598. }
  9599. // Ensure the sign of `-0` is preserved.
  9600. start = toFinite(start);
  9601. if (end === undefined) {
  9602. end = start;
  9603. start = 0;
  9604. } else {
  9605. end = toFinite(end);
  9606. }
  9607. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  9608. return baseRange(start, end, step, fromRight);
  9609. };
  9610. }
  9611. /**
  9612. * Creates a function that performs a relational operation on two values.
  9613. *
  9614. * @private
  9615. * @param {Function} operator The function to perform the operation.
  9616. * @returns {Function} Returns the new relational operation function.
  9617. */
  9618. function createRelationalOperation(operator) {
  9619. return function(value, other) {
  9620. if (!(typeof value == 'string' && typeof other == 'string')) {
  9621. value = toNumber(value);
  9622. other = toNumber(other);
  9623. }
  9624. return operator(value, other);
  9625. };
  9626. }
  9627. /**
  9628. * Creates a function that wraps `func` to continue currying.
  9629. *
  9630. * @private
  9631. * @param {Function} func The function to wrap.
  9632. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9633. * @param {Function} wrapFunc The function to create the `func` wrapper.
  9634. * @param {*} placeholder The placeholder value.
  9635. * @param {*} [thisArg] The `this` binding of `func`.
  9636. * @param {Array} [partials] The arguments to prepend to those provided to
  9637. * the new function.
  9638. * @param {Array} [holders] The `partials` placeholder indexes.
  9639. * @param {Array} [argPos] The argument positions of the new function.
  9640. * @param {number} [ary] The arity cap of `func`.
  9641. * @param {number} [arity] The arity of `func`.
  9642. * @returns {Function} Returns the new wrapped function.
  9643. */
  9644. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  9645. var isCurry = bitmask & WRAP_CURRY_FLAG,
  9646. newHolders = isCurry ? holders : undefined,
  9647. newHoldersRight = isCurry ? undefined : holders,
  9648. newPartials = isCurry ? partials : undefined,
  9649. newPartialsRight = isCurry ? undefined : partials;
  9650. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  9651. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  9652. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  9653. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  9654. }
  9655. var newData = [
  9656. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  9657. newHoldersRight, argPos, ary, arity
  9658. ];
  9659. var result = wrapFunc.apply(undefined, newData);
  9660. if (isLaziable(func)) {
  9661. setData(result, newData);
  9662. }
  9663. result.placeholder = placeholder;
  9664. return setWrapToString(result, func, bitmask);
  9665. }
  9666. /**
  9667. * Creates a function like `_.round`.
  9668. *
  9669. * @private
  9670. * @param {string} methodName The name of the `Math` method to use when rounding.
  9671. * @returns {Function} Returns the new round function.
  9672. */
  9673. function createRound(methodName) {
  9674. var func = Math[methodName];
  9675. return function(number, precision) {
  9676. number = toNumber(number);
  9677. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  9678. if (precision && nativeIsFinite(number)) {
  9679. // Shift with exponential notation to avoid floating-point issues.
  9680. // See [MDN](https://mdn.io/round#Examples) for more details.
  9681. var pair = (toString(number) + 'e').split('e'),
  9682. value = func(pair[0] + 'e' + (+pair[1] + precision));
  9683. pair = (toString(value) + 'e').split('e');
  9684. return +(pair[0] + 'e' + (+pair[1] - precision));
  9685. }
  9686. return func(number);
  9687. };
  9688. }
  9689. /**
  9690. * Creates a set object of `values`.
  9691. *
  9692. * @private
  9693. * @param {Array} values The values to add to the set.
  9694. * @returns {Object} Returns the new set.
  9695. */
  9696. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  9697. return new Set(values);
  9698. };
  9699. /**
  9700. * Creates a `_.toPairs` or `_.toPairsIn` function.
  9701. *
  9702. * @private
  9703. * @param {Function} keysFunc The function to get the keys of a given object.
  9704. * @returns {Function} Returns the new pairs function.
  9705. */
  9706. function createToPairs(keysFunc) {
  9707. return function(object) {
  9708. var tag = getTag(object);
  9709. if (tag == mapTag) {
  9710. return mapToArray(object);
  9711. }
  9712. if (tag == setTag) {
  9713. return setToPairs(object);
  9714. }
  9715. return baseToPairs(object, keysFunc(object));
  9716. };
  9717. }
  9718. /**
  9719. * Creates a function that either curries or invokes `func` with optional
  9720. * `this` binding and partially applied arguments.
  9721. *
  9722. * @private
  9723. * @param {Function|string} func The function or method name to wrap.
  9724. * @param {number} bitmask The bitmask flags.
  9725. * 1 - `_.bind`
  9726. * 2 - `_.bindKey`
  9727. * 4 - `_.curry` or `_.curryRight` of a bound function
  9728. * 8 - `_.curry`
  9729. * 16 - `_.curryRight`
  9730. * 32 - `_.partial`
  9731. * 64 - `_.partialRight`
  9732. * 128 - `_.rearg`
  9733. * 256 - `_.ary`
  9734. * 512 - `_.flip`
  9735. * @param {*} [thisArg] The `this` binding of `func`.
  9736. * @param {Array} [partials] The arguments to be partially applied.
  9737. * @param {Array} [holders] The `partials` placeholder indexes.
  9738. * @param {Array} [argPos] The argument positions of the new function.
  9739. * @param {number} [ary] The arity cap of `func`.
  9740. * @param {number} [arity] The arity of `func`.
  9741. * @returns {Function} Returns the new wrapped function.
  9742. */
  9743. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  9744. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  9745. if (!isBindKey && typeof func != 'function') {
  9746. throw new TypeError(FUNC_ERROR_TEXT);
  9747. }
  9748. var length = partials ? partials.length : 0;
  9749. if (!length) {
  9750. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  9751. partials = holders = undefined;
  9752. }
  9753. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  9754. arity = arity === undefined ? arity : toInteger(arity);
  9755. length -= holders ? holders.length : 0;
  9756. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  9757. var partialsRight = partials,
  9758. holdersRight = holders;
  9759. partials = holders = undefined;
  9760. }
  9761. var data = isBindKey ? undefined : getData(func);
  9762. var newData = [
  9763. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  9764. argPos, ary, arity
  9765. ];
  9766. if (data) {
  9767. mergeData(newData, data);
  9768. }
  9769. func = newData[0];
  9770. bitmask = newData[1];
  9771. thisArg = newData[2];
  9772. partials = newData[3];
  9773. holders = newData[4];
  9774. arity = newData[9] = newData[9] === undefined
  9775. ? (isBindKey ? 0 : func.length)
  9776. : nativeMax(newData[9] - length, 0);
  9777. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  9778. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  9779. }
  9780. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  9781. var result = createBind(func, bitmask, thisArg);
  9782. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  9783. result = createCurry(func, bitmask, arity);
  9784. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  9785. result = createPartial(func, bitmask, thisArg, partials);
  9786. } else {
  9787. result = createHybrid.apply(undefined, newData);
  9788. }
  9789. var setter = data ? baseSetData : setData;
  9790. return setWrapToString(setter(result, newData), func, bitmask);
  9791. }
  9792. /**
  9793. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  9794. * of source objects to the destination object for all destination properties
  9795. * that resolve to `undefined`.
  9796. *
  9797. * @private
  9798. * @param {*} objValue The destination value.
  9799. * @param {*} srcValue The source value.
  9800. * @param {string} key The key of the property to assign.
  9801. * @param {Object} object The parent object of `objValue`.
  9802. * @returns {*} Returns the value to assign.
  9803. */
  9804. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  9805. if (objValue === undefined ||
  9806. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  9807. return srcValue;
  9808. }
  9809. return objValue;
  9810. }
  9811. /**
  9812. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  9813. * objects into destination objects that are passed thru.
  9814. *
  9815. * @private
  9816. * @param {*} objValue The destination value.
  9817. * @param {*} srcValue The source value.
  9818. * @param {string} key The key of the property to merge.
  9819. * @param {Object} object The parent object of `objValue`.
  9820. * @param {Object} source The parent object of `srcValue`.
  9821. * @param {Object} [stack] Tracks traversed source values and their merged
  9822. * counterparts.
  9823. * @returns {*} Returns the value to assign.
  9824. */
  9825. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  9826. if (isObject(objValue) && isObject(srcValue)) {
  9827. // Recursively merge objects and arrays (susceptible to call stack limits).
  9828. stack.set(srcValue, objValue);
  9829. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  9830. stack['delete'](srcValue);
  9831. }
  9832. return objValue;
  9833. }
  9834. /**
  9835. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  9836. * objects.
  9837. *
  9838. * @private
  9839. * @param {*} value The value to inspect.
  9840. * @param {string} key The key of the property to inspect.
  9841. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  9842. */
  9843. function customOmitClone(value) {
  9844. return isPlainObject(value) ? undefined : value;
  9845. }
  9846. /**
  9847. * A specialized version of `baseIsEqualDeep` for arrays with support for
  9848. * partial deep comparisons.
  9849. *
  9850. * @private
  9851. * @param {Array} array The array to compare.
  9852. * @param {Array} other The other array to compare.
  9853. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  9854. * @param {Function} customizer The function to customize comparisons.
  9855. * @param {Function} equalFunc The function to determine equivalents of values.
  9856. * @param {Object} stack Tracks traversed `array` and `other` objects.
  9857. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  9858. */
  9859. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  9860. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  9861. arrLength = array.length,
  9862. othLength = other.length;
  9863. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  9864. return false;
  9865. }
  9866. // Check that cyclic values are equal.
  9867. var arrStacked = stack.get(array);
  9868. var othStacked = stack.get(other);
  9869. if (arrStacked && othStacked) {
  9870. return arrStacked == other && othStacked == array;
  9871. }
  9872. var index = -1,
  9873. result = true,
  9874. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  9875. stack.set(array, other);
  9876. stack.set(other, array);
  9877. // Ignore non-index properties.
  9878. while (++index < arrLength) {
  9879. var arrValue = array[index],
  9880. othValue = other[index];
  9881. if (customizer) {
  9882. var compared = isPartial
  9883. ? customizer(othValue, arrValue, index, other, array, stack)
  9884. : customizer(arrValue, othValue, index, array, other, stack);
  9885. }
  9886. if (compared !== undefined) {
  9887. if (compared) {
  9888. continue;
  9889. }
  9890. result = false;
  9891. break;
  9892. }
  9893. // Recursively compare arrays (susceptible to call stack limits).
  9894. if (seen) {
  9895. if (!arraySome(other, function(othValue, othIndex) {
  9896. if (!cacheHas(seen, othIndex) &&
  9897. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  9898. return seen.push(othIndex);
  9899. }
  9900. })) {
  9901. result = false;
  9902. break;
  9903. }
  9904. } else if (!(
  9905. arrValue === othValue ||
  9906. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  9907. )) {
  9908. result = false;
  9909. break;
  9910. }
  9911. }
  9912. stack['delete'](array);
  9913. stack['delete'](other);
  9914. return result;
  9915. }
  9916. /**
  9917. * A specialized version of `baseIsEqualDeep` for comparing objects of
  9918. * the same `toStringTag`.
  9919. *
  9920. * **Note:** This function only supports comparing values with tags of
  9921. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  9922. *
  9923. * @private
  9924. * @param {Object} object The object to compare.
  9925. * @param {Object} other The other object to compare.
  9926. * @param {string} tag The `toStringTag` of the objects to compare.
  9927. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  9928. * @param {Function} customizer The function to customize comparisons.
  9929. * @param {Function} equalFunc The function to determine equivalents of values.
  9930. * @param {Object} stack Tracks traversed `object` and `other` objects.
  9931. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  9932. */
  9933. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  9934. switch (tag) {
  9935. case dataViewTag:
  9936. if ((object.byteLength != other.byteLength) ||
  9937. (object.byteOffset != other.byteOffset)) {
  9938. return false;
  9939. }
  9940. object = object.buffer;
  9941. other = other.buffer;
  9942. case arrayBufferTag:
  9943. if ((object.byteLength != other.byteLength) ||
  9944. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  9945. return false;
  9946. }
  9947. return true;
  9948. case boolTag:
  9949. case dateTag:
  9950. case numberTag:
  9951. // Coerce booleans to `1` or `0` and dates to milliseconds.
  9952. // Invalid dates are coerced to `NaN`.
  9953. return eq(+object, +other);
  9954. case errorTag:
  9955. return object.name == other.name && object.message == other.message;
  9956. case regexpTag:
  9957. case stringTag:
  9958. // Coerce regexes to strings and treat strings, primitives and objects,
  9959. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  9960. // for more details.
  9961. return object == (other + '');
  9962. case mapTag:
  9963. var convert = mapToArray;
  9964. case setTag:
  9965. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  9966. convert || (convert = setToArray);
  9967. if (object.size != other.size && !isPartial) {
  9968. return false;
  9969. }
  9970. // Assume cyclic values are equal.
  9971. var stacked = stack.get(object);
  9972. if (stacked) {
  9973. return stacked == other;
  9974. }
  9975. bitmask |= COMPARE_UNORDERED_FLAG;
  9976. // Recursively compare objects (susceptible to call stack limits).
  9977. stack.set(object, other);
  9978. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  9979. stack['delete'](object);
  9980. return result;
  9981. case symbolTag:
  9982. if (symbolValueOf) {
  9983. return symbolValueOf.call(object) == symbolValueOf.call(other);
  9984. }
  9985. }
  9986. return false;
  9987. }
  9988. /**
  9989. * A specialized version of `baseIsEqualDeep` for objects with support for
  9990. * partial deep comparisons.
  9991. *
  9992. * @private
  9993. * @param {Object} object The object to compare.
  9994. * @param {Object} other The other object to compare.
  9995. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  9996. * @param {Function} customizer The function to customize comparisons.
  9997. * @param {Function} equalFunc The function to determine equivalents of values.
  9998. * @param {Object} stack Tracks traversed `object` and `other` objects.
  9999. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  10000. */
  10001. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  10002. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  10003. objProps = getAllKeys(object),
  10004. objLength = objProps.length,
  10005. othProps = getAllKeys(other),
  10006. othLength = othProps.length;
  10007. if (objLength != othLength && !isPartial) {
  10008. return false;
  10009. }
  10010. var index = objLength;
  10011. while (index--) {
  10012. var key = objProps[index];
  10013. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  10014. return false;
  10015. }
  10016. }
  10017. // Check that cyclic values are equal.
  10018. var objStacked = stack.get(object);
  10019. var othStacked = stack.get(other);
  10020. if (objStacked && othStacked) {
  10021. return objStacked == other && othStacked == object;
  10022. }
  10023. var result = true;
  10024. stack.set(object, other);
  10025. stack.set(other, object);
  10026. var skipCtor = isPartial;
  10027. while (++index < objLength) {
  10028. key = objProps[index];
  10029. var objValue = object[key],
  10030. othValue = other[key];
  10031. if (customizer) {
  10032. var compared = isPartial
  10033. ? customizer(othValue, objValue, key, other, object, stack)
  10034. : customizer(objValue, othValue, key, object, other, stack);
  10035. }
  10036. // Recursively compare objects (susceptible to call stack limits).
  10037. if (!(compared === undefined
  10038. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  10039. : compared
  10040. )) {
  10041. result = false;
  10042. break;
  10043. }
  10044. skipCtor || (skipCtor = key == 'constructor');
  10045. }
  10046. if (result && !skipCtor) {
  10047. var objCtor = object.constructor,
  10048. othCtor = other.constructor;
  10049. // Non `Object` object instances with different constructors are not equal.
  10050. if (objCtor != othCtor &&
  10051. ('constructor' in object && 'constructor' in other) &&
  10052. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  10053. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  10054. result = false;
  10055. }
  10056. }
  10057. stack['delete'](object);
  10058. stack['delete'](other);
  10059. return result;
  10060. }
  10061. /**
  10062. * A specialized version of `baseRest` which flattens the rest array.
  10063. *
  10064. * @private
  10065. * @param {Function} func The function to apply a rest parameter to.
  10066. * @returns {Function} Returns the new function.
  10067. */
  10068. function flatRest(func) {
  10069. return setToString(overRest(func, undefined, flatten), func + '');
  10070. }
  10071. /**
  10072. * Creates an array of own enumerable property names and symbols of `object`.
  10073. *
  10074. * @private
  10075. * @param {Object} object The object to query.
  10076. * @returns {Array} Returns the array of property names and symbols.
  10077. */
  10078. function getAllKeys(object) {
  10079. return baseGetAllKeys(object, keys, getSymbols);
  10080. }
  10081. /**
  10082. * Creates an array of own and inherited enumerable property names and
  10083. * symbols of `object`.
  10084. *
  10085. * @private
  10086. * @param {Object} object The object to query.
  10087. * @returns {Array} Returns the array of property names and symbols.
  10088. */
  10089. function getAllKeysIn(object) {
  10090. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  10091. }
  10092. /**
  10093. * Gets metadata for `func`.
  10094. *
  10095. * @private
  10096. * @param {Function} func The function to query.
  10097. * @returns {*} Returns the metadata for `func`.
  10098. */
  10099. var getData = !metaMap ? noop : function(func) {
  10100. return metaMap.get(func);
  10101. };
  10102. /**
  10103. * Gets the name of `func`.
  10104. *
  10105. * @private
  10106. * @param {Function} func The function to query.
  10107. * @returns {string} Returns the function name.
  10108. */
  10109. function getFuncName(func) {
  10110. var result = (func.name + ''),
  10111. array = realNames[result],
  10112. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  10113. while (length--) {
  10114. var data = array[length],
  10115. otherFunc = data.func;
  10116. if (otherFunc == null || otherFunc == func) {
  10117. return data.name;
  10118. }
  10119. }
  10120. return result;
  10121. }
  10122. /**
  10123. * Gets the argument placeholder value for `func`.
  10124. *
  10125. * @private
  10126. * @param {Function} func The function to inspect.
  10127. * @returns {*} Returns the placeholder value.
  10128. */
  10129. function getHolder(func) {
  10130. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  10131. return object.placeholder;
  10132. }
  10133. /**
  10134. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  10135. * this function returns the custom method, otherwise it returns `baseIteratee`.
  10136. * If arguments are provided, the chosen function is invoked with them and
  10137. * its result is returned.
  10138. *
  10139. * @private
  10140. * @param {*} [value] The value to convert to an iteratee.
  10141. * @param {number} [arity] The arity of the created iteratee.
  10142. * @returns {Function} Returns the chosen function or its result.
  10143. */
  10144. function getIteratee() {
  10145. var result = lodash.iteratee || iteratee;
  10146. result = result === iteratee ? baseIteratee : result;
  10147. return arguments.length ? result(arguments[0], arguments[1]) : result;
  10148. }
  10149. /**
  10150. * Gets the data for `map`.
  10151. *
  10152. * @private
  10153. * @param {Object} map The map to query.
  10154. * @param {string} key The reference key.
  10155. * @returns {*} Returns the map data.
  10156. */
  10157. function getMapData(map, key) {
  10158. var data = map.__data__;
  10159. return isKeyable(key)
  10160. ? data[typeof key == 'string' ? 'string' : 'hash']
  10161. : data.map;
  10162. }
  10163. /**
  10164. * Gets the property names, values, and compare flags of `object`.
  10165. *
  10166. * @private
  10167. * @param {Object} object The object to query.
  10168. * @returns {Array} Returns the match data of `object`.
  10169. */
  10170. function getMatchData(object) {
  10171. var result = keys(object),
  10172. length = result.length;
  10173. while (length--) {
  10174. var key = result[length],
  10175. value = object[key];
  10176. result[length] = [key, value, isStrictComparable(value)];
  10177. }
  10178. return result;
  10179. }
  10180. /**
  10181. * Gets the native function at `key` of `object`.
  10182. *
  10183. * @private
  10184. * @param {Object} object The object to query.
  10185. * @param {string} key The key of the method to get.
  10186. * @returns {*} Returns the function if it's native, else `undefined`.
  10187. */
  10188. function getNative(object, key) {
  10189. var value = getValue(object, key);
  10190. return baseIsNative(value) ? value : undefined;
  10191. }
  10192. /**
  10193. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  10194. *
  10195. * @private
  10196. * @param {*} value The value to query.
  10197. * @returns {string} Returns the raw `toStringTag`.
  10198. */
  10199. function getRawTag(value) {
  10200. var isOwn = hasOwnProperty.call(value, symToStringTag),
  10201. tag = value[symToStringTag];
  10202. try {
  10203. value[symToStringTag] = undefined;
  10204. var unmasked = true;
  10205. } catch (e) {}
  10206. var result = nativeObjectToString.call(value);
  10207. if (unmasked) {
  10208. if (isOwn) {
  10209. value[symToStringTag] = tag;
  10210. } else {
  10211. delete value[symToStringTag];
  10212. }
  10213. }
  10214. return result;
  10215. }
  10216. /**
  10217. * Creates an array of the own enumerable symbols of `object`.
  10218. *
  10219. * @private
  10220. * @param {Object} object The object to query.
  10221. * @returns {Array} Returns the array of symbols.
  10222. */
  10223. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  10224. if (object == null) {
  10225. return [];
  10226. }
  10227. object = Object(object);
  10228. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  10229. return propertyIsEnumerable.call(object, symbol);
  10230. });
  10231. };
  10232. /**
  10233. * Creates an array of the own and inherited enumerable symbols of `object`.
  10234. *
  10235. * @private
  10236. * @param {Object} object The object to query.
  10237. * @returns {Array} Returns the array of symbols.
  10238. */
  10239. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  10240. var result = [];
  10241. while (object) {
  10242. arrayPush(result, getSymbols(object));
  10243. object = getPrototype(object);
  10244. }
  10245. return result;
  10246. };
  10247. /**
  10248. * Gets the `toStringTag` of `value`.
  10249. *
  10250. * @private
  10251. * @param {*} value The value to query.
  10252. * @returns {string} Returns the `toStringTag`.
  10253. */
  10254. var getTag = baseGetTag;
  10255. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  10256. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  10257. (Map && getTag(new Map) != mapTag) ||
  10258. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  10259. (Set && getTag(new Set) != setTag) ||
  10260. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  10261. getTag = function(value) {
  10262. var result = baseGetTag(value),
  10263. Ctor = result == objectTag ? value.constructor : undefined,
  10264. ctorString = Ctor ? toSource(Ctor) : '';
  10265. if (ctorString) {
  10266. switch (ctorString) {
  10267. case dataViewCtorString: return dataViewTag;
  10268. case mapCtorString: return mapTag;
  10269. case promiseCtorString: return promiseTag;
  10270. case setCtorString: return setTag;
  10271. case weakMapCtorString: return weakMapTag;
  10272. }
  10273. }
  10274. return result;
  10275. };
  10276. }
  10277. /**
  10278. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  10279. *
  10280. * @private
  10281. * @param {number} start The start of the view.
  10282. * @param {number} end The end of the view.
  10283. * @param {Array} transforms The transformations to apply to the view.
  10284. * @returns {Object} Returns an object containing the `start` and `end`
  10285. * positions of the view.
  10286. */
  10287. function getView(start, end, transforms) {
  10288. var index = -1,
  10289. length = transforms.length;
  10290. while (++index < length) {
  10291. var data = transforms[index],
  10292. size = data.size;
  10293. switch (data.type) {
  10294. case 'drop': start += size; break;
  10295. case 'dropRight': end -= size; break;
  10296. case 'take': end = nativeMin(end, start + size); break;
  10297. case 'takeRight': start = nativeMax(start, end - size); break;
  10298. }
  10299. }
  10300. return { 'start': start, 'end': end };
  10301. }
  10302. /**
  10303. * Extracts wrapper details from the `source` body comment.
  10304. *
  10305. * @private
  10306. * @param {string} source The source to inspect.
  10307. * @returns {Array} Returns the wrapper details.
  10308. */
  10309. function getWrapDetails(source) {
  10310. var match = source.match(reWrapDetails);
  10311. return match ? match[1].split(reSplitDetails) : [];
  10312. }
  10313. /**
  10314. * Checks if `path` exists on `object`.
  10315. *
  10316. * @private
  10317. * @param {Object} object The object to query.
  10318. * @param {Array|string} path The path to check.
  10319. * @param {Function} hasFunc The function to check properties.
  10320. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  10321. */
  10322. function hasPath(object, path, hasFunc) {
  10323. path = castPath(path, object);
  10324. var index = -1,
  10325. length = path.length,
  10326. result = false;
  10327. while (++index < length) {
  10328. var key = toKey(path[index]);
  10329. if (!(result = object != null && hasFunc(object, key))) {
  10330. break;
  10331. }
  10332. object = object[key];
  10333. }
  10334. if (result || ++index != length) {
  10335. return result;
  10336. }
  10337. length = object == null ? 0 : object.length;
  10338. return !!length && isLength(length) && isIndex(key, length) &&
  10339. (isArray(object) || isArguments(object));
  10340. }
  10341. /**
  10342. * Initializes an array clone.
  10343. *
  10344. * @private
  10345. * @param {Array} array The array to clone.
  10346. * @returns {Array} Returns the initialized clone.
  10347. */
  10348. function initCloneArray(array) {
  10349. var length = array.length,
  10350. result = new array.constructor(length);
  10351. // Add properties assigned by `RegExp#exec`.
  10352. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  10353. result.index = array.index;
  10354. result.input = array.input;
  10355. }
  10356. return result;
  10357. }
  10358. /**
  10359. * Initializes an object clone.
  10360. *
  10361. * @private
  10362. * @param {Object} object The object to clone.
  10363. * @returns {Object} Returns the initialized clone.
  10364. */
  10365. function initCloneObject(object) {
  10366. return (typeof object.constructor == 'function' && !isPrototype(object))
  10367. ? baseCreate(getPrototype(object))
  10368. : {};
  10369. }
  10370. /**
  10371. * Initializes an object clone based on its `toStringTag`.
  10372. *
  10373. * **Note:** This function only supports cloning values with tags of
  10374. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  10375. *
  10376. * @private
  10377. * @param {Object} object The object to clone.
  10378. * @param {string} tag The `toStringTag` of the object to clone.
  10379. * @param {boolean} [isDeep] Specify a deep clone.
  10380. * @returns {Object} Returns the initialized clone.
  10381. */
  10382. function initCloneByTag(object, tag, isDeep) {
  10383. var Ctor = object.constructor;
  10384. switch (tag) {
  10385. case arrayBufferTag:
  10386. return cloneArrayBuffer(object);
  10387. case boolTag:
  10388. case dateTag:
  10389. return new Ctor(+object);
  10390. case dataViewTag:
  10391. return cloneDataView(object, isDeep);
  10392. case float32Tag: case float64Tag:
  10393. case int8Tag: case int16Tag: case int32Tag:
  10394. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  10395. return cloneTypedArray(object, isDeep);
  10396. case mapTag:
  10397. return new Ctor;
  10398. case numberTag:
  10399. case stringTag:
  10400. return new Ctor(object);
  10401. case regexpTag:
  10402. return cloneRegExp(object);
  10403. case setTag:
  10404. return new Ctor;
  10405. case symbolTag:
  10406. return cloneSymbol(object);
  10407. }
  10408. }
  10409. /**
  10410. * Inserts wrapper `details` in a comment at the top of the `source` body.
  10411. *
  10412. * @private
  10413. * @param {string} source The source to modify.
  10414. * @returns {Array} details The details to insert.
  10415. * @returns {string} Returns the modified source.
  10416. */
  10417. function insertWrapDetails(source, details) {
  10418. var length = details.length;
  10419. if (!length) {
  10420. return source;
  10421. }
  10422. var lastIndex = length - 1;
  10423. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  10424. details = details.join(length > 2 ? ', ' : ' ');
  10425. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  10426. }
  10427. /**
  10428. * Checks if `value` is a flattenable `arguments` object or array.
  10429. *
  10430. * @private
  10431. * @param {*} value The value to check.
  10432. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  10433. */
  10434. function isFlattenable(value) {
  10435. return isArray(value) || isArguments(value) ||
  10436. !!(spreadableSymbol && value && value[spreadableSymbol]);
  10437. }
  10438. /**
  10439. * Checks if `value` is a valid array-like index.
  10440. *
  10441. * @private
  10442. * @param {*} value The value to check.
  10443. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  10444. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  10445. */
  10446. function isIndex(value, length) {
  10447. var type = typeof value;
  10448. length = length == null ? MAX_SAFE_INTEGER : length;
  10449. return !!length &&
  10450. (type == 'number' ||
  10451. (type != 'symbol' && reIsUint.test(value))) &&
  10452. (value > -1 && value % 1 == 0 && value < length);
  10453. }
  10454. /**
  10455. * Checks if the given arguments are from an iteratee call.
  10456. *
  10457. * @private
  10458. * @param {*} value The potential iteratee value argument.
  10459. * @param {*} index The potential iteratee index or key argument.
  10460. * @param {*} object The potential iteratee object argument.
  10461. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  10462. * else `false`.
  10463. */
  10464. function isIterateeCall(value, index, object) {
  10465. if (!isObject(object)) {
  10466. return false;
  10467. }
  10468. var type = typeof index;
  10469. if (type == 'number'
  10470. ? (isArrayLike(object) && isIndex(index, object.length))
  10471. : (type == 'string' && index in object)
  10472. ) {
  10473. return eq(object[index], value);
  10474. }
  10475. return false;
  10476. }
  10477. /**
  10478. * Checks if `value` is a property name and not a property path.
  10479. *
  10480. * @private
  10481. * @param {*} value The value to check.
  10482. * @param {Object} [object] The object to query keys on.
  10483. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  10484. */
  10485. function isKey(value, object) {
  10486. if (isArray(value)) {
  10487. return false;
  10488. }
  10489. var type = typeof value;
  10490. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  10491. value == null || isSymbol(value)) {
  10492. return true;
  10493. }
  10494. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  10495. (object != null && value in Object(object));
  10496. }
  10497. /**
  10498. * Checks if `value` is suitable for use as unique object key.
  10499. *
  10500. * @private
  10501. * @param {*} value The value to check.
  10502. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10503. */
  10504. function isKeyable(value) {
  10505. var type = typeof value;
  10506. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10507. ? (value !== '__proto__')
  10508. : (value === null);
  10509. }
  10510. /**
  10511. * Checks if `func` has a lazy counterpart.
  10512. *
  10513. * @private
  10514. * @param {Function} func The function to check.
  10515. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  10516. * else `false`.
  10517. */
  10518. function isLaziable(func) {
  10519. var funcName = getFuncName(func),
  10520. other = lodash[funcName];
  10521. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  10522. return false;
  10523. }
  10524. if (func === other) {
  10525. return true;
  10526. }
  10527. var data = getData(other);
  10528. return !!data && func === data[0];
  10529. }
  10530. /**
  10531. * Checks if `func` has its source masked.
  10532. *
  10533. * @private
  10534. * @param {Function} func The function to check.
  10535. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10536. */
  10537. function isMasked(func) {
  10538. return !!maskSrcKey && (maskSrcKey in func);
  10539. }
  10540. /**
  10541. * Checks if `func` is capable of being masked.
  10542. *
  10543. * @private
  10544. * @param {*} value The value to check.
  10545. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  10546. */
  10547. var isMaskable = coreJsData ? isFunction : stubFalse;
  10548. /**
  10549. * Checks if `value` is likely a prototype object.
  10550. *
  10551. * @private
  10552. * @param {*} value The value to check.
  10553. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  10554. */
  10555. function isPrototype(value) {
  10556. var Ctor = value && value.constructor,
  10557. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  10558. return value === proto;
  10559. }
  10560. /**
  10561. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  10562. *
  10563. * @private
  10564. * @param {*} value The value to check.
  10565. * @returns {boolean} Returns `true` if `value` if suitable for strict
  10566. * equality comparisons, else `false`.
  10567. */
  10568. function isStrictComparable(value) {
  10569. return value === value && !isObject(value);
  10570. }
  10571. /**
  10572. * A specialized version of `matchesProperty` for source values suitable
  10573. * for strict equality comparisons, i.e. `===`.
  10574. *
  10575. * @private
  10576. * @param {string} key The key of the property to get.
  10577. * @param {*} srcValue The value to match.
  10578. * @returns {Function} Returns the new spec function.
  10579. */
  10580. function matchesStrictComparable(key, srcValue) {
  10581. return function(object) {
  10582. if (object == null) {
  10583. return false;
  10584. }
  10585. return object[key] === srcValue &&
  10586. (srcValue !== undefined || (key in Object(object)));
  10587. };
  10588. }
  10589. /**
  10590. * A specialized version of `_.memoize` which clears the memoized function's
  10591. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  10592. *
  10593. * @private
  10594. * @param {Function} func The function to have its output memoized.
  10595. * @returns {Function} Returns the new memoized function.
  10596. */
  10597. function memoizeCapped(func) {
  10598. var result = memoize(func, function(key) {
  10599. if (cache.size === MAX_MEMOIZE_SIZE) {
  10600. cache.clear();
  10601. }
  10602. return key;
  10603. });
  10604. var cache = result.cache;
  10605. return result;
  10606. }
  10607. /**
  10608. * Merges the function metadata of `source` into `data`.
  10609. *
  10610. * Merging metadata reduces the number of wrappers used to invoke a function.
  10611. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  10612. * may be applied regardless of execution order. Methods like `_.ary` and
  10613. * `_.rearg` modify function arguments, making the order in which they are
  10614. * executed important, preventing the merging of metadata. However, we make
  10615. * an exception for a safe combined case where curried functions have `_.ary`
  10616. * and or `_.rearg` applied.
  10617. *
  10618. * @private
  10619. * @param {Array} data The destination metadata.
  10620. * @param {Array} source The source metadata.
  10621. * @returns {Array} Returns `data`.
  10622. */
  10623. function mergeData(data, source) {
  10624. var bitmask = data[1],
  10625. srcBitmask = source[1],
  10626. newBitmask = bitmask | srcBitmask,
  10627. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  10628. var isCombo =
  10629. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  10630. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  10631. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  10632. // Exit early if metadata can't be merged.
  10633. if (!(isCommon || isCombo)) {
  10634. return data;
  10635. }
  10636. // Use source `thisArg` if available.
  10637. if (srcBitmask & WRAP_BIND_FLAG) {
  10638. data[2] = source[2];
  10639. // Set when currying a bound function.
  10640. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  10641. }
  10642. // Compose partial arguments.
  10643. var value = source[3];
  10644. if (value) {
  10645. var partials = data[3];
  10646. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  10647. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  10648. }
  10649. // Compose partial right arguments.
  10650. value = source[5];
  10651. if (value) {
  10652. partials = data[5];
  10653. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  10654. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  10655. }
  10656. // Use source `argPos` if available.
  10657. value = source[7];
  10658. if (value) {
  10659. data[7] = value;
  10660. }
  10661. // Use source `ary` if it's smaller.
  10662. if (srcBitmask & WRAP_ARY_FLAG) {
  10663. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  10664. }
  10665. // Use source `arity` if one is not provided.
  10666. if (data[9] == null) {
  10667. data[9] = source[9];
  10668. }
  10669. // Use source `func` and merge bitmasks.
  10670. data[0] = source[0];
  10671. data[1] = newBitmask;
  10672. return data;
  10673. }
  10674. /**
  10675. * This function is like
  10676. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  10677. * except that it includes inherited enumerable properties.
  10678. *
  10679. * @private
  10680. * @param {Object} object The object to query.
  10681. * @returns {Array} Returns the array of property names.
  10682. */
  10683. function nativeKeysIn(object) {
  10684. var result = [];
  10685. if (object != null) {
  10686. for (var key in Object(object)) {
  10687. result.push(key);
  10688. }
  10689. }
  10690. return result;
  10691. }
  10692. /**
  10693. * Converts `value` to a string using `Object.prototype.toString`.
  10694. *
  10695. * @private
  10696. * @param {*} value The value to convert.
  10697. * @returns {string} Returns the converted string.
  10698. */
  10699. function objectToString(value) {
  10700. return nativeObjectToString.call(value);
  10701. }
  10702. /**
  10703. * A specialized version of `baseRest` which transforms the rest array.
  10704. *
  10705. * @private
  10706. * @param {Function} func The function to apply a rest parameter to.
  10707. * @param {number} [start=func.length-1] The start position of the rest parameter.
  10708. * @param {Function} transform The rest array transform.
  10709. * @returns {Function} Returns the new function.
  10710. */
  10711. function overRest(func, start, transform) {
  10712. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  10713. return function() {
  10714. var args = arguments,
  10715. index = -1,
  10716. length = nativeMax(args.length - start, 0),
  10717. array = Array(length);
  10718. while (++index < length) {
  10719. array[index] = args[start + index];
  10720. }
  10721. index = -1;
  10722. var otherArgs = Array(start + 1);
  10723. while (++index < start) {
  10724. otherArgs[index] = args[index];
  10725. }
  10726. otherArgs[start] = transform(array);
  10727. return apply(func, this, otherArgs);
  10728. };
  10729. }
  10730. /**
  10731. * Gets the parent value at `path` of `object`.
  10732. *
  10733. * @private
  10734. * @param {Object} object The object to query.
  10735. * @param {Array} path The path to get the parent value of.
  10736. * @returns {*} Returns the parent value.
  10737. */
  10738. function parent(object, path) {
  10739. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  10740. }
  10741. /**
  10742. * Reorder `array` according to the specified indexes where the element at
  10743. * the first index is assigned as the first element, the element at
  10744. * the second index is assigned as the second element, and so on.
  10745. *
  10746. * @private
  10747. * @param {Array} array The array to reorder.
  10748. * @param {Array} indexes The arranged array indexes.
  10749. * @returns {Array} Returns `array`.
  10750. */
  10751. function reorder(array, indexes) {
  10752. var arrLength = array.length,
  10753. length = nativeMin(indexes.length, arrLength),
  10754. oldArray = copyArray(array);
  10755. while (length--) {
  10756. var index = indexes[length];
  10757. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  10758. }
  10759. return array;
  10760. }
  10761. /**
  10762. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  10763. *
  10764. * @private
  10765. * @param {Object} object The object to query.
  10766. * @param {string} key The key of the property to get.
  10767. * @returns {*} Returns the property value.
  10768. */
  10769. function safeGet(object, key) {
  10770. if (key === 'constructor' && typeof object[key] === 'function') {
  10771. return;
  10772. }
  10773. if (key == '__proto__') {
  10774. return;
  10775. }
  10776. return object[key];
  10777. }
  10778. /**
  10779. * Sets metadata for `func`.
  10780. *
  10781. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  10782. * period of time, it will trip its breaker and transition to an identity
  10783. * function to avoid garbage collection pauses in V8. See
  10784. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  10785. * for more details.
  10786. *
  10787. * @private
  10788. * @param {Function} func The function to associate metadata with.
  10789. * @param {*} data The metadata.
  10790. * @returns {Function} Returns `func`.
  10791. */
  10792. var setData = shortOut(baseSetData);
  10793. /**
  10794. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  10795. *
  10796. * @private
  10797. * @param {Function} func The function to delay.
  10798. * @param {number} wait The number of milliseconds to delay invocation.
  10799. * @returns {number|Object} Returns the timer id or timeout object.
  10800. */
  10801. var setTimeout = ctxSetTimeout || function(func, wait) {
  10802. return root.setTimeout(func, wait);
  10803. };
  10804. /**
  10805. * Sets the `toString` method of `func` to return `string`.
  10806. *
  10807. * @private
  10808. * @param {Function} func The function to modify.
  10809. * @param {Function} string The `toString` result.
  10810. * @returns {Function} Returns `func`.
  10811. */
  10812. var setToString = shortOut(baseSetToString);
  10813. /**
  10814. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  10815. * with wrapper details in a comment at the top of the source body.
  10816. *
  10817. * @private
  10818. * @param {Function} wrapper The function to modify.
  10819. * @param {Function} reference The reference function.
  10820. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10821. * @returns {Function} Returns `wrapper`.
  10822. */
  10823. function setWrapToString(wrapper, reference, bitmask) {
  10824. var source = (reference + '');
  10825. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  10826. }
  10827. /**
  10828. * Creates a function that'll short out and invoke `identity` instead
  10829. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  10830. * milliseconds.
  10831. *
  10832. * @private
  10833. * @param {Function} func The function to restrict.
  10834. * @returns {Function} Returns the new shortable function.
  10835. */
  10836. function shortOut(func) {
  10837. var count = 0,
  10838. lastCalled = 0;
  10839. return function() {
  10840. var stamp = nativeNow(),
  10841. remaining = HOT_SPAN - (stamp - lastCalled);
  10842. lastCalled = stamp;
  10843. if (remaining > 0) {
  10844. if (++count >= HOT_COUNT) {
  10845. return arguments[0];
  10846. }
  10847. } else {
  10848. count = 0;
  10849. }
  10850. return func.apply(undefined, arguments);
  10851. };
  10852. }
  10853. /**
  10854. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  10855. *
  10856. * @private
  10857. * @param {Array} array The array to shuffle.
  10858. * @param {number} [size=array.length] The size of `array`.
  10859. * @returns {Array} Returns `array`.
  10860. */
  10861. function shuffleSelf(array, size) {
  10862. var index = -1,
  10863. length = array.length,
  10864. lastIndex = length - 1;
  10865. size = size === undefined ? length : size;
  10866. while (++index < size) {
  10867. var rand = baseRandom(index, lastIndex),
  10868. value = array[rand];
  10869. array[rand] = array[index];
  10870. array[index] = value;
  10871. }
  10872. array.length = size;
  10873. return array;
  10874. }
  10875. /**
  10876. * Converts `string` to a property path array.
  10877. *
  10878. * @private
  10879. * @param {string} string The string to convert.
  10880. * @returns {Array} Returns the property path array.
  10881. */
  10882. var stringToPath = memoizeCapped(function(string) {
  10883. var result = [];
  10884. if (string.charCodeAt(0) === 46 /* . */) {
  10885. result.push('');
  10886. }
  10887. string.replace(rePropName, function(match, number, quote, subString) {
  10888. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  10889. });
  10890. return result;
  10891. });
  10892. /**
  10893. * Converts `value` to a string key if it's not a string or symbol.
  10894. *
  10895. * @private
  10896. * @param {*} value The value to inspect.
  10897. * @returns {string|symbol} Returns the key.
  10898. */
  10899. function toKey(value) {
  10900. if (typeof value == 'string' || isSymbol(value)) {
  10901. return value;
  10902. }
  10903. var result = (value + '');
  10904. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  10905. }
  10906. /**
  10907. * Converts `func` to its source code.
  10908. *
  10909. * @private
  10910. * @param {Function} func The function to convert.
  10911. * @returns {string} Returns the source code.
  10912. */
  10913. function toSource(func) {
  10914. if (func != null) {
  10915. try {
  10916. return funcToString.call(func);
  10917. } catch (e) {}
  10918. try {
  10919. return (func + '');
  10920. } catch (e) {}
  10921. }
  10922. return '';
  10923. }
  10924. /**
  10925. * Updates wrapper `details` based on `bitmask` flags.
  10926. *
  10927. * @private
  10928. * @returns {Array} details The details to modify.
  10929. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10930. * @returns {Array} Returns `details`.
  10931. */
  10932. function updateWrapDetails(details, bitmask) {
  10933. arrayEach(wrapFlags, function(pair) {
  10934. var value = '_.' + pair[0];
  10935. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  10936. details.push(value);
  10937. }
  10938. });
  10939. return details.sort();
  10940. }
  10941. /**
  10942. * Creates a clone of `wrapper`.
  10943. *
  10944. * @private
  10945. * @param {Object} wrapper The wrapper to clone.
  10946. * @returns {Object} Returns the cloned wrapper.
  10947. */
  10948. function wrapperClone(wrapper) {
  10949. if (wrapper instanceof LazyWrapper) {
  10950. return wrapper.clone();
  10951. }
  10952. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  10953. result.__actions__ = copyArray(wrapper.__actions__);
  10954. result.__index__ = wrapper.__index__;
  10955. result.__values__ = wrapper.__values__;
  10956. return result;
  10957. }
  10958. /*------------------------------------------------------------------------*/
  10959. /**
  10960. * Creates an array of elements split into groups the length of `size`.
  10961. * If `array` can't be split evenly, the final chunk will be the remaining
  10962. * elements.
  10963. *
  10964. * @static
  10965. * @memberOf _
  10966. * @since 3.0.0
  10967. * @category Array
  10968. * @param {Array} array The array to process.
  10969. * @param {number} [size=1] The length of each chunk
  10970. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10971. * @returns {Array} Returns the new array of chunks.
  10972. * @example
  10973. *
  10974. * _.chunk(['a', 'b', 'c', 'd'], 2);
  10975. * // => [['a', 'b'], ['c', 'd']]
  10976. *
  10977. * _.chunk(['a', 'b', 'c', 'd'], 3);
  10978. * // => [['a', 'b', 'c'], ['d']]
  10979. */
  10980. function chunk(array, size, guard) {
  10981. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  10982. size = 1;
  10983. } else {
  10984. size = nativeMax(toInteger(size), 0);
  10985. }
  10986. var length = array == null ? 0 : array.length;
  10987. if (!length || size < 1) {
  10988. return [];
  10989. }
  10990. var index = 0,
  10991. resIndex = 0,
  10992. result = Array(nativeCeil(length / size));
  10993. while (index < length) {
  10994. result[resIndex++] = baseSlice(array, index, (index += size));
  10995. }
  10996. return result;
  10997. }
  10998. /**
  10999. * Creates an array with all falsey values removed. The values `false`, `null`,
  11000. * `0`, `""`, `undefined`, and `NaN` are falsey.
  11001. *
  11002. * @static
  11003. * @memberOf _
  11004. * @since 0.1.0
  11005. * @category Array
  11006. * @param {Array} array The array to compact.
  11007. * @returns {Array} Returns the new array of filtered values.
  11008. * @example
  11009. *
  11010. * _.compact([0, 1, false, 2, '', 3]);
  11011. * // => [1, 2, 3]
  11012. */
  11013. function compact(array) {
  11014. var index = -1,
  11015. length = array == null ? 0 : array.length,
  11016. resIndex = 0,
  11017. result = [];
  11018. while (++index < length) {
  11019. var value = array[index];
  11020. if (value) {
  11021. result[resIndex++] = value;
  11022. }
  11023. }
  11024. return result;
  11025. }
  11026. /**
  11027. * Creates a new array concatenating `array` with any additional arrays
  11028. * and/or values.
  11029. *
  11030. * @static
  11031. * @memberOf _
  11032. * @since 4.0.0
  11033. * @category Array
  11034. * @param {Array} array The array to concatenate.
  11035. * @param {...*} [values] The values to concatenate.
  11036. * @returns {Array} Returns the new concatenated array.
  11037. * @example
  11038. *
  11039. * var array = [1];
  11040. * var other = _.concat(array, 2, [3], [[4]]);
  11041. *
  11042. * console.log(other);
  11043. * // => [1, 2, 3, [4]]
  11044. *
  11045. * console.log(array);
  11046. * // => [1]
  11047. */
  11048. function concat() {
  11049. var length = arguments.length;
  11050. if (!length) {
  11051. return [];
  11052. }
  11053. var args = Array(length - 1),
  11054. array = arguments[0],
  11055. index = length;
  11056. while (index--) {
  11057. args[index - 1] = arguments[index];
  11058. }
  11059. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  11060. }
  11061. /**
  11062. * Creates an array of `array` values not included in the other given arrays
  11063. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11064. * for equality comparisons. The order and references of result values are
  11065. * determined by the first array.
  11066. *
  11067. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  11068. *
  11069. * @static
  11070. * @memberOf _
  11071. * @since 0.1.0
  11072. * @category Array
  11073. * @param {Array} array The array to inspect.
  11074. * @param {...Array} [values] The values to exclude.
  11075. * @returns {Array} Returns the new array of filtered values.
  11076. * @see _.without, _.xor
  11077. * @example
  11078. *
  11079. * _.difference([2, 1], [2, 3]);
  11080. * // => [1]
  11081. */
  11082. var difference = baseRest(function(array, values) {
  11083. return isArrayLikeObject(array)
  11084. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  11085. : [];
  11086. });
  11087. /**
  11088. * This method is like `_.difference` except that it accepts `iteratee` which
  11089. * is invoked for each element of `array` and `values` to generate the criterion
  11090. * by which they're compared. The order and references of result values are
  11091. * determined by the first array. The iteratee is invoked with one argument:
  11092. * (value).
  11093. *
  11094. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  11095. *
  11096. * @static
  11097. * @memberOf _
  11098. * @since 4.0.0
  11099. * @category Array
  11100. * @param {Array} array The array to inspect.
  11101. * @param {...Array} [values] The values to exclude.
  11102. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  11103. * @returns {Array} Returns the new array of filtered values.
  11104. * @example
  11105. *
  11106. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  11107. * // => [1.2]
  11108. *
  11109. * // The `_.property` iteratee shorthand.
  11110. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  11111. * // => [{ 'x': 2 }]
  11112. */
  11113. var differenceBy = baseRest(function(array, values) {
  11114. var iteratee = last(values);
  11115. if (isArrayLikeObject(iteratee)) {
  11116. iteratee = undefined;
  11117. }
  11118. return isArrayLikeObject(array)
  11119. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  11120. : [];
  11121. });
  11122. /**
  11123. * This method is like `_.difference` except that it accepts `comparator`
  11124. * which is invoked to compare elements of `array` to `values`. The order and
  11125. * references of result values are determined by the first array. The comparator
  11126. * is invoked with two arguments: (arrVal, othVal).
  11127. *
  11128. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  11129. *
  11130. * @static
  11131. * @memberOf _
  11132. * @since 4.0.0
  11133. * @category Array
  11134. * @param {Array} array The array to inspect.
  11135. * @param {...Array} [values] The values to exclude.
  11136. * @param {Function} [comparator] The comparator invoked per element.
  11137. * @returns {Array} Returns the new array of filtered values.
  11138. * @example
  11139. *
  11140. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  11141. *
  11142. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  11143. * // => [{ 'x': 2, 'y': 1 }]
  11144. */
  11145. var differenceWith = baseRest(function(array, values) {
  11146. var comparator = last(values);
  11147. if (isArrayLikeObject(comparator)) {
  11148. comparator = undefined;
  11149. }
  11150. return isArrayLikeObject(array)
  11151. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  11152. : [];
  11153. });
  11154. /**
  11155. * Creates a slice of `array` with `n` elements dropped from the beginning.
  11156. *
  11157. * @static
  11158. * @memberOf _
  11159. * @since 0.5.0
  11160. * @category Array
  11161. * @param {Array} array The array to query.
  11162. * @param {number} [n=1] The number of elements to drop.
  11163. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11164. * @returns {Array} Returns the slice of `array`.
  11165. * @example
  11166. *
  11167. * _.drop([1, 2, 3]);
  11168. * // => [2, 3]
  11169. *
  11170. * _.drop([1, 2, 3], 2);
  11171. * // => [3]
  11172. *
  11173. * _.drop([1, 2, 3], 5);
  11174. * // => []
  11175. *
  11176. * _.drop([1, 2, 3], 0);
  11177. * // => [1, 2, 3]
  11178. */
  11179. function drop(array, n, guard) {
  11180. var length = array == null ? 0 : array.length;
  11181. if (!length) {
  11182. return [];
  11183. }
  11184. n = (guard || n === undefined) ? 1 : toInteger(n);
  11185. return baseSlice(array, n < 0 ? 0 : n, length);
  11186. }
  11187. /**
  11188. * Creates a slice of `array` with `n` elements dropped from the end.
  11189. *
  11190. * @static
  11191. * @memberOf _
  11192. * @since 3.0.0
  11193. * @category Array
  11194. * @param {Array} array The array to query.
  11195. * @param {number} [n=1] The number of elements to drop.
  11196. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11197. * @returns {Array} Returns the slice of `array`.
  11198. * @example
  11199. *
  11200. * _.dropRight([1, 2, 3]);
  11201. * // => [1, 2]
  11202. *
  11203. * _.dropRight([1, 2, 3], 2);
  11204. * // => [1]
  11205. *
  11206. * _.dropRight([1, 2, 3], 5);
  11207. * // => []
  11208. *
  11209. * _.dropRight([1, 2, 3], 0);
  11210. * // => [1, 2, 3]
  11211. */
  11212. function dropRight(array, n, guard) {
  11213. var length = array == null ? 0 : array.length;
  11214. if (!length) {
  11215. return [];
  11216. }
  11217. n = (guard || n === undefined) ? 1 : toInteger(n);
  11218. n = length - n;
  11219. return baseSlice(array, 0, n < 0 ? 0 : n);
  11220. }
  11221. /**
  11222. * Creates a slice of `array` excluding elements dropped from the end.
  11223. * Elements are dropped until `predicate` returns falsey. The predicate is
  11224. * invoked with three arguments: (value, index, array).
  11225. *
  11226. * @static
  11227. * @memberOf _
  11228. * @since 3.0.0
  11229. * @category Array
  11230. * @param {Array} array The array to query.
  11231. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11232. * @returns {Array} Returns the slice of `array`.
  11233. * @example
  11234. *
  11235. * var users = [
  11236. * { 'user': 'barney', 'active': true },
  11237. * { 'user': 'fred', 'active': false },
  11238. * { 'user': 'pebbles', 'active': false }
  11239. * ];
  11240. *
  11241. * _.dropRightWhile(users, function(o) { return !o.active; });
  11242. * // => objects for ['barney']
  11243. *
  11244. * // The `_.matches` iteratee shorthand.
  11245. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  11246. * // => objects for ['barney', 'fred']
  11247. *
  11248. * // The `_.matchesProperty` iteratee shorthand.
  11249. * _.dropRightWhile(users, ['active', false]);
  11250. * // => objects for ['barney']
  11251. *
  11252. * // The `_.property` iteratee shorthand.
  11253. * _.dropRightWhile(users, 'active');
  11254. * // => objects for ['barney', 'fred', 'pebbles']
  11255. */
  11256. function dropRightWhile(array, predicate) {
  11257. return (array && array.length)
  11258. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  11259. : [];
  11260. }
  11261. /**
  11262. * Creates a slice of `array` excluding elements dropped from the beginning.
  11263. * Elements are dropped until `predicate` returns falsey. The predicate is
  11264. * invoked with three arguments: (value, index, array).
  11265. *
  11266. * @static
  11267. * @memberOf _
  11268. * @since 3.0.0
  11269. * @category Array
  11270. * @param {Array} array The array to query.
  11271. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11272. * @returns {Array} Returns the slice of `array`.
  11273. * @example
  11274. *
  11275. * var users = [
  11276. * { 'user': 'barney', 'active': false },
  11277. * { 'user': 'fred', 'active': false },
  11278. * { 'user': 'pebbles', 'active': true }
  11279. * ];
  11280. *
  11281. * _.dropWhile(users, function(o) { return !o.active; });
  11282. * // => objects for ['pebbles']
  11283. *
  11284. * // The `_.matches` iteratee shorthand.
  11285. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  11286. * // => objects for ['fred', 'pebbles']
  11287. *
  11288. * // The `_.matchesProperty` iteratee shorthand.
  11289. * _.dropWhile(users, ['active', false]);
  11290. * // => objects for ['pebbles']
  11291. *
  11292. * // The `_.property` iteratee shorthand.
  11293. * _.dropWhile(users, 'active');
  11294. * // => objects for ['barney', 'fred', 'pebbles']
  11295. */
  11296. function dropWhile(array, predicate) {
  11297. return (array && array.length)
  11298. ? baseWhile(array, getIteratee(predicate, 3), true)
  11299. : [];
  11300. }
  11301. /**
  11302. * Fills elements of `array` with `value` from `start` up to, but not
  11303. * including, `end`.
  11304. *
  11305. * **Note:** This method mutates `array`.
  11306. *
  11307. * @static
  11308. * @memberOf _
  11309. * @since 3.2.0
  11310. * @category Array
  11311. * @param {Array} array The array to fill.
  11312. * @param {*} value The value to fill `array` with.
  11313. * @param {number} [start=0] The start position.
  11314. * @param {number} [end=array.length] The end position.
  11315. * @returns {Array} Returns `array`.
  11316. * @example
  11317. *
  11318. * var array = [1, 2, 3];
  11319. *
  11320. * _.fill(array, 'a');
  11321. * console.log(array);
  11322. * // => ['a', 'a', 'a']
  11323. *
  11324. * _.fill(Array(3), 2);
  11325. * // => [2, 2, 2]
  11326. *
  11327. * _.fill([4, 6, 8, 10], '*', 1, 3);
  11328. * // => [4, '*', '*', 10]
  11329. */
  11330. function fill(array, value, start, end) {
  11331. var length = array == null ? 0 : array.length;
  11332. if (!length) {
  11333. return [];
  11334. }
  11335. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  11336. start = 0;
  11337. end = length;
  11338. }
  11339. return baseFill(array, value, start, end);
  11340. }
  11341. /**
  11342. * This method is like `_.find` except that it returns the index of the first
  11343. * element `predicate` returns truthy for instead of the element itself.
  11344. *
  11345. * @static
  11346. * @memberOf _
  11347. * @since 1.1.0
  11348. * @category Array
  11349. * @param {Array} array The array to inspect.
  11350. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11351. * @param {number} [fromIndex=0] The index to search from.
  11352. * @returns {number} Returns the index of the found element, else `-1`.
  11353. * @example
  11354. *
  11355. * var users = [
  11356. * { 'user': 'barney', 'active': false },
  11357. * { 'user': 'fred', 'active': false },
  11358. * { 'user': 'pebbles', 'active': true }
  11359. * ];
  11360. *
  11361. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  11362. * // => 0
  11363. *
  11364. * // The `_.matches` iteratee shorthand.
  11365. * _.findIndex(users, { 'user': 'fred', 'active': false });
  11366. * // => 1
  11367. *
  11368. * // The `_.matchesProperty` iteratee shorthand.
  11369. * _.findIndex(users, ['active', false]);
  11370. * // => 0
  11371. *
  11372. * // The `_.property` iteratee shorthand.
  11373. * _.findIndex(users, 'active');
  11374. * // => 2
  11375. */
  11376. function findIndex(array, predicate, fromIndex) {
  11377. var length = array == null ? 0 : array.length;
  11378. if (!length) {
  11379. return -1;
  11380. }
  11381. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  11382. if (index < 0) {
  11383. index = nativeMax(length + index, 0);
  11384. }
  11385. return baseFindIndex(array, getIteratee(predicate, 3), index);
  11386. }
  11387. /**
  11388. * This method is like `_.findIndex` except that it iterates over elements
  11389. * of `collection` from right to left.
  11390. *
  11391. * @static
  11392. * @memberOf _
  11393. * @since 2.0.0
  11394. * @category Array
  11395. * @param {Array} array The array to inspect.
  11396. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11397. * @param {number} [fromIndex=array.length-1] The index to search from.
  11398. * @returns {number} Returns the index of the found element, else `-1`.
  11399. * @example
  11400. *
  11401. * var users = [
  11402. * { 'user': 'barney', 'active': true },
  11403. * { 'user': 'fred', 'active': false },
  11404. * { 'user': 'pebbles', 'active': false }
  11405. * ];
  11406. *
  11407. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  11408. * // => 2
  11409. *
  11410. * // The `_.matches` iteratee shorthand.
  11411. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  11412. * // => 0
  11413. *
  11414. * // The `_.matchesProperty` iteratee shorthand.
  11415. * _.findLastIndex(users, ['active', false]);
  11416. * // => 2
  11417. *
  11418. * // The `_.property` iteratee shorthand.
  11419. * _.findLastIndex(users, 'active');
  11420. * // => 0
  11421. */
  11422. function findLastIndex(array, predicate, fromIndex) {
  11423. var length = array == null ? 0 : array.length;
  11424. if (!length) {
  11425. return -1;
  11426. }
  11427. var index = length - 1;
  11428. if (fromIndex !== undefined) {
  11429. index = toInteger(fromIndex);
  11430. index = fromIndex < 0
  11431. ? nativeMax(length + index, 0)
  11432. : nativeMin(index, length - 1);
  11433. }
  11434. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  11435. }
  11436. /**
  11437. * Flattens `array` a single level deep.
  11438. *
  11439. * @static
  11440. * @memberOf _
  11441. * @since 0.1.0
  11442. * @category Array
  11443. * @param {Array} array The array to flatten.
  11444. * @returns {Array} Returns the new flattened array.
  11445. * @example
  11446. *
  11447. * _.flatten([1, [2, [3, [4]], 5]]);
  11448. * // => [1, 2, [3, [4]], 5]
  11449. */
  11450. function flatten(array) {
  11451. var length = array == null ? 0 : array.length;
  11452. return length ? baseFlatten(array, 1) : [];
  11453. }
  11454. /**
  11455. * Recursively flattens `array`.
  11456. *
  11457. * @static
  11458. * @memberOf _
  11459. * @since 3.0.0
  11460. * @category Array
  11461. * @param {Array} array The array to flatten.
  11462. * @returns {Array} Returns the new flattened array.
  11463. * @example
  11464. *
  11465. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  11466. * // => [1, 2, 3, 4, 5]
  11467. */
  11468. function flattenDeep(array) {
  11469. var length = array == null ? 0 : array.length;
  11470. return length ? baseFlatten(array, INFINITY) : [];
  11471. }
  11472. /**
  11473. * Recursively flatten `array` up to `depth` times.
  11474. *
  11475. * @static
  11476. * @memberOf _
  11477. * @since 4.4.0
  11478. * @category Array
  11479. * @param {Array} array The array to flatten.
  11480. * @param {number} [depth=1] The maximum recursion depth.
  11481. * @returns {Array} Returns the new flattened array.
  11482. * @example
  11483. *
  11484. * var array = [1, [2, [3, [4]], 5]];
  11485. *
  11486. * _.flattenDepth(array, 1);
  11487. * // => [1, 2, [3, [4]], 5]
  11488. *
  11489. * _.flattenDepth(array, 2);
  11490. * // => [1, 2, 3, [4], 5]
  11491. */
  11492. function flattenDepth(array, depth) {
  11493. var length = array == null ? 0 : array.length;
  11494. if (!length) {
  11495. return [];
  11496. }
  11497. depth = depth === undefined ? 1 : toInteger(depth);
  11498. return baseFlatten(array, depth);
  11499. }
  11500. /**
  11501. * The inverse of `_.toPairs`; this method returns an object composed
  11502. * from key-value `pairs`.
  11503. *
  11504. * @static
  11505. * @memberOf _
  11506. * @since 4.0.0
  11507. * @category Array
  11508. * @param {Array} pairs The key-value pairs.
  11509. * @returns {Object} Returns the new object.
  11510. * @example
  11511. *
  11512. * _.fromPairs([['a', 1], ['b', 2]]);
  11513. * // => { 'a': 1, 'b': 2 }
  11514. */
  11515. function fromPairs(pairs) {
  11516. var index = -1,
  11517. length = pairs == null ? 0 : pairs.length,
  11518. result = {};
  11519. while (++index < length) {
  11520. var pair = pairs[index];
  11521. result[pair[0]] = pair[1];
  11522. }
  11523. return result;
  11524. }
  11525. /**
  11526. * Gets the first element of `array`.
  11527. *
  11528. * @static
  11529. * @memberOf _
  11530. * @since 0.1.0
  11531. * @alias first
  11532. * @category Array
  11533. * @param {Array} array The array to query.
  11534. * @returns {*} Returns the first element of `array`.
  11535. * @example
  11536. *
  11537. * _.head([1, 2, 3]);
  11538. * // => 1
  11539. *
  11540. * _.head([]);
  11541. * // => undefined
  11542. */
  11543. function head(array) {
  11544. return (array && array.length) ? array[0] : undefined;
  11545. }
  11546. /**
  11547. * Gets the index at which the first occurrence of `value` is found in `array`
  11548. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11549. * for equality comparisons. If `fromIndex` is negative, it's used as the
  11550. * offset from the end of `array`.
  11551. *
  11552. * @static
  11553. * @memberOf _
  11554. * @since 0.1.0
  11555. * @category Array
  11556. * @param {Array} array The array to inspect.
  11557. * @param {*} value The value to search for.
  11558. * @param {number} [fromIndex=0] The index to search from.
  11559. * @returns {number} Returns the index of the matched value, else `-1`.
  11560. * @example
  11561. *
  11562. * _.indexOf([1, 2, 1, 2], 2);
  11563. * // => 1
  11564. *
  11565. * // Search from the `fromIndex`.
  11566. * _.indexOf([1, 2, 1, 2], 2, 2);
  11567. * // => 3
  11568. */
  11569. function indexOf(array, value, fromIndex) {
  11570. var length = array == null ? 0 : array.length;
  11571. if (!length) {
  11572. return -1;
  11573. }
  11574. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  11575. if (index < 0) {
  11576. index = nativeMax(length + index, 0);
  11577. }
  11578. return baseIndexOf(array, value, index);
  11579. }
  11580. /**
  11581. * Gets all but the last element of `array`.
  11582. *
  11583. * @static
  11584. * @memberOf _
  11585. * @since 0.1.0
  11586. * @category Array
  11587. * @param {Array} array The array to query.
  11588. * @returns {Array} Returns the slice of `array`.
  11589. * @example
  11590. *
  11591. * _.initial([1, 2, 3]);
  11592. * // => [1, 2]
  11593. */
  11594. function initial(array) {
  11595. var length = array == null ? 0 : array.length;
  11596. return length ? baseSlice(array, 0, -1) : [];
  11597. }
  11598. /**
  11599. * Creates an array of unique values that are included in all given arrays
  11600. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11601. * for equality comparisons. The order and references of result values are
  11602. * determined by the first array.
  11603. *
  11604. * @static
  11605. * @memberOf _
  11606. * @since 0.1.0
  11607. * @category Array
  11608. * @param {...Array} [arrays] The arrays to inspect.
  11609. * @returns {Array} Returns the new array of intersecting values.
  11610. * @example
  11611. *
  11612. * _.intersection([2, 1], [2, 3]);
  11613. * // => [2]
  11614. */
  11615. var intersection = baseRest(function(arrays) {
  11616. var mapped = arrayMap(arrays, castArrayLikeObject);
  11617. return (mapped.length && mapped[0] === arrays[0])
  11618. ? baseIntersection(mapped)
  11619. : [];
  11620. });
  11621. /**
  11622. * This method is like `_.intersection` except that it accepts `iteratee`
  11623. * which is invoked for each element of each `arrays` to generate the criterion
  11624. * by which they're compared. The order and references of result values are
  11625. * determined by the first array. The iteratee is invoked with one argument:
  11626. * (value).
  11627. *
  11628. * @static
  11629. * @memberOf _
  11630. * @since 4.0.0
  11631. * @category Array
  11632. * @param {...Array} [arrays] The arrays to inspect.
  11633. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  11634. * @returns {Array} Returns the new array of intersecting values.
  11635. * @example
  11636. *
  11637. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  11638. * // => [2.1]
  11639. *
  11640. * // The `_.property` iteratee shorthand.
  11641. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  11642. * // => [{ 'x': 1 }]
  11643. */
  11644. var intersectionBy = baseRest(function(arrays) {
  11645. var iteratee = last(arrays),
  11646. mapped = arrayMap(arrays, castArrayLikeObject);
  11647. if (iteratee === last(mapped)) {
  11648. iteratee = undefined;
  11649. } else {
  11650. mapped.pop();
  11651. }
  11652. return (mapped.length && mapped[0] === arrays[0])
  11653. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  11654. : [];
  11655. });
  11656. /**
  11657. * This method is like `_.intersection` except that it accepts `comparator`
  11658. * which is invoked to compare elements of `arrays`. The order and references
  11659. * of result values are determined by the first array. The comparator is
  11660. * invoked with two arguments: (arrVal, othVal).
  11661. *
  11662. * @static
  11663. * @memberOf _
  11664. * @since 4.0.0
  11665. * @category Array
  11666. * @param {...Array} [arrays] The arrays to inspect.
  11667. * @param {Function} [comparator] The comparator invoked per element.
  11668. * @returns {Array} Returns the new array of intersecting values.
  11669. * @example
  11670. *
  11671. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  11672. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  11673. *
  11674. * _.intersectionWith(objects, others, _.isEqual);
  11675. * // => [{ 'x': 1, 'y': 2 }]
  11676. */
  11677. var intersectionWith = baseRest(function(arrays) {
  11678. var comparator = last(arrays),
  11679. mapped = arrayMap(arrays, castArrayLikeObject);
  11680. comparator = typeof comparator == 'function' ? comparator : undefined;
  11681. if (comparator) {
  11682. mapped.pop();
  11683. }
  11684. return (mapped.length && mapped[0] === arrays[0])
  11685. ? baseIntersection(mapped, undefined, comparator)
  11686. : [];
  11687. });
  11688. /**
  11689. * Converts all elements in `array` into a string separated by `separator`.
  11690. *
  11691. * @static
  11692. * @memberOf _
  11693. * @since 4.0.0
  11694. * @category Array
  11695. * @param {Array} array The array to convert.
  11696. * @param {string} [separator=','] The element separator.
  11697. * @returns {string} Returns the joined string.
  11698. * @example
  11699. *
  11700. * _.join(['a', 'b', 'c'], '~');
  11701. * // => 'a~b~c'
  11702. */
  11703. function join(array, separator) {
  11704. return array == null ? '' : nativeJoin.call(array, separator);
  11705. }
  11706. /**
  11707. * Gets the last element of `array`.
  11708. *
  11709. * @static
  11710. * @memberOf _
  11711. * @since 0.1.0
  11712. * @category Array
  11713. * @param {Array} array The array to query.
  11714. * @returns {*} Returns the last element of `array`.
  11715. * @example
  11716. *
  11717. * _.last([1, 2, 3]);
  11718. * // => 3
  11719. */
  11720. function last(array) {
  11721. var length = array == null ? 0 : array.length;
  11722. return length ? array[length - 1] : undefined;
  11723. }
  11724. /**
  11725. * This method is like `_.indexOf` except that it iterates over elements of
  11726. * `array` from right to left.
  11727. *
  11728. * @static
  11729. * @memberOf _
  11730. * @since 0.1.0
  11731. * @category Array
  11732. * @param {Array} array The array to inspect.
  11733. * @param {*} value The value to search for.
  11734. * @param {number} [fromIndex=array.length-1] The index to search from.
  11735. * @returns {number} Returns the index of the matched value, else `-1`.
  11736. * @example
  11737. *
  11738. * _.lastIndexOf([1, 2, 1, 2], 2);
  11739. * // => 3
  11740. *
  11741. * // Search from the `fromIndex`.
  11742. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  11743. * // => 1
  11744. */
  11745. function lastIndexOf(array, value, fromIndex) {
  11746. var length = array == null ? 0 : array.length;
  11747. if (!length) {
  11748. return -1;
  11749. }
  11750. var index = length;
  11751. if (fromIndex !== undefined) {
  11752. index = toInteger(fromIndex);
  11753. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  11754. }
  11755. return value === value
  11756. ? strictLastIndexOf(array, value, index)
  11757. : baseFindIndex(array, baseIsNaN, index, true);
  11758. }
  11759. /**
  11760. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  11761. * element from the end is returned.
  11762. *
  11763. * @static
  11764. * @memberOf _
  11765. * @since 4.11.0
  11766. * @category Array
  11767. * @param {Array} array The array to query.
  11768. * @param {number} [n=0] The index of the element to return.
  11769. * @returns {*} Returns the nth element of `array`.
  11770. * @example
  11771. *
  11772. * var array = ['a', 'b', 'c', 'd'];
  11773. *
  11774. * _.nth(array, 1);
  11775. * // => 'b'
  11776. *
  11777. * _.nth(array, -2);
  11778. * // => 'c';
  11779. */
  11780. function nth(array, n) {
  11781. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  11782. }
  11783. /**
  11784. * Removes all given values from `array` using
  11785. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11786. * for equality comparisons.
  11787. *
  11788. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  11789. * to remove elements from an array by predicate.
  11790. *
  11791. * @static
  11792. * @memberOf _
  11793. * @since 2.0.0
  11794. * @category Array
  11795. * @param {Array} array The array to modify.
  11796. * @param {...*} [values] The values to remove.
  11797. * @returns {Array} Returns `array`.
  11798. * @example
  11799. *
  11800. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  11801. *
  11802. * _.pull(array, 'a', 'c');
  11803. * console.log(array);
  11804. * // => ['b', 'b']
  11805. */
  11806. var pull = baseRest(pullAll);
  11807. /**
  11808. * This method is like `_.pull` except that it accepts an array of values to remove.
  11809. *
  11810. * **Note:** Unlike `_.difference`, this method mutates `array`.
  11811. *
  11812. * @static
  11813. * @memberOf _
  11814. * @since 4.0.0
  11815. * @category Array
  11816. * @param {Array} array The array to modify.
  11817. * @param {Array} values The values to remove.
  11818. * @returns {Array} Returns `array`.
  11819. * @example
  11820. *
  11821. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  11822. *
  11823. * _.pullAll(array, ['a', 'c']);
  11824. * console.log(array);
  11825. * // => ['b', 'b']
  11826. */
  11827. function pullAll(array, values) {
  11828. return (array && array.length && values && values.length)
  11829. ? basePullAll(array, values)
  11830. : array;
  11831. }
  11832. /**
  11833. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  11834. * invoked for each element of `array` and `values` to generate the criterion
  11835. * by which they're compared. The iteratee is invoked with one argument: (value).
  11836. *
  11837. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  11838. *
  11839. * @static
  11840. * @memberOf _
  11841. * @since 4.0.0
  11842. * @category Array
  11843. * @param {Array} array The array to modify.
  11844. * @param {Array} values The values to remove.
  11845. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  11846. * @returns {Array} Returns `array`.
  11847. * @example
  11848. *
  11849. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  11850. *
  11851. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  11852. * console.log(array);
  11853. * // => [{ 'x': 2 }]
  11854. */
  11855. function pullAllBy(array, values, iteratee) {
  11856. return (array && array.length && values && values.length)
  11857. ? basePullAll(array, values, getIteratee(iteratee, 2))
  11858. : array;
  11859. }
  11860. /**
  11861. * This method is like `_.pullAll` except that it accepts `comparator` which
  11862. * is invoked to compare elements of `array` to `values`. The comparator is
  11863. * invoked with two arguments: (arrVal, othVal).
  11864. *
  11865. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  11866. *
  11867. * @static
  11868. * @memberOf _
  11869. * @since 4.6.0
  11870. * @category Array
  11871. * @param {Array} array The array to modify.
  11872. * @param {Array} values The values to remove.
  11873. * @param {Function} [comparator] The comparator invoked per element.
  11874. * @returns {Array} Returns `array`.
  11875. * @example
  11876. *
  11877. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  11878. *
  11879. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  11880. * console.log(array);
  11881. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  11882. */
  11883. function pullAllWith(array, values, comparator) {
  11884. return (array && array.length && values && values.length)
  11885. ? basePullAll(array, values, undefined, comparator)
  11886. : array;
  11887. }
  11888. /**
  11889. * Removes elements from `array` corresponding to `indexes` and returns an
  11890. * array of removed elements.
  11891. *
  11892. * **Note:** Unlike `_.at`, this method mutates `array`.
  11893. *
  11894. * @static
  11895. * @memberOf _
  11896. * @since 3.0.0
  11897. * @category Array
  11898. * @param {Array} array The array to modify.
  11899. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  11900. * @returns {Array} Returns the new array of removed elements.
  11901. * @example
  11902. *
  11903. * var array = ['a', 'b', 'c', 'd'];
  11904. * var pulled = _.pullAt(array, [1, 3]);
  11905. *
  11906. * console.log(array);
  11907. * // => ['a', 'c']
  11908. *
  11909. * console.log(pulled);
  11910. * // => ['b', 'd']
  11911. */
  11912. var pullAt = flatRest(function(array, indexes) {
  11913. var length = array == null ? 0 : array.length,
  11914. result = baseAt(array, indexes);
  11915. basePullAt(array, arrayMap(indexes, function(index) {
  11916. return isIndex(index, length) ? +index : index;
  11917. }).sort(compareAscending));
  11918. return result;
  11919. });
  11920. /**
  11921. * Removes all elements from `array` that `predicate` returns truthy for
  11922. * and returns an array of the removed elements. The predicate is invoked
  11923. * with three arguments: (value, index, array).
  11924. *
  11925. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  11926. * to pull elements from an array by value.
  11927. *
  11928. * @static
  11929. * @memberOf _
  11930. * @since 2.0.0
  11931. * @category Array
  11932. * @param {Array} array The array to modify.
  11933. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11934. * @returns {Array} Returns the new array of removed elements.
  11935. * @example
  11936. *
  11937. * var array = [1, 2, 3, 4];
  11938. * var evens = _.remove(array, function(n) {
  11939. * return n % 2 == 0;
  11940. * });
  11941. *
  11942. * console.log(array);
  11943. * // => [1, 3]
  11944. *
  11945. * console.log(evens);
  11946. * // => [2, 4]
  11947. */
  11948. function remove(array, predicate) {
  11949. var result = [];
  11950. if (!(array && array.length)) {
  11951. return result;
  11952. }
  11953. var index = -1,
  11954. indexes = [],
  11955. length = array.length;
  11956. predicate = getIteratee(predicate, 3);
  11957. while (++index < length) {
  11958. var value = array[index];
  11959. if (predicate(value, index, array)) {
  11960. result.push(value);
  11961. indexes.push(index);
  11962. }
  11963. }
  11964. basePullAt(array, indexes);
  11965. return result;
  11966. }
  11967. /**
  11968. * Reverses `array` so that the first element becomes the last, the second
  11969. * element becomes the second to last, and so on.
  11970. *
  11971. * **Note:** This method mutates `array` and is based on
  11972. * [`Array#reverse`](https://mdn.io/Array/reverse).
  11973. *
  11974. * @static
  11975. * @memberOf _
  11976. * @since 4.0.0
  11977. * @category Array
  11978. * @param {Array} array The array to modify.
  11979. * @returns {Array} Returns `array`.
  11980. * @example
  11981. *
  11982. * var array = [1, 2, 3];
  11983. *
  11984. * _.reverse(array);
  11985. * // => [3, 2, 1]
  11986. *
  11987. * console.log(array);
  11988. * // => [3, 2, 1]
  11989. */
  11990. function reverse(array) {
  11991. return array == null ? array : nativeReverse.call(array);
  11992. }
  11993. /**
  11994. * Creates a slice of `array` from `start` up to, but not including, `end`.
  11995. *
  11996. * **Note:** This method is used instead of
  11997. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  11998. * returned.
  11999. *
  12000. * @static
  12001. * @memberOf _
  12002. * @since 3.0.0
  12003. * @category Array
  12004. * @param {Array} array The array to slice.
  12005. * @param {number} [start=0] The start position.
  12006. * @param {number} [end=array.length] The end position.
  12007. * @returns {Array} Returns the slice of `array`.
  12008. */
  12009. function slice(array, start, end) {
  12010. var length = array == null ? 0 : array.length;
  12011. if (!length) {
  12012. return [];
  12013. }
  12014. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  12015. start = 0;
  12016. end = length;
  12017. }
  12018. else {
  12019. start = start == null ? 0 : toInteger(start);
  12020. end = end === undefined ? length : toInteger(end);
  12021. }
  12022. return baseSlice(array, start, end);
  12023. }
  12024. /**
  12025. * Uses a binary search to determine the lowest index at which `value`
  12026. * should be inserted into `array` in order to maintain its sort order.
  12027. *
  12028. * @static
  12029. * @memberOf _
  12030. * @since 0.1.0
  12031. * @category Array
  12032. * @param {Array} array The sorted array to inspect.
  12033. * @param {*} value The value to evaluate.
  12034. * @returns {number} Returns the index at which `value` should be inserted
  12035. * into `array`.
  12036. * @example
  12037. *
  12038. * _.sortedIndex([30, 50], 40);
  12039. * // => 1
  12040. */
  12041. function sortedIndex(array, value) {
  12042. return baseSortedIndex(array, value);
  12043. }
  12044. /**
  12045. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  12046. * which is invoked for `value` and each element of `array` to compute their
  12047. * sort ranking. The iteratee is invoked with one argument: (value).
  12048. *
  12049. * @static
  12050. * @memberOf _
  12051. * @since 4.0.0
  12052. * @category Array
  12053. * @param {Array} array The sorted array to inspect.
  12054. * @param {*} value The value to evaluate.
  12055. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12056. * @returns {number} Returns the index at which `value` should be inserted
  12057. * into `array`.
  12058. * @example
  12059. *
  12060. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  12061. *
  12062. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  12063. * // => 0
  12064. *
  12065. * // The `_.property` iteratee shorthand.
  12066. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  12067. * // => 0
  12068. */
  12069. function sortedIndexBy(array, value, iteratee) {
  12070. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  12071. }
  12072. /**
  12073. * This method is like `_.indexOf` except that it performs a binary
  12074. * search on a sorted `array`.
  12075. *
  12076. * @static
  12077. * @memberOf _
  12078. * @since 4.0.0
  12079. * @category Array
  12080. * @param {Array} array The array to inspect.
  12081. * @param {*} value The value to search for.
  12082. * @returns {number} Returns the index of the matched value, else `-1`.
  12083. * @example
  12084. *
  12085. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  12086. * // => 1
  12087. */
  12088. function sortedIndexOf(array, value) {
  12089. var length = array == null ? 0 : array.length;
  12090. if (length) {
  12091. var index = baseSortedIndex(array, value);
  12092. if (index < length && eq(array[index], value)) {
  12093. return index;
  12094. }
  12095. }
  12096. return -1;
  12097. }
  12098. /**
  12099. * This method is like `_.sortedIndex` except that it returns the highest
  12100. * index at which `value` should be inserted into `array` in order to
  12101. * maintain its sort order.
  12102. *
  12103. * @static
  12104. * @memberOf _
  12105. * @since 3.0.0
  12106. * @category Array
  12107. * @param {Array} array The sorted array to inspect.
  12108. * @param {*} value The value to evaluate.
  12109. * @returns {number} Returns the index at which `value` should be inserted
  12110. * into `array`.
  12111. * @example
  12112. *
  12113. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  12114. * // => 4
  12115. */
  12116. function sortedLastIndex(array, value) {
  12117. return baseSortedIndex(array, value, true);
  12118. }
  12119. /**
  12120. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  12121. * which is invoked for `value` and each element of `array` to compute their
  12122. * sort ranking. The iteratee is invoked with one argument: (value).
  12123. *
  12124. * @static
  12125. * @memberOf _
  12126. * @since 4.0.0
  12127. * @category Array
  12128. * @param {Array} array The sorted array to inspect.
  12129. * @param {*} value The value to evaluate.
  12130. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12131. * @returns {number} Returns the index at which `value` should be inserted
  12132. * into `array`.
  12133. * @example
  12134. *
  12135. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  12136. *
  12137. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  12138. * // => 1
  12139. *
  12140. * // The `_.property` iteratee shorthand.
  12141. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  12142. * // => 1
  12143. */
  12144. function sortedLastIndexBy(array, value, iteratee) {
  12145. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  12146. }
  12147. /**
  12148. * This method is like `_.lastIndexOf` except that it performs a binary
  12149. * search on a sorted `array`.
  12150. *
  12151. * @static
  12152. * @memberOf _
  12153. * @since 4.0.0
  12154. * @category Array
  12155. * @param {Array} array The array to inspect.
  12156. * @param {*} value The value to search for.
  12157. * @returns {number} Returns the index of the matched value, else `-1`.
  12158. * @example
  12159. *
  12160. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  12161. * // => 3
  12162. */
  12163. function sortedLastIndexOf(array, value) {
  12164. var length = array == null ? 0 : array.length;
  12165. if (length) {
  12166. var index = baseSortedIndex(array, value, true) - 1;
  12167. if (eq(array[index], value)) {
  12168. return index;
  12169. }
  12170. }
  12171. return -1;
  12172. }
  12173. /**
  12174. * This method is like `_.uniq` except that it's designed and optimized
  12175. * for sorted arrays.
  12176. *
  12177. * @static
  12178. * @memberOf _
  12179. * @since 4.0.0
  12180. * @category Array
  12181. * @param {Array} array The array to inspect.
  12182. * @returns {Array} Returns the new duplicate free array.
  12183. * @example
  12184. *
  12185. * _.sortedUniq([1, 1, 2]);
  12186. * // => [1, 2]
  12187. */
  12188. function sortedUniq(array) {
  12189. return (array && array.length)
  12190. ? baseSortedUniq(array)
  12191. : [];
  12192. }
  12193. /**
  12194. * This method is like `_.uniqBy` except that it's designed and optimized
  12195. * for sorted arrays.
  12196. *
  12197. * @static
  12198. * @memberOf _
  12199. * @since 4.0.0
  12200. * @category Array
  12201. * @param {Array} array The array to inspect.
  12202. * @param {Function} [iteratee] The iteratee invoked per element.
  12203. * @returns {Array} Returns the new duplicate free array.
  12204. * @example
  12205. *
  12206. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  12207. * // => [1.1, 2.3]
  12208. */
  12209. function sortedUniqBy(array, iteratee) {
  12210. return (array && array.length)
  12211. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  12212. : [];
  12213. }
  12214. /**
  12215. * Gets all but the first element of `array`.
  12216. *
  12217. * @static
  12218. * @memberOf _
  12219. * @since 4.0.0
  12220. * @category Array
  12221. * @param {Array} array The array to query.
  12222. * @returns {Array} Returns the slice of `array`.
  12223. * @example
  12224. *
  12225. * _.tail([1, 2, 3]);
  12226. * // => [2, 3]
  12227. */
  12228. function tail(array) {
  12229. var length = array == null ? 0 : array.length;
  12230. return length ? baseSlice(array, 1, length) : [];
  12231. }
  12232. /**
  12233. * Creates a slice of `array` with `n` elements taken from the beginning.
  12234. *
  12235. * @static
  12236. * @memberOf _
  12237. * @since 0.1.0
  12238. * @category Array
  12239. * @param {Array} array The array to query.
  12240. * @param {number} [n=1] The number of elements to take.
  12241. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12242. * @returns {Array} Returns the slice of `array`.
  12243. * @example
  12244. *
  12245. * _.take([1, 2, 3]);
  12246. * // => [1]
  12247. *
  12248. * _.take([1, 2, 3], 2);
  12249. * // => [1, 2]
  12250. *
  12251. * _.take([1, 2, 3], 5);
  12252. * // => [1, 2, 3]
  12253. *
  12254. * _.take([1, 2, 3], 0);
  12255. * // => []
  12256. */
  12257. function take(array, n, guard) {
  12258. if (!(array && array.length)) {
  12259. return [];
  12260. }
  12261. n = (guard || n === undefined) ? 1 : toInteger(n);
  12262. return baseSlice(array, 0, n < 0 ? 0 : n);
  12263. }
  12264. /**
  12265. * Creates a slice of `array` with `n` elements taken from the end.
  12266. *
  12267. * @static
  12268. * @memberOf _
  12269. * @since 3.0.0
  12270. * @category Array
  12271. * @param {Array} array The array to query.
  12272. * @param {number} [n=1] The number of elements to take.
  12273. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12274. * @returns {Array} Returns the slice of `array`.
  12275. * @example
  12276. *
  12277. * _.takeRight([1, 2, 3]);
  12278. * // => [3]
  12279. *
  12280. * _.takeRight([1, 2, 3], 2);
  12281. * // => [2, 3]
  12282. *
  12283. * _.takeRight([1, 2, 3], 5);
  12284. * // => [1, 2, 3]
  12285. *
  12286. * _.takeRight([1, 2, 3], 0);
  12287. * // => []
  12288. */
  12289. function takeRight(array, n, guard) {
  12290. var length = array == null ? 0 : array.length;
  12291. if (!length) {
  12292. return [];
  12293. }
  12294. n = (guard || n === undefined) ? 1 : toInteger(n);
  12295. n = length - n;
  12296. return baseSlice(array, n < 0 ? 0 : n, length);
  12297. }
  12298. /**
  12299. * Creates a slice of `array` with elements taken from the end. Elements are
  12300. * taken until `predicate` returns falsey. The predicate is invoked with
  12301. * three arguments: (value, index, array).
  12302. *
  12303. * @static
  12304. * @memberOf _
  12305. * @since 3.0.0
  12306. * @category Array
  12307. * @param {Array} array The array to query.
  12308. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12309. * @returns {Array} Returns the slice of `array`.
  12310. * @example
  12311. *
  12312. * var users = [
  12313. * { 'user': 'barney', 'active': true },
  12314. * { 'user': 'fred', 'active': false },
  12315. * { 'user': 'pebbles', 'active': false }
  12316. * ];
  12317. *
  12318. * _.takeRightWhile(users, function(o) { return !o.active; });
  12319. * // => objects for ['fred', 'pebbles']
  12320. *
  12321. * // The `_.matches` iteratee shorthand.
  12322. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  12323. * // => objects for ['pebbles']
  12324. *
  12325. * // The `_.matchesProperty` iteratee shorthand.
  12326. * _.takeRightWhile(users, ['active', false]);
  12327. * // => objects for ['fred', 'pebbles']
  12328. *
  12329. * // The `_.property` iteratee shorthand.
  12330. * _.takeRightWhile(users, 'active');
  12331. * // => []
  12332. */
  12333. function takeRightWhile(array, predicate) {
  12334. return (array && array.length)
  12335. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  12336. : [];
  12337. }
  12338. /**
  12339. * Creates a slice of `array` with elements taken from the beginning. Elements
  12340. * are taken until `predicate` returns falsey. The predicate is invoked with
  12341. * three arguments: (value, index, array).
  12342. *
  12343. * @static
  12344. * @memberOf _
  12345. * @since 3.0.0
  12346. * @category Array
  12347. * @param {Array} array The array to query.
  12348. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12349. * @returns {Array} Returns the slice of `array`.
  12350. * @example
  12351. *
  12352. * var users = [
  12353. * { 'user': 'barney', 'active': false },
  12354. * { 'user': 'fred', 'active': false },
  12355. * { 'user': 'pebbles', 'active': true }
  12356. * ];
  12357. *
  12358. * _.takeWhile(users, function(o) { return !o.active; });
  12359. * // => objects for ['barney', 'fred']
  12360. *
  12361. * // The `_.matches` iteratee shorthand.
  12362. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  12363. * // => objects for ['barney']
  12364. *
  12365. * // The `_.matchesProperty` iteratee shorthand.
  12366. * _.takeWhile(users, ['active', false]);
  12367. * // => objects for ['barney', 'fred']
  12368. *
  12369. * // The `_.property` iteratee shorthand.
  12370. * _.takeWhile(users, 'active');
  12371. * // => []
  12372. */
  12373. function takeWhile(array, predicate) {
  12374. return (array && array.length)
  12375. ? baseWhile(array, getIteratee(predicate, 3))
  12376. : [];
  12377. }
  12378. /**
  12379. * Creates an array of unique values, in order, from all given arrays using
  12380. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12381. * for equality comparisons.
  12382. *
  12383. * @static
  12384. * @memberOf _
  12385. * @since 0.1.0
  12386. * @category Array
  12387. * @param {...Array} [arrays] The arrays to inspect.
  12388. * @returns {Array} Returns the new array of combined values.
  12389. * @example
  12390. *
  12391. * _.union([2], [1, 2]);
  12392. * // => [2, 1]
  12393. */
  12394. var union = baseRest(function(arrays) {
  12395. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  12396. });
  12397. /**
  12398. * This method is like `_.union` except that it accepts `iteratee` which is
  12399. * invoked for each element of each `arrays` to generate the criterion by
  12400. * which uniqueness is computed. Result values are chosen from the first
  12401. * array in which the value occurs. The iteratee is invoked with one argument:
  12402. * (value).
  12403. *
  12404. * @static
  12405. * @memberOf _
  12406. * @since 4.0.0
  12407. * @category Array
  12408. * @param {...Array} [arrays] The arrays to inspect.
  12409. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12410. * @returns {Array} Returns the new array of combined values.
  12411. * @example
  12412. *
  12413. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  12414. * // => [2.1, 1.2]
  12415. *
  12416. * // The `_.property` iteratee shorthand.
  12417. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  12418. * // => [{ 'x': 1 }, { 'x': 2 }]
  12419. */
  12420. var unionBy = baseRest(function(arrays) {
  12421. var iteratee = last(arrays);
  12422. if (isArrayLikeObject(iteratee)) {
  12423. iteratee = undefined;
  12424. }
  12425. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  12426. });
  12427. /**
  12428. * This method is like `_.union` except that it accepts `comparator` which
  12429. * is invoked to compare elements of `arrays`. Result values are chosen from
  12430. * the first array in which the value occurs. The comparator is invoked
  12431. * with two arguments: (arrVal, othVal).
  12432. *
  12433. * @static
  12434. * @memberOf _
  12435. * @since 4.0.0
  12436. * @category Array
  12437. * @param {...Array} [arrays] The arrays to inspect.
  12438. * @param {Function} [comparator] The comparator invoked per element.
  12439. * @returns {Array} Returns the new array of combined values.
  12440. * @example
  12441. *
  12442. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12443. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12444. *
  12445. * _.unionWith(objects, others, _.isEqual);
  12446. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  12447. */
  12448. var unionWith = baseRest(function(arrays) {
  12449. var comparator = last(arrays);
  12450. comparator = typeof comparator == 'function' ? comparator : undefined;
  12451. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  12452. });
  12453. /**
  12454. * Creates a duplicate-free version of an array, using
  12455. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12456. * for equality comparisons, in which only the first occurrence of each element
  12457. * is kept. The order of result values is determined by the order they occur
  12458. * in the array.
  12459. *
  12460. * @static
  12461. * @memberOf _
  12462. * @since 0.1.0
  12463. * @category Array
  12464. * @param {Array} array The array to inspect.
  12465. * @returns {Array} Returns the new duplicate free array.
  12466. * @example
  12467. *
  12468. * _.uniq([2, 1, 2]);
  12469. * // => [2, 1]
  12470. */
  12471. function uniq(array) {
  12472. return (array && array.length) ? baseUniq(array) : [];
  12473. }
  12474. /**
  12475. * This method is like `_.uniq` except that it accepts `iteratee` which is
  12476. * invoked for each element in `array` to generate the criterion by which
  12477. * uniqueness is computed. The order of result values is determined by the
  12478. * order they occur in the array. The iteratee is invoked with one argument:
  12479. * (value).
  12480. *
  12481. * @static
  12482. * @memberOf _
  12483. * @since 4.0.0
  12484. * @category Array
  12485. * @param {Array} array The array to inspect.
  12486. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12487. * @returns {Array} Returns the new duplicate free array.
  12488. * @example
  12489. *
  12490. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  12491. * // => [2.1, 1.2]
  12492. *
  12493. * // The `_.property` iteratee shorthand.
  12494. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  12495. * // => [{ 'x': 1 }, { 'x': 2 }]
  12496. */
  12497. function uniqBy(array, iteratee) {
  12498. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  12499. }
  12500. /**
  12501. * This method is like `_.uniq` except that it accepts `comparator` which
  12502. * is invoked to compare elements of `array`. The order of result values is
  12503. * determined by the order they occur in the array.The comparator is invoked
  12504. * with two arguments: (arrVal, othVal).
  12505. *
  12506. * @static
  12507. * @memberOf _
  12508. * @since 4.0.0
  12509. * @category Array
  12510. * @param {Array} array The array to inspect.
  12511. * @param {Function} [comparator] The comparator invoked per element.
  12512. * @returns {Array} Returns the new duplicate free array.
  12513. * @example
  12514. *
  12515. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12516. *
  12517. * _.uniqWith(objects, _.isEqual);
  12518. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  12519. */
  12520. function uniqWith(array, comparator) {
  12521. comparator = typeof comparator == 'function' ? comparator : undefined;
  12522. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  12523. }
  12524. /**
  12525. * This method is like `_.zip` except that it accepts an array of grouped
  12526. * elements and creates an array regrouping the elements to their pre-zip
  12527. * configuration.
  12528. *
  12529. * @static
  12530. * @memberOf _
  12531. * @since 1.2.0
  12532. * @category Array
  12533. * @param {Array} array The array of grouped elements to process.
  12534. * @returns {Array} Returns the new array of regrouped elements.
  12535. * @example
  12536. *
  12537. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  12538. * // => [['a', 1, true], ['b', 2, false]]
  12539. *
  12540. * _.unzip(zipped);
  12541. * // => [['a', 'b'], [1, 2], [true, false]]
  12542. */
  12543. function unzip(array) {
  12544. if (!(array && array.length)) {
  12545. return [];
  12546. }
  12547. var length = 0;
  12548. array = arrayFilter(array, function(group) {
  12549. if (isArrayLikeObject(group)) {
  12550. length = nativeMax(group.length, length);
  12551. return true;
  12552. }
  12553. });
  12554. return baseTimes(length, function(index) {
  12555. return arrayMap(array, baseProperty(index));
  12556. });
  12557. }
  12558. /**
  12559. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  12560. * how regrouped values should be combined. The iteratee is invoked with the
  12561. * elements of each group: (...group).
  12562. *
  12563. * @static
  12564. * @memberOf _
  12565. * @since 3.8.0
  12566. * @category Array
  12567. * @param {Array} array The array of grouped elements to process.
  12568. * @param {Function} [iteratee=_.identity] The function to combine
  12569. * regrouped values.
  12570. * @returns {Array} Returns the new array of regrouped elements.
  12571. * @example
  12572. *
  12573. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  12574. * // => [[1, 10, 100], [2, 20, 200]]
  12575. *
  12576. * _.unzipWith(zipped, _.add);
  12577. * // => [3, 30, 300]
  12578. */
  12579. function unzipWith(array, iteratee) {
  12580. if (!(array && array.length)) {
  12581. return [];
  12582. }
  12583. var result = unzip(array);
  12584. if (iteratee == null) {
  12585. return result;
  12586. }
  12587. return arrayMap(result, function(group) {
  12588. return apply(iteratee, undefined, group);
  12589. });
  12590. }
  12591. /**
  12592. * Creates an array excluding all given values using
  12593. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12594. * for equality comparisons.
  12595. *
  12596. * **Note:** Unlike `_.pull`, this method returns a new array.
  12597. *
  12598. * @static
  12599. * @memberOf _
  12600. * @since 0.1.0
  12601. * @category Array
  12602. * @param {Array} array The array to inspect.
  12603. * @param {...*} [values] The values to exclude.
  12604. * @returns {Array} Returns the new array of filtered values.
  12605. * @see _.difference, _.xor
  12606. * @example
  12607. *
  12608. * _.without([2, 1, 2, 3], 1, 2);
  12609. * // => [3]
  12610. */
  12611. var without = baseRest(function(array, values) {
  12612. return isArrayLikeObject(array)
  12613. ? baseDifference(array, values)
  12614. : [];
  12615. });
  12616. /**
  12617. * Creates an array of unique values that is the
  12618. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  12619. * of the given arrays. The order of result values is determined by the order
  12620. * they occur in the arrays.
  12621. *
  12622. * @static
  12623. * @memberOf _
  12624. * @since 2.4.0
  12625. * @category Array
  12626. * @param {...Array} [arrays] The arrays to inspect.
  12627. * @returns {Array} Returns the new array of filtered values.
  12628. * @see _.difference, _.without
  12629. * @example
  12630. *
  12631. * _.xor([2, 1], [2, 3]);
  12632. * // => [1, 3]
  12633. */
  12634. var xor = baseRest(function(arrays) {
  12635. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  12636. });
  12637. /**
  12638. * This method is like `_.xor` except that it accepts `iteratee` which is
  12639. * invoked for each element of each `arrays` to generate the criterion by
  12640. * which by which they're compared. The order of result values is determined
  12641. * by the order they occur in the arrays. The iteratee is invoked with one
  12642. * argument: (value).
  12643. *
  12644. * @static
  12645. * @memberOf _
  12646. * @since 4.0.0
  12647. * @category Array
  12648. * @param {...Array} [arrays] The arrays to inspect.
  12649. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12650. * @returns {Array} Returns the new array of filtered values.
  12651. * @example
  12652. *
  12653. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  12654. * // => [1.2, 3.4]
  12655. *
  12656. * // The `_.property` iteratee shorthand.
  12657. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  12658. * // => [{ 'x': 2 }]
  12659. */
  12660. var xorBy = baseRest(function(arrays) {
  12661. var iteratee = last(arrays);
  12662. if (isArrayLikeObject(iteratee)) {
  12663. iteratee = undefined;
  12664. }
  12665. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  12666. });
  12667. /**
  12668. * This method is like `_.xor` except that it accepts `comparator` which is
  12669. * invoked to compare elements of `arrays`. The order of result values is
  12670. * determined by the order they occur in the arrays. The comparator is invoked
  12671. * with two arguments: (arrVal, othVal).
  12672. *
  12673. * @static
  12674. * @memberOf _
  12675. * @since 4.0.0
  12676. * @category Array
  12677. * @param {...Array} [arrays] The arrays to inspect.
  12678. * @param {Function} [comparator] The comparator invoked per element.
  12679. * @returns {Array} Returns the new array of filtered values.
  12680. * @example
  12681. *
  12682. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12683. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12684. *
  12685. * _.xorWith(objects, others, _.isEqual);
  12686. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  12687. */
  12688. var xorWith = baseRest(function(arrays) {
  12689. var comparator = last(arrays);
  12690. comparator = typeof comparator == 'function' ? comparator : undefined;
  12691. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  12692. });
  12693. /**
  12694. * Creates an array of grouped elements, the first of which contains the
  12695. * first elements of the given arrays, the second of which contains the
  12696. * second elements of the given arrays, and so on.
  12697. *
  12698. * @static
  12699. * @memberOf _
  12700. * @since 0.1.0
  12701. * @category Array
  12702. * @param {...Array} [arrays] The arrays to process.
  12703. * @returns {Array} Returns the new array of grouped elements.
  12704. * @example
  12705. *
  12706. * _.zip(['a', 'b'], [1, 2], [true, false]);
  12707. * // => [['a', 1, true], ['b', 2, false]]
  12708. */
  12709. var zip = baseRest(unzip);
  12710. /**
  12711. * This method is like `_.fromPairs` except that it accepts two arrays,
  12712. * one of property identifiers and one of corresponding values.
  12713. *
  12714. * @static
  12715. * @memberOf _
  12716. * @since 0.4.0
  12717. * @category Array
  12718. * @param {Array} [props=[]] The property identifiers.
  12719. * @param {Array} [values=[]] The property values.
  12720. * @returns {Object} Returns the new object.
  12721. * @example
  12722. *
  12723. * _.zipObject(['a', 'b'], [1, 2]);
  12724. * // => { 'a': 1, 'b': 2 }
  12725. */
  12726. function zipObject(props, values) {
  12727. return baseZipObject(props || [], values || [], assignValue);
  12728. }
  12729. /**
  12730. * This method is like `_.zipObject` except that it supports property paths.
  12731. *
  12732. * @static
  12733. * @memberOf _
  12734. * @since 4.1.0
  12735. * @category Array
  12736. * @param {Array} [props=[]] The property identifiers.
  12737. * @param {Array} [values=[]] The property values.
  12738. * @returns {Object} Returns the new object.
  12739. * @example
  12740. *
  12741. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  12742. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  12743. */
  12744. function zipObjectDeep(props, values) {
  12745. return baseZipObject(props || [], values || [], baseSet);
  12746. }
  12747. /**
  12748. * This method is like `_.zip` except that it accepts `iteratee` to specify
  12749. * how grouped values should be combined. The iteratee is invoked with the
  12750. * elements of each group: (...group).
  12751. *
  12752. * @static
  12753. * @memberOf _
  12754. * @since 3.8.0
  12755. * @category Array
  12756. * @param {...Array} [arrays] The arrays to process.
  12757. * @param {Function} [iteratee=_.identity] The function to combine
  12758. * grouped values.
  12759. * @returns {Array} Returns the new array of grouped elements.
  12760. * @example
  12761. *
  12762. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  12763. * return a + b + c;
  12764. * });
  12765. * // => [111, 222]
  12766. */
  12767. var zipWith = baseRest(function(arrays) {
  12768. var length = arrays.length,
  12769. iteratee = length > 1 ? arrays[length - 1] : undefined;
  12770. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  12771. return unzipWith(arrays, iteratee);
  12772. });
  12773. /*------------------------------------------------------------------------*/
  12774. /**
  12775. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  12776. * chain sequences enabled. The result of such sequences must be unwrapped
  12777. * with `_#value`.
  12778. *
  12779. * @static
  12780. * @memberOf _
  12781. * @since 1.3.0
  12782. * @category Seq
  12783. * @param {*} value The value to wrap.
  12784. * @returns {Object} Returns the new `lodash` wrapper instance.
  12785. * @example
  12786. *
  12787. * var users = [
  12788. * { 'user': 'barney', 'age': 36 },
  12789. * { 'user': 'fred', 'age': 40 },
  12790. * { 'user': 'pebbles', 'age': 1 }
  12791. * ];
  12792. *
  12793. * var youngest = _
  12794. * .chain(users)
  12795. * .sortBy('age')
  12796. * .map(function(o) {
  12797. * return o.user + ' is ' + o.age;
  12798. * })
  12799. * .head()
  12800. * .value();
  12801. * // => 'pebbles is 1'
  12802. */
  12803. function chain(value) {
  12804. var result = lodash(value);
  12805. result.__chain__ = true;
  12806. return result;
  12807. }
  12808. /**
  12809. * This method invokes `interceptor` and returns `value`. The interceptor
  12810. * is invoked with one argument; (value). The purpose of this method is to
  12811. * "tap into" a method chain sequence in order to modify intermediate results.
  12812. *
  12813. * @static
  12814. * @memberOf _
  12815. * @since 0.1.0
  12816. * @category Seq
  12817. * @param {*} value The value to provide to `interceptor`.
  12818. * @param {Function} interceptor The function to invoke.
  12819. * @returns {*} Returns `value`.
  12820. * @example
  12821. *
  12822. * _([1, 2, 3])
  12823. * .tap(function(array) {
  12824. * // Mutate input array.
  12825. * array.pop();
  12826. * })
  12827. * .reverse()
  12828. * .value();
  12829. * // => [2, 1]
  12830. */
  12831. function tap(value, interceptor) {
  12832. interceptor(value);
  12833. return value;
  12834. }
  12835. /**
  12836. * This method is like `_.tap` except that it returns the result of `interceptor`.
  12837. * The purpose of this method is to "pass thru" values replacing intermediate
  12838. * results in a method chain sequence.
  12839. *
  12840. * @static
  12841. * @memberOf _
  12842. * @since 3.0.0
  12843. * @category Seq
  12844. * @param {*} value The value to provide to `interceptor`.
  12845. * @param {Function} interceptor The function to invoke.
  12846. * @returns {*} Returns the result of `interceptor`.
  12847. * @example
  12848. *
  12849. * _(' abc ')
  12850. * .chain()
  12851. * .trim()
  12852. * .thru(function(value) {
  12853. * return [value];
  12854. * })
  12855. * .value();
  12856. * // => ['abc']
  12857. */
  12858. function thru(value, interceptor) {
  12859. return interceptor(value);
  12860. }
  12861. /**
  12862. * This method is the wrapper version of `_.at`.
  12863. *
  12864. * @name at
  12865. * @memberOf _
  12866. * @since 1.0.0
  12867. * @category Seq
  12868. * @param {...(string|string[])} [paths] The property paths to pick.
  12869. * @returns {Object} Returns the new `lodash` wrapper instance.
  12870. * @example
  12871. *
  12872. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  12873. *
  12874. * _(object).at(['a[0].b.c', 'a[1]']).value();
  12875. * // => [3, 4]
  12876. */
  12877. var wrapperAt = flatRest(function(paths) {
  12878. var length = paths.length,
  12879. start = length ? paths[0] : 0,
  12880. value = this.__wrapped__,
  12881. interceptor = function(object) { return baseAt(object, paths); };
  12882. if (length > 1 || this.__actions__.length ||
  12883. !(value instanceof LazyWrapper) || !isIndex(start)) {
  12884. return this.thru(interceptor);
  12885. }
  12886. value = value.slice(start, +start + (length ? 1 : 0));
  12887. value.__actions__.push({
  12888. 'func': thru,
  12889. 'args': [interceptor],
  12890. 'thisArg': undefined
  12891. });
  12892. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  12893. if (length && !array.length) {
  12894. array.push(undefined);
  12895. }
  12896. return array;
  12897. });
  12898. });
  12899. /**
  12900. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  12901. *
  12902. * @name chain
  12903. * @memberOf _
  12904. * @since 0.1.0
  12905. * @category Seq
  12906. * @returns {Object} Returns the new `lodash` wrapper instance.
  12907. * @example
  12908. *
  12909. * var users = [
  12910. * { 'user': 'barney', 'age': 36 },
  12911. * { 'user': 'fred', 'age': 40 }
  12912. * ];
  12913. *
  12914. * // A sequence without explicit chaining.
  12915. * _(users).head();
  12916. * // => { 'user': 'barney', 'age': 36 }
  12917. *
  12918. * // A sequence with explicit chaining.
  12919. * _(users)
  12920. * .chain()
  12921. * .head()
  12922. * .pick('user')
  12923. * .value();
  12924. * // => { 'user': 'barney' }
  12925. */
  12926. function wrapperChain() {
  12927. return chain(this);
  12928. }
  12929. /**
  12930. * Executes the chain sequence and returns the wrapped result.
  12931. *
  12932. * @name commit
  12933. * @memberOf _
  12934. * @since 3.2.0
  12935. * @category Seq
  12936. * @returns {Object} Returns the new `lodash` wrapper instance.
  12937. * @example
  12938. *
  12939. * var array = [1, 2];
  12940. * var wrapped = _(array).push(3);
  12941. *
  12942. * console.log(array);
  12943. * // => [1, 2]
  12944. *
  12945. * wrapped = wrapped.commit();
  12946. * console.log(array);
  12947. * // => [1, 2, 3]
  12948. *
  12949. * wrapped.last();
  12950. * // => 3
  12951. *
  12952. * console.log(array);
  12953. * // => [1, 2, 3]
  12954. */
  12955. function wrapperCommit() {
  12956. return new LodashWrapper(this.value(), this.__chain__);
  12957. }
  12958. /**
  12959. * Gets the next value on a wrapped object following the
  12960. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  12961. *
  12962. * @name next
  12963. * @memberOf _
  12964. * @since 4.0.0
  12965. * @category Seq
  12966. * @returns {Object} Returns the next iterator value.
  12967. * @example
  12968. *
  12969. * var wrapped = _([1, 2]);
  12970. *
  12971. * wrapped.next();
  12972. * // => { 'done': false, 'value': 1 }
  12973. *
  12974. * wrapped.next();
  12975. * // => { 'done': false, 'value': 2 }
  12976. *
  12977. * wrapped.next();
  12978. * // => { 'done': true, 'value': undefined }
  12979. */
  12980. function wrapperNext() {
  12981. if (this.__values__ === undefined) {
  12982. this.__values__ = toArray(this.value());
  12983. }
  12984. var done = this.__index__ >= this.__values__.length,
  12985. value = done ? undefined : this.__values__[this.__index__++];
  12986. return { 'done': done, 'value': value };
  12987. }
  12988. /**
  12989. * Enables the wrapper to be iterable.
  12990. *
  12991. * @name Symbol.iterator
  12992. * @memberOf _
  12993. * @since 4.0.0
  12994. * @category Seq
  12995. * @returns {Object} Returns the wrapper object.
  12996. * @example
  12997. *
  12998. * var wrapped = _([1, 2]);
  12999. *
  13000. * wrapped[Symbol.iterator]() === wrapped;
  13001. * // => true
  13002. *
  13003. * Array.from(wrapped);
  13004. * // => [1, 2]
  13005. */
  13006. function wrapperToIterator() {
  13007. return this;
  13008. }
  13009. /**
  13010. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  13011. *
  13012. * @name plant
  13013. * @memberOf _
  13014. * @since 3.2.0
  13015. * @category Seq
  13016. * @param {*} value The value to plant.
  13017. * @returns {Object} Returns the new `lodash` wrapper instance.
  13018. * @example
  13019. *
  13020. * function square(n) {
  13021. * return n * n;
  13022. * }
  13023. *
  13024. * var wrapped = _([1, 2]).map(square);
  13025. * var other = wrapped.plant([3, 4]);
  13026. *
  13027. * other.value();
  13028. * // => [9, 16]
  13029. *
  13030. * wrapped.value();
  13031. * // => [1, 4]
  13032. */
  13033. function wrapperPlant(value) {
  13034. var result,
  13035. parent = this;
  13036. while (parent instanceof baseLodash) {
  13037. var clone = wrapperClone(parent);
  13038. clone.__index__ = 0;
  13039. clone.__values__ = undefined;
  13040. if (result) {
  13041. previous.__wrapped__ = clone;
  13042. } else {
  13043. result = clone;
  13044. }
  13045. var previous = clone;
  13046. parent = parent.__wrapped__;
  13047. }
  13048. previous.__wrapped__ = value;
  13049. return result;
  13050. }
  13051. /**
  13052. * This method is the wrapper version of `_.reverse`.
  13053. *
  13054. * **Note:** This method mutates the wrapped array.
  13055. *
  13056. * @name reverse
  13057. * @memberOf _
  13058. * @since 0.1.0
  13059. * @category Seq
  13060. * @returns {Object} Returns the new `lodash` wrapper instance.
  13061. * @example
  13062. *
  13063. * var array = [1, 2, 3];
  13064. *
  13065. * _(array).reverse().value()
  13066. * // => [3, 2, 1]
  13067. *
  13068. * console.log(array);
  13069. * // => [3, 2, 1]
  13070. */
  13071. function wrapperReverse() {
  13072. var value = this.__wrapped__;
  13073. if (value instanceof LazyWrapper) {
  13074. var wrapped = value;
  13075. if (this.__actions__.length) {
  13076. wrapped = new LazyWrapper(this);
  13077. }
  13078. wrapped = wrapped.reverse();
  13079. wrapped.__actions__.push({
  13080. 'func': thru,
  13081. 'args': [reverse],
  13082. 'thisArg': undefined
  13083. });
  13084. return new LodashWrapper(wrapped, this.__chain__);
  13085. }
  13086. return this.thru(reverse);
  13087. }
  13088. /**
  13089. * Executes the chain sequence to resolve the unwrapped value.
  13090. *
  13091. * @name value
  13092. * @memberOf _
  13093. * @since 0.1.0
  13094. * @alias toJSON, valueOf
  13095. * @category Seq
  13096. * @returns {*} Returns the resolved unwrapped value.
  13097. * @example
  13098. *
  13099. * _([1, 2, 3]).value();
  13100. * // => [1, 2, 3]
  13101. */
  13102. function wrapperValue() {
  13103. return baseWrapperValue(this.__wrapped__, this.__actions__);
  13104. }
  13105. /*------------------------------------------------------------------------*/
  13106. /**
  13107. * Creates an object composed of keys generated from the results of running
  13108. * each element of `collection` thru `iteratee`. The corresponding value of
  13109. * each key is the number of times the key was returned by `iteratee`. The
  13110. * iteratee is invoked with one argument: (value).
  13111. *
  13112. * @static
  13113. * @memberOf _
  13114. * @since 0.5.0
  13115. * @category Collection
  13116. * @param {Array|Object} collection The collection to iterate over.
  13117. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13118. * @returns {Object} Returns the composed aggregate object.
  13119. * @example
  13120. *
  13121. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  13122. * // => { '4': 1, '6': 2 }
  13123. *
  13124. * // The `_.property` iteratee shorthand.
  13125. * _.countBy(['one', 'two', 'three'], 'length');
  13126. * // => { '3': 2, '5': 1 }
  13127. */
  13128. var countBy = createAggregator(function(result, value, key) {
  13129. if (hasOwnProperty.call(result, key)) {
  13130. ++result[key];
  13131. } else {
  13132. baseAssignValue(result, key, 1);
  13133. }
  13134. });
  13135. /**
  13136. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  13137. * Iteration is stopped once `predicate` returns falsey. The predicate is
  13138. * invoked with three arguments: (value, index|key, collection).
  13139. *
  13140. * **Note:** This method returns `true` for
  13141. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  13142. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  13143. * elements of empty collections.
  13144. *
  13145. * @static
  13146. * @memberOf _
  13147. * @since 0.1.0
  13148. * @category Collection
  13149. * @param {Array|Object} collection The collection to iterate over.
  13150. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13151. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13152. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  13153. * else `false`.
  13154. * @example
  13155. *
  13156. * _.every([true, 1, null, 'yes'], Boolean);
  13157. * // => false
  13158. *
  13159. * var users = [
  13160. * { 'user': 'barney', 'age': 36, 'active': false },
  13161. * { 'user': 'fred', 'age': 40, 'active': false }
  13162. * ];
  13163. *
  13164. * // The `_.matches` iteratee shorthand.
  13165. * _.every(users, { 'user': 'barney', 'active': false });
  13166. * // => false
  13167. *
  13168. * // The `_.matchesProperty` iteratee shorthand.
  13169. * _.every(users, ['active', false]);
  13170. * // => true
  13171. *
  13172. * // The `_.property` iteratee shorthand.
  13173. * _.every(users, 'active');
  13174. * // => false
  13175. */
  13176. function every(collection, predicate, guard) {
  13177. var func = isArray(collection) ? arrayEvery : baseEvery;
  13178. if (guard && isIterateeCall(collection, predicate, guard)) {
  13179. predicate = undefined;
  13180. }
  13181. return func(collection, getIteratee(predicate, 3));
  13182. }
  13183. /**
  13184. * Iterates over elements of `collection`, returning an array of all elements
  13185. * `predicate` returns truthy for. The predicate is invoked with three
  13186. * arguments: (value, index|key, collection).
  13187. *
  13188. * **Note:** Unlike `_.remove`, this method returns a new array.
  13189. *
  13190. * @static
  13191. * @memberOf _
  13192. * @since 0.1.0
  13193. * @category Collection
  13194. * @param {Array|Object} collection The collection to iterate over.
  13195. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13196. * @returns {Array} Returns the new filtered array.
  13197. * @see _.reject
  13198. * @example
  13199. *
  13200. * var users = [
  13201. * { 'user': 'barney', 'age': 36, 'active': true },
  13202. * { 'user': 'fred', 'age': 40, 'active': false }
  13203. * ];
  13204. *
  13205. * _.filter(users, function(o) { return !o.active; });
  13206. * // => objects for ['fred']
  13207. *
  13208. * // The `_.matches` iteratee shorthand.
  13209. * _.filter(users, { 'age': 36, 'active': true });
  13210. * // => objects for ['barney']
  13211. *
  13212. * // The `_.matchesProperty` iteratee shorthand.
  13213. * _.filter(users, ['active', false]);
  13214. * // => objects for ['fred']
  13215. *
  13216. * // The `_.property` iteratee shorthand.
  13217. * _.filter(users, 'active');
  13218. * // => objects for ['barney']
  13219. *
  13220. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  13221. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  13222. * // => objects for ['fred', 'barney']
  13223. */
  13224. function filter(collection, predicate) {
  13225. var func = isArray(collection) ? arrayFilter : baseFilter;
  13226. return func(collection, getIteratee(predicate, 3));
  13227. }
  13228. /**
  13229. * Iterates over elements of `collection`, returning the first element
  13230. * `predicate` returns truthy for. The predicate is invoked with three
  13231. * arguments: (value, index|key, collection).
  13232. *
  13233. * @static
  13234. * @memberOf _
  13235. * @since 0.1.0
  13236. * @category Collection
  13237. * @param {Array|Object} collection The collection to inspect.
  13238. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13239. * @param {number} [fromIndex=0] The index to search from.
  13240. * @returns {*} Returns the matched element, else `undefined`.
  13241. * @example
  13242. *
  13243. * var users = [
  13244. * { 'user': 'barney', 'age': 36, 'active': true },
  13245. * { 'user': 'fred', 'age': 40, 'active': false },
  13246. * { 'user': 'pebbles', 'age': 1, 'active': true }
  13247. * ];
  13248. *
  13249. * _.find(users, function(o) { return o.age < 40; });
  13250. * // => object for 'barney'
  13251. *
  13252. * // The `_.matches` iteratee shorthand.
  13253. * _.find(users, { 'age': 1, 'active': true });
  13254. * // => object for 'pebbles'
  13255. *
  13256. * // The `_.matchesProperty` iteratee shorthand.
  13257. * _.find(users, ['active', false]);
  13258. * // => object for 'fred'
  13259. *
  13260. * // The `_.property` iteratee shorthand.
  13261. * _.find(users, 'active');
  13262. * // => object for 'barney'
  13263. */
  13264. var find = createFind(findIndex);
  13265. /**
  13266. * This method is like `_.find` except that it iterates over elements of
  13267. * `collection` from right to left.
  13268. *
  13269. * @static
  13270. * @memberOf _
  13271. * @since 2.0.0
  13272. * @category Collection
  13273. * @param {Array|Object} collection The collection to inspect.
  13274. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13275. * @param {number} [fromIndex=collection.length-1] The index to search from.
  13276. * @returns {*} Returns the matched element, else `undefined`.
  13277. * @example
  13278. *
  13279. * _.findLast([1, 2, 3, 4], function(n) {
  13280. * return n % 2 == 1;
  13281. * });
  13282. * // => 3
  13283. */
  13284. var findLast = createFind(findLastIndex);
  13285. /**
  13286. * Creates a flattened array of values by running each element in `collection`
  13287. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  13288. * with three arguments: (value, index|key, collection).
  13289. *
  13290. * @static
  13291. * @memberOf _
  13292. * @since 4.0.0
  13293. * @category Collection
  13294. * @param {Array|Object} collection The collection to iterate over.
  13295. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13296. * @returns {Array} Returns the new flattened array.
  13297. * @example
  13298. *
  13299. * function duplicate(n) {
  13300. * return [n, n];
  13301. * }
  13302. *
  13303. * _.flatMap([1, 2], duplicate);
  13304. * // => [1, 1, 2, 2]
  13305. */
  13306. function flatMap(collection, iteratee) {
  13307. return baseFlatten(map(collection, iteratee), 1);
  13308. }
  13309. /**
  13310. * This method is like `_.flatMap` except that it recursively flattens the
  13311. * mapped results.
  13312. *
  13313. * @static
  13314. * @memberOf _
  13315. * @since 4.7.0
  13316. * @category Collection
  13317. * @param {Array|Object} collection The collection to iterate over.
  13318. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13319. * @returns {Array} Returns the new flattened array.
  13320. * @example
  13321. *
  13322. * function duplicate(n) {
  13323. * return [[[n, n]]];
  13324. * }
  13325. *
  13326. * _.flatMapDeep([1, 2], duplicate);
  13327. * // => [1, 1, 2, 2]
  13328. */
  13329. function flatMapDeep(collection, iteratee) {
  13330. return baseFlatten(map(collection, iteratee), INFINITY);
  13331. }
  13332. /**
  13333. * This method is like `_.flatMap` except that it recursively flattens the
  13334. * mapped results up to `depth` times.
  13335. *
  13336. * @static
  13337. * @memberOf _
  13338. * @since 4.7.0
  13339. * @category Collection
  13340. * @param {Array|Object} collection The collection to iterate over.
  13341. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13342. * @param {number} [depth=1] The maximum recursion depth.
  13343. * @returns {Array} Returns the new flattened array.
  13344. * @example
  13345. *
  13346. * function duplicate(n) {
  13347. * return [[[n, n]]];
  13348. * }
  13349. *
  13350. * _.flatMapDepth([1, 2], duplicate, 2);
  13351. * // => [[1, 1], [2, 2]]
  13352. */
  13353. function flatMapDepth(collection, iteratee, depth) {
  13354. depth = depth === undefined ? 1 : toInteger(depth);
  13355. return baseFlatten(map(collection, iteratee), depth);
  13356. }
  13357. /**
  13358. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  13359. * The iteratee is invoked with three arguments: (value, index|key, collection).
  13360. * Iteratee functions may exit iteration early by explicitly returning `false`.
  13361. *
  13362. * **Note:** As with other "Collections" methods, objects with a "length"
  13363. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  13364. * or `_.forOwn` for object iteration.
  13365. *
  13366. * @static
  13367. * @memberOf _
  13368. * @since 0.1.0
  13369. * @alias each
  13370. * @category Collection
  13371. * @param {Array|Object} collection The collection to iterate over.
  13372. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13373. * @returns {Array|Object} Returns `collection`.
  13374. * @see _.forEachRight
  13375. * @example
  13376. *
  13377. * _.forEach([1, 2], function(value) {
  13378. * console.log(value);
  13379. * });
  13380. * // => Logs `1` then `2`.
  13381. *
  13382. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  13383. * console.log(key);
  13384. * });
  13385. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  13386. */
  13387. function forEach(collection, iteratee) {
  13388. var func = isArray(collection) ? arrayEach : baseEach;
  13389. return func(collection, getIteratee(iteratee, 3));
  13390. }
  13391. /**
  13392. * This method is like `_.forEach` except that it iterates over elements of
  13393. * `collection` from right to left.
  13394. *
  13395. * @static
  13396. * @memberOf _
  13397. * @since 2.0.0
  13398. * @alias eachRight
  13399. * @category Collection
  13400. * @param {Array|Object} collection The collection to iterate over.
  13401. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13402. * @returns {Array|Object} Returns `collection`.
  13403. * @see _.forEach
  13404. * @example
  13405. *
  13406. * _.forEachRight([1, 2], function(value) {
  13407. * console.log(value);
  13408. * });
  13409. * // => Logs `2` then `1`.
  13410. */
  13411. function forEachRight(collection, iteratee) {
  13412. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  13413. return func(collection, getIteratee(iteratee, 3));
  13414. }
  13415. /**
  13416. * Creates an object composed of keys generated from the results of running
  13417. * each element of `collection` thru `iteratee`. The order of grouped values
  13418. * is determined by the order they occur in `collection`. The corresponding
  13419. * value of each key is an array of elements responsible for generating the
  13420. * key. The iteratee is invoked with one argument: (value).
  13421. *
  13422. * @static
  13423. * @memberOf _
  13424. * @since 0.1.0
  13425. * @category Collection
  13426. * @param {Array|Object} collection The collection to iterate over.
  13427. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13428. * @returns {Object} Returns the composed aggregate object.
  13429. * @example
  13430. *
  13431. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  13432. * // => { '4': [4.2], '6': [6.1, 6.3] }
  13433. *
  13434. * // The `_.property` iteratee shorthand.
  13435. * _.groupBy(['one', 'two', 'three'], 'length');
  13436. * // => { '3': ['one', 'two'], '5': ['three'] }
  13437. */
  13438. var groupBy = createAggregator(function(result, value, key) {
  13439. if (hasOwnProperty.call(result, key)) {
  13440. result[key].push(value);
  13441. } else {
  13442. baseAssignValue(result, key, [value]);
  13443. }
  13444. });
  13445. /**
  13446. * Checks if `value` is in `collection`. If `collection` is a string, it's
  13447. * checked for a substring of `value`, otherwise
  13448. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13449. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  13450. * the offset from the end of `collection`.
  13451. *
  13452. * @static
  13453. * @memberOf _
  13454. * @since 0.1.0
  13455. * @category Collection
  13456. * @param {Array|Object|string} collection The collection to inspect.
  13457. * @param {*} value The value to search for.
  13458. * @param {number} [fromIndex=0] The index to search from.
  13459. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  13460. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  13461. * @example
  13462. *
  13463. * _.includes([1, 2, 3], 1);
  13464. * // => true
  13465. *
  13466. * _.includes([1, 2, 3], 1, 2);
  13467. * // => false
  13468. *
  13469. * _.includes({ 'a': 1, 'b': 2 }, 1);
  13470. * // => true
  13471. *
  13472. * _.includes('abcd', 'bc');
  13473. * // => true
  13474. */
  13475. function includes(collection, value, fromIndex, guard) {
  13476. collection = isArrayLike(collection) ? collection : values(collection);
  13477. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  13478. var length = collection.length;
  13479. if (fromIndex < 0) {
  13480. fromIndex = nativeMax(length + fromIndex, 0);
  13481. }
  13482. return isString(collection)
  13483. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  13484. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  13485. }
  13486. /**
  13487. * Invokes the method at `path` of each element in `collection`, returning
  13488. * an array of the results of each invoked method. Any additional arguments
  13489. * are provided to each invoked method. If `path` is a function, it's invoked
  13490. * for, and `this` bound to, each element in `collection`.
  13491. *
  13492. * @static
  13493. * @memberOf _
  13494. * @since 4.0.0
  13495. * @category Collection
  13496. * @param {Array|Object} collection The collection to iterate over.
  13497. * @param {Array|Function|string} path The path of the method to invoke or
  13498. * the function invoked per iteration.
  13499. * @param {...*} [args] The arguments to invoke each method with.
  13500. * @returns {Array} Returns the array of results.
  13501. * @example
  13502. *
  13503. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  13504. * // => [[1, 5, 7], [1, 2, 3]]
  13505. *
  13506. * _.invokeMap([123, 456], String.prototype.split, '');
  13507. * // => [['1', '2', '3'], ['4', '5', '6']]
  13508. */
  13509. var invokeMap = baseRest(function(collection, path, args) {
  13510. var index = -1,
  13511. isFunc = typeof path == 'function',
  13512. result = isArrayLike(collection) ? Array(collection.length) : [];
  13513. baseEach(collection, function(value) {
  13514. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  13515. });
  13516. return result;
  13517. });
  13518. /**
  13519. * Creates an object composed of keys generated from the results of running
  13520. * each element of `collection` thru `iteratee`. The corresponding value of
  13521. * each key is the last element responsible for generating the key. The
  13522. * iteratee is invoked with one argument: (value).
  13523. *
  13524. * @static
  13525. * @memberOf _
  13526. * @since 4.0.0
  13527. * @category Collection
  13528. * @param {Array|Object} collection The collection to iterate over.
  13529. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13530. * @returns {Object} Returns the composed aggregate object.
  13531. * @example
  13532. *
  13533. * var array = [
  13534. * { 'dir': 'left', 'code': 97 },
  13535. * { 'dir': 'right', 'code': 100 }
  13536. * ];
  13537. *
  13538. * _.keyBy(array, function(o) {
  13539. * return String.fromCharCode(o.code);
  13540. * });
  13541. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  13542. *
  13543. * _.keyBy(array, 'dir');
  13544. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  13545. */
  13546. var keyBy = createAggregator(function(result, value, key) {
  13547. baseAssignValue(result, key, value);
  13548. });
  13549. /**
  13550. * Creates an array of values by running each element in `collection` thru
  13551. * `iteratee`. The iteratee is invoked with three arguments:
  13552. * (value, index|key, collection).
  13553. *
  13554. * Many lodash methods are guarded to work as iteratees for methods like
  13555. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  13556. *
  13557. * The guarded methods are:
  13558. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  13559. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  13560. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  13561. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  13562. *
  13563. * @static
  13564. * @memberOf _
  13565. * @since 0.1.0
  13566. * @category Collection
  13567. * @param {Array|Object} collection The collection to iterate over.
  13568. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13569. * @returns {Array} Returns the new mapped array.
  13570. * @example
  13571. *
  13572. * function square(n) {
  13573. * return n * n;
  13574. * }
  13575. *
  13576. * _.map([4, 8], square);
  13577. * // => [16, 64]
  13578. *
  13579. * _.map({ 'a': 4, 'b': 8 }, square);
  13580. * // => [16, 64] (iteration order is not guaranteed)
  13581. *
  13582. * var users = [
  13583. * { 'user': 'barney' },
  13584. * { 'user': 'fred' }
  13585. * ];
  13586. *
  13587. * // The `_.property` iteratee shorthand.
  13588. * _.map(users, 'user');
  13589. * // => ['barney', 'fred']
  13590. */
  13591. function map(collection, iteratee) {
  13592. var func = isArray(collection) ? arrayMap : baseMap;
  13593. return func(collection, getIteratee(iteratee, 3));
  13594. }
  13595. /**
  13596. * This method is like `_.sortBy` except that it allows specifying the sort
  13597. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  13598. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  13599. * descending or "asc" for ascending sort order of corresponding values.
  13600. *
  13601. * @static
  13602. * @memberOf _
  13603. * @since 4.0.0
  13604. * @category Collection
  13605. * @param {Array|Object} collection The collection to iterate over.
  13606. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  13607. * The iteratees to sort by.
  13608. * @param {string[]} [orders] The sort orders of `iteratees`.
  13609. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  13610. * @returns {Array} Returns the new sorted array.
  13611. * @example
  13612. *
  13613. * var users = [
  13614. * { 'user': 'fred', 'age': 48 },
  13615. * { 'user': 'barney', 'age': 34 },
  13616. * { 'user': 'fred', 'age': 40 },
  13617. * { 'user': 'barney', 'age': 36 }
  13618. * ];
  13619. *
  13620. * // Sort by `user` in ascending order and by `age` in descending order.
  13621. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  13622. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  13623. */
  13624. function orderBy(collection, iteratees, orders, guard) {
  13625. if (collection == null) {
  13626. return [];
  13627. }
  13628. if (!isArray(iteratees)) {
  13629. iteratees = iteratees == null ? [] : [iteratees];
  13630. }
  13631. orders = guard ? undefined : orders;
  13632. if (!isArray(orders)) {
  13633. orders = orders == null ? [] : [orders];
  13634. }
  13635. return baseOrderBy(collection, iteratees, orders);
  13636. }
  13637. /**
  13638. * Creates an array of elements split into two groups, the first of which
  13639. * contains elements `predicate` returns truthy for, the second of which
  13640. * contains elements `predicate` returns falsey for. The predicate is
  13641. * invoked with one argument: (value).
  13642. *
  13643. * @static
  13644. * @memberOf _
  13645. * @since 3.0.0
  13646. * @category Collection
  13647. * @param {Array|Object} collection The collection to iterate over.
  13648. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13649. * @returns {Array} Returns the array of grouped elements.
  13650. * @example
  13651. *
  13652. * var users = [
  13653. * { 'user': 'barney', 'age': 36, 'active': false },
  13654. * { 'user': 'fred', 'age': 40, 'active': true },
  13655. * { 'user': 'pebbles', 'age': 1, 'active': false }
  13656. * ];
  13657. *
  13658. * _.partition(users, function(o) { return o.active; });
  13659. * // => objects for [['fred'], ['barney', 'pebbles']]
  13660. *
  13661. * // The `_.matches` iteratee shorthand.
  13662. * _.partition(users, { 'age': 1, 'active': false });
  13663. * // => objects for [['pebbles'], ['barney', 'fred']]
  13664. *
  13665. * // The `_.matchesProperty` iteratee shorthand.
  13666. * _.partition(users, ['active', false]);
  13667. * // => objects for [['barney', 'pebbles'], ['fred']]
  13668. *
  13669. * // The `_.property` iteratee shorthand.
  13670. * _.partition(users, 'active');
  13671. * // => objects for [['fred'], ['barney', 'pebbles']]
  13672. */
  13673. var partition = createAggregator(function(result, value, key) {
  13674. result[key ? 0 : 1].push(value);
  13675. }, function() { return [[], []]; });
  13676. /**
  13677. * Reduces `collection` to a value which is the accumulated result of running
  13678. * each element in `collection` thru `iteratee`, where each successive
  13679. * invocation is supplied the return value of the previous. If `accumulator`
  13680. * is not given, the first element of `collection` is used as the initial
  13681. * value. The iteratee is invoked with four arguments:
  13682. * (accumulator, value, index|key, collection).
  13683. *
  13684. * Many lodash methods are guarded to work as iteratees for methods like
  13685. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  13686. *
  13687. * The guarded methods are:
  13688. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  13689. * and `sortBy`
  13690. *
  13691. * @static
  13692. * @memberOf _
  13693. * @since 0.1.0
  13694. * @category Collection
  13695. * @param {Array|Object} collection The collection to iterate over.
  13696. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13697. * @param {*} [accumulator] The initial value.
  13698. * @returns {*} Returns the accumulated value.
  13699. * @see _.reduceRight
  13700. * @example
  13701. *
  13702. * _.reduce([1, 2], function(sum, n) {
  13703. * return sum + n;
  13704. * }, 0);
  13705. * // => 3
  13706. *
  13707. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  13708. * (result[value] || (result[value] = [])).push(key);
  13709. * return result;
  13710. * }, {});
  13711. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  13712. */
  13713. function reduce(collection, iteratee, accumulator) {
  13714. var func = isArray(collection) ? arrayReduce : baseReduce,
  13715. initAccum = arguments.length < 3;
  13716. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  13717. }
  13718. /**
  13719. * This method is like `_.reduce` except that it iterates over elements of
  13720. * `collection` from right to left.
  13721. *
  13722. * @static
  13723. * @memberOf _
  13724. * @since 0.1.0
  13725. * @category Collection
  13726. * @param {Array|Object} collection The collection to iterate over.
  13727. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13728. * @param {*} [accumulator] The initial value.
  13729. * @returns {*} Returns the accumulated value.
  13730. * @see _.reduce
  13731. * @example
  13732. *
  13733. * var array = [[0, 1], [2, 3], [4, 5]];
  13734. *
  13735. * _.reduceRight(array, function(flattened, other) {
  13736. * return flattened.concat(other);
  13737. * }, []);
  13738. * // => [4, 5, 2, 3, 0, 1]
  13739. */
  13740. function reduceRight(collection, iteratee, accumulator) {
  13741. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  13742. initAccum = arguments.length < 3;
  13743. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  13744. }
  13745. /**
  13746. * The opposite of `_.filter`; this method returns the elements of `collection`
  13747. * that `predicate` does **not** return truthy for.
  13748. *
  13749. * @static
  13750. * @memberOf _
  13751. * @since 0.1.0
  13752. * @category Collection
  13753. * @param {Array|Object} collection The collection to iterate over.
  13754. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13755. * @returns {Array} Returns the new filtered array.
  13756. * @see _.filter
  13757. * @example
  13758. *
  13759. * var users = [
  13760. * { 'user': 'barney', 'age': 36, 'active': false },
  13761. * { 'user': 'fred', 'age': 40, 'active': true }
  13762. * ];
  13763. *
  13764. * _.reject(users, function(o) { return !o.active; });
  13765. * // => objects for ['fred']
  13766. *
  13767. * // The `_.matches` iteratee shorthand.
  13768. * _.reject(users, { 'age': 40, 'active': true });
  13769. * // => objects for ['barney']
  13770. *
  13771. * // The `_.matchesProperty` iteratee shorthand.
  13772. * _.reject(users, ['active', false]);
  13773. * // => objects for ['fred']
  13774. *
  13775. * // The `_.property` iteratee shorthand.
  13776. * _.reject(users, 'active');
  13777. * // => objects for ['barney']
  13778. */
  13779. function reject(collection, predicate) {
  13780. var func = isArray(collection) ? arrayFilter : baseFilter;
  13781. return func(collection, negate(getIteratee(predicate, 3)));
  13782. }
  13783. /**
  13784. * Gets a random element from `collection`.
  13785. *
  13786. * @static
  13787. * @memberOf _
  13788. * @since 2.0.0
  13789. * @category Collection
  13790. * @param {Array|Object} collection The collection to sample.
  13791. * @returns {*} Returns the random element.
  13792. * @example
  13793. *
  13794. * _.sample([1, 2, 3, 4]);
  13795. * // => 2
  13796. */
  13797. function sample(collection) {
  13798. var func = isArray(collection) ? arraySample : baseSample;
  13799. return func(collection);
  13800. }
  13801. /**
  13802. * Gets `n` random elements at unique keys from `collection` up to the
  13803. * size of `collection`.
  13804. *
  13805. * @static
  13806. * @memberOf _
  13807. * @since 4.0.0
  13808. * @category Collection
  13809. * @param {Array|Object} collection The collection to sample.
  13810. * @param {number} [n=1] The number of elements to sample.
  13811. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13812. * @returns {Array} Returns the random elements.
  13813. * @example
  13814. *
  13815. * _.sampleSize([1, 2, 3], 2);
  13816. * // => [3, 1]
  13817. *
  13818. * _.sampleSize([1, 2, 3], 4);
  13819. * // => [2, 3, 1]
  13820. */
  13821. function sampleSize(collection, n, guard) {
  13822. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  13823. n = 1;
  13824. } else {
  13825. n = toInteger(n);
  13826. }
  13827. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  13828. return func(collection, n);
  13829. }
  13830. /**
  13831. * Creates an array of shuffled values, using a version of the
  13832. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  13833. *
  13834. * @static
  13835. * @memberOf _
  13836. * @since 0.1.0
  13837. * @category Collection
  13838. * @param {Array|Object} collection The collection to shuffle.
  13839. * @returns {Array} Returns the new shuffled array.
  13840. * @example
  13841. *
  13842. * _.shuffle([1, 2, 3, 4]);
  13843. * // => [4, 1, 3, 2]
  13844. */
  13845. function shuffle(collection) {
  13846. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  13847. return func(collection);
  13848. }
  13849. /**
  13850. * Gets the size of `collection` by returning its length for array-like
  13851. * values or the number of own enumerable string keyed properties for objects.
  13852. *
  13853. * @static
  13854. * @memberOf _
  13855. * @since 0.1.0
  13856. * @category Collection
  13857. * @param {Array|Object|string} collection The collection to inspect.
  13858. * @returns {number} Returns the collection size.
  13859. * @example
  13860. *
  13861. * _.size([1, 2, 3]);
  13862. * // => 3
  13863. *
  13864. * _.size({ 'a': 1, 'b': 2 });
  13865. * // => 2
  13866. *
  13867. * _.size('pebbles');
  13868. * // => 7
  13869. */
  13870. function size(collection) {
  13871. if (collection == null) {
  13872. return 0;
  13873. }
  13874. if (isArrayLike(collection)) {
  13875. return isString(collection) ? stringSize(collection) : collection.length;
  13876. }
  13877. var tag = getTag(collection);
  13878. if (tag == mapTag || tag == setTag) {
  13879. return collection.size;
  13880. }
  13881. return baseKeys(collection).length;
  13882. }
  13883. /**
  13884. * Checks if `predicate` returns truthy for **any** element of `collection`.
  13885. * Iteration is stopped once `predicate` returns truthy. The predicate is
  13886. * invoked with three arguments: (value, index|key, collection).
  13887. *
  13888. * @static
  13889. * @memberOf _
  13890. * @since 0.1.0
  13891. * @category Collection
  13892. * @param {Array|Object} collection The collection to iterate over.
  13893. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13894. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13895. * @returns {boolean} Returns `true` if any element passes the predicate check,
  13896. * else `false`.
  13897. * @example
  13898. *
  13899. * _.some([null, 0, 'yes', false], Boolean);
  13900. * // => true
  13901. *
  13902. * var users = [
  13903. * { 'user': 'barney', 'active': true },
  13904. * { 'user': 'fred', 'active': false }
  13905. * ];
  13906. *
  13907. * // The `_.matches` iteratee shorthand.
  13908. * _.some(users, { 'user': 'barney', 'active': false });
  13909. * // => false
  13910. *
  13911. * // The `_.matchesProperty` iteratee shorthand.
  13912. * _.some(users, ['active', false]);
  13913. * // => true
  13914. *
  13915. * // The `_.property` iteratee shorthand.
  13916. * _.some(users, 'active');
  13917. * // => true
  13918. */
  13919. function some(collection, predicate, guard) {
  13920. var func = isArray(collection) ? arraySome : baseSome;
  13921. if (guard && isIterateeCall(collection, predicate, guard)) {
  13922. predicate = undefined;
  13923. }
  13924. return func(collection, getIteratee(predicate, 3));
  13925. }
  13926. /**
  13927. * Creates an array of elements, sorted in ascending order by the results of
  13928. * running each element in a collection thru each iteratee. This method
  13929. * performs a stable sort, that is, it preserves the original sort order of
  13930. * equal elements. The iteratees are invoked with one argument: (value).
  13931. *
  13932. * @static
  13933. * @memberOf _
  13934. * @since 0.1.0
  13935. * @category Collection
  13936. * @param {Array|Object} collection The collection to iterate over.
  13937. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  13938. * The iteratees to sort by.
  13939. * @returns {Array} Returns the new sorted array.
  13940. * @example
  13941. *
  13942. * var users = [
  13943. * { 'user': 'fred', 'age': 48 },
  13944. * { 'user': 'barney', 'age': 36 },
  13945. * { 'user': 'fred', 'age': 30 },
  13946. * { 'user': 'barney', 'age': 34 }
  13947. * ];
  13948. *
  13949. * _.sortBy(users, [function(o) { return o.user; }]);
  13950. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  13951. *
  13952. * _.sortBy(users, ['user', 'age']);
  13953. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  13954. */
  13955. var sortBy = baseRest(function(collection, iteratees) {
  13956. if (collection == null) {
  13957. return [];
  13958. }
  13959. var length = iteratees.length;
  13960. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  13961. iteratees = [];
  13962. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  13963. iteratees = [iteratees[0]];
  13964. }
  13965. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  13966. });
  13967. /*------------------------------------------------------------------------*/
  13968. /**
  13969. * Gets the timestamp of the number of milliseconds that have elapsed since
  13970. * the Unix epoch (1 January 1970 00:00:00 UTC).
  13971. *
  13972. * @static
  13973. * @memberOf _
  13974. * @since 2.4.0
  13975. * @category Date
  13976. * @returns {number} Returns the timestamp.
  13977. * @example
  13978. *
  13979. * _.defer(function(stamp) {
  13980. * console.log(_.now() - stamp);
  13981. * }, _.now());
  13982. * // => Logs the number of milliseconds it took for the deferred invocation.
  13983. */
  13984. var now = ctxNow || function() {
  13985. return root.Date.now();
  13986. };
  13987. /*------------------------------------------------------------------------*/
  13988. /**
  13989. * The opposite of `_.before`; this method creates a function that invokes
  13990. * `func` once it's called `n` or more times.
  13991. *
  13992. * @static
  13993. * @memberOf _
  13994. * @since 0.1.0
  13995. * @category Function
  13996. * @param {number} n The number of calls before `func` is invoked.
  13997. * @param {Function} func The function to restrict.
  13998. * @returns {Function} Returns the new restricted function.
  13999. * @example
  14000. *
  14001. * var saves = ['profile', 'settings'];
  14002. *
  14003. * var done = _.after(saves.length, function() {
  14004. * console.log('done saving!');
  14005. * });
  14006. *
  14007. * _.forEach(saves, function(type) {
  14008. * asyncSave({ 'type': type, 'complete': done });
  14009. * });
  14010. * // => Logs 'done saving!' after the two async saves have completed.
  14011. */
  14012. function after(n, func) {
  14013. if (typeof func != 'function') {
  14014. throw new TypeError(FUNC_ERROR_TEXT);
  14015. }
  14016. n = toInteger(n);
  14017. return function() {
  14018. if (--n < 1) {
  14019. return func.apply(this, arguments);
  14020. }
  14021. };
  14022. }
  14023. /**
  14024. * Creates a function that invokes `func`, with up to `n` arguments,
  14025. * ignoring any additional arguments.
  14026. *
  14027. * @static
  14028. * @memberOf _
  14029. * @since 3.0.0
  14030. * @category Function
  14031. * @param {Function} func The function to cap arguments for.
  14032. * @param {number} [n=func.length] The arity cap.
  14033. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14034. * @returns {Function} Returns the new capped function.
  14035. * @example
  14036. *
  14037. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  14038. * // => [6, 8, 10]
  14039. */
  14040. function ary(func, n, guard) {
  14041. n = guard ? undefined : n;
  14042. n = (func && n == null) ? func.length : n;
  14043. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  14044. }
  14045. /**
  14046. * Creates a function that invokes `func`, with the `this` binding and arguments
  14047. * of the created function, while it's called less than `n` times. Subsequent
  14048. * calls to the created function return the result of the last `func` invocation.
  14049. *
  14050. * @static
  14051. * @memberOf _
  14052. * @since 3.0.0
  14053. * @category Function
  14054. * @param {number} n The number of calls at which `func` is no longer invoked.
  14055. * @param {Function} func The function to restrict.
  14056. * @returns {Function} Returns the new restricted function.
  14057. * @example
  14058. *
  14059. * jQuery(element).on('click', _.before(5, addContactToList));
  14060. * // => Allows adding up to 4 contacts to the list.
  14061. */
  14062. function before(n, func) {
  14063. var result;
  14064. if (typeof func != 'function') {
  14065. throw new TypeError(FUNC_ERROR_TEXT);
  14066. }
  14067. n = toInteger(n);
  14068. return function() {
  14069. if (--n > 0) {
  14070. result = func.apply(this, arguments);
  14071. }
  14072. if (n <= 1) {
  14073. func = undefined;
  14074. }
  14075. return result;
  14076. };
  14077. }
  14078. /**
  14079. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  14080. * and `partials` prepended to the arguments it receives.
  14081. *
  14082. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  14083. * may be used as a placeholder for partially applied arguments.
  14084. *
  14085. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  14086. * property of bound functions.
  14087. *
  14088. * @static
  14089. * @memberOf _
  14090. * @since 0.1.0
  14091. * @category Function
  14092. * @param {Function} func The function to bind.
  14093. * @param {*} thisArg The `this` binding of `func`.
  14094. * @param {...*} [partials] The arguments to be partially applied.
  14095. * @returns {Function} Returns the new bound function.
  14096. * @example
  14097. *
  14098. * function greet(greeting, punctuation) {
  14099. * return greeting + ' ' + this.user + punctuation;
  14100. * }
  14101. *
  14102. * var object = { 'user': 'fred' };
  14103. *
  14104. * var bound = _.bind(greet, object, 'hi');
  14105. * bound('!');
  14106. * // => 'hi fred!'
  14107. *
  14108. * // Bound with placeholders.
  14109. * var bound = _.bind(greet, object, _, '!');
  14110. * bound('hi');
  14111. * // => 'hi fred!'
  14112. */
  14113. var bind = baseRest(function(func, thisArg, partials) {
  14114. var bitmask = WRAP_BIND_FLAG;
  14115. if (partials.length) {
  14116. var holders = replaceHolders(partials, getHolder(bind));
  14117. bitmask |= WRAP_PARTIAL_FLAG;
  14118. }
  14119. return createWrap(func, bitmask, thisArg, partials, holders);
  14120. });
  14121. /**
  14122. * Creates a function that invokes the method at `object[key]` with `partials`
  14123. * prepended to the arguments it receives.
  14124. *
  14125. * This method differs from `_.bind` by allowing bound functions to reference
  14126. * methods that may be redefined or don't yet exist. See
  14127. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  14128. * for more details.
  14129. *
  14130. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  14131. * builds, may be used as a placeholder for partially applied arguments.
  14132. *
  14133. * @static
  14134. * @memberOf _
  14135. * @since 0.10.0
  14136. * @category Function
  14137. * @param {Object} object The object to invoke the method on.
  14138. * @param {string} key The key of the method.
  14139. * @param {...*} [partials] The arguments to be partially applied.
  14140. * @returns {Function} Returns the new bound function.
  14141. * @example
  14142. *
  14143. * var object = {
  14144. * 'user': 'fred',
  14145. * 'greet': function(greeting, punctuation) {
  14146. * return greeting + ' ' + this.user + punctuation;
  14147. * }
  14148. * };
  14149. *
  14150. * var bound = _.bindKey(object, 'greet', 'hi');
  14151. * bound('!');
  14152. * // => 'hi fred!'
  14153. *
  14154. * object.greet = function(greeting, punctuation) {
  14155. * return greeting + 'ya ' + this.user + punctuation;
  14156. * };
  14157. *
  14158. * bound('!');
  14159. * // => 'hiya fred!'
  14160. *
  14161. * // Bound with placeholders.
  14162. * var bound = _.bindKey(object, 'greet', _, '!');
  14163. * bound('hi');
  14164. * // => 'hiya fred!'
  14165. */
  14166. var bindKey = baseRest(function(object, key, partials) {
  14167. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  14168. if (partials.length) {
  14169. var holders = replaceHolders(partials, getHolder(bindKey));
  14170. bitmask |= WRAP_PARTIAL_FLAG;
  14171. }
  14172. return createWrap(key, bitmask, object, partials, holders);
  14173. });
  14174. /**
  14175. * Creates a function that accepts arguments of `func` and either invokes
  14176. * `func` returning its result, if at least `arity` number of arguments have
  14177. * been provided, or returns a function that accepts the remaining `func`
  14178. * arguments, and so on. The arity of `func` may be specified if `func.length`
  14179. * is not sufficient.
  14180. *
  14181. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  14182. * may be used as a placeholder for provided arguments.
  14183. *
  14184. * **Note:** This method doesn't set the "length" property of curried functions.
  14185. *
  14186. * @static
  14187. * @memberOf _
  14188. * @since 2.0.0
  14189. * @category Function
  14190. * @param {Function} func The function to curry.
  14191. * @param {number} [arity=func.length] The arity of `func`.
  14192. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14193. * @returns {Function} Returns the new curried function.
  14194. * @example
  14195. *
  14196. * var abc = function(a, b, c) {
  14197. * return [a, b, c];
  14198. * };
  14199. *
  14200. * var curried = _.curry(abc);
  14201. *
  14202. * curried(1)(2)(3);
  14203. * // => [1, 2, 3]
  14204. *
  14205. * curried(1, 2)(3);
  14206. * // => [1, 2, 3]
  14207. *
  14208. * curried(1, 2, 3);
  14209. * // => [1, 2, 3]
  14210. *
  14211. * // Curried with placeholders.
  14212. * curried(1)(_, 3)(2);
  14213. * // => [1, 2, 3]
  14214. */
  14215. function curry(func, arity, guard) {
  14216. arity = guard ? undefined : arity;
  14217. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  14218. result.placeholder = curry.placeholder;
  14219. return result;
  14220. }
  14221. /**
  14222. * This method is like `_.curry` except that arguments are applied to `func`
  14223. * in the manner of `_.partialRight` instead of `_.partial`.
  14224. *
  14225. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  14226. * builds, may be used as a placeholder for provided arguments.
  14227. *
  14228. * **Note:** This method doesn't set the "length" property of curried functions.
  14229. *
  14230. * @static
  14231. * @memberOf _
  14232. * @since 3.0.0
  14233. * @category Function
  14234. * @param {Function} func The function to curry.
  14235. * @param {number} [arity=func.length] The arity of `func`.
  14236. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14237. * @returns {Function} Returns the new curried function.
  14238. * @example
  14239. *
  14240. * var abc = function(a, b, c) {
  14241. * return [a, b, c];
  14242. * };
  14243. *
  14244. * var curried = _.curryRight(abc);
  14245. *
  14246. * curried(3)(2)(1);
  14247. * // => [1, 2, 3]
  14248. *
  14249. * curried(2, 3)(1);
  14250. * // => [1, 2, 3]
  14251. *
  14252. * curried(1, 2, 3);
  14253. * // => [1, 2, 3]
  14254. *
  14255. * // Curried with placeholders.
  14256. * curried(3)(1, _)(2);
  14257. * // => [1, 2, 3]
  14258. */
  14259. function curryRight(func, arity, guard) {
  14260. arity = guard ? undefined : arity;
  14261. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  14262. result.placeholder = curryRight.placeholder;
  14263. return result;
  14264. }
  14265. /**
  14266. * Creates a debounced function that delays invoking `func` until after `wait`
  14267. * milliseconds have elapsed since the last time the debounced function was
  14268. * invoked. The debounced function comes with a `cancel` method to cancel
  14269. * delayed `func` invocations and a `flush` method to immediately invoke them.
  14270. * Provide `options` to indicate whether `func` should be invoked on the
  14271. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  14272. * with the last arguments provided to the debounced function. Subsequent
  14273. * calls to the debounced function return the result of the last `func`
  14274. * invocation.
  14275. *
  14276. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  14277. * invoked on the trailing edge of the timeout only if the debounced function
  14278. * is invoked more than once during the `wait` timeout.
  14279. *
  14280. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  14281. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  14282. *
  14283. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  14284. * for details over the differences between `_.debounce` and `_.throttle`.
  14285. *
  14286. * @static
  14287. * @memberOf _
  14288. * @since 0.1.0
  14289. * @category Function
  14290. * @param {Function} func The function to debounce.
  14291. * @param {number} [wait=0] The number of milliseconds to delay.
  14292. * @param {Object} [options={}] The options object.
  14293. * @param {boolean} [options.leading=false]
  14294. * Specify invoking on the leading edge of the timeout.
  14295. * @param {number} [options.maxWait]
  14296. * The maximum time `func` is allowed to be delayed before it's invoked.
  14297. * @param {boolean} [options.trailing=true]
  14298. * Specify invoking on the trailing edge of the timeout.
  14299. * @returns {Function} Returns the new debounced function.
  14300. * @example
  14301. *
  14302. * // Avoid costly calculations while the window size is in flux.
  14303. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  14304. *
  14305. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  14306. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  14307. * 'leading': true,
  14308. * 'trailing': false
  14309. * }));
  14310. *
  14311. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  14312. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  14313. * var source = new EventSource('/stream');
  14314. * jQuery(source).on('message', debounced);
  14315. *
  14316. * // Cancel the trailing debounced invocation.
  14317. * jQuery(window).on('popstate', debounced.cancel);
  14318. */
  14319. function debounce(func, wait, options) {
  14320. var lastArgs,
  14321. lastThis,
  14322. maxWait,
  14323. result,
  14324. timerId,
  14325. lastCallTime,
  14326. lastInvokeTime = 0,
  14327. leading = false,
  14328. maxing = false,
  14329. trailing = true;
  14330. if (typeof func != 'function') {
  14331. throw new TypeError(FUNC_ERROR_TEXT);
  14332. }
  14333. wait = toNumber(wait) || 0;
  14334. if (isObject(options)) {
  14335. leading = !!options.leading;
  14336. maxing = 'maxWait' in options;
  14337. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  14338. trailing = 'trailing' in options ? !!options.trailing : trailing;
  14339. }
  14340. function invokeFunc(time) {
  14341. var args = lastArgs,
  14342. thisArg = lastThis;
  14343. lastArgs = lastThis = undefined;
  14344. lastInvokeTime = time;
  14345. result = func.apply(thisArg, args);
  14346. return result;
  14347. }
  14348. function leadingEdge(time) {
  14349. // Reset any `maxWait` timer.
  14350. lastInvokeTime = time;
  14351. // Start the timer for the trailing edge.
  14352. timerId = setTimeout(timerExpired, wait);
  14353. // Invoke the leading edge.
  14354. return leading ? invokeFunc(time) : result;
  14355. }
  14356. function remainingWait(time) {
  14357. var timeSinceLastCall = time - lastCallTime,
  14358. timeSinceLastInvoke = time - lastInvokeTime,
  14359. timeWaiting = wait - timeSinceLastCall;
  14360. return maxing
  14361. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  14362. : timeWaiting;
  14363. }
  14364. function shouldInvoke(time) {
  14365. var timeSinceLastCall = time - lastCallTime,
  14366. timeSinceLastInvoke = time - lastInvokeTime;
  14367. // Either this is the first call, activity has stopped and we're at the
  14368. // trailing edge, the system time has gone backwards and we're treating
  14369. // it as the trailing edge, or we've hit the `maxWait` limit.
  14370. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  14371. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  14372. }
  14373. function timerExpired() {
  14374. var time = now();
  14375. if (shouldInvoke(time)) {
  14376. return trailingEdge(time);
  14377. }
  14378. // Restart the timer.
  14379. timerId = setTimeout(timerExpired, remainingWait(time));
  14380. }
  14381. function trailingEdge(time) {
  14382. timerId = undefined;
  14383. // Only invoke if we have `lastArgs` which means `func` has been
  14384. // debounced at least once.
  14385. if (trailing && lastArgs) {
  14386. return invokeFunc(time);
  14387. }
  14388. lastArgs = lastThis = undefined;
  14389. return result;
  14390. }
  14391. function cancel() {
  14392. if (timerId !== undefined) {
  14393. clearTimeout(timerId);
  14394. }
  14395. lastInvokeTime = 0;
  14396. lastArgs = lastCallTime = lastThis = timerId = undefined;
  14397. }
  14398. function flush() {
  14399. return timerId === undefined ? result : trailingEdge(now());
  14400. }
  14401. function debounced() {
  14402. var time = now(),
  14403. isInvoking = shouldInvoke(time);
  14404. lastArgs = arguments;
  14405. lastThis = this;
  14406. lastCallTime = time;
  14407. if (isInvoking) {
  14408. if (timerId === undefined) {
  14409. return leadingEdge(lastCallTime);
  14410. }
  14411. if (maxing) {
  14412. // Handle invocations in a tight loop.
  14413. clearTimeout(timerId);
  14414. timerId = setTimeout(timerExpired, wait);
  14415. return invokeFunc(lastCallTime);
  14416. }
  14417. }
  14418. if (timerId === undefined) {
  14419. timerId = setTimeout(timerExpired, wait);
  14420. }
  14421. return result;
  14422. }
  14423. debounced.cancel = cancel;
  14424. debounced.flush = flush;
  14425. return debounced;
  14426. }
  14427. /**
  14428. * Defers invoking the `func` until the current call stack has cleared. Any
  14429. * additional arguments are provided to `func` when it's invoked.
  14430. *
  14431. * @static
  14432. * @memberOf _
  14433. * @since 0.1.0
  14434. * @category Function
  14435. * @param {Function} func The function to defer.
  14436. * @param {...*} [args] The arguments to invoke `func` with.
  14437. * @returns {number} Returns the timer id.
  14438. * @example
  14439. *
  14440. * _.defer(function(text) {
  14441. * console.log(text);
  14442. * }, 'deferred');
  14443. * // => Logs 'deferred' after one millisecond.
  14444. */
  14445. var defer = baseRest(function(func, args) {
  14446. return baseDelay(func, 1, args);
  14447. });
  14448. /**
  14449. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  14450. * provided to `func` when it's invoked.
  14451. *
  14452. * @static
  14453. * @memberOf _
  14454. * @since 0.1.0
  14455. * @category Function
  14456. * @param {Function} func The function to delay.
  14457. * @param {number} wait The number of milliseconds to delay invocation.
  14458. * @param {...*} [args] The arguments to invoke `func` with.
  14459. * @returns {number} Returns the timer id.
  14460. * @example
  14461. *
  14462. * _.delay(function(text) {
  14463. * console.log(text);
  14464. * }, 1000, 'later');
  14465. * // => Logs 'later' after one second.
  14466. */
  14467. var delay = baseRest(function(func, wait, args) {
  14468. return baseDelay(func, toNumber(wait) || 0, args);
  14469. });
  14470. /**
  14471. * Creates a function that invokes `func` with arguments reversed.
  14472. *
  14473. * @static
  14474. * @memberOf _
  14475. * @since 4.0.0
  14476. * @category Function
  14477. * @param {Function} func The function to flip arguments for.
  14478. * @returns {Function} Returns the new flipped function.
  14479. * @example
  14480. *
  14481. * var flipped = _.flip(function() {
  14482. * return _.toArray(arguments);
  14483. * });
  14484. *
  14485. * flipped('a', 'b', 'c', 'd');
  14486. * // => ['d', 'c', 'b', 'a']
  14487. */
  14488. function flip(func) {
  14489. return createWrap(func, WRAP_FLIP_FLAG);
  14490. }
  14491. /**
  14492. * Creates a function that memoizes the result of `func`. If `resolver` is
  14493. * provided, it determines the cache key for storing the result based on the
  14494. * arguments provided to the memoized function. By default, the first argument
  14495. * provided to the memoized function is used as the map cache key. The `func`
  14496. * is invoked with the `this` binding of the memoized function.
  14497. *
  14498. * **Note:** The cache is exposed as the `cache` property on the memoized
  14499. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  14500. * constructor with one whose instances implement the
  14501. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  14502. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  14503. *
  14504. * @static
  14505. * @memberOf _
  14506. * @since 0.1.0
  14507. * @category Function
  14508. * @param {Function} func The function to have its output memoized.
  14509. * @param {Function} [resolver] The function to resolve the cache key.
  14510. * @returns {Function} Returns the new memoized function.
  14511. * @example
  14512. *
  14513. * var object = { 'a': 1, 'b': 2 };
  14514. * var other = { 'c': 3, 'd': 4 };
  14515. *
  14516. * var values = _.memoize(_.values);
  14517. * values(object);
  14518. * // => [1, 2]
  14519. *
  14520. * values(other);
  14521. * // => [3, 4]
  14522. *
  14523. * object.a = 2;
  14524. * values(object);
  14525. * // => [1, 2]
  14526. *
  14527. * // Modify the result cache.
  14528. * values.cache.set(object, ['a', 'b']);
  14529. * values(object);
  14530. * // => ['a', 'b']
  14531. *
  14532. * // Replace `_.memoize.Cache`.
  14533. * _.memoize.Cache = WeakMap;
  14534. */
  14535. function memoize(func, resolver) {
  14536. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  14537. throw new TypeError(FUNC_ERROR_TEXT);
  14538. }
  14539. var memoized = function() {
  14540. var args = arguments,
  14541. key = resolver ? resolver.apply(this, args) : args[0],
  14542. cache = memoized.cache;
  14543. if (cache.has(key)) {
  14544. return cache.get(key);
  14545. }
  14546. var result = func.apply(this, args);
  14547. memoized.cache = cache.set(key, result) || cache;
  14548. return result;
  14549. };
  14550. memoized.cache = new (memoize.Cache || MapCache);
  14551. return memoized;
  14552. }
  14553. // Expose `MapCache`.
  14554. memoize.Cache = MapCache;
  14555. /**
  14556. * Creates a function that negates the result of the predicate `func`. The
  14557. * `func` predicate is invoked with the `this` binding and arguments of the
  14558. * created function.
  14559. *
  14560. * @static
  14561. * @memberOf _
  14562. * @since 3.0.0
  14563. * @category Function
  14564. * @param {Function} predicate The predicate to negate.
  14565. * @returns {Function} Returns the new negated function.
  14566. * @example
  14567. *
  14568. * function isEven(n) {
  14569. * return n % 2 == 0;
  14570. * }
  14571. *
  14572. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  14573. * // => [1, 3, 5]
  14574. */
  14575. function negate(predicate) {
  14576. if (typeof predicate != 'function') {
  14577. throw new TypeError(FUNC_ERROR_TEXT);
  14578. }
  14579. return function() {
  14580. var args = arguments;
  14581. switch (args.length) {
  14582. case 0: return !predicate.call(this);
  14583. case 1: return !predicate.call(this, args[0]);
  14584. case 2: return !predicate.call(this, args[0], args[1]);
  14585. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  14586. }
  14587. return !predicate.apply(this, args);
  14588. };
  14589. }
  14590. /**
  14591. * Creates a function that is restricted to invoking `func` once. Repeat calls
  14592. * to the function return the value of the first invocation. The `func` is
  14593. * invoked with the `this` binding and arguments of the created function.
  14594. *
  14595. * @static
  14596. * @memberOf _
  14597. * @since 0.1.0
  14598. * @category Function
  14599. * @param {Function} func The function to restrict.
  14600. * @returns {Function} Returns the new restricted function.
  14601. * @example
  14602. *
  14603. * var initialize = _.once(createApplication);
  14604. * initialize();
  14605. * initialize();
  14606. * // => `createApplication` is invoked once
  14607. */
  14608. function once(func) {
  14609. return before(2, func);
  14610. }
  14611. /**
  14612. * Creates a function that invokes `func` with its arguments transformed.
  14613. *
  14614. * @static
  14615. * @since 4.0.0
  14616. * @memberOf _
  14617. * @category Function
  14618. * @param {Function} func The function to wrap.
  14619. * @param {...(Function|Function[])} [transforms=[_.identity]]
  14620. * The argument transforms.
  14621. * @returns {Function} Returns the new function.
  14622. * @example
  14623. *
  14624. * function doubled(n) {
  14625. * return n * 2;
  14626. * }
  14627. *
  14628. * function square(n) {
  14629. * return n * n;
  14630. * }
  14631. *
  14632. * var func = _.overArgs(function(x, y) {
  14633. * return [x, y];
  14634. * }, [square, doubled]);
  14635. *
  14636. * func(9, 3);
  14637. * // => [81, 6]
  14638. *
  14639. * func(10, 5);
  14640. * // => [100, 10]
  14641. */
  14642. var overArgs = castRest(function(func, transforms) {
  14643. transforms = (transforms.length == 1 && isArray(transforms[0]))
  14644. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  14645. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  14646. var funcsLength = transforms.length;
  14647. return baseRest(function(args) {
  14648. var index = -1,
  14649. length = nativeMin(args.length, funcsLength);
  14650. while (++index < length) {
  14651. args[index] = transforms[index].call(this, args[index]);
  14652. }
  14653. return apply(func, this, args);
  14654. });
  14655. });
  14656. /**
  14657. * Creates a function that invokes `func` with `partials` prepended to the
  14658. * arguments it receives. This method is like `_.bind` except it does **not**
  14659. * alter the `this` binding.
  14660. *
  14661. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  14662. * builds, may be used as a placeholder for partially applied arguments.
  14663. *
  14664. * **Note:** This method doesn't set the "length" property of partially
  14665. * applied functions.
  14666. *
  14667. * @static
  14668. * @memberOf _
  14669. * @since 0.2.0
  14670. * @category Function
  14671. * @param {Function} func The function to partially apply arguments to.
  14672. * @param {...*} [partials] The arguments to be partially applied.
  14673. * @returns {Function} Returns the new partially applied function.
  14674. * @example
  14675. *
  14676. * function greet(greeting, name) {
  14677. * return greeting + ' ' + name;
  14678. * }
  14679. *
  14680. * var sayHelloTo = _.partial(greet, 'hello');
  14681. * sayHelloTo('fred');
  14682. * // => 'hello fred'
  14683. *
  14684. * // Partially applied with placeholders.
  14685. * var greetFred = _.partial(greet, _, 'fred');
  14686. * greetFred('hi');
  14687. * // => 'hi fred'
  14688. */
  14689. var partial = baseRest(function(func, partials) {
  14690. var holders = replaceHolders(partials, getHolder(partial));
  14691. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  14692. });
  14693. /**
  14694. * This method is like `_.partial` except that partially applied arguments
  14695. * are appended to the arguments it receives.
  14696. *
  14697. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  14698. * builds, may be used as a placeholder for partially applied arguments.
  14699. *
  14700. * **Note:** This method doesn't set the "length" property of partially
  14701. * applied functions.
  14702. *
  14703. * @static
  14704. * @memberOf _
  14705. * @since 1.0.0
  14706. * @category Function
  14707. * @param {Function} func The function to partially apply arguments to.
  14708. * @param {...*} [partials] The arguments to be partially applied.
  14709. * @returns {Function} Returns the new partially applied function.
  14710. * @example
  14711. *
  14712. * function greet(greeting, name) {
  14713. * return greeting + ' ' + name;
  14714. * }
  14715. *
  14716. * var greetFred = _.partialRight(greet, 'fred');
  14717. * greetFred('hi');
  14718. * // => 'hi fred'
  14719. *
  14720. * // Partially applied with placeholders.
  14721. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  14722. * sayHelloTo('fred');
  14723. * // => 'hello fred'
  14724. */
  14725. var partialRight = baseRest(function(func, partials) {
  14726. var holders = replaceHolders(partials, getHolder(partialRight));
  14727. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  14728. });
  14729. /**
  14730. * Creates a function that invokes `func` with arguments arranged according
  14731. * to the specified `indexes` where the argument value at the first index is
  14732. * provided as the first argument, the argument value at the second index is
  14733. * provided as the second argument, and so on.
  14734. *
  14735. * @static
  14736. * @memberOf _
  14737. * @since 3.0.0
  14738. * @category Function
  14739. * @param {Function} func The function to rearrange arguments for.
  14740. * @param {...(number|number[])} indexes The arranged argument indexes.
  14741. * @returns {Function} Returns the new function.
  14742. * @example
  14743. *
  14744. * var rearged = _.rearg(function(a, b, c) {
  14745. * return [a, b, c];
  14746. * }, [2, 0, 1]);
  14747. *
  14748. * rearged('b', 'c', 'a')
  14749. * // => ['a', 'b', 'c']
  14750. */
  14751. var rearg = flatRest(function(func, indexes) {
  14752. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  14753. });
  14754. /**
  14755. * Creates a function that invokes `func` with the `this` binding of the
  14756. * created function and arguments from `start` and beyond provided as
  14757. * an array.
  14758. *
  14759. * **Note:** This method is based on the
  14760. * [rest parameter](https://mdn.io/rest_parameters).
  14761. *
  14762. * @static
  14763. * @memberOf _
  14764. * @since 4.0.0
  14765. * @category Function
  14766. * @param {Function} func The function to apply a rest parameter to.
  14767. * @param {number} [start=func.length-1] The start position of the rest parameter.
  14768. * @returns {Function} Returns the new function.
  14769. * @example
  14770. *
  14771. * var say = _.rest(function(what, names) {
  14772. * return what + ' ' + _.initial(names).join(', ') +
  14773. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  14774. * });
  14775. *
  14776. * say('hello', 'fred', 'barney', 'pebbles');
  14777. * // => 'hello fred, barney, & pebbles'
  14778. */
  14779. function rest(func, start) {
  14780. if (typeof func != 'function') {
  14781. throw new TypeError(FUNC_ERROR_TEXT);
  14782. }
  14783. start = start === undefined ? start : toInteger(start);
  14784. return baseRest(func, start);
  14785. }
  14786. /**
  14787. * Creates a function that invokes `func` with the `this` binding of the
  14788. * create function and an array of arguments much like
  14789. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  14790. *
  14791. * **Note:** This method is based on the
  14792. * [spread operator](https://mdn.io/spread_operator).
  14793. *
  14794. * @static
  14795. * @memberOf _
  14796. * @since 3.2.0
  14797. * @category Function
  14798. * @param {Function} func The function to spread arguments over.
  14799. * @param {number} [start=0] The start position of the spread.
  14800. * @returns {Function} Returns the new function.
  14801. * @example
  14802. *
  14803. * var say = _.spread(function(who, what) {
  14804. * return who + ' says ' + what;
  14805. * });
  14806. *
  14807. * say(['fred', 'hello']);
  14808. * // => 'fred says hello'
  14809. *
  14810. * var numbers = Promise.all([
  14811. * Promise.resolve(40),
  14812. * Promise.resolve(36)
  14813. * ]);
  14814. *
  14815. * numbers.then(_.spread(function(x, y) {
  14816. * return x + y;
  14817. * }));
  14818. * // => a Promise of 76
  14819. */
  14820. function spread(func, start) {
  14821. if (typeof func != 'function') {
  14822. throw new TypeError(FUNC_ERROR_TEXT);
  14823. }
  14824. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  14825. return baseRest(function(args) {
  14826. var array = args[start],
  14827. otherArgs = castSlice(args, 0, start);
  14828. if (array) {
  14829. arrayPush(otherArgs, array);
  14830. }
  14831. return apply(func, this, otherArgs);
  14832. });
  14833. }
  14834. /**
  14835. * Creates a throttled function that only invokes `func` at most once per
  14836. * every `wait` milliseconds. The throttled function comes with a `cancel`
  14837. * method to cancel delayed `func` invocations and a `flush` method to
  14838. * immediately invoke them. Provide `options` to indicate whether `func`
  14839. * should be invoked on the leading and/or trailing edge of the `wait`
  14840. * timeout. The `func` is invoked with the last arguments provided to the
  14841. * throttled function. Subsequent calls to the throttled function return the
  14842. * result of the last `func` invocation.
  14843. *
  14844. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  14845. * invoked on the trailing edge of the timeout only if the throttled function
  14846. * is invoked more than once during the `wait` timeout.
  14847. *
  14848. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  14849. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  14850. *
  14851. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  14852. * for details over the differences between `_.throttle` and `_.debounce`.
  14853. *
  14854. * @static
  14855. * @memberOf _
  14856. * @since 0.1.0
  14857. * @category Function
  14858. * @param {Function} func The function to throttle.
  14859. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  14860. * @param {Object} [options={}] The options object.
  14861. * @param {boolean} [options.leading=true]
  14862. * Specify invoking on the leading edge of the timeout.
  14863. * @param {boolean} [options.trailing=true]
  14864. * Specify invoking on the trailing edge of the timeout.
  14865. * @returns {Function} Returns the new throttled function.
  14866. * @example
  14867. *
  14868. * // Avoid excessively updating the position while scrolling.
  14869. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  14870. *
  14871. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  14872. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  14873. * jQuery(element).on('click', throttled);
  14874. *
  14875. * // Cancel the trailing throttled invocation.
  14876. * jQuery(window).on('popstate', throttled.cancel);
  14877. */
  14878. function throttle(func, wait, options) {
  14879. var leading = true,
  14880. trailing = true;
  14881. if (typeof func != 'function') {
  14882. throw new TypeError(FUNC_ERROR_TEXT);
  14883. }
  14884. if (isObject(options)) {
  14885. leading = 'leading' in options ? !!options.leading : leading;
  14886. trailing = 'trailing' in options ? !!options.trailing : trailing;
  14887. }
  14888. return debounce(func, wait, {
  14889. 'leading': leading,
  14890. 'maxWait': wait,
  14891. 'trailing': trailing
  14892. });
  14893. }
  14894. /**
  14895. * Creates a function that accepts up to one argument, ignoring any
  14896. * additional arguments.
  14897. *
  14898. * @static
  14899. * @memberOf _
  14900. * @since 4.0.0
  14901. * @category Function
  14902. * @param {Function} func The function to cap arguments for.
  14903. * @returns {Function} Returns the new capped function.
  14904. * @example
  14905. *
  14906. * _.map(['6', '8', '10'], _.unary(parseInt));
  14907. * // => [6, 8, 10]
  14908. */
  14909. function unary(func) {
  14910. return ary(func, 1);
  14911. }
  14912. /**
  14913. * Creates a function that provides `value` to `wrapper` as its first
  14914. * argument. Any additional arguments provided to the function are appended
  14915. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  14916. * binding of the created function.
  14917. *
  14918. * @static
  14919. * @memberOf _
  14920. * @since 0.1.0
  14921. * @category Function
  14922. * @param {*} value The value to wrap.
  14923. * @param {Function} [wrapper=identity] The wrapper function.
  14924. * @returns {Function} Returns the new function.
  14925. * @example
  14926. *
  14927. * var p = _.wrap(_.escape, function(func, text) {
  14928. * return '<p>' + func(text) + '</p>';
  14929. * });
  14930. *
  14931. * p('fred, barney, & pebbles');
  14932. * // => '<p>fred, barney, &amp; pebbles</p>'
  14933. */
  14934. function wrap(value, wrapper) {
  14935. return partial(castFunction(wrapper), value);
  14936. }
  14937. /*------------------------------------------------------------------------*/
  14938. /**
  14939. * Casts `value` as an array if it's not one.
  14940. *
  14941. * @static
  14942. * @memberOf _
  14943. * @since 4.4.0
  14944. * @category Lang
  14945. * @param {*} value The value to inspect.
  14946. * @returns {Array} Returns the cast array.
  14947. * @example
  14948. *
  14949. * _.castArray(1);
  14950. * // => [1]
  14951. *
  14952. * _.castArray({ 'a': 1 });
  14953. * // => [{ 'a': 1 }]
  14954. *
  14955. * _.castArray('abc');
  14956. * // => ['abc']
  14957. *
  14958. * _.castArray(null);
  14959. * // => [null]
  14960. *
  14961. * _.castArray(undefined);
  14962. * // => [undefined]
  14963. *
  14964. * _.castArray();
  14965. * // => []
  14966. *
  14967. * var array = [1, 2, 3];
  14968. * console.log(_.castArray(array) === array);
  14969. * // => true
  14970. */
  14971. function castArray() {
  14972. if (!arguments.length) {
  14973. return [];
  14974. }
  14975. var value = arguments[0];
  14976. return isArray(value) ? value : [value];
  14977. }
  14978. /**
  14979. * Creates a shallow clone of `value`.
  14980. *
  14981. * **Note:** This method is loosely based on the
  14982. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  14983. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  14984. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  14985. * arrays. The own enumerable properties of `arguments` objects are cloned
  14986. * as plain objects. An empty object is returned for uncloneable values such
  14987. * as error objects, functions, DOM nodes, and WeakMaps.
  14988. *
  14989. * @static
  14990. * @memberOf _
  14991. * @since 0.1.0
  14992. * @category Lang
  14993. * @param {*} value The value to clone.
  14994. * @returns {*} Returns the cloned value.
  14995. * @see _.cloneDeep
  14996. * @example
  14997. *
  14998. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  14999. *
  15000. * var shallow = _.clone(objects);
  15001. * console.log(shallow[0] === objects[0]);
  15002. * // => true
  15003. */
  15004. function clone(value) {
  15005. return baseClone(value, CLONE_SYMBOLS_FLAG);
  15006. }
  15007. /**
  15008. * This method is like `_.clone` except that it accepts `customizer` which
  15009. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  15010. * cloning is handled by the method instead. The `customizer` is invoked with
  15011. * up to four arguments; (value [, index|key, object, stack]).
  15012. *
  15013. * @static
  15014. * @memberOf _
  15015. * @since 4.0.0
  15016. * @category Lang
  15017. * @param {*} value The value to clone.
  15018. * @param {Function} [customizer] The function to customize cloning.
  15019. * @returns {*} Returns the cloned value.
  15020. * @see _.cloneDeepWith
  15021. * @example
  15022. *
  15023. * function customizer(value) {
  15024. * if (_.isElement(value)) {
  15025. * return value.cloneNode(false);
  15026. * }
  15027. * }
  15028. *
  15029. * var el = _.cloneWith(document.body, customizer);
  15030. *
  15031. * console.log(el === document.body);
  15032. * // => false
  15033. * console.log(el.nodeName);
  15034. * // => 'BODY'
  15035. * console.log(el.childNodes.length);
  15036. * // => 0
  15037. */
  15038. function cloneWith(value, customizer) {
  15039. customizer = typeof customizer == 'function' ? customizer : undefined;
  15040. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  15041. }
  15042. /**
  15043. * This method is like `_.clone` except that it recursively clones `value`.
  15044. *
  15045. * @static
  15046. * @memberOf _
  15047. * @since 1.0.0
  15048. * @category Lang
  15049. * @param {*} value The value to recursively clone.
  15050. * @returns {*} Returns the deep cloned value.
  15051. * @see _.clone
  15052. * @example
  15053. *
  15054. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  15055. *
  15056. * var deep = _.cloneDeep(objects);
  15057. * console.log(deep[0] === objects[0]);
  15058. * // => false
  15059. */
  15060. function cloneDeep(value) {
  15061. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  15062. }
  15063. /**
  15064. * This method is like `_.cloneWith` except that it recursively clones `value`.
  15065. *
  15066. * @static
  15067. * @memberOf _
  15068. * @since 4.0.0
  15069. * @category Lang
  15070. * @param {*} value The value to recursively clone.
  15071. * @param {Function} [customizer] The function to customize cloning.
  15072. * @returns {*} Returns the deep cloned value.
  15073. * @see _.cloneWith
  15074. * @example
  15075. *
  15076. * function customizer(value) {
  15077. * if (_.isElement(value)) {
  15078. * return value.cloneNode(true);
  15079. * }
  15080. * }
  15081. *
  15082. * var el = _.cloneDeepWith(document.body, customizer);
  15083. *
  15084. * console.log(el === document.body);
  15085. * // => false
  15086. * console.log(el.nodeName);
  15087. * // => 'BODY'
  15088. * console.log(el.childNodes.length);
  15089. * // => 20
  15090. */
  15091. function cloneDeepWith(value, customizer) {
  15092. customizer = typeof customizer == 'function' ? customizer : undefined;
  15093. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  15094. }
  15095. /**
  15096. * Checks if `object` conforms to `source` by invoking the predicate
  15097. * properties of `source` with the corresponding property values of `object`.
  15098. *
  15099. * **Note:** This method is equivalent to `_.conforms` when `source` is
  15100. * partially applied.
  15101. *
  15102. * @static
  15103. * @memberOf _
  15104. * @since 4.14.0
  15105. * @category Lang
  15106. * @param {Object} object The object to inspect.
  15107. * @param {Object} source The object of property predicates to conform to.
  15108. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  15109. * @example
  15110. *
  15111. * var object = { 'a': 1, 'b': 2 };
  15112. *
  15113. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  15114. * // => true
  15115. *
  15116. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  15117. * // => false
  15118. */
  15119. function conformsTo(object, source) {
  15120. return source == null || baseConformsTo(object, source, keys(source));
  15121. }
  15122. /**
  15123. * Performs a
  15124. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  15125. * comparison between two values to determine if they are equivalent.
  15126. *
  15127. * @static
  15128. * @memberOf _
  15129. * @since 4.0.0
  15130. * @category Lang
  15131. * @param {*} value The value to compare.
  15132. * @param {*} other The other value to compare.
  15133. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15134. * @example
  15135. *
  15136. * var object = { 'a': 1 };
  15137. * var other = { 'a': 1 };
  15138. *
  15139. * _.eq(object, object);
  15140. * // => true
  15141. *
  15142. * _.eq(object, other);
  15143. * // => false
  15144. *
  15145. * _.eq('a', 'a');
  15146. * // => true
  15147. *
  15148. * _.eq('a', Object('a'));
  15149. * // => false
  15150. *
  15151. * _.eq(NaN, NaN);
  15152. * // => true
  15153. */
  15154. function eq(value, other) {
  15155. return value === other || (value !== value && other !== other);
  15156. }
  15157. /**
  15158. * Checks if `value` is greater than `other`.
  15159. *
  15160. * @static
  15161. * @memberOf _
  15162. * @since 3.9.0
  15163. * @category Lang
  15164. * @param {*} value The value to compare.
  15165. * @param {*} other The other value to compare.
  15166. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  15167. * else `false`.
  15168. * @see _.lt
  15169. * @example
  15170. *
  15171. * _.gt(3, 1);
  15172. * // => true
  15173. *
  15174. * _.gt(3, 3);
  15175. * // => false
  15176. *
  15177. * _.gt(1, 3);
  15178. * // => false
  15179. */
  15180. var gt = createRelationalOperation(baseGt);
  15181. /**
  15182. * Checks if `value` is greater than or equal to `other`.
  15183. *
  15184. * @static
  15185. * @memberOf _
  15186. * @since 3.9.0
  15187. * @category Lang
  15188. * @param {*} value The value to compare.
  15189. * @param {*} other The other value to compare.
  15190. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  15191. * `other`, else `false`.
  15192. * @see _.lte
  15193. * @example
  15194. *
  15195. * _.gte(3, 1);
  15196. * // => true
  15197. *
  15198. * _.gte(3, 3);
  15199. * // => true
  15200. *
  15201. * _.gte(1, 3);
  15202. * // => false
  15203. */
  15204. var gte = createRelationalOperation(function(value, other) {
  15205. return value >= other;
  15206. });
  15207. /**
  15208. * Checks if `value` is likely an `arguments` object.
  15209. *
  15210. * @static
  15211. * @memberOf _
  15212. * @since 0.1.0
  15213. * @category Lang
  15214. * @param {*} value The value to check.
  15215. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  15216. * else `false`.
  15217. * @example
  15218. *
  15219. * _.isArguments(function() { return arguments; }());
  15220. * // => true
  15221. *
  15222. * _.isArguments([1, 2, 3]);
  15223. * // => false
  15224. */
  15225. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  15226. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  15227. !propertyIsEnumerable.call(value, 'callee');
  15228. };
  15229. /**
  15230. * Checks if `value` is classified as an `Array` object.
  15231. *
  15232. * @static
  15233. * @memberOf _
  15234. * @since 0.1.0
  15235. * @category Lang
  15236. * @param {*} value The value to check.
  15237. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  15238. * @example
  15239. *
  15240. * _.isArray([1, 2, 3]);
  15241. * // => true
  15242. *
  15243. * _.isArray(document.body.children);
  15244. * // => false
  15245. *
  15246. * _.isArray('abc');
  15247. * // => false
  15248. *
  15249. * _.isArray(_.noop);
  15250. * // => false
  15251. */
  15252. var isArray = Array.isArray;
  15253. /**
  15254. * Checks if `value` is classified as an `ArrayBuffer` object.
  15255. *
  15256. * @static
  15257. * @memberOf _
  15258. * @since 4.3.0
  15259. * @category Lang
  15260. * @param {*} value The value to check.
  15261. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  15262. * @example
  15263. *
  15264. * _.isArrayBuffer(new ArrayBuffer(2));
  15265. * // => true
  15266. *
  15267. * _.isArrayBuffer(new Array(2));
  15268. * // => false
  15269. */
  15270. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  15271. /**
  15272. * Checks if `value` is array-like. A value is considered array-like if it's
  15273. * not a function and has a `value.length` that's an integer greater than or
  15274. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  15275. *
  15276. * @static
  15277. * @memberOf _
  15278. * @since 4.0.0
  15279. * @category Lang
  15280. * @param {*} value The value to check.
  15281. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  15282. * @example
  15283. *
  15284. * _.isArrayLike([1, 2, 3]);
  15285. * // => true
  15286. *
  15287. * _.isArrayLike(document.body.children);
  15288. * // => true
  15289. *
  15290. * _.isArrayLike('abc');
  15291. * // => true
  15292. *
  15293. * _.isArrayLike(_.noop);
  15294. * // => false
  15295. */
  15296. function isArrayLike(value) {
  15297. return value != null && isLength(value.length) && !isFunction(value);
  15298. }
  15299. /**
  15300. * This method is like `_.isArrayLike` except that it also checks if `value`
  15301. * is an object.
  15302. *
  15303. * @static
  15304. * @memberOf _
  15305. * @since 4.0.0
  15306. * @category Lang
  15307. * @param {*} value The value to check.
  15308. * @returns {boolean} Returns `true` if `value` is an array-like object,
  15309. * else `false`.
  15310. * @example
  15311. *
  15312. * _.isArrayLikeObject([1, 2, 3]);
  15313. * // => true
  15314. *
  15315. * _.isArrayLikeObject(document.body.children);
  15316. * // => true
  15317. *
  15318. * _.isArrayLikeObject('abc');
  15319. * // => false
  15320. *
  15321. * _.isArrayLikeObject(_.noop);
  15322. * // => false
  15323. */
  15324. function isArrayLikeObject(value) {
  15325. return isObjectLike(value) && isArrayLike(value);
  15326. }
  15327. /**
  15328. * Checks if `value` is classified as a boolean primitive or object.
  15329. *
  15330. * @static
  15331. * @memberOf _
  15332. * @since 0.1.0
  15333. * @category Lang
  15334. * @param {*} value The value to check.
  15335. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  15336. * @example
  15337. *
  15338. * _.isBoolean(false);
  15339. * // => true
  15340. *
  15341. * _.isBoolean(null);
  15342. * // => false
  15343. */
  15344. function isBoolean(value) {
  15345. return value === true || value === false ||
  15346. (isObjectLike(value) && baseGetTag(value) == boolTag);
  15347. }
  15348. /**
  15349. * Checks if `value` is a buffer.
  15350. *
  15351. * @static
  15352. * @memberOf _
  15353. * @since 4.3.0
  15354. * @category Lang
  15355. * @param {*} value The value to check.
  15356. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  15357. * @example
  15358. *
  15359. * _.isBuffer(new Buffer(2));
  15360. * // => true
  15361. *
  15362. * _.isBuffer(new Uint8Array(2));
  15363. * // => false
  15364. */
  15365. var isBuffer = nativeIsBuffer || stubFalse;
  15366. /**
  15367. * Checks if `value` is classified as a `Date` object.
  15368. *
  15369. * @static
  15370. * @memberOf _
  15371. * @since 0.1.0
  15372. * @category Lang
  15373. * @param {*} value The value to check.
  15374. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  15375. * @example
  15376. *
  15377. * _.isDate(new Date);
  15378. * // => true
  15379. *
  15380. * _.isDate('Mon April 23 2012');
  15381. * // => false
  15382. */
  15383. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  15384. /**
  15385. * Checks if `value` is likely a DOM element.
  15386. *
  15387. * @static
  15388. * @memberOf _
  15389. * @since 0.1.0
  15390. * @category Lang
  15391. * @param {*} value The value to check.
  15392. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  15393. * @example
  15394. *
  15395. * _.isElement(document.body);
  15396. * // => true
  15397. *
  15398. * _.isElement('<body>');
  15399. * // => false
  15400. */
  15401. function isElement(value) {
  15402. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  15403. }
  15404. /**
  15405. * Checks if `value` is an empty object, collection, map, or set.
  15406. *
  15407. * Objects are considered empty if they have no own enumerable string keyed
  15408. * properties.
  15409. *
  15410. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  15411. * jQuery-like collections are considered empty if they have a `length` of `0`.
  15412. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  15413. *
  15414. * @static
  15415. * @memberOf _
  15416. * @since 0.1.0
  15417. * @category Lang
  15418. * @param {*} value The value to check.
  15419. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  15420. * @example
  15421. *
  15422. * _.isEmpty(null);
  15423. * // => true
  15424. *
  15425. * _.isEmpty(true);
  15426. * // => true
  15427. *
  15428. * _.isEmpty(1);
  15429. * // => true
  15430. *
  15431. * _.isEmpty([1, 2, 3]);
  15432. * // => false
  15433. *
  15434. * _.isEmpty({ 'a': 1 });
  15435. * // => false
  15436. */
  15437. function isEmpty(value) {
  15438. if (value == null) {
  15439. return true;
  15440. }
  15441. if (isArrayLike(value) &&
  15442. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  15443. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  15444. return !value.length;
  15445. }
  15446. var tag = getTag(value);
  15447. if (tag == mapTag || tag == setTag) {
  15448. return !value.size;
  15449. }
  15450. if (isPrototype(value)) {
  15451. return !baseKeys(value).length;
  15452. }
  15453. for (var key in value) {
  15454. if (hasOwnProperty.call(value, key)) {
  15455. return false;
  15456. }
  15457. }
  15458. return true;
  15459. }
  15460. /**
  15461. * Performs a deep comparison between two values to determine if they are
  15462. * equivalent.
  15463. *
  15464. * **Note:** This method supports comparing arrays, array buffers, booleans,
  15465. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  15466. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  15467. * by their own, not inherited, enumerable properties. Functions and DOM
  15468. * nodes are compared by strict equality, i.e. `===`.
  15469. *
  15470. * @static
  15471. * @memberOf _
  15472. * @since 0.1.0
  15473. * @category Lang
  15474. * @param {*} value The value to compare.
  15475. * @param {*} other The other value to compare.
  15476. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15477. * @example
  15478. *
  15479. * var object = { 'a': 1 };
  15480. * var other = { 'a': 1 };
  15481. *
  15482. * _.isEqual(object, other);
  15483. * // => true
  15484. *
  15485. * object === other;
  15486. * // => false
  15487. */
  15488. function isEqual(value, other) {
  15489. return baseIsEqual(value, other);
  15490. }
  15491. /**
  15492. * This method is like `_.isEqual` except that it accepts `customizer` which
  15493. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  15494. * are handled by the method instead. The `customizer` is invoked with up to
  15495. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  15496. *
  15497. * @static
  15498. * @memberOf _
  15499. * @since 4.0.0
  15500. * @category Lang
  15501. * @param {*} value The value to compare.
  15502. * @param {*} other The other value to compare.
  15503. * @param {Function} [customizer] The function to customize comparisons.
  15504. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15505. * @example
  15506. *
  15507. * function isGreeting(value) {
  15508. * return /^h(?:i|ello)$/.test(value);
  15509. * }
  15510. *
  15511. * function customizer(objValue, othValue) {
  15512. * if (isGreeting(objValue) && isGreeting(othValue)) {
  15513. * return true;
  15514. * }
  15515. * }
  15516. *
  15517. * var array = ['hello', 'goodbye'];
  15518. * var other = ['hi', 'goodbye'];
  15519. *
  15520. * _.isEqualWith(array, other, customizer);
  15521. * // => true
  15522. */
  15523. function isEqualWith(value, other, customizer) {
  15524. customizer = typeof customizer == 'function' ? customizer : undefined;
  15525. var result = customizer ? customizer(value, other) : undefined;
  15526. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  15527. }
  15528. /**
  15529. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  15530. * `SyntaxError`, `TypeError`, or `URIError` object.
  15531. *
  15532. * @static
  15533. * @memberOf _
  15534. * @since 3.0.0
  15535. * @category Lang
  15536. * @param {*} value The value to check.
  15537. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  15538. * @example
  15539. *
  15540. * _.isError(new Error);
  15541. * // => true
  15542. *
  15543. * _.isError(Error);
  15544. * // => false
  15545. */
  15546. function isError(value) {
  15547. if (!isObjectLike(value)) {
  15548. return false;
  15549. }
  15550. var tag = baseGetTag(value);
  15551. return tag == errorTag || tag == domExcTag ||
  15552. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  15553. }
  15554. /**
  15555. * Checks if `value` is a finite primitive number.
  15556. *
  15557. * **Note:** This method is based on
  15558. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  15559. *
  15560. * @static
  15561. * @memberOf _
  15562. * @since 0.1.0
  15563. * @category Lang
  15564. * @param {*} value The value to check.
  15565. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  15566. * @example
  15567. *
  15568. * _.isFinite(3);
  15569. * // => true
  15570. *
  15571. * _.isFinite(Number.MIN_VALUE);
  15572. * // => true
  15573. *
  15574. * _.isFinite(Infinity);
  15575. * // => false
  15576. *
  15577. * _.isFinite('3');
  15578. * // => false
  15579. */
  15580. function isFinite(value) {
  15581. return typeof value == 'number' && nativeIsFinite(value);
  15582. }
  15583. /**
  15584. * Checks if `value` is classified as a `Function` object.
  15585. *
  15586. * @static
  15587. * @memberOf _
  15588. * @since 0.1.0
  15589. * @category Lang
  15590. * @param {*} value The value to check.
  15591. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  15592. * @example
  15593. *
  15594. * _.isFunction(_);
  15595. * // => true
  15596. *
  15597. * _.isFunction(/abc/);
  15598. * // => false
  15599. */
  15600. function isFunction(value) {
  15601. if (!isObject(value)) {
  15602. return false;
  15603. }
  15604. // The use of `Object#toString` avoids issues with the `typeof` operator
  15605. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  15606. var tag = baseGetTag(value);
  15607. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  15608. }
  15609. /**
  15610. * Checks if `value` is an integer.
  15611. *
  15612. * **Note:** This method is based on
  15613. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  15614. *
  15615. * @static
  15616. * @memberOf _
  15617. * @since 4.0.0
  15618. * @category Lang
  15619. * @param {*} value The value to check.
  15620. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  15621. * @example
  15622. *
  15623. * _.isInteger(3);
  15624. * // => true
  15625. *
  15626. * _.isInteger(Number.MIN_VALUE);
  15627. * // => false
  15628. *
  15629. * _.isInteger(Infinity);
  15630. * // => false
  15631. *
  15632. * _.isInteger('3');
  15633. * // => false
  15634. */
  15635. function isInteger(value) {
  15636. return typeof value == 'number' && value == toInteger(value);
  15637. }
  15638. /**
  15639. * Checks if `value` is a valid array-like length.
  15640. *
  15641. * **Note:** This method is loosely based on
  15642. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  15643. *
  15644. * @static
  15645. * @memberOf _
  15646. * @since 4.0.0
  15647. * @category Lang
  15648. * @param {*} value The value to check.
  15649. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  15650. * @example
  15651. *
  15652. * _.isLength(3);
  15653. * // => true
  15654. *
  15655. * _.isLength(Number.MIN_VALUE);
  15656. * // => false
  15657. *
  15658. * _.isLength(Infinity);
  15659. * // => false
  15660. *
  15661. * _.isLength('3');
  15662. * // => false
  15663. */
  15664. function isLength(value) {
  15665. return typeof value == 'number' &&
  15666. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  15667. }
  15668. /**
  15669. * Checks if `value` is the
  15670. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  15671. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  15672. *
  15673. * @static
  15674. * @memberOf _
  15675. * @since 0.1.0
  15676. * @category Lang
  15677. * @param {*} value The value to check.
  15678. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  15679. * @example
  15680. *
  15681. * _.isObject({});
  15682. * // => true
  15683. *
  15684. * _.isObject([1, 2, 3]);
  15685. * // => true
  15686. *
  15687. * _.isObject(_.noop);
  15688. * // => true
  15689. *
  15690. * _.isObject(null);
  15691. * // => false
  15692. */
  15693. function isObject(value) {
  15694. var type = typeof value;
  15695. return value != null && (type == 'object' || type == 'function');
  15696. }
  15697. /**
  15698. * Checks if `value` is object-like. A value is object-like if it's not `null`
  15699. * and has a `typeof` result of "object".
  15700. *
  15701. * @static
  15702. * @memberOf _
  15703. * @since 4.0.0
  15704. * @category Lang
  15705. * @param {*} value The value to check.
  15706. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  15707. * @example
  15708. *
  15709. * _.isObjectLike({});
  15710. * // => true
  15711. *
  15712. * _.isObjectLike([1, 2, 3]);
  15713. * // => true
  15714. *
  15715. * _.isObjectLike(_.noop);
  15716. * // => false
  15717. *
  15718. * _.isObjectLike(null);
  15719. * // => false
  15720. */
  15721. function isObjectLike(value) {
  15722. return value != null && typeof value == 'object';
  15723. }
  15724. /**
  15725. * Checks if `value` is classified as a `Map` object.
  15726. *
  15727. * @static
  15728. * @memberOf _
  15729. * @since 4.3.0
  15730. * @category Lang
  15731. * @param {*} value The value to check.
  15732. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  15733. * @example
  15734. *
  15735. * _.isMap(new Map);
  15736. * // => true
  15737. *
  15738. * _.isMap(new WeakMap);
  15739. * // => false
  15740. */
  15741. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  15742. /**
  15743. * Performs a partial deep comparison between `object` and `source` to
  15744. * determine if `object` contains equivalent property values.
  15745. *
  15746. * **Note:** This method is equivalent to `_.matches` when `source` is
  15747. * partially applied.
  15748. *
  15749. * Partial comparisons will match empty array and empty object `source`
  15750. * values against any array or object value, respectively. See `_.isEqual`
  15751. * for a list of supported value comparisons.
  15752. *
  15753. * @static
  15754. * @memberOf _
  15755. * @since 3.0.0
  15756. * @category Lang
  15757. * @param {Object} object The object to inspect.
  15758. * @param {Object} source The object of property values to match.
  15759. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  15760. * @example
  15761. *
  15762. * var object = { 'a': 1, 'b': 2 };
  15763. *
  15764. * _.isMatch(object, { 'b': 2 });
  15765. * // => true
  15766. *
  15767. * _.isMatch(object, { 'b': 1 });
  15768. * // => false
  15769. */
  15770. function isMatch(object, source) {
  15771. return object === source || baseIsMatch(object, source, getMatchData(source));
  15772. }
  15773. /**
  15774. * This method is like `_.isMatch` except that it accepts `customizer` which
  15775. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  15776. * are handled by the method instead. The `customizer` is invoked with five
  15777. * arguments: (objValue, srcValue, index|key, object, source).
  15778. *
  15779. * @static
  15780. * @memberOf _
  15781. * @since 4.0.0
  15782. * @category Lang
  15783. * @param {Object} object The object to inspect.
  15784. * @param {Object} source The object of property values to match.
  15785. * @param {Function} [customizer] The function to customize comparisons.
  15786. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  15787. * @example
  15788. *
  15789. * function isGreeting(value) {
  15790. * return /^h(?:i|ello)$/.test(value);
  15791. * }
  15792. *
  15793. * function customizer(objValue, srcValue) {
  15794. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  15795. * return true;
  15796. * }
  15797. * }
  15798. *
  15799. * var object = { 'greeting': 'hello' };
  15800. * var source = { 'greeting': 'hi' };
  15801. *
  15802. * _.isMatchWith(object, source, customizer);
  15803. * // => true
  15804. */
  15805. function isMatchWith(object, source, customizer) {
  15806. customizer = typeof customizer == 'function' ? customizer : undefined;
  15807. return baseIsMatch(object, source, getMatchData(source), customizer);
  15808. }
  15809. /**
  15810. * Checks if `value` is `NaN`.
  15811. *
  15812. * **Note:** This method is based on
  15813. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  15814. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  15815. * `undefined` and other non-number values.
  15816. *
  15817. * @static
  15818. * @memberOf _
  15819. * @since 0.1.0
  15820. * @category Lang
  15821. * @param {*} value The value to check.
  15822. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  15823. * @example
  15824. *
  15825. * _.isNaN(NaN);
  15826. * // => true
  15827. *
  15828. * _.isNaN(new Number(NaN));
  15829. * // => true
  15830. *
  15831. * isNaN(undefined);
  15832. * // => true
  15833. *
  15834. * _.isNaN(undefined);
  15835. * // => false
  15836. */
  15837. function isNaN(value) {
  15838. // An `NaN` primitive is the only value that is not equal to itself.
  15839. // Perform the `toStringTag` check first to avoid errors with some
  15840. // ActiveX objects in IE.
  15841. return isNumber(value) && value != +value;
  15842. }
  15843. /**
  15844. * Checks if `value` is a pristine native function.
  15845. *
  15846. * **Note:** This method can't reliably detect native functions in the presence
  15847. * of the core-js package because core-js circumvents this kind of detection.
  15848. * Despite multiple requests, the core-js maintainer has made it clear: any
  15849. * attempt to fix the detection will be obstructed. As a result, we're left
  15850. * with little choice but to throw an error. Unfortunately, this also affects
  15851. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  15852. * which rely on core-js.
  15853. *
  15854. * @static
  15855. * @memberOf _
  15856. * @since 3.0.0
  15857. * @category Lang
  15858. * @param {*} value The value to check.
  15859. * @returns {boolean} Returns `true` if `value` is a native function,
  15860. * else `false`.
  15861. * @example
  15862. *
  15863. * _.isNative(Array.prototype.push);
  15864. * // => true
  15865. *
  15866. * _.isNative(_);
  15867. * // => false
  15868. */
  15869. function isNative(value) {
  15870. if (isMaskable(value)) {
  15871. throw new Error(CORE_ERROR_TEXT);
  15872. }
  15873. return baseIsNative(value);
  15874. }
  15875. /**
  15876. * Checks if `value` is `null`.
  15877. *
  15878. * @static
  15879. * @memberOf _
  15880. * @since 0.1.0
  15881. * @category Lang
  15882. * @param {*} value The value to check.
  15883. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  15884. * @example
  15885. *
  15886. * _.isNull(null);
  15887. * // => true
  15888. *
  15889. * _.isNull(void 0);
  15890. * // => false
  15891. */
  15892. function isNull(value) {
  15893. return value === null;
  15894. }
  15895. /**
  15896. * Checks if `value` is `null` or `undefined`.
  15897. *
  15898. * @static
  15899. * @memberOf _
  15900. * @since 4.0.0
  15901. * @category Lang
  15902. * @param {*} value The value to check.
  15903. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  15904. * @example
  15905. *
  15906. * _.isNil(null);
  15907. * // => true
  15908. *
  15909. * _.isNil(void 0);
  15910. * // => true
  15911. *
  15912. * _.isNil(NaN);
  15913. * // => false
  15914. */
  15915. function isNil(value) {
  15916. return value == null;
  15917. }
  15918. /**
  15919. * Checks if `value` is classified as a `Number` primitive or object.
  15920. *
  15921. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  15922. * classified as numbers, use the `_.isFinite` method.
  15923. *
  15924. * @static
  15925. * @memberOf _
  15926. * @since 0.1.0
  15927. * @category Lang
  15928. * @param {*} value The value to check.
  15929. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  15930. * @example
  15931. *
  15932. * _.isNumber(3);
  15933. * // => true
  15934. *
  15935. * _.isNumber(Number.MIN_VALUE);
  15936. * // => true
  15937. *
  15938. * _.isNumber(Infinity);
  15939. * // => true
  15940. *
  15941. * _.isNumber('3');
  15942. * // => false
  15943. */
  15944. function isNumber(value) {
  15945. return typeof value == 'number' ||
  15946. (isObjectLike(value) && baseGetTag(value) == numberTag);
  15947. }
  15948. /**
  15949. * Checks if `value` is a plain object, that is, an object created by the
  15950. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  15951. *
  15952. * @static
  15953. * @memberOf _
  15954. * @since 0.8.0
  15955. * @category Lang
  15956. * @param {*} value The value to check.
  15957. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  15958. * @example
  15959. *
  15960. * function Foo() {
  15961. * this.a = 1;
  15962. * }
  15963. *
  15964. * _.isPlainObject(new Foo);
  15965. * // => false
  15966. *
  15967. * _.isPlainObject([1, 2, 3]);
  15968. * // => false
  15969. *
  15970. * _.isPlainObject({ 'x': 0, 'y': 0 });
  15971. * // => true
  15972. *
  15973. * _.isPlainObject(Object.create(null));
  15974. * // => true
  15975. */
  15976. function isPlainObject(value) {
  15977. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  15978. return false;
  15979. }
  15980. var proto = getPrototype(value);
  15981. if (proto === null) {
  15982. return true;
  15983. }
  15984. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  15985. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  15986. funcToString.call(Ctor) == objectCtorString;
  15987. }
  15988. /**
  15989. * Checks if `value` is classified as a `RegExp` object.
  15990. *
  15991. * @static
  15992. * @memberOf _
  15993. * @since 0.1.0
  15994. * @category Lang
  15995. * @param {*} value The value to check.
  15996. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  15997. * @example
  15998. *
  15999. * _.isRegExp(/abc/);
  16000. * // => true
  16001. *
  16002. * _.isRegExp('/abc/');
  16003. * // => false
  16004. */
  16005. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  16006. /**
  16007. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  16008. * double precision number which isn't the result of a rounded unsafe integer.
  16009. *
  16010. * **Note:** This method is based on
  16011. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  16012. *
  16013. * @static
  16014. * @memberOf _
  16015. * @since 4.0.0
  16016. * @category Lang
  16017. * @param {*} value The value to check.
  16018. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  16019. * @example
  16020. *
  16021. * _.isSafeInteger(3);
  16022. * // => true
  16023. *
  16024. * _.isSafeInteger(Number.MIN_VALUE);
  16025. * // => false
  16026. *
  16027. * _.isSafeInteger(Infinity);
  16028. * // => false
  16029. *
  16030. * _.isSafeInteger('3');
  16031. * // => false
  16032. */
  16033. function isSafeInteger(value) {
  16034. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  16035. }
  16036. /**
  16037. * Checks if `value` is classified as a `Set` object.
  16038. *
  16039. * @static
  16040. * @memberOf _
  16041. * @since 4.3.0
  16042. * @category Lang
  16043. * @param {*} value The value to check.
  16044. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  16045. * @example
  16046. *
  16047. * _.isSet(new Set);
  16048. * // => true
  16049. *
  16050. * _.isSet(new WeakSet);
  16051. * // => false
  16052. */
  16053. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  16054. /**
  16055. * Checks if `value` is classified as a `String` primitive or object.
  16056. *
  16057. * @static
  16058. * @since 0.1.0
  16059. * @memberOf _
  16060. * @category Lang
  16061. * @param {*} value The value to check.
  16062. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  16063. * @example
  16064. *
  16065. * _.isString('abc');
  16066. * // => true
  16067. *
  16068. * _.isString(1);
  16069. * // => false
  16070. */
  16071. function isString(value) {
  16072. return typeof value == 'string' ||
  16073. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  16074. }
  16075. /**
  16076. * Checks if `value` is classified as a `Symbol` primitive or object.
  16077. *
  16078. * @static
  16079. * @memberOf _
  16080. * @since 4.0.0
  16081. * @category Lang
  16082. * @param {*} value The value to check.
  16083. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  16084. * @example
  16085. *
  16086. * _.isSymbol(Symbol.iterator);
  16087. * // => true
  16088. *
  16089. * _.isSymbol('abc');
  16090. * // => false
  16091. */
  16092. function isSymbol(value) {
  16093. return typeof value == 'symbol' ||
  16094. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  16095. }
  16096. /**
  16097. * Checks if `value` is classified as a typed array.
  16098. *
  16099. * @static
  16100. * @memberOf _
  16101. * @since 3.0.0
  16102. * @category Lang
  16103. * @param {*} value The value to check.
  16104. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  16105. * @example
  16106. *
  16107. * _.isTypedArray(new Uint8Array);
  16108. * // => true
  16109. *
  16110. * _.isTypedArray([]);
  16111. * // => false
  16112. */
  16113. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  16114. /**
  16115. * Checks if `value` is `undefined`.
  16116. *
  16117. * @static
  16118. * @since 0.1.0
  16119. * @memberOf _
  16120. * @category Lang
  16121. * @param {*} value The value to check.
  16122. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  16123. * @example
  16124. *
  16125. * _.isUndefined(void 0);
  16126. * // => true
  16127. *
  16128. * _.isUndefined(null);
  16129. * // => false
  16130. */
  16131. function isUndefined(value) {
  16132. return value === undefined;
  16133. }
  16134. /**
  16135. * Checks if `value` is classified as a `WeakMap` object.
  16136. *
  16137. * @static
  16138. * @memberOf _
  16139. * @since 4.3.0
  16140. * @category Lang
  16141. * @param {*} value The value to check.
  16142. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  16143. * @example
  16144. *
  16145. * _.isWeakMap(new WeakMap);
  16146. * // => true
  16147. *
  16148. * _.isWeakMap(new Map);
  16149. * // => false
  16150. */
  16151. function isWeakMap(value) {
  16152. return isObjectLike(value) && getTag(value) == weakMapTag;
  16153. }
  16154. /**
  16155. * Checks if `value` is classified as a `WeakSet` object.
  16156. *
  16157. * @static
  16158. * @memberOf _
  16159. * @since 4.3.0
  16160. * @category Lang
  16161. * @param {*} value The value to check.
  16162. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  16163. * @example
  16164. *
  16165. * _.isWeakSet(new WeakSet);
  16166. * // => true
  16167. *
  16168. * _.isWeakSet(new Set);
  16169. * // => false
  16170. */
  16171. function isWeakSet(value) {
  16172. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  16173. }
  16174. /**
  16175. * Checks if `value` is less than `other`.
  16176. *
  16177. * @static
  16178. * @memberOf _
  16179. * @since 3.9.0
  16180. * @category Lang
  16181. * @param {*} value The value to compare.
  16182. * @param {*} other The other value to compare.
  16183. * @returns {boolean} Returns `true` if `value` is less than `other`,
  16184. * else `false`.
  16185. * @see _.gt
  16186. * @example
  16187. *
  16188. * _.lt(1, 3);
  16189. * // => true
  16190. *
  16191. * _.lt(3, 3);
  16192. * // => false
  16193. *
  16194. * _.lt(3, 1);
  16195. * // => false
  16196. */
  16197. var lt = createRelationalOperation(baseLt);
  16198. /**
  16199. * Checks if `value` is less than or equal to `other`.
  16200. *
  16201. * @static
  16202. * @memberOf _
  16203. * @since 3.9.0
  16204. * @category Lang
  16205. * @param {*} value The value to compare.
  16206. * @param {*} other The other value to compare.
  16207. * @returns {boolean} Returns `true` if `value` is less than or equal to
  16208. * `other`, else `false`.
  16209. * @see _.gte
  16210. * @example
  16211. *
  16212. * _.lte(1, 3);
  16213. * // => true
  16214. *
  16215. * _.lte(3, 3);
  16216. * // => true
  16217. *
  16218. * _.lte(3, 1);
  16219. * // => false
  16220. */
  16221. var lte = createRelationalOperation(function(value, other) {
  16222. return value <= other;
  16223. });
  16224. /**
  16225. * Converts `value` to an array.
  16226. *
  16227. * @static
  16228. * @since 0.1.0
  16229. * @memberOf _
  16230. * @category Lang
  16231. * @param {*} value The value to convert.
  16232. * @returns {Array} Returns the converted array.
  16233. * @example
  16234. *
  16235. * _.toArray({ 'a': 1, 'b': 2 });
  16236. * // => [1, 2]
  16237. *
  16238. * _.toArray('abc');
  16239. * // => ['a', 'b', 'c']
  16240. *
  16241. * _.toArray(1);
  16242. * // => []
  16243. *
  16244. * _.toArray(null);
  16245. * // => []
  16246. */
  16247. function toArray(value) {
  16248. if (!value) {
  16249. return [];
  16250. }
  16251. if (isArrayLike(value)) {
  16252. return isString(value) ? stringToArray(value) : copyArray(value);
  16253. }
  16254. if (symIterator && value[symIterator]) {
  16255. return iteratorToArray(value[symIterator]());
  16256. }
  16257. var tag = getTag(value),
  16258. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  16259. return func(value);
  16260. }
  16261. /**
  16262. * Converts `value` to a finite number.
  16263. *
  16264. * @static
  16265. * @memberOf _
  16266. * @since 4.12.0
  16267. * @category Lang
  16268. * @param {*} value The value to convert.
  16269. * @returns {number} Returns the converted number.
  16270. * @example
  16271. *
  16272. * _.toFinite(3.2);
  16273. * // => 3.2
  16274. *
  16275. * _.toFinite(Number.MIN_VALUE);
  16276. * // => 5e-324
  16277. *
  16278. * _.toFinite(Infinity);
  16279. * // => 1.7976931348623157e+308
  16280. *
  16281. * _.toFinite('3.2');
  16282. * // => 3.2
  16283. */
  16284. function toFinite(value) {
  16285. if (!value) {
  16286. return value === 0 ? value : 0;
  16287. }
  16288. value = toNumber(value);
  16289. if (value === INFINITY || value === -INFINITY) {
  16290. var sign = (value < 0 ? -1 : 1);
  16291. return sign * MAX_INTEGER;
  16292. }
  16293. return value === value ? value : 0;
  16294. }
  16295. /**
  16296. * Converts `value` to an integer.
  16297. *
  16298. * **Note:** This method is loosely based on
  16299. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  16300. *
  16301. * @static
  16302. * @memberOf _
  16303. * @since 4.0.0
  16304. * @category Lang
  16305. * @param {*} value The value to convert.
  16306. * @returns {number} Returns the converted integer.
  16307. * @example
  16308. *
  16309. * _.toInteger(3.2);
  16310. * // => 3
  16311. *
  16312. * _.toInteger(Number.MIN_VALUE);
  16313. * // => 0
  16314. *
  16315. * _.toInteger(Infinity);
  16316. * // => 1.7976931348623157e+308
  16317. *
  16318. * _.toInteger('3.2');
  16319. * // => 3
  16320. */
  16321. function toInteger(value) {
  16322. var result = toFinite(value),
  16323. remainder = result % 1;
  16324. return result === result ? (remainder ? result - remainder : result) : 0;
  16325. }
  16326. /**
  16327. * Converts `value` to an integer suitable for use as the length of an
  16328. * array-like object.
  16329. *
  16330. * **Note:** This method is based on
  16331. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  16332. *
  16333. * @static
  16334. * @memberOf _
  16335. * @since 4.0.0
  16336. * @category Lang
  16337. * @param {*} value The value to convert.
  16338. * @returns {number} Returns the converted integer.
  16339. * @example
  16340. *
  16341. * _.toLength(3.2);
  16342. * // => 3
  16343. *
  16344. * _.toLength(Number.MIN_VALUE);
  16345. * // => 0
  16346. *
  16347. * _.toLength(Infinity);
  16348. * // => 4294967295
  16349. *
  16350. * _.toLength('3.2');
  16351. * // => 3
  16352. */
  16353. function toLength(value) {
  16354. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  16355. }
  16356. /**
  16357. * Converts `value` to a number.
  16358. *
  16359. * @static
  16360. * @memberOf _
  16361. * @since 4.0.0
  16362. * @category Lang
  16363. * @param {*} value The value to process.
  16364. * @returns {number} Returns the number.
  16365. * @example
  16366. *
  16367. * _.toNumber(3.2);
  16368. * // => 3.2
  16369. *
  16370. * _.toNumber(Number.MIN_VALUE);
  16371. * // => 5e-324
  16372. *
  16373. * _.toNumber(Infinity);
  16374. * // => Infinity
  16375. *
  16376. * _.toNumber('3.2');
  16377. * // => 3.2
  16378. */
  16379. function toNumber(value) {
  16380. if (typeof value == 'number') {
  16381. return value;
  16382. }
  16383. if (isSymbol(value)) {
  16384. return NAN;
  16385. }
  16386. if (isObject(value)) {
  16387. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  16388. value = isObject(other) ? (other + '') : other;
  16389. }
  16390. if (typeof value != 'string') {
  16391. return value === 0 ? value : +value;
  16392. }
  16393. value = baseTrim(value);
  16394. var isBinary = reIsBinary.test(value);
  16395. return (isBinary || reIsOctal.test(value))
  16396. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  16397. : (reIsBadHex.test(value) ? NAN : +value);
  16398. }
  16399. /**
  16400. * Converts `value` to a plain object flattening inherited enumerable string
  16401. * keyed properties of `value` to own properties of the plain object.
  16402. *
  16403. * @static
  16404. * @memberOf _
  16405. * @since 3.0.0
  16406. * @category Lang
  16407. * @param {*} value The value to convert.
  16408. * @returns {Object} Returns the converted plain object.
  16409. * @example
  16410. *
  16411. * function Foo() {
  16412. * this.b = 2;
  16413. * }
  16414. *
  16415. * Foo.prototype.c = 3;
  16416. *
  16417. * _.assign({ 'a': 1 }, new Foo);
  16418. * // => { 'a': 1, 'b': 2 }
  16419. *
  16420. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  16421. * // => { 'a': 1, 'b': 2, 'c': 3 }
  16422. */
  16423. function toPlainObject(value) {
  16424. return copyObject(value, keysIn(value));
  16425. }
  16426. /**
  16427. * Converts `value` to a safe integer. A safe integer can be compared and
  16428. * represented correctly.
  16429. *
  16430. * @static
  16431. * @memberOf _
  16432. * @since 4.0.0
  16433. * @category Lang
  16434. * @param {*} value The value to convert.
  16435. * @returns {number} Returns the converted integer.
  16436. * @example
  16437. *
  16438. * _.toSafeInteger(3.2);
  16439. * // => 3
  16440. *
  16441. * _.toSafeInteger(Number.MIN_VALUE);
  16442. * // => 0
  16443. *
  16444. * _.toSafeInteger(Infinity);
  16445. * // => 9007199254740991
  16446. *
  16447. * _.toSafeInteger('3.2');
  16448. * // => 3
  16449. */
  16450. function toSafeInteger(value) {
  16451. return value
  16452. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  16453. : (value === 0 ? value : 0);
  16454. }
  16455. /**
  16456. * Converts `value` to a string. An empty string is returned for `null`
  16457. * and `undefined` values. The sign of `-0` is preserved.
  16458. *
  16459. * @static
  16460. * @memberOf _
  16461. * @since 4.0.0
  16462. * @category Lang
  16463. * @param {*} value The value to convert.
  16464. * @returns {string} Returns the converted string.
  16465. * @example
  16466. *
  16467. * _.toString(null);
  16468. * // => ''
  16469. *
  16470. * _.toString(-0);
  16471. * // => '-0'
  16472. *
  16473. * _.toString([1, 2, 3]);
  16474. * // => '1,2,3'
  16475. */
  16476. function toString(value) {
  16477. return value == null ? '' : baseToString(value);
  16478. }
  16479. /*------------------------------------------------------------------------*/
  16480. /**
  16481. * Assigns own enumerable string keyed properties of source objects to the
  16482. * destination object. Source objects are applied from left to right.
  16483. * Subsequent sources overwrite property assignments of previous sources.
  16484. *
  16485. * **Note:** This method mutates `object` and is loosely based on
  16486. * [`Object.assign`](https://mdn.io/Object/assign).
  16487. *
  16488. * @static
  16489. * @memberOf _
  16490. * @since 0.10.0
  16491. * @category Object
  16492. * @param {Object} object The destination object.
  16493. * @param {...Object} [sources] The source objects.
  16494. * @returns {Object} Returns `object`.
  16495. * @see _.assignIn
  16496. * @example
  16497. *
  16498. * function Foo() {
  16499. * this.a = 1;
  16500. * }
  16501. *
  16502. * function Bar() {
  16503. * this.c = 3;
  16504. * }
  16505. *
  16506. * Foo.prototype.b = 2;
  16507. * Bar.prototype.d = 4;
  16508. *
  16509. * _.assign({ 'a': 0 }, new Foo, new Bar);
  16510. * // => { 'a': 1, 'c': 3 }
  16511. */
  16512. var assign = createAssigner(function(object, source) {
  16513. if (isPrototype(source) || isArrayLike(source)) {
  16514. copyObject(source, keys(source), object);
  16515. return;
  16516. }
  16517. for (var key in source) {
  16518. if (hasOwnProperty.call(source, key)) {
  16519. assignValue(object, key, source[key]);
  16520. }
  16521. }
  16522. });
  16523. /**
  16524. * This method is like `_.assign` except that it iterates over own and
  16525. * inherited source properties.
  16526. *
  16527. * **Note:** This method mutates `object`.
  16528. *
  16529. * @static
  16530. * @memberOf _
  16531. * @since 4.0.0
  16532. * @alias extend
  16533. * @category Object
  16534. * @param {Object} object The destination object.
  16535. * @param {...Object} [sources] The source objects.
  16536. * @returns {Object} Returns `object`.
  16537. * @see _.assign
  16538. * @example
  16539. *
  16540. * function Foo() {
  16541. * this.a = 1;
  16542. * }
  16543. *
  16544. * function Bar() {
  16545. * this.c = 3;
  16546. * }
  16547. *
  16548. * Foo.prototype.b = 2;
  16549. * Bar.prototype.d = 4;
  16550. *
  16551. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  16552. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  16553. */
  16554. var assignIn = createAssigner(function(object, source) {
  16555. copyObject(source, keysIn(source), object);
  16556. });
  16557. /**
  16558. * This method is like `_.assignIn` except that it accepts `customizer`
  16559. * which is invoked to produce the assigned values. If `customizer` returns
  16560. * `undefined`, assignment is handled by the method instead. The `customizer`
  16561. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  16562. *
  16563. * **Note:** This method mutates `object`.
  16564. *
  16565. * @static
  16566. * @memberOf _
  16567. * @since 4.0.0
  16568. * @alias extendWith
  16569. * @category Object
  16570. * @param {Object} object The destination object.
  16571. * @param {...Object} sources The source objects.
  16572. * @param {Function} [customizer] The function to customize assigned values.
  16573. * @returns {Object} Returns `object`.
  16574. * @see _.assignWith
  16575. * @example
  16576. *
  16577. * function customizer(objValue, srcValue) {
  16578. * return _.isUndefined(objValue) ? srcValue : objValue;
  16579. * }
  16580. *
  16581. * var defaults = _.partialRight(_.assignInWith, customizer);
  16582. *
  16583. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16584. * // => { 'a': 1, 'b': 2 }
  16585. */
  16586. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  16587. copyObject(source, keysIn(source), object, customizer);
  16588. });
  16589. /**
  16590. * This method is like `_.assign` except that it accepts `customizer`
  16591. * which is invoked to produce the assigned values. If `customizer` returns
  16592. * `undefined`, assignment is handled by the method instead. The `customizer`
  16593. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  16594. *
  16595. * **Note:** This method mutates `object`.
  16596. *
  16597. * @static
  16598. * @memberOf _
  16599. * @since 4.0.0
  16600. * @category Object
  16601. * @param {Object} object The destination object.
  16602. * @param {...Object} sources The source objects.
  16603. * @param {Function} [customizer] The function to customize assigned values.
  16604. * @returns {Object} Returns `object`.
  16605. * @see _.assignInWith
  16606. * @example
  16607. *
  16608. * function customizer(objValue, srcValue) {
  16609. * return _.isUndefined(objValue) ? srcValue : objValue;
  16610. * }
  16611. *
  16612. * var defaults = _.partialRight(_.assignWith, customizer);
  16613. *
  16614. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16615. * // => { 'a': 1, 'b': 2 }
  16616. */
  16617. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  16618. copyObject(source, keys(source), object, customizer);
  16619. });
  16620. /**
  16621. * Creates an array of values corresponding to `paths` of `object`.
  16622. *
  16623. * @static
  16624. * @memberOf _
  16625. * @since 1.0.0
  16626. * @category Object
  16627. * @param {Object} object The object to iterate over.
  16628. * @param {...(string|string[])} [paths] The property paths to pick.
  16629. * @returns {Array} Returns the picked values.
  16630. * @example
  16631. *
  16632. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  16633. *
  16634. * _.at(object, ['a[0].b.c', 'a[1]']);
  16635. * // => [3, 4]
  16636. */
  16637. var at = flatRest(baseAt);
  16638. /**
  16639. * Creates an object that inherits from the `prototype` object. If a
  16640. * `properties` object is given, its own enumerable string keyed properties
  16641. * are assigned to the created object.
  16642. *
  16643. * @static
  16644. * @memberOf _
  16645. * @since 2.3.0
  16646. * @category Object
  16647. * @param {Object} prototype The object to inherit from.
  16648. * @param {Object} [properties] The properties to assign to the object.
  16649. * @returns {Object} Returns the new object.
  16650. * @example
  16651. *
  16652. * function Shape() {
  16653. * this.x = 0;
  16654. * this.y = 0;
  16655. * }
  16656. *
  16657. * function Circle() {
  16658. * Shape.call(this);
  16659. * }
  16660. *
  16661. * Circle.prototype = _.create(Shape.prototype, {
  16662. * 'constructor': Circle
  16663. * });
  16664. *
  16665. * var circle = new Circle;
  16666. * circle instanceof Circle;
  16667. * // => true
  16668. *
  16669. * circle instanceof Shape;
  16670. * // => true
  16671. */
  16672. function create(prototype, properties) {
  16673. var result = baseCreate(prototype);
  16674. return properties == null ? result : baseAssign(result, properties);
  16675. }
  16676. /**
  16677. * Assigns own and inherited enumerable string keyed properties of source
  16678. * objects to the destination object for all destination properties that
  16679. * resolve to `undefined`. Source objects are applied from left to right.
  16680. * Once a property is set, additional values of the same property are ignored.
  16681. *
  16682. * **Note:** This method mutates `object`.
  16683. *
  16684. * @static
  16685. * @since 0.1.0
  16686. * @memberOf _
  16687. * @category Object
  16688. * @param {Object} object The destination object.
  16689. * @param {...Object} [sources] The source objects.
  16690. * @returns {Object} Returns `object`.
  16691. * @see _.defaultsDeep
  16692. * @example
  16693. *
  16694. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16695. * // => { 'a': 1, 'b': 2 }
  16696. */
  16697. var defaults = baseRest(function(object, sources) {
  16698. object = Object(object);
  16699. var index = -1;
  16700. var length = sources.length;
  16701. var guard = length > 2 ? sources[2] : undefined;
  16702. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  16703. length = 1;
  16704. }
  16705. while (++index < length) {
  16706. var source = sources[index];
  16707. var props = keysIn(source);
  16708. var propsIndex = -1;
  16709. var propsLength = props.length;
  16710. while (++propsIndex < propsLength) {
  16711. var key = props[propsIndex];
  16712. var value = object[key];
  16713. if (value === undefined ||
  16714. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  16715. object[key] = source[key];
  16716. }
  16717. }
  16718. }
  16719. return object;
  16720. });
  16721. /**
  16722. * This method is like `_.defaults` except that it recursively assigns
  16723. * default properties.
  16724. *
  16725. * **Note:** This method mutates `object`.
  16726. *
  16727. * @static
  16728. * @memberOf _
  16729. * @since 3.10.0
  16730. * @category Object
  16731. * @param {Object} object The destination object.
  16732. * @param {...Object} [sources] The source objects.
  16733. * @returns {Object} Returns `object`.
  16734. * @see _.defaults
  16735. * @example
  16736. *
  16737. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  16738. * // => { 'a': { 'b': 2, 'c': 3 } }
  16739. */
  16740. var defaultsDeep = baseRest(function(args) {
  16741. args.push(undefined, customDefaultsMerge);
  16742. return apply(mergeWith, undefined, args);
  16743. });
  16744. /**
  16745. * This method is like `_.find` except that it returns the key of the first
  16746. * element `predicate` returns truthy for instead of the element itself.
  16747. *
  16748. * @static
  16749. * @memberOf _
  16750. * @since 1.1.0
  16751. * @category Object
  16752. * @param {Object} object The object to inspect.
  16753. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16754. * @returns {string|undefined} Returns the key of the matched element,
  16755. * else `undefined`.
  16756. * @example
  16757. *
  16758. * var users = {
  16759. * 'barney': { 'age': 36, 'active': true },
  16760. * 'fred': { 'age': 40, 'active': false },
  16761. * 'pebbles': { 'age': 1, 'active': true }
  16762. * };
  16763. *
  16764. * _.findKey(users, function(o) { return o.age < 40; });
  16765. * // => 'barney' (iteration order is not guaranteed)
  16766. *
  16767. * // The `_.matches` iteratee shorthand.
  16768. * _.findKey(users, { 'age': 1, 'active': true });
  16769. * // => 'pebbles'
  16770. *
  16771. * // The `_.matchesProperty` iteratee shorthand.
  16772. * _.findKey(users, ['active', false]);
  16773. * // => 'fred'
  16774. *
  16775. * // The `_.property` iteratee shorthand.
  16776. * _.findKey(users, 'active');
  16777. * // => 'barney'
  16778. */
  16779. function findKey(object, predicate) {
  16780. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  16781. }
  16782. /**
  16783. * This method is like `_.findKey` except that it iterates over elements of
  16784. * a collection in the opposite order.
  16785. *
  16786. * @static
  16787. * @memberOf _
  16788. * @since 2.0.0
  16789. * @category Object
  16790. * @param {Object} object The object to inspect.
  16791. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16792. * @returns {string|undefined} Returns the key of the matched element,
  16793. * else `undefined`.
  16794. * @example
  16795. *
  16796. * var users = {
  16797. * 'barney': { 'age': 36, 'active': true },
  16798. * 'fred': { 'age': 40, 'active': false },
  16799. * 'pebbles': { 'age': 1, 'active': true }
  16800. * };
  16801. *
  16802. * _.findLastKey(users, function(o) { return o.age < 40; });
  16803. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  16804. *
  16805. * // The `_.matches` iteratee shorthand.
  16806. * _.findLastKey(users, { 'age': 36, 'active': true });
  16807. * // => 'barney'
  16808. *
  16809. * // The `_.matchesProperty` iteratee shorthand.
  16810. * _.findLastKey(users, ['active', false]);
  16811. * // => 'fred'
  16812. *
  16813. * // The `_.property` iteratee shorthand.
  16814. * _.findLastKey(users, 'active');
  16815. * // => 'pebbles'
  16816. */
  16817. function findLastKey(object, predicate) {
  16818. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  16819. }
  16820. /**
  16821. * Iterates over own and inherited enumerable string keyed properties of an
  16822. * object and invokes `iteratee` for each property. The iteratee is invoked
  16823. * with three arguments: (value, key, object). Iteratee functions may exit
  16824. * iteration early by explicitly returning `false`.
  16825. *
  16826. * @static
  16827. * @memberOf _
  16828. * @since 0.3.0
  16829. * @category Object
  16830. * @param {Object} object The object to iterate over.
  16831. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16832. * @returns {Object} Returns `object`.
  16833. * @see _.forInRight
  16834. * @example
  16835. *
  16836. * function Foo() {
  16837. * this.a = 1;
  16838. * this.b = 2;
  16839. * }
  16840. *
  16841. * Foo.prototype.c = 3;
  16842. *
  16843. * _.forIn(new Foo, function(value, key) {
  16844. * console.log(key);
  16845. * });
  16846. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  16847. */
  16848. function forIn(object, iteratee) {
  16849. return object == null
  16850. ? object
  16851. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  16852. }
  16853. /**
  16854. * This method is like `_.forIn` except that it iterates over properties of
  16855. * `object` in the opposite order.
  16856. *
  16857. * @static
  16858. * @memberOf _
  16859. * @since 2.0.0
  16860. * @category Object
  16861. * @param {Object} object The object to iterate over.
  16862. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16863. * @returns {Object} Returns `object`.
  16864. * @see _.forIn
  16865. * @example
  16866. *
  16867. * function Foo() {
  16868. * this.a = 1;
  16869. * this.b = 2;
  16870. * }
  16871. *
  16872. * Foo.prototype.c = 3;
  16873. *
  16874. * _.forInRight(new Foo, function(value, key) {
  16875. * console.log(key);
  16876. * });
  16877. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  16878. */
  16879. function forInRight(object, iteratee) {
  16880. return object == null
  16881. ? object
  16882. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  16883. }
  16884. /**
  16885. * Iterates over own enumerable string keyed properties of an object and
  16886. * invokes `iteratee` for each property. The iteratee is invoked with three
  16887. * arguments: (value, key, object). Iteratee functions may exit iteration
  16888. * early by explicitly returning `false`.
  16889. *
  16890. * @static
  16891. * @memberOf _
  16892. * @since 0.3.0
  16893. * @category Object
  16894. * @param {Object} object The object to iterate over.
  16895. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16896. * @returns {Object} Returns `object`.
  16897. * @see _.forOwnRight
  16898. * @example
  16899. *
  16900. * function Foo() {
  16901. * this.a = 1;
  16902. * this.b = 2;
  16903. * }
  16904. *
  16905. * Foo.prototype.c = 3;
  16906. *
  16907. * _.forOwn(new Foo, function(value, key) {
  16908. * console.log(key);
  16909. * });
  16910. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  16911. */
  16912. function forOwn(object, iteratee) {
  16913. return object && baseForOwn(object, getIteratee(iteratee, 3));
  16914. }
  16915. /**
  16916. * This method is like `_.forOwn` except that it iterates over properties of
  16917. * `object` in the opposite order.
  16918. *
  16919. * @static
  16920. * @memberOf _
  16921. * @since 2.0.0
  16922. * @category Object
  16923. * @param {Object} object The object to iterate over.
  16924. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16925. * @returns {Object} Returns `object`.
  16926. * @see _.forOwn
  16927. * @example
  16928. *
  16929. * function Foo() {
  16930. * this.a = 1;
  16931. * this.b = 2;
  16932. * }
  16933. *
  16934. * Foo.prototype.c = 3;
  16935. *
  16936. * _.forOwnRight(new Foo, function(value, key) {
  16937. * console.log(key);
  16938. * });
  16939. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  16940. */
  16941. function forOwnRight(object, iteratee) {
  16942. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  16943. }
  16944. /**
  16945. * Creates an array of function property names from own enumerable properties
  16946. * of `object`.
  16947. *
  16948. * @static
  16949. * @since 0.1.0
  16950. * @memberOf _
  16951. * @category Object
  16952. * @param {Object} object The object to inspect.
  16953. * @returns {Array} Returns the function names.
  16954. * @see _.functionsIn
  16955. * @example
  16956. *
  16957. * function Foo() {
  16958. * this.a = _.constant('a');
  16959. * this.b = _.constant('b');
  16960. * }
  16961. *
  16962. * Foo.prototype.c = _.constant('c');
  16963. *
  16964. * _.functions(new Foo);
  16965. * // => ['a', 'b']
  16966. */
  16967. function functions(object) {
  16968. return object == null ? [] : baseFunctions(object, keys(object));
  16969. }
  16970. /**
  16971. * Creates an array of function property names from own and inherited
  16972. * enumerable properties of `object`.
  16973. *
  16974. * @static
  16975. * @memberOf _
  16976. * @since 4.0.0
  16977. * @category Object
  16978. * @param {Object} object The object to inspect.
  16979. * @returns {Array} Returns the function names.
  16980. * @see _.functions
  16981. * @example
  16982. *
  16983. * function Foo() {
  16984. * this.a = _.constant('a');
  16985. * this.b = _.constant('b');
  16986. * }
  16987. *
  16988. * Foo.prototype.c = _.constant('c');
  16989. *
  16990. * _.functionsIn(new Foo);
  16991. * // => ['a', 'b', 'c']
  16992. */
  16993. function functionsIn(object) {
  16994. return object == null ? [] : baseFunctions(object, keysIn(object));
  16995. }
  16996. /**
  16997. * Gets the value at `path` of `object`. If the resolved value is
  16998. * `undefined`, the `defaultValue` is returned in its place.
  16999. *
  17000. * @static
  17001. * @memberOf _
  17002. * @since 3.7.0
  17003. * @category Object
  17004. * @param {Object} object The object to query.
  17005. * @param {Array|string} path The path of the property to get.
  17006. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  17007. * @returns {*} Returns the resolved value.
  17008. * @example
  17009. *
  17010. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17011. *
  17012. * _.get(object, 'a[0].b.c');
  17013. * // => 3
  17014. *
  17015. * _.get(object, ['a', '0', 'b', 'c']);
  17016. * // => 3
  17017. *
  17018. * _.get(object, 'a.b.c', 'default');
  17019. * // => 'default'
  17020. */
  17021. function get(object, path, defaultValue) {
  17022. var result = object == null ? undefined : baseGet(object, path);
  17023. return result === undefined ? defaultValue : result;
  17024. }
  17025. /**
  17026. * Checks if `path` is a direct property of `object`.
  17027. *
  17028. * @static
  17029. * @since 0.1.0
  17030. * @memberOf _
  17031. * @category Object
  17032. * @param {Object} object The object to query.
  17033. * @param {Array|string} path The path to check.
  17034. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  17035. * @example
  17036. *
  17037. * var object = { 'a': { 'b': 2 } };
  17038. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  17039. *
  17040. * _.has(object, 'a');
  17041. * // => true
  17042. *
  17043. * _.has(object, 'a.b');
  17044. * // => true
  17045. *
  17046. * _.has(object, ['a', 'b']);
  17047. * // => true
  17048. *
  17049. * _.has(other, 'a');
  17050. * // => false
  17051. */
  17052. function has(object, path) {
  17053. return object != null && hasPath(object, path, baseHas);
  17054. }
  17055. /**
  17056. * Checks if `path` is a direct or inherited property of `object`.
  17057. *
  17058. * @static
  17059. * @memberOf _
  17060. * @since 4.0.0
  17061. * @category Object
  17062. * @param {Object} object The object to query.
  17063. * @param {Array|string} path The path to check.
  17064. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  17065. * @example
  17066. *
  17067. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  17068. *
  17069. * _.hasIn(object, 'a');
  17070. * // => true
  17071. *
  17072. * _.hasIn(object, 'a.b');
  17073. * // => true
  17074. *
  17075. * _.hasIn(object, ['a', 'b']);
  17076. * // => true
  17077. *
  17078. * _.hasIn(object, 'b');
  17079. * // => false
  17080. */
  17081. function hasIn(object, path) {
  17082. return object != null && hasPath(object, path, baseHasIn);
  17083. }
  17084. /**
  17085. * Creates an object composed of the inverted keys and values of `object`.
  17086. * If `object` contains duplicate values, subsequent values overwrite
  17087. * property assignments of previous values.
  17088. *
  17089. * @static
  17090. * @memberOf _
  17091. * @since 0.7.0
  17092. * @category Object
  17093. * @param {Object} object The object to invert.
  17094. * @returns {Object} Returns the new inverted object.
  17095. * @example
  17096. *
  17097. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  17098. *
  17099. * _.invert(object);
  17100. * // => { '1': 'c', '2': 'b' }
  17101. */
  17102. var invert = createInverter(function(result, value, key) {
  17103. if (value != null &&
  17104. typeof value.toString != 'function') {
  17105. value = nativeObjectToString.call(value);
  17106. }
  17107. result[value] = key;
  17108. }, constant(identity));
  17109. /**
  17110. * This method is like `_.invert` except that the inverted object is generated
  17111. * from the results of running each element of `object` thru `iteratee`. The
  17112. * corresponding inverted value of each inverted key is an array of keys
  17113. * responsible for generating the inverted value. The iteratee is invoked
  17114. * with one argument: (value).
  17115. *
  17116. * @static
  17117. * @memberOf _
  17118. * @since 4.1.0
  17119. * @category Object
  17120. * @param {Object} object The object to invert.
  17121. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17122. * @returns {Object} Returns the new inverted object.
  17123. * @example
  17124. *
  17125. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  17126. *
  17127. * _.invertBy(object);
  17128. * // => { '1': ['a', 'c'], '2': ['b'] }
  17129. *
  17130. * _.invertBy(object, function(value) {
  17131. * return 'group' + value;
  17132. * });
  17133. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  17134. */
  17135. var invertBy = createInverter(function(result, value, key) {
  17136. if (value != null &&
  17137. typeof value.toString != 'function') {
  17138. value = nativeObjectToString.call(value);
  17139. }
  17140. if (hasOwnProperty.call(result, value)) {
  17141. result[value].push(key);
  17142. } else {
  17143. result[value] = [key];
  17144. }
  17145. }, getIteratee);
  17146. /**
  17147. * Invokes the method at `path` of `object`.
  17148. *
  17149. * @static
  17150. * @memberOf _
  17151. * @since 4.0.0
  17152. * @category Object
  17153. * @param {Object} object The object to query.
  17154. * @param {Array|string} path The path of the method to invoke.
  17155. * @param {...*} [args] The arguments to invoke the method with.
  17156. * @returns {*} Returns the result of the invoked method.
  17157. * @example
  17158. *
  17159. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  17160. *
  17161. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  17162. * // => [2, 3]
  17163. */
  17164. var invoke = baseRest(baseInvoke);
  17165. /**
  17166. * Creates an array of the own enumerable property names of `object`.
  17167. *
  17168. * **Note:** Non-object values are coerced to objects. See the
  17169. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  17170. * for more details.
  17171. *
  17172. * @static
  17173. * @since 0.1.0
  17174. * @memberOf _
  17175. * @category Object
  17176. * @param {Object} object The object to query.
  17177. * @returns {Array} Returns the array of property names.
  17178. * @example
  17179. *
  17180. * function Foo() {
  17181. * this.a = 1;
  17182. * this.b = 2;
  17183. * }
  17184. *
  17185. * Foo.prototype.c = 3;
  17186. *
  17187. * _.keys(new Foo);
  17188. * // => ['a', 'b'] (iteration order is not guaranteed)
  17189. *
  17190. * _.keys('hi');
  17191. * // => ['0', '1']
  17192. */
  17193. function keys(object) {
  17194. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  17195. }
  17196. /**
  17197. * Creates an array of the own and inherited enumerable property names of `object`.
  17198. *
  17199. * **Note:** Non-object values are coerced to objects.
  17200. *
  17201. * @static
  17202. * @memberOf _
  17203. * @since 3.0.0
  17204. * @category Object
  17205. * @param {Object} object The object to query.
  17206. * @returns {Array} Returns the array of property names.
  17207. * @example
  17208. *
  17209. * function Foo() {
  17210. * this.a = 1;
  17211. * this.b = 2;
  17212. * }
  17213. *
  17214. * Foo.prototype.c = 3;
  17215. *
  17216. * _.keysIn(new Foo);
  17217. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  17218. */
  17219. function keysIn(object) {
  17220. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  17221. }
  17222. /**
  17223. * The opposite of `_.mapValues`; this method creates an object with the
  17224. * same values as `object` and keys generated by running each own enumerable
  17225. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  17226. * with three arguments: (value, key, object).
  17227. *
  17228. * @static
  17229. * @memberOf _
  17230. * @since 3.8.0
  17231. * @category Object
  17232. * @param {Object} object The object to iterate over.
  17233. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17234. * @returns {Object} Returns the new mapped object.
  17235. * @see _.mapValues
  17236. * @example
  17237. *
  17238. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  17239. * return key + value;
  17240. * });
  17241. * // => { 'a1': 1, 'b2': 2 }
  17242. */
  17243. function mapKeys(object, iteratee) {
  17244. var result = {};
  17245. iteratee = getIteratee(iteratee, 3);
  17246. baseForOwn(object, function(value, key, object) {
  17247. baseAssignValue(result, iteratee(value, key, object), value);
  17248. });
  17249. return result;
  17250. }
  17251. /**
  17252. * Creates an object with the same keys as `object` and values generated
  17253. * by running each own enumerable string keyed property of `object` thru
  17254. * `iteratee`. The iteratee is invoked with three arguments:
  17255. * (value, key, object).
  17256. *
  17257. * @static
  17258. * @memberOf _
  17259. * @since 2.4.0
  17260. * @category Object
  17261. * @param {Object} object The object to iterate over.
  17262. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17263. * @returns {Object} Returns the new mapped object.
  17264. * @see _.mapKeys
  17265. * @example
  17266. *
  17267. * var users = {
  17268. * 'fred': { 'user': 'fred', 'age': 40 },
  17269. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  17270. * };
  17271. *
  17272. * _.mapValues(users, function(o) { return o.age; });
  17273. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  17274. *
  17275. * // The `_.property` iteratee shorthand.
  17276. * _.mapValues(users, 'age');
  17277. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  17278. */
  17279. function mapValues(object, iteratee) {
  17280. var result = {};
  17281. iteratee = getIteratee(iteratee, 3);
  17282. baseForOwn(object, function(value, key, object) {
  17283. baseAssignValue(result, key, iteratee(value, key, object));
  17284. });
  17285. return result;
  17286. }
  17287. /**
  17288. * This method is like `_.assign` except that it recursively merges own and
  17289. * inherited enumerable string keyed properties of source objects into the
  17290. * destination object. Source properties that resolve to `undefined` are
  17291. * skipped if a destination value exists. Array and plain object properties
  17292. * are merged recursively. Other objects and value types are overridden by
  17293. * assignment. Source objects are applied from left to right. Subsequent
  17294. * sources overwrite property assignments of previous sources.
  17295. *
  17296. * **Note:** This method mutates `object`.
  17297. *
  17298. * @static
  17299. * @memberOf _
  17300. * @since 0.5.0
  17301. * @category Object
  17302. * @param {Object} object The destination object.
  17303. * @param {...Object} [sources] The source objects.
  17304. * @returns {Object} Returns `object`.
  17305. * @example
  17306. *
  17307. * var object = {
  17308. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  17309. * };
  17310. *
  17311. * var other = {
  17312. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  17313. * };
  17314. *
  17315. * _.merge(object, other);
  17316. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  17317. */
  17318. var merge = createAssigner(function(object, source, srcIndex) {
  17319. baseMerge(object, source, srcIndex);
  17320. });
  17321. /**
  17322. * This method is like `_.merge` except that it accepts `customizer` which
  17323. * is invoked to produce the merged values of the destination and source
  17324. * properties. If `customizer` returns `undefined`, merging is handled by the
  17325. * method instead. The `customizer` is invoked with six arguments:
  17326. * (objValue, srcValue, key, object, source, stack).
  17327. *
  17328. * **Note:** This method mutates `object`.
  17329. *
  17330. * @static
  17331. * @memberOf _
  17332. * @since 4.0.0
  17333. * @category Object
  17334. * @param {Object} object The destination object.
  17335. * @param {...Object} sources The source objects.
  17336. * @param {Function} customizer The function to customize assigned values.
  17337. * @returns {Object} Returns `object`.
  17338. * @example
  17339. *
  17340. * function customizer(objValue, srcValue) {
  17341. * if (_.isArray(objValue)) {
  17342. * return objValue.concat(srcValue);
  17343. * }
  17344. * }
  17345. *
  17346. * var object = { 'a': [1], 'b': [2] };
  17347. * var other = { 'a': [3], 'b': [4] };
  17348. *
  17349. * _.mergeWith(object, other, customizer);
  17350. * // => { 'a': [1, 3], 'b': [2, 4] }
  17351. */
  17352. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  17353. baseMerge(object, source, srcIndex, customizer);
  17354. });
  17355. /**
  17356. * The opposite of `_.pick`; this method creates an object composed of the
  17357. * own and inherited enumerable property paths of `object` that are not omitted.
  17358. *
  17359. * **Note:** This method is considerably slower than `_.pick`.
  17360. *
  17361. * @static
  17362. * @since 0.1.0
  17363. * @memberOf _
  17364. * @category Object
  17365. * @param {Object} object The source object.
  17366. * @param {...(string|string[])} [paths] The property paths to omit.
  17367. * @returns {Object} Returns the new object.
  17368. * @example
  17369. *
  17370. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17371. *
  17372. * _.omit(object, ['a', 'c']);
  17373. * // => { 'b': '2' }
  17374. */
  17375. var omit = flatRest(function(object, paths) {
  17376. var result = {};
  17377. if (object == null) {
  17378. return result;
  17379. }
  17380. var isDeep = false;
  17381. paths = arrayMap(paths, function(path) {
  17382. path = castPath(path, object);
  17383. isDeep || (isDeep = path.length > 1);
  17384. return path;
  17385. });
  17386. copyObject(object, getAllKeysIn(object), result);
  17387. if (isDeep) {
  17388. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  17389. }
  17390. var length = paths.length;
  17391. while (length--) {
  17392. baseUnset(result, paths[length]);
  17393. }
  17394. return result;
  17395. });
  17396. /**
  17397. * The opposite of `_.pickBy`; this method creates an object composed of
  17398. * the own and inherited enumerable string keyed properties of `object` that
  17399. * `predicate` doesn't return truthy for. The predicate is invoked with two
  17400. * arguments: (value, key).
  17401. *
  17402. * @static
  17403. * @memberOf _
  17404. * @since 4.0.0
  17405. * @category Object
  17406. * @param {Object} object The source object.
  17407. * @param {Function} [predicate=_.identity] The function invoked per property.
  17408. * @returns {Object} Returns the new object.
  17409. * @example
  17410. *
  17411. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17412. *
  17413. * _.omitBy(object, _.isNumber);
  17414. * // => { 'b': '2' }
  17415. */
  17416. function omitBy(object, predicate) {
  17417. return pickBy(object, negate(getIteratee(predicate)));
  17418. }
  17419. /**
  17420. * Creates an object composed of the picked `object` properties.
  17421. *
  17422. * @static
  17423. * @since 0.1.0
  17424. * @memberOf _
  17425. * @category Object
  17426. * @param {Object} object The source object.
  17427. * @param {...(string|string[])} [paths] The property paths to pick.
  17428. * @returns {Object} Returns the new object.
  17429. * @example
  17430. *
  17431. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17432. *
  17433. * _.pick(object, ['a', 'c']);
  17434. * // => { 'a': 1, 'c': 3 }
  17435. */
  17436. var pick = flatRest(function(object, paths) {
  17437. return object == null ? {} : basePick(object, paths);
  17438. });
  17439. /**
  17440. * Creates an object composed of the `object` properties `predicate` returns
  17441. * truthy for. The predicate is invoked with two arguments: (value, key).
  17442. *
  17443. * @static
  17444. * @memberOf _
  17445. * @since 4.0.0
  17446. * @category Object
  17447. * @param {Object} object The source object.
  17448. * @param {Function} [predicate=_.identity] The function invoked per property.
  17449. * @returns {Object} Returns the new object.
  17450. * @example
  17451. *
  17452. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17453. *
  17454. * _.pickBy(object, _.isNumber);
  17455. * // => { 'a': 1, 'c': 3 }
  17456. */
  17457. function pickBy(object, predicate) {
  17458. if (object == null) {
  17459. return {};
  17460. }
  17461. var props = arrayMap(getAllKeysIn(object), function(prop) {
  17462. return [prop];
  17463. });
  17464. predicate = getIteratee(predicate);
  17465. return basePickBy(object, props, function(value, path) {
  17466. return predicate(value, path[0]);
  17467. });
  17468. }
  17469. /**
  17470. * This method is like `_.get` except that if the resolved value is a
  17471. * function it's invoked with the `this` binding of its parent object and
  17472. * its result is returned.
  17473. *
  17474. * @static
  17475. * @since 0.1.0
  17476. * @memberOf _
  17477. * @category Object
  17478. * @param {Object} object The object to query.
  17479. * @param {Array|string} path The path of the property to resolve.
  17480. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  17481. * @returns {*} Returns the resolved value.
  17482. * @example
  17483. *
  17484. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  17485. *
  17486. * _.result(object, 'a[0].b.c1');
  17487. * // => 3
  17488. *
  17489. * _.result(object, 'a[0].b.c2');
  17490. * // => 4
  17491. *
  17492. * _.result(object, 'a[0].b.c3', 'default');
  17493. * // => 'default'
  17494. *
  17495. * _.result(object, 'a[0].b.c3', _.constant('default'));
  17496. * // => 'default'
  17497. */
  17498. function result(object, path, defaultValue) {
  17499. path = castPath(path, object);
  17500. var index = -1,
  17501. length = path.length;
  17502. // Ensure the loop is entered when path is empty.
  17503. if (!length) {
  17504. length = 1;
  17505. object = undefined;
  17506. }
  17507. while (++index < length) {
  17508. var value = object == null ? undefined : object[toKey(path[index])];
  17509. if (value === undefined) {
  17510. index = length;
  17511. value = defaultValue;
  17512. }
  17513. object = isFunction(value) ? value.call(object) : value;
  17514. }
  17515. return object;
  17516. }
  17517. /**
  17518. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  17519. * it's created. Arrays are created for missing index properties while objects
  17520. * are created for all other missing properties. Use `_.setWith` to customize
  17521. * `path` creation.
  17522. *
  17523. * **Note:** This method mutates `object`.
  17524. *
  17525. * @static
  17526. * @memberOf _
  17527. * @since 3.7.0
  17528. * @category Object
  17529. * @param {Object} object The object to modify.
  17530. * @param {Array|string} path The path of the property to set.
  17531. * @param {*} value The value to set.
  17532. * @returns {Object} Returns `object`.
  17533. * @example
  17534. *
  17535. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17536. *
  17537. * _.set(object, 'a[0].b.c', 4);
  17538. * console.log(object.a[0].b.c);
  17539. * // => 4
  17540. *
  17541. * _.set(object, ['x', '0', 'y', 'z'], 5);
  17542. * console.log(object.x[0].y.z);
  17543. * // => 5
  17544. */
  17545. function set(object, path, value) {
  17546. return object == null ? object : baseSet(object, path, value);
  17547. }
  17548. /**
  17549. * This method is like `_.set` except that it accepts `customizer` which is
  17550. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  17551. * path creation is handled by the method instead. The `customizer` is invoked
  17552. * with three arguments: (nsValue, key, nsObject).
  17553. *
  17554. * **Note:** This method mutates `object`.
  17555. *
  17556. * @static
  17557. * @memberOf _
  17558. * @since 4.0.0
  17559. * @category Object
  17560. * @param {Object} object The object to modify.
  17561. * @param {Array|string} path The path of the property to set.
  17562. * @param {*} value The value to set.
  17563. * @param {Function} [customizer] The function to customize assigned values.
  17564. * @returns {Object} Returns `object`.
  17565. * @example
  17566. *
  17567. * var object = {};
  17568. *
  17569. * _.setWith(object, '[0][1]', 'a', Object);
  17570. * // => { '0': { '1': 'a' } }
  17571. */
  17572. function setWith(object, path, value, customizer) {
  17573. customizer = typeof customizer == 'function' ? customizer : undefined;
  17574. return object == null ? object : baseSet(object, path, value, customizer);
  17575. }
  17576. /**
  17577. * Creates an array of own enumerable string keyed-value pairs for `object`
  17578. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  17579. * entries are returned.
  17580. *
  17581. * @static
  17582. * @memberOf _
  17583. * @since 4.0.0
  17584. * @alias entries
  17585. * @category Object
  17586. * @param {Object} object The object to query.
  17587. * @returns {Array} Returns the key-value pairs.
  17588. * @example
  17589. *
  17590. * function Foo() {
  17591. * this.a = 1;
  17592. * this.b = 2;
  17593. * }
  17594. *
  17595. * Foo.prototype.c = 3;
  17596. *
  17597. * _.toPairs(new Foo);
  17598. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  17599. */
  17600. var toPairs = createToPairs(keys);
  17601. /**
  17602. * Creates an array of own and inherited enumerable string keyed-value pairs
  17603. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  17604. * or set, its entries are returned.
  17605. *
  17606. * @static
  17607. * @memberOf _
  17608. * @since 4.0.0
  17609. * @alias entriesIn
  17610. * @category Object
  17611. * @param {Object} object The object to query.
  17612. * @returns {Array} Returns the key-value pairs.
  17613. * @example
  17614. *
  17615. * function Foo() {
  17616. * this.a = 1;
  17617. * this.b = 2;
  17618. * }
  17619. *
  17620. * Foo.prototype.c = 3;
  17621. *
  17622. * _.toPairsIn(new Foo);
  17623. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  17624. */
  17625. var toPairsIn = createToPairs(keysIn);
  17626. /**
  17627. * An alternative to `_.reduce`; this method transforms `object` to a new
  17628. * `accumulator` object which is the result of running each of its own
  17629. * enumerable string keyed properties thru `iteratee`, with each invocation
  17630. * potentially mutating the `accumulator` object. If `accumulator` is not
  17631. * provided, a new object with the same `[[Prototype]]` will be used. The
  17632. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  17633. * Iteratee functions may exit iteration early by explicitly returning `false`.
  17634. *
  17635. * @static
  17636. * @memberOf _
  17637. * @since 1.3.0
  17638. * @category Object
  17639. * @param {Object} object The object to iterate over.
  17640. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17641. * @param {*} [accumulator] The custom accumulator value.
  17642. * @returns {*} Returns the accumulated value.
  17643. * @example
  17644. *
  17645. * _.transform([2, 3, 4], function(result, n) {
  17646. * result.push(n *= n);
  17647. * return n % 2 == 0;
  17648. * }, []);
  17649. * // => [4, 9]
  17650. *
  17651. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  17652. * (result[value] || (result[value] = [])).push(key);
  17653. * }, {});
  17654. * // => { '1': ['a', 'c'], '2': ['b'] }
  17655. */
  17656. function transform(object, iteratee, accumulator) {
  17657. var isArr = isArray(object),
  17658. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  17659. iteratee = getIteratee(iteratee, 4);
  17660. if (accumulator == null) {
  17661. var Ctor = object && object.constructor;
  17662. if (isArrLike) {
  17663. accumulator = isArr ? new Ctor : [];
  17664. }
  17665. else if (isObject(object)) {
  17666. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  17667. }
  17668. else {
  17669. accumulator = {};
  17670. }
  17671. }
  17672. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  17673. return iteratee(accumulator, value, index, object);
  17674. });
  17675. return accumulator;
  17676. }
  17677. /**
  17678. * Removes the property at `path` of `object`.
  17679. *
  17680. * **Note:** This method mutates `object`.
  17681. *
  17682. * @static
  17683. * @memberOf _
  17684. * @since 4.0.0
  17685. * @category Object
  17686. * @param {Object} object The object to modify.
  17687. * @param {Array|string} path The path of the property to unset.
  17688. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17689. * @example
  17690. *
  17691. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  17692. * _.unset(object, 'a[0].b.c');
  17693. * // => true
  17694. *
  17695. * console.log(object);
  17696. * // => { 'a': [{ 'b': {} }] };
  17697. *
  17698. * _.unset(object, ['a', '0', 'b', 'c']);
  17699. * // => true
  17700. *
  17701. * console.log(object);
  17702. * // => { 'a': [{ 'b': {} }] };
  17703. */
  17704. function unset(object, path) {
  17705. return object == null ? true : baseUnset(object, path);
  17706. }
  17707. /**
  17708. * This method is like `_.set` except that accepts `updater` to produce the
  17709. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  17710. * is invoked with one argument: (value).
  17711. *
  17712. * **Note:** This method mutates `object`.
  17713. *
  17714. * @static
  17715. * @memberOf _
  17716. * @since 4.6.0
  17717. * @category Object
  17718. * @param {Object} object The object to modify.
  17719. * @param {Array|string} path The path of the property to set.
  17720. * @param {Function} updater The function to produce the updated value.
  17721. * @returns {Object} Returns `object`.
  17722. * @example
  17723. *
  17724. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17725. *
  17726. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  17727. * console.log(object.a[0].b.c);
  17728. * // => 9
  17729. *
  17730. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  17731. * console.log(object.x[0].y.z);
  17732. * // => 0
  17733. */
  17734. function update(object, path, updater) {
  17735. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  17736. }
  17737. /**
  17738. * This method is like `_.update` except that it accepts `customizer` which is
  17739. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  17740. * path creation is handled by the method instead. The `customizer` is invoked
  17741. * with three arguments: (nsValue, key, nsObject).
  17742. *
  17743. * **Note:** This method mutates `object`.
  17744. *
  17745. * @static
  17746. * @memberOf _
  17747. * @since 4.6.0
  17748. * @category Object
  17749. * @param {Object} object The object to modify.
  17750. * @param {Array|string} path The path of the property to set.
  17751. * @param {Function} updater The function to produce the updated value.
  17752. * @param {Function} [customizer] The function to customize assigned values.
  17753. * @returns {Object} Returns `object`.
  17754. * @example
  17755. *
  17756. * var object = {};
  17757. *
  17758. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  17759. * // => { '0': { '1': 'a' } }
  17760. */
  17761. function updateWith(object, path, updater, customizer) {
  17762. customizer = typeof customizer == 'function' ? customizer : undefined;
  17763. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  17764. }
  17765. /**
  17766. * Creates an array of the own enumerable string keyed property values of `object`.
  17767. *
  17768. * **Note:** Non-object values are coerced to objects.
  17769. *
  17770. * @static
  17771. * @since 0.1.0
  17772. * @memberOf _
  17773. * @category Object
  17774. * @param {Object} object The object to query.
  17775. * @returns {Array} Returns the array of property values.
  17776. * @example
  17777. *
  17778. * function Foo() {
  17779. * this.a = 1;
  17780. * this.b = 2;
  17781. * }
  17782. *
  17783. * Foo.prototype.c = 3;
  17784. *
  17785. * _.values(new Foo);
  17786. * // => [1, 2] (iteration order is not guaranteed)
  17787. *
  17788. * _.values('hi');
  17789. * // => ['h', 'i']
  17790. */
  17791. function values(object) {
  17792. return object == null ? [] : baseValues(object, keys(object));
  17793. }
  17794. /**
  17795. * Creates an array of the own and inherited enumerable string keyed property
  17796. * values of `object`.
  17797. *
  17798. * **Note:** Non-object values are coerced to objects.
  17799. *
  17800. * @static
  17801. * @memberOf _
  17802. * @since 3.0.0
  17803. * @category Object
  17804. * @param {Object} object The object to query.
  17805. * @returns {Array} Returns the array of property values.
  17806. * @example
  17807. *
  17808. * function Foo() {
  17809. * this.a = 1;
  17810. * this.b = 2;
  17811. * }
  17812. *
  17813. * Foo.prototype.c = 3;
  17814. *
  17815. * _.valuesIn(new Foo);
  17816. * // => [1, 2, 3] (iteration order is not guaranteed)
  17817. */
  17818. function valuesIn(object) {
  17819. return object == null ? [] : baseValues(object, keysIn(object));
  17820. }
  17821. /*------------------------------------------------------------------------*/
  17822. /**
  17823. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  17824. *
  17825. * @static
  17826. * @memberOf _
  17827. * @since 4.0.0
  17828. * @category Number
  17829. * @param {number} number The number to clamp.
  17830. * @param {number} [lower] The lower bound.
  17831. * @param {number} upper The upper bound.
  17832. * @returns {number} Returns the clamped number.
  17833. * @example
  17834. *
  17835. * _.clamp(-10, -5, 5);
  17836. * // => -5
  17837. *
  17838. * _.clamp(10, -5, 5);
  17839. * // => 5
  17840. */
  17841. function clamp(number, lower, upper) {
  17842. if (upper === undefined) {
  17843. upper = lower;
  17844. lower = undefined;
  17845. }
  17846. if (upper !== undefined) {
  17847. upper = toNumber(upper);
  17848. upper = upper === upper ? upper : 0;
  17849. }
  17850. if (lower !== undefined) {
  17851. lower = toNumber(lower);
  17852. lower = lower === lower ? lower : 0;
  17853. }
  17854. return baseClamp(toNumber(number), lower, upper);
  17855. }
  17856. /**
  17857. * Checks if `n` is between `start` and up to, but not including, `end`. If
  17858. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  17859. * If `start` is greater than `end` the params are swapped to support
  17860. * negative ranges.
  17861. *
  17862. * @static
  17863. * @memberOf _
  17864. * @since 3.3.0
  17865. * @category Number
  17866. * @param {number} number The number to check.
  17867. * @param {number} [start=0] The start of the range.
  17868. * @param {number} end The end of the range.
  17869. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  17870. * @see _.range, _.rangeRight
  17871. * @example
  17872. *
  17873. * _.inRange(3, 2, 4);
  17874. * // => true
  17875. *
  17876. * _.inRange(4, 8);
  17877. * // => true
  17878. *
  17879. * _.inRange(4, 2);
  17880. * // => false
  17881. *
  17882. * _.inRange(2, 2);
  17883. * // => false
  17884. *
  17885. * _.inRange(1.2, 2);
  17886. * // => true
  17887. *
  17888. * _.inRange(5.2, 4);
  17889. * // => false
  17890. *
  17891. * _.inRange(-3, -2, -6);
  17892. * // => true
  17893. */
  17894. function inRange(number, start, end) {
  17895. start = toFinite(start);
  17896. if (end === undefined) {
  17897. end = start;
  17898. start = 0;
  17899. } else {
  17900. end = toFinite(end);
  17901. }
  17902. number = toNumber(number);
  17903. return baseInRange(number, start, end);
  17904. }
  17905. /**
  17906. * Produces a random number between the inclusive `lower` and `upper` bounds.
  17907. * If only one argument is provided a number between `0` and the given number
  17908. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  17909. * floats, a floating-point number is returned instead of an integer.
  17910. *
  17911. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  17912. * floating-point values which can produce unexpected results.
  17913. *
  17914. * @static
  17915. * @memberOf _
  17916. * @since 0.7.0
  17917. * @category Number
  17918. * @param {number} [lower=0] The lower bound.
  17919. * @param {number} [upper=1] The upper bound.
  17920. * @param {boolean} [floating] Specify returning a floating-point number.
  17921. * @returns {number} Returns the random number.
  17922. * @example
  17923. *
  17924. * _.random(0, 5);
  17925. * // => an integer between 0 and 5
  17926. *
  17927. * _.random(5);
  17928. * // => also an integer between 0 and 5
  17929. *
  17930. * _.random(5, true);
  17931. * // => a floating-point number between 0 and 5
  17932. *
  17933. * _.random(1.2, 5.2);
  17934. * // => a floating-point number between 1.2 and 5.2
  17935. */
  17936. function random(lower, upper, floating) {
  17937. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  17938. upper = floating = undefined;
  17939. }
  17940. if (floating === undefined) {
  17941. if (typeof upper == 'boolean') {
  17942. floating = upper;
  17943. upper = undefined;
  17944. }
  17945. else if (typeof lower == 'boolean') {
  17946. floating = lower;
  17947. lower = undefined;
  17948. }
  17949. }
  17950. if (lower === undefined && upper === undefined) {
  17951. lower = 0;
  17952. upper = 1;
  17953. }
  17954. else {
  17955. lower = toFinite(lower);
  17956. if (upper === undefined) {
  17957. upper = lower;
  17958. lower = 0;
  17959. } else {
  17960. upper = toFinite(upper);
  17961. }
  17962. }
  17963. if (lower > upper) {
  17964. var temp = lower;
  17965. lower = upper;
  17966. upper = temp;
  17967. }
  17968. if (floating || lower % 1 || upper % 1) {
  17969. var rand = nativeRandom();
  17970. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  17971. }
  17972. return baseRandom(lower, upper);
  17973. }
  17974. /*------------------------------------------------------------------------*/
  17975. /**
  17976. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  17977. *
  17978. * @static
  17979. * @memberOf _
  17980. * @since 3.0.0
  17981. * @category String
  17982. * @param {string} [string=''] The string to convert.
  17983. * @returns {string} Returns the camel cased string.
  17984. * @example
  17985. *
  17986. * _.camelCase('Foo Bar');
  17987. * // => 'fooBar'
  17988. *
  17989. * _.camelCase('--foo-bar--');
  17990. * // => 'fooBar'
  17991. *
  17992. * _.camelCase('__FOO_BAR__');
  17993. * // => 'fooBar'
  17994. */
  17995. var camelCase = createCompounder(function(result, word, index) {
  17996. word = word.toLowerCase();
  17997. return result + (index ? capitalize(word) : word);
  17998. });
  17999. /**
  18000. * Converts the first character of `string` to upper case and the remaining
  18001. * to lower case.
  18002. *
  18003. * @static
  18004. * @memberOf _
  18005. * @since 3.0.0
  18006. * @category String
  18007. * @param {string} [string=''] The string to capitalize.
  18008. * @returns {string} Returns the capitalized string.
  18009. * @example
  18010. *
  18011. * _.capitalize('FRED');
  18012. * // => 'Fred'
  18013. */
  18014. function capitalize(string) {
  18015. return upperFirst(toString(string).toLowerCase());
  18016. }
  18017. /**
  18018. * Deburrs `string` by converting
  18019. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  18020. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  18021. * letters to basic Latin letters and removing
  18022. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  18023. *
  18024. * @static
  18025. * @memberOf _
  18026. * @since 3.0.0
  18027. * @category String
  18028. * @param {string} [string=''] The string to deburr.
  18029. * @returns {string} Returns the deburred string.
  18030. * @example
  18031. *
  18032. * _.deburr('déjà vu');
  18033. * // => 'deja vu'
  18034. */
  18035. function deburr(string) {
  18036. string = toString(string);
  18037. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  18038. }
  18039. /**
  18040. * Checks if `string` ends with the given target string.
  18041. *
  18042. * @static
  18043. * @memberOf _
  18044. * @since 3.0.0
  18045. * @category String
  18046. * @param {string} [string=''] The string to inspect.
  18047. * @param {string} [target] The string to search for.
  18048. * @param {number} [position=string.length] The position to search up to.
  18049. * @returns {boolean} Returns `true` if `string` ends with `target`,
  18050. * else `false`.
  18051. * @example
  18052. *
  18053. * _.endsWith('abc', 'c');
  18054. * // => true
  18055. *
  18056. * _.endsWith('abc', 'b');
  18057. * // => false
  18058. *
  18059. * _.endsWith('abc', 'b', 2);
  18060. * // => true
  18061. */
  18062. function endsWith(string, target, position) {
  18063. string = toString(string);
  18064. target = baseToString(target);
  18065. var length = string.length;
  18066. position = position === undefined
  18067. ? length
  18068. : baseClamp(toInteger(position), 0, length);
  18069. var end = position;
  18070. position -= target.length;
  18071. return position >= 0 && string.slice(position, end) == target;
  18072. }
  18073. /**
  18074. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  18075. * corresponding HTML entities.
  18076. *
  18077. * **Note:** No other characters are escaped. To escape additional
  18078. * characters use a third-party library like [_he_](https://mths.be/he).
  18079. *
  18080. * Though the ">" character is escaped for symmetry, characters like
  18081. * ">" and "/" don't need escaping in HTML and have no special meaning
  18082. * unless they're part of a tag or unquoted attribute value. See
  18083. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  18084. * (under "semi-related fun fact") for more details.
  18085. *
  18086. * When working with HTML you should always
  18087. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  18088. * XSS vectors.
  18089. *
  18090. * @static
  18091. * @since 0.1.0
  18092. * @memberOf _
  18093. * @category String
  18094. * @param {string} [string=''] The string to escape.
  18095. * @returns {string} Returns the escaped string.
  18096. * @example
  18097. *
  18098. * _.escape('fred, barney, & pebbles');
  18099. * // => 'fred, barney, &amp; pebbles'
  18100. */
  18101. function escape(string) {
  18102. string = toString(string);
  18103. return (string && reHasUnescapedHtml.test(string))
  18104. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  18105. : string;
  18106. }
  18107. /**
  18108. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  18109. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  18110. *
  18111. * @static
  18112. * @memberOf _
  18113. * @since 3.0.0
  18114. * @category String
  18115. * @param {string} [string=''] The string to escape.
  18116. * @returns {string} Returns the escaped string.
  18117. * @example
  18118. *
  18119. * _.escapeRegExp('[lodash](https://lodash.com/)');
  18120. * // => '\[lodash\]\(https://lodash\.com/\)'
  18121. */
  18122. function escapeRegExp(string) {
  18123. string = toString(string);
  18124. return (string && reHasRegExpChar.test(string))
  18125. ? string.replace(reRegExpChar, '\\$&')
  18126. : string;
  18127. }
  18128. /**
  18129. * Converts `string` to
  18130. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  18131. *
  18132. * @static
  18133. * @memberOf _
  18134. * @since 3.0.0
  18135. * @category String
  18136. * @param {string} [string=''] The string to convert.
  18137. * @returns {string} Returns the kebab cased string.
  18138. * @example
  18139. *
  18140. * _.kebabCase('Foo Bar');
  18141. * // => 'foo-bar'
  18142. *
  18143. * _.kebabCase('fooBar');
  18144. * // => 'foo-bar'
  18145. *
  18146. * _.kebabCase('__FOO_BAR__');
  18147. * // => 'foo-bar'
  18148. */
  18149. var kebabCase = createCompounder(function(result, word, index) {
  18150. return result + (index ? '-' : '') + word.toLowerCase();
  18151. });
  18152. /**
  18153. * Converts `string`, as space separated words, to lower case.
  18154. *
  18155. * @static
  18156. * @memberOf _
  18157. * @since 4.0.0
  18158. * @category String
  18159. * @param {string} [string=''] The string to convert.
  18160. * @returns {string} Returns the lower cased string.
  18161. * @example
  18162. *
  18163. * _.lowerCase('--Foo-Bar--');
  18164. * // => 'foo bar'
  18165. *
  18166. * _.lowerCase('fooBar');
  18167. * // => 'foo bar'
  18168. *
  18169. * _.lowerCase('__FOO_BAR__');
  18170. * // => 'foo bar'
  18171. */
  18172. var lowerCase = createCompounder(function(result, word, index) {
  18173. return result + (index ? ' ' : '') + word.toLowerCase();
  18174. });
  18175. /**
  18176. * Converts the first character of `string` to lower case.
  18177. *
  18178. * @static
  18179. * @memberOf _
  18180. * @since 4.0.0
  18181. * @category String
  18182. * @param {string} [string=''] The string to convert.
  18183. * @returns {string} Returns the converted string.
  18184. * @example
  18185. *
  18186. * _.lowerFirst('Fred');
  18187. * // => 'fred'
  18188. *
  18189. * _.lowerFirst('FRED');
  18190. * // => 'fRED'
  18191. */
  18192. var lowerFirst = createCaseFirst('toLowerCase');
  18193. /**
  18194. * Pads `string` on the left and right sides if it's shorter than `length`.
  18195. * Padding characters are truncated if they can't be evenly divided by `length`.
  18196. *
  18197. * @static
  18198. * @memberOf _
  18199. * @since 3.0.0
  18200. * @category String
  18201. * @param {string} [string=''] The string to pad.
  18202. * @param {number} [length=0] The padding length.
  18203. * @param {string} [chars=' '] The string used as padding.
  18204. * @returns {string} Returns the padded string.
  18205. * @example
  18206. *
  18207. * _.pad('abc', 8);
  18208. * // => ' abc '
  18209. *
  18210. * _.pad('abc', 8, '_-');
  18211. * // => '_-abc_-_'
  18212. *
  18213. * _.pad('abc', 3);
  18214. * // => 'abc'
  18215. */
  18216. function pad(string, length, chars) {
  18217. string = toString(string);
  18218. length = toInteger(length);
  18219. var strLength = length ? stringSize(string) : 0;
  18220. if (!length || strLength >= length) {
  18221. return string;
  18222. }
  18223. var mid = (length - strLength) / 2;
  18224. return (
  18225. createPadding(nativeFloor(mid), chars) +
  18226. string +
  18227. createPadding(nativeCeil(mid), chars)
  18228. );
  18229. }
  18230. /**
  18231. * Pads `string` on the right side if it's shorter than `length`. Padding
  18232. * characters are truncated if they exceed `length`.
  18233. *
  18234. * @static
  18235. * @memberOf _
  18236. * @since 4.0.0
  18237. * @category String
  18238. * @param {string} [string=''] The string to pad.
  18239. * @param {number} [length=0] The padding length.
  18240. * @param {string} [chars=' '] The string used as padding.
  18241. * @returns {string} Returns the padded string.
  18242. * @example
  18243. *
  18244. * _.padEnd('abc', 6);
  18245. * // => 'abc '
  18246. *
  18247. * _.padEnd('abc', 6, '_-');
  18248. * // => 'abc_-_'
  18249. *
  18250. * _.padEnd('abc', 3);
  18251. * // => 'abc'
  18252. */
  18253. function padEnd(string, length, chars) {
  18254. string = toString(string);
  18255. length = toInteger(length);
  18256. var strLength = length ? stringSize(string) : 0;
  18257. return (length && strLength < length)
  18258. ? (string + createPadding(length - strLength, chars))
  18259. : string;
  18260. }
  18261. /**
  18262. * Pads `string` on the left side if it's shorter than `length`. Padding
  18263. * characters are truncated if they exceed `length`.
  18264. *
  18265. * @static
  18266. * @memberOf _
  18267. * @since 4.0.0
  18268. * @category String
  18269. * @param {string} [string=''] The string to pad.
  18270. * @param {number} [length=0] The padding length.
  18271. * @param {string} [chars=' '] The string used as padding.
  18272. * @returns {string} Returns the padded string.
  18273. * @example
  18274. *
  18275. * _.padStart('abc', 6);
  18276. * // => ' abc'
  18277. *
  18278. * _.padStart('abc', 6, '_-');
  18279. * // => '_-_abc'
  18280. *
  18281. * _.padStart('abc', 3);
  18282. * // => 'abc'
  18283. */
  18284. function padStart(string, length, chars) {
  18285. string = toString(string);
  18286. length = toInteger(length);
  18287. var strLength = length ? stringSize(string) : 0;
  18288. return (length && strLength < length)
  18289. ? (createPadding(length - strLength, chars) + string)
  18290. : string;
  18291. }
  18292. /**
  18293. * Converts `string` to an integer of the specified radix. If `radix` is
  18294. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  18295. * hexadecimal, in which case a `radix` of `16` is used.
  18296. *
  18297. * **Note:** This method aligns with the
  18298. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  18299. *
  18300. * @static
  18301. * @memberOf _
  18302. * @since 1.1.0
  18303. * @category String
  18304. * @param {string} string The string to convert.
  18305. * @param {number} [radix=10] The radix to interpret `value` by.
  18306. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18307. * @returns {number} Returns the converted integer.
  18308. * @example
  18309. *
  18310. * _.parseInt('08');
  18311. * // => 8
  18312. *
  18313. * _.map(['6', '08', '10'], _.parseInt);
  18314. * // => [6, 8, 10]
  18315. */
  18316. function parseInt(string, radix, guard) {
  18317. if (guard || radix == null) {
  18318. radix = 0;
  18319. } else if (radix) {
  18320. radix = +radix;
  18321. }
  18322. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  18323. }
  18324. /**
  18325. * Repeats the given string `n` times.
  18326. *
  18327. * @static
  18328. * @memberOf _
  18329. * @since 3.0.0
  18330. * @category String
  18331. * @param {string} [string=''] The string to repeat.
  18332. * @param {number} [n=1] The number of times to repeat the string.
  18333. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18334. * @returns {string} Returns the repeated string.
  18335. * @example
  18336. *
  18337. * _.repeat('*', 3);
  18338. * // => '***'
  18339. *
  18340. * _.repeat('abc', 2);
  18341. * // => 'abcabc'
  18342. *
  18343. * _.repeat('abc', 0);
  18344. * // => ''
  18345. */
  18346. function repeat(string, n, guard) {
  18347. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  18348. n = 1;
  18349. } else {
  18350. n = toInteger(n);
  18351. }
  18352. return baseRepeat(toString(string), n);
  18353. }
  18354. /**
  18355. * Replaces matches for `pattern` in `string` with `replacement`.
  18356. *
  18357. * **Note:** This method is based on
  18358. * [`String#replace`](https://mdn.io/String/replace).
  18359. *
  18360. * @static
  18361. * @memberOf _
  18362. * @since 4.0.0
  18363. * @category String
  18364. * @param {string} [string=''] The string to modify.
  18365. * @param {RegExp|string} pattern The pattern to replace.
  18366. * @param {Function|string} replacement The match replacement.
  18367. * @returns {string} Returns the modified string.
  18368. * @example
  18369. *
  18370. * _.replace('Hi Fred', 'Fred', 'Barney');
  18371. * // => 'Hi Barney'
  18372. */
  18373. function replace() {
  18374. var args = arguments,
  18375. string = toString(args[0]);
  18376. return args.length < 3 ? string : string.replace(args[1], args[2]);
  18377. }
  18378. /**
  18379. * Converts `string` to
  18380. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  18381. *
  18382. * @static
  18383. * @memberOf _
  18384. * @since 3.0.0
  18385. * @category String
  18386. * @param {string} [string=''] The string to convert.
  18387. * @returns {string} Returns the snake cased string.
  18388. * @example
  18389. *
  18390. * _.snakeCase('Foo Bar');
  18391. * // => 'foo_bar'
  18392. *
  18393. * _.snakeCase('fooBar');
  18394. * // => 'foo_bar'
  18395. *
  18396. * _.snakeCase('--FOO-BAR--');
  18397. * // => 'foo_bar'
  18398. */
  18399. var snakeCase = createCompounder(function(result, word, index) {
  18400. return result + (index ? '_' : '') + word.toLowerCase();
  18401. });
  18402. /**
  18403. * Splits `string` by `separator`.
  18404. *
  18405. * **Note:** This method is based on
  18406. * [`String#split`](https://mdn.io/String/split).
  18407. *
  18408. * @static
  18409. * @memberOf _
  18410. * @since 4.0.0
  18411. * @category String
  18412. * @param {string} [string=''] The string to split.
  18413. * @param {RegExp|string} separator The separator pattern to split by.
  18414. * @param {number} [limit] The length to truncate results to.
  18415. * @returns {Array} Returns the string segments.
  18416. * @example
  18417. *
  18418. * _.split('a-b-c', '-', 2);
  18419. * // => ['a', 'b']
  18420. */
  18421. function split(string, separator, limit) {
  18422. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  18423. separator = limit = undefined;
  18424. }
  18425. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  18426. if (!limit) {
  18427. return [];
  18428. }
  18429. string = toString(string);
  18430. if (string && (
  18431. typeof separator == 'string' ||
  18432. (separator != null && !isRegExp(separator))
  18433. )) {
  18434. separator = baseToString(separator);
  18435. if (!separator && hasUnicode(string)) {
  18436. return castSlice(stringToArray(string), 0, limit);
  18437. }
  18438. }
  18439. return string.split(separator, limit);
  18440. }
  18441. /**
  18442. * Converts `string` to
  18443. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  18444. *
  18445. * @static
  18446. * @memberOf _
  18447. * @since 3.1.0
  18448. * @category String
  18449. * @param {string} [string=''] The string to convert.
  18450. * @returns {string} Returns the start cased string.
  18451. * @example
  18452. *
  18453. * _.startCase('--foo-bar--');
  18454. * // => 'Foo Bar'
  18455. *
  18456. * _.startCase('fooBar');
  18457. * // => 'Foo Bar'
  18458. *
  18459. * _.startCase('__FOO_BAR__');
  18460. * // => 'FOO BAR'
  18461. */
  18462. var startCase = createCompounder(function(result, word, index) {
  18463. return result + (index ? ' ' : '') + upperFirst(word);
  18464. });
  18465. /**
  18466. * Checks if `string` starts with the given target string.
  18467. *
  18468. * @static
  18469. * @memberOf _
  18470. * @since 3.0.0
  18471. * @category String
  18472. * @param {string} [string=''] The string to inspect.
  18473. * @param {string} [target] The string to search for.
  18474. * @param {number} [position=0] The position to search from.
  18475. * @returns {boolean} Returns `true` if `string` starts with `target`,
  18476. * else `false`.
  18477. * @example
  18478. *
  18479. * _.startsWith('abc', 'a');
  18480. * // => true
  18481. *
  18482. * _.startsWith('abc', 'b');
  18483. * // => false
  18484. *
  18485. * _.startsWith('abc', 'b', 1);
  18486. * // => true
  18487. */
  18488. function startsWith(string, target, position) {
  18489. string = toString(string);
  18490. position = position == null
  18491. ? 0
  18492. : baseClamp(toInteger(position), 0, string.length);
  18493. target = baseToString(target);
  18494. return string.slice(position, position + target.length) == target;
  18495. }
  18496. /**
  18497. * Creates a compiled template function that can interpolate data properties
  18498. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  18499. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  18500. * properties may be accessed as free variables in the template. If a setting
  18501. * object is given, it takes precedence over `_.templateSettings` values.
  18502. *
  18503. * **Note:** In the development build `_.template` utilizes
  18504. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  18505. * for easier debugging.
  18506. *
  18507. * For more information on precompiling templates see
  18508. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  18509. *
  18510. * For more information on Chrome extension sandboxes see
  18511. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  18512. *
  18513. * @static
  18514. * @since 0.1.0
  18515. * @memberOf _
  18516. * @category String
  18517. * @param {string} [string=''] The template string.
  18518. * @param {Object} [options={}] The options object.
  18519. * @param {RegExp} [options.escape=_.templateSettings.escape]
  18520. * The HTML "escape" delimiter.
  18521. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  18522. * The "evaluate" delimiter.
  18523. * @param {Object} [options.imports=_.templateSettings.imports]
  18524. * An object to import into the template as free variables.
  18525. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  18526. * The "interpolate" delimiter.
  18527. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  18528. * The sourceURL of the compiled template.
  18529. * @param {string} [options.variable='obj']
  18530. * The data object variable name.
  18531. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18532. * @returns {Function} Returns the compiled template function.
  18533. * @example
  18534. *
  18535. * // Use the "interpolate" delimiter to create a compiled template.
  18536. * var compiled = _.template('hello <%= user %>!');
  18537. * compiled({ 'user': 'fred' });
  18538. * // => 'hello fred!'
  18539. *
  18540. * // Use the HTML "escape" delimiter to escape data property values.
  18541. * var compiled = _.template('<b><%- value %></b>');
  18542. * compiled({ 'value': '<script>' });
  18543. * // => '<b>&lt;script&gt;</b>'
  18544. *
  18545. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  18546. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  18547. * compiled({ 'users': ['fred', 'barney'] });
  18548. * // => '<li>fred</li><li>barney</li>'
  18549. *
  18550. * // Use the internal `print` function in "evaluate" delimiters.
  18551. * var compiled = _.template('<% print("hello " + user); %>!');
  18552. * compiled({ 'user': 'barney' });
  18553. * // => 'hello barney!'
  18554. *
  18555. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  18556. * // Disable support by replacing the "interpolate" delimiter.
  18557. * var compiled = _.template('hello ${ user }!');
  18558. * compiled({ 'user': 'pebbles' });
  18559. * // => 'hello pebbles!'
  18560. *
  18561. * // Use backslashes to treat delimiters as plain text.
  18562. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  18563. * compiled({ 'value': 'ignored' });
  18564. * // => '<%- value %>'
  18565. *
  18566. * // Use the `imports` option to import `jQuery` as `jq`.
  18567. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  18568. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  18569. * compiled({ 'users': ['fred', 'barney'] });
  18570. * // => '<li>fred</li><li>barney</li>'
  18571. *
  18572. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  18573. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  18574. * compiled(data);
  18575. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  18576. *
  18577. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  18578. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  18579. * compiled.source;
  18580. * // => function(data) {
  18581. * // var __t, __p = '';
  18582. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  18583. * // return __p;
  18584. * // }
  18585. *
  18586. * // Use custom template delimiters.
  18587. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  18588. * var compiled = _.template('hello {{ user }}!');
  18589. * compiled({ 'user': 'mustache' });
  18590. * // => 'hello mustache!'
  18591. *
  18592. * // Use the `source` property to inline compiled templates for meaningful
  18593. * // line numbers in error messages and stack traces.
  18594. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  18595. * var JST = {\
  18596. * "main": ' + _.template(mainText).source + '\
  18597. * };\
  18598. * ');
  18599. */
  18600. function template(string, options, guard) {
  18601. // Based on John Resig's `tmpl` implementation
  18602. // (http://ejohn.org/blog/javascript-micro-templating/)
  18603. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  18604. var settings = lodash.templateSettings;
  18605. if (guard && isIterateeCall(string, options, guard)) {
  18606. options = undefined;
  18607. }
  18608. string = toString(string);
  18609. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  18610. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  18611. importsKeys = keys(imports),
  18612. importsValues = baseValues(imports, importsKeys);
  18613. var isEscaping,
  18614. isEvaluating,
  18615. index = 0,
  18616. interpolate = options.interpolate || reNoMatch,
  18617. source = "__p += '";
  18618. // Compile the regexp to match each delimiter.
  18619. var reDelimiters = RegExp(
  18620. (options.escape || reNoMatch).source + '|' +
  18621. interpolate.source + '|' +
  18622. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  18623. (options.evaluate || reNoMatch).source + '|$'
  18624. , 'g');
  18625. // Use a sourceURL for easier debugging.
  18626. // The sourceURL gets injected into the source that's eval-ed, so be careful
  18627. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  18628. // and escape the comment, thus injecting code that gets evaled.
  18629. var sourceURL = '//# sourceURL=' +
  18630. (hasOwnProperty.call(options, 'sourceURL')
  18631. ? (options.sourceURL + '').replace(/\s/g, ' ')
  18632. : ('lodash.templateSources[' + (++templateCounter) + ']')
  18633. ) + '\n';
  18634. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  18635. interpolateValue || (interpolateValue = esTemplateValue);
  18636. // Escape characters that can't be included in string literals.
  18637. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  18638. // Replace delimiters with snippets.
  18639. if (escapeValue) {
  18640. isEscaping = true;
  18641. source += "' +\n__e(" + escapeValue + ") +\n'";
  18642. }
  18643. if (evaluateValue) {
  18644. isEvaluating = true;
  18645. source += "';\n" + evaluateValue + ";\n__p += '";
  18646. }
  18647. if (interpolateValue) {
  18648. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  18649. }
  18650. index = offset + match.length;
  18651. // The JS engine embedded in Adobe products needs `match` returned in
  18652. // order to produce the correct `offset` value.
  18653. return match;
  18654. });
  18655. source += "';\n";
  18656. // If `variable` is not specified wrap a with-statement around the generated
  18657. // code to add the data object to the top of the scope chain.
  18658. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  18659. if (!variable) {
  18660. source = 'with (obj) {\n' + source + '\n}\n';
  18661. }
  18662. // Throw an error if a forbidden character was found in `variable`, to prevent
  18663. // potential command injection attacks.
  18664. else if (reForbiddenIdentifierChars.test(variable)) {
  18665. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  18666. }
  18667. // Cleanup code by stripping empty strings.
  18668. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  18669. .replace(reEmptyStringMiddle, '$1')
  18670. .replace(reEmptyStringTrailing, '$1;');
  18671. // Frame code as the function body.
  18672. source = 'function(' + (variable || 'obj') + ') {\n' +
  18673. (variable
  18674. ? ''
  18675. : 'obj || (obj = {});\n'
  18676. ) +
  18677. "var __t, __p = ''" +
  18678. (isEscaping
  18679. ? ', __e = _.escape'
  18680. : ''
  18681. ) +
  18682. (isEvaluating
  18683. ? ', __j = Array.prototype.join;\n' +
  18684. "function print() { __p += __j.call(arguments, '') }\n"
  18685. : ';\n'
  18686. ) +
  18687. source +
  18688. 'return __p\n}';
  18689. var result = attempt(function() {
  18690. return Function(importsKeys, sourceURL + 'return ' + source)
  18691. .apply(undefined, importsValues);
  18692. });
  18693. // Provide the compiled function's source by its `toString` method or
  18694. // the `source` property as a convenience for inlining compiled templates.
  18695. result.source = source;
  18696. if (isError(result)) {
  18697. throw result;
  18698. }
  18699. return result;
  18700. }
  18701. /**
  18702. * Converts `string`, as a whole, to lower case just like
  18703. * [String#toLowerCase](https://mdn.io/toLowerCase).
  18704. *
  18705. * @static
  18706. * @memberOf _
  18707. * @since 4.0.0
  18708. * @category String
  18709. * @param {string} [string=''] The string to convert.
  18710. * @returns {string} Returns the lower cased string.
  18711. * @example
  18712. *
  18713. * _.toLower('--Foo-Bar--');
  18714. * // => '--foo-bar--'
  18715. *
  18716. * _.toLower('fooBar');
  18717. * // => 'foobar'
  18718. *
  18719. * _.toLower('__FOO_BAR__');
  18720. * // => '__foo_bar__'
  18721. */
  18722. function toLower(value) {
  18723. return toString(value).toLowerCase();
  18724. }
  18725. /**
  18726. * Converts `string`, as a whole, to upper case just like
  18727. * [String#toUpperCase](https://mdn.io/toUpperCase).
  18728. *
  18729. * @static
  18730. * @memberOf _
  18731. * @since 4.0.0
  18732. * @category String
  18733. * @param {string} [string=''] The string to convert.
  18734. * @returns {string} Returns the upper cased string.
  18735. * @example
  18736. *
  18737. * _.toUpper('--foo-bar--');
  18738. * // => '--FOO-BAR--'
  18739. *
  18740. * _.toUpper('fooBar');
  18741. * // => 'FOOBAR'
  18742. *
  18743. * _.toUpper('__foo_bar__');
  18744. * // => '__FOO_BAR__'
  18745. */
  18746. function toUpper(value) {
  18747. return toString(value).toUpperCase();
  18748. }
  18749. /**
  18750. * Removes leading and trailing whitespace or specified characters from `string`.
  18751. *
  18752. * @static
  18753. * @memberOf _
  18754. * @since 3.0.0
  18755. * @category String
  18756. * @param {string} [string=''] The string to trim.
  18757. * @param {string} [chars=whitespace] The characters to trim.
  18758. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18759. * @returns {string} Returns the trimmed string.
  18760. * @example
  18761. *
  18762. * _.trim(' abc ');
  18763. * // => 'abc'
  18764. *
  18765. * _.trim('-_-abc-_-', '_-');
  18766. * // => 'abc'
  18767. *
  18768. * _.map([' foo ', ' bar '], _.trim);
  18769. * // => ['foo', 'bar']
  18770. */
  18771. function trim(string, chars, guard) {
  18772. string = toString(string);
  18773. if (string && (guard || chars === undefined)) {
  18774. return baseTrim(string);
  18775. }
  18776. if (!string || !(chars = baseToString(chars))) {
  18777. return string;
  18778. }
  18779. var strSymbols = stringToArray(string),
  18780. chrSymbols = stringToArray(chars),
  18781. start = charsStartIndex(strSymbols, chrSymbols),
  18782. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  18783. return castSlice(strSymbols, start, end).join('');
  18784. }
  18785. /**
  18786. * Removes trailing whitespace or specified characters from `string`.
  18787. *
  18788. * @static
  18789. * @memberOf _
  18790. * @since 4.0.0
  18791. * @category String
  18792. * @param {string} [string=''] The string to trim.
  18793. * @param {string} [chars=whitespace] The characters to trim.
  18794. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18795. * @returns {string} Returns the trimmed string.
  18796. * @example
  18797. *
  18798. * _.trimEnd(' abc ');
  18799. * // => ' abc'
  18800. *
  18801. * _.trimEnd('-_-abc-_-', '_-');
  18802. * // => '-_-abc'
  18803. */
  18804. function trimEnd(string, chars, guard) {
  18805. string = toString(string);
  18806. if (string && (guard || chars === undefined)) {
  18807. return string.slice(0, trimmedEndIndex(string) + 1);
  18808. }
  18809. if (!string || !(chars = baseToString(chars))) {
  18810. return string;
  18811. }
  18812. var strSymbols = stringToArray(string),
  18813. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  18814. return castSlice(strSymbols, 0, end).join('');
  18815. }
  18816. /**
  18817. * Removes leading whitespace or specified characters from `string`.
  18818. *
  18819. * @static
  18820. * @memberOf _
  18821. * @since 4.0.0
  18822. * @category String
  18823. * @param {string} [string=''] The string to trim.
  18824. * @param {string} [chars=whitespace] The characters to trim.
  18825. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18826. * @returns {string} Returns the trimmed string.
  18827. * @example
  18828. *
  18829. * _.trimStart(' abc ');
  18830. * // => 'abc '
  18831. *
  18832. * _.trimStart('-_-abc-_-', '_-');
  18833. * // => 'abc-_-'
  18834. */
  18835. function trimStart(string, chars, guard) {
  18836. string = toString(string);
  18837. if (string && (guard || chars === undefined)) {
  18838. return string.replace(reTrimStart, '');
  18839. }
  18840. if (!string || !(chars = baseToString(chars))) {
  18841. return string;
  18842. }
  18843. var strSymbols = stringToArray(string),
  18844. start = charsStartIndex(strSymbols, stringToArray(chars));
  18845. return castSlice(strSymbols, start).join('');
  18846. }
  18847. /**
  18848. * Truncates `string` if it's longer than the given maximum string length.
  18849. * The last characters of the truncated string are replaced with the omission
  18850. * string which defaults to "...".
  18851. *
  18852. * @static
  18853. * @memberOf _
  18854. * @since 4.0.0
  18855. * @category String
  18856. * @param {string} [string=''] The string to truncate.
  18857. * @param {Object} [options={}] The options object.
  18858. * @param {number} [options.length=30] The maximum string length.
  18859. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  18860. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  18861. * @returns {string} Returns the truncated string.
  18862. * @example
  18863. *
  18864. * _.truncate('hi-diddly-ho there, neighborino');
  18865. * // => 'hi-diddly-ho there, neighbo...'
  18866. *
  18867. * _.truncate('hi-diddly-ho there, neighborino', {
  18868. * 'length': 24,
  18869. * 'separator': ' '
  18870. * });
  18871. * // => 'hi-diddly-ho there,...'
  18872. *
  18873. * _.truncate('hi-diddly-ho there, neighborino', {
  18874. * 'length': 24,
  18875. * 'separator': /,? +/
  18876. * });
  18877. * // => 'hi-diddly-ho there...'
  18878. *
  18879. * _.truncate('hi-diddly-ho there, neighborino', {
  18880. * 'omission': ' [...]'
  18881. * });
  18882. * // => 'hi-diddly-ho there, neig [...]'
  18883. */
  18884. function truncate(string, options) {
  18885. var length = DEFAULT_TRUNC_LENGTH,
  18886. omission = DEFAULT_TRUNC_OMISSION;
  18887. if (isObject(options)) {
  18888. var separator = 'separator' in options ? options.separator : separator;
  18889. length = 'length' in options ? toInteger(options.length) : length;
  18890. omission = 'omission' in options ? baseToString(options.omission) : omission;
  18891. }
  18892. string = toString(string);
  18893. var strLength = string.length;
  18894. if (hasUnicode(string)) {
  18895. var strSymbols = stringToArray(string);
  18896. strLength = strSymbols.length;
  18897. }
  18898. if (length >= strLength) {
  18899. return string;
  18900. }
  18901. var end = length - stringSize(omission);
  18902. if (end < 1) {
  18903. return omission;
  18904. }
  18905. var result = strSymbols
  18906. ? castSlice(strSymbols, 0, end).join('')
  18907. : string.slice(0, end);
  18908. if (separator === undefined) {
  18909. return result + omission;
  18910. }
  18911. if (strSymbols) {
  18912. end += (result.length - end);
  18913. }
  18914. if (isRegExp(separator)) {
  18915. if (string.slice(end).search(separator)) {
  18916. var match,
  18917. substring = result;
  18918. if (!separator.global) {
  18919. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  18920. }
  18921. separator.lastIndex = 0;
  18922. while ((match = separator.exec(substring))) {
  18923. var newEnd = match.index;
  18924. }
  18925. result = result.slice(0, newEnd === undefined ? end : newEnd);
  18926. }
  18927. } else if (string.indexOf(baseToString(separator), end) != end) {
  18928. var index = result.lastIndexOf(separator);
  18929. if (index > -1) {
  18930. result = result.slice(0, index);
  18931. }
  18932. }
  18933. return result + omission;
  18934. }
  18935. /**
  18936. * The inverse of `_.escape`; this method converts the HTML entities
  18937. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  18938. * their corresponding characters.
  18939. *
  18940. * **Note:** No other HTML entities are unescaped. To unescape additional
  18941. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  18942. *
  18943. * @static
  18944. * @memberOf _
  18945. * @since 0.6.0
  18946. * @category String
  18947. * @param {string} [string=''] The string to unescape.
  18948. * @returns {string} Returns the unescaped string.
  18949. * @example
  18950. *
  18951. * _.unescape('fred, barney, &amp; pebbles');
  18952. * // => 'fred, barney, & pebbles'
  18953. */
  18954. function unescape(string) {
  18955. string = toString(string);
  18956. return (string && reHasEscapedHtml.test(string))
  18957. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  18958. : string;
  18959. }
  18960. /**
  18961. * Converts `string`, as space separated words, to upper case.
  18962. *
  18963. * @static
  18964. * @memberOf _
  18965. * @since 4.0.0
  18966. * @category String
  18967. * @param {string} [string=''] The string to convert.
  18968. * @returns {string} Returns the upper cased string.
  18969. * @example
  18970. *
  18971. * _.upperCase('--foo-bar');
  18972. * // => 'FOO BAR'
  18973. *
  18974. * _.upperCase('fooBar');
  18975. * // => 'FOO BAR'
  18976. *
  18977. * _.upperCase('__foo_bar__');
  18978. * // => 'FOO BAR'
  18979. */
  18980. var upperCase = createCompounder(function(result, word, index) {
  18981. return result + (index ? ' ' : '') + word.toUpperCase();
  18982. });
  18983. /**
  18984. * Converts the first character of `string` to upper case.
  18985. *
  18986. * @static
  18987. * @memberOf _
  18988. * @since 4.0.0
  18989. * @category String
  18990. * @param {string} [string=''] The string to convert.
  18991. * @returns {string} Returns the converted string.
  18992. * @example
  18993. *
  18994. * _.upperFirst('fred');
  18995. * // => 'Fred'
  18996. *
  18997. * _.upperFirst('FRED');
  18998. * // => 'FRED'
  18999. */
  19000. var upperFirst = createCaseFirst('toUpperCase');
  19001. /**
  19002. * Splits `string` into an array of its words.
  19003. *
  19004. * @static
  19005. * @memberOf _
  19006. * @since 3.0.0
  19007. * @category String
  19008. * @param {string} [string=''] The string to inspect.
  19009. * @param {RegExp|string} [pattern] The pattern to match words.
  19010. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19011. * @returns {Array} Returns the words of `string`.
  19012. * @example
  19013. *
  19014. * _.words('fred, barney, & pebbles');
  19015. * // => ['fred', 'barney', 'pebbles']
  19016. *
  19017. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  19018. * // => ['fred', 'barney', '&', 'pebbles']
  19019. */
  19020. function words(string, pattern, guard) {
  19021. string = toString(string);
  19022. pattern = guard ? undefined : pattern;
  19023. if (pattern === undefined) {
  19024. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  19025. }
  19026. return string.match(pattern) || [];
  19027. }
  19028. /*------------------------------------------------------------------------*/
  19029. /**
  19030. * Attempts to invoke `func`, returning either the result or the caught error
  19031. * object. Any additional arguments are provided to `func` when it's invoked.
  19032. *
  19033. * @static
  19034. * @memberOf _
  19035. * @since 3.0.0
  19036. * @category Util
  19037. * @param {Function} func The function to attempt.
  19038. * @param {...*} [args] The arguments to invoke `func` with.
  19039. * @returns {*} Returns the `func` result or error object.
  19040. * @example
  19041. *
  19042. * // Avoid throwing errors for invalid selectors.
  19043. * var elements = _.attempt(function(selector) {
  19044. * return document.querySelectorAll(selector);
  19045. * }, '>_>');
  19046. *
  19047. * if (_.isError(elements)) {
  19048. * elements = [];
  19049. * }
  19050. */
  19051. var attempt = baseRest(function(func, args) {
  19052. try {
  19053. return apply(func, undefined, args);
  19054. } catch (e) {
  19055. return isError(e) ? e : new Error(e);
  19056. }
  19057. });
  19058. /**
  19059. * Binds methods of an object to the object itself, overwriting the existing
  19060. * method.
  19061. *
  19062. * **Note:** This method doesn't set the "length" property of bound functions.
  19063. *
  19064. * @static
  19065. * @since 0.1.0
  19066. * @memberOf _
  19067. * @category Util
  19068. * @param {Object} object The object to bind and assign the bound methods to.
  19069. * @param {...(string|string[])} methodNames The object method names to bind.
  19070. * @returns {Object} Returns `object`.
  19071. * @example
  19072. *
  19073. * var view = {
  19074. * 'label': 'docs',
  19075. * 'click': function() {
  19076. * console.log('clicked ' + this.label);
  19077. * }
  19078. * };
  19079. *
  19080. * _.bindAll(view, ['click']);
  19081. * jQuery(element).on('click', view.click);
  19082. * // => Logs 'clicked docs' when clicked.
  19083. */
  19084. var bindAll = flatRest(function(object, methodNames) {
  19085. arrayEach(methodNames, function(key) {
  19086. key = toKey(key);
  19087. baseAssignValue(object, key, bind(object[key], object));
  19088. });
  19089. return object;
  19090. });
  19091. /**
  19092. * Creates a function that iterates over `pairs` and invokes the corresponding
  19093. * function of the first predicate to return truthy. The predicate-function
  19094. * pairs are invoked with the `this` binding and arguments of the created
  19095. * function.
  19096. *
  19097. * @static
  19098. * @memberOf _
  19099. * @since 4.0.0
  19100. * @category Util
  19101. * @param {Array} pairs The predicate-function pairs.
  19102. * @returns {Function} Returns the new composite function.
  19103. * @example
  19104. *
  19105. * var func = _.cond([
  19106. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  19107. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  19108. * [_.stubTrue, _.constant('no match')]
  19109. * ]);
  19110. *
  19111. * func({ 'a': 1, 'b': 2 });
  19112. * // => 'matches A'
  19113. *
  19114. * func({ 'a': 0, 'b': 1 });
  19115. * // => 'matches B'
  19116. *
  19117. * func({ 'a': '1', 'b': '2' });
  19118. * // => 'no match'
  19119. */
  19120. function cond(pairs) {
  19121. var length = pairs == null ? 0 : pairs.length,
  19122. toIteratee = getIteratee();
  19123. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  19124. if (typeof pair[1] != 'function') {
  19125. throw new TypeError(FUNC_ERROR_TEXT);
  19126. }
  19127. return [toIteratee(pair[0]), pair[1]];
  19128. });
  19129. return baseRest(function(args) {
  19130. var index = -1;
  19131. while (++index < length) {
  19132. var pair = pairs[index];
  19133. if (apply(pair[0], this, args)) {
  19134. return apply(pair[1], this, args);
  19135. }
  19136. }
  19137. });
  19138. }
  19139. /**
  19140. * Creates a function that invokes the predicate properties of `source` with
  19141. * the corresponding property values of a given object, returning `true` if
  19142. * all predicates return truthy, else `false`.
  19143. *
  19144. * **Note:** The created function is equivalent to `_.conformsTo` with
  19145. * `source` partially applied.
  19146. *
  19147. * @static
  19148. * @memberOf _
  19149. * @since 4.0.0
  19150. * @category Util
  19151. * @param {Object} source The object of property predicates to conform to.
  19152. * @returns {Function} Returns the new spec function.
  19153. * @example
  19154. *
  19155. * var objects = [
  19156. * { 'a': 2, 'b': 1 },
  19157. * { 'a': 1, 'b': 2 }
  19158. * ];
  19159. *
  19160. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  19161. * // => [{ 'a': 1, 'b': 2 }]
  19162. */
  19163. function conforms(source) {
  19164. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  19165. }
  19166. /**
  19167. * Creates a function that returns `value`.
  19168. *
  19169. * @static
  19170. * @memberOf _
  19171. * @since 2.4.0
  19172. * @category Util
  19173. * @param {*} value The value to return from the new function.
  19174. * @returns {Function} Returns the new constant function.
  19175. * @example
  19176. *
  19177. * var objects = _.times(2, _.constant({ 'a': 1 }));
  19178. *
  19179. * console.log(objects);
  19180. * // => [{ 'a': 1 }, { 'a': 1 }]
  19181. *
  19182. * console.log(objects[0] === objects[1]);
  19183. * // => true
  19184. */
  19185. function constant(value) {
  19186. return function() {
  19187. return value;
  19188. };
  19189. }
  19190. /**
  19191. * Checks `value` to determine whether a default value should be returned in
  19192. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  19193. * or `undefined`.
  19194. *
  19195. * @static
  19196. * @memberOf _
  19197. * @since 4.14.0
  19198. * @category Util
  19199. * @param {*} value The value to check.
  19200. * @param {*} defaultValue The default value.
  19201. * @returns {*} Returns the resolved value.
  19202. * @example
  19203. *
  19204. * _.defaultTo(1, 10);
  19205. * // => 1
  19206. *
  19207. * _.defaultTo(undefined, 10);
  19208. * // => 10
  19209. */
  19210. function defaultTo(value, defaultValue) {
  19211. return (value == null || value !== value) ? defaultValue : value;
  19212. }
  19213. /**
  19214. * Creates a function that returns the result of invoking the given functions
  19215. * with the `this` binding of the created function, where each successive
  19216. * invocation is supplied the return value of the previous.
  19217. *
  19218. * @static
  19219. * @memberOf _
  19220. * @since 3.0.0
  19221. * @category Util
  19222. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  19223. * @returns {Function} Returns the new composite function.
  19224. * @see _.flowRight
  19225. * @example
  19226. *
  19227. * function square(n) {
  19228. * return n * n;
  19229. * }
  19230. *
  19231. * var addSquare = _.flow([_.add, square]);
  19232. * addSquare(1, 2);
  19233. * // => 9
  19234. */
  19235. var flow = createFlow();
  19236. /**
  19237. * This method is like `_.flow` except that it creates a function that
  19238. * invokes the given functions from right to left.
  19239. *
  19240. * @static
  19241. * @since 3.0.0
  19242. * @memberOf _
  19243. * @category Util
  19244. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  19245. * @returns {Function} Returns the new composite function.
  19246. * @see _.flow
  19247. * @example
  19248. *
  19249. * function square(n) {
  19250. * return n * n;
  19251. * }
  19252. *
  19253. * var addSquare = _.flowRight([square, _.add]);
  19254. * addSquare(1, 2);
  19255. * // => 9
  19256. */
  19257. var flowRight = createFlow(true);
  19258. /**
  19259. * This method returns the first argument it receives.
  19260. *
  19261. * @static
  19262. * @since 0.1.0
  19263. * @memberOf _
  19264. * @category Util
  19265. * @param {*} value Any value.
  19266. * @returns {*} Returns `value`.
  19267. * @example
  19268. *
  19269. * var object = { 'a': 1 };
  19270. *
  19271. * console.log(_.identity(object) === object);
  19272. * // => true
  19273. */
  19274. function identity(value) {
  19275. return value;
  19276. }
  19277. /**
  19278. * Creates a function that invokes `func` with the arguments of the created
  19279. * function. If `func` is a property name, the created function returns the
  19280. * property value for a given element. If `func` is an array or object, the
  19281. * created function returns `true` for elements that contain the equivalent
  19282. * source properties, otherwise it returns `false`.
  19283. *
  19284. * @static
  19285. * @since 4.0.0
  19286. * @memberOf _
  19287. * @category Util
  19288. * @param {*} [func=_.identity] The value to convert to a callback.
  19289. * @returns {Function} Returns the callback.
  19290. * @example
  19291. *
  19292. * var users = [
  19293. * { 'user': 'barney', 'age': 36, 'active': true },
  19294. * { 'user': 'fred', 'age': 40, 'active': false }
  19295. * ];
  19296. *
  19297. * // The `_.matches` iteratee shorthand.
  19298. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  19299. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  19300. *
  19301. * // The `_.matchesProperty` iteratee shorthand.
  19302. * _.filter(users, _.iteratee(['user', 'fred']));
  19303. * // => [{ 'user': 'fred', 'age': 40 }]
  19304. *
  19305. * // The `_.property` iteratee shorthand.
  19306. * _.map(users, _.iteratee('user'));
  19307. * // => ['barney', 'fred']
  19308. *
  19309. * // Create custom iteratee shorthands.
  19310. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  19311. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  19312. * return func.test(string);
  19313. * };
  19314. * });
  19315. *
  19316. * _.filter(['abc', 'def'], /ef/);
  19317. * // => ['def']
  19318. */
  19319. function iteratee(func) {
  19320. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  19321. }
  19322. /**
  19323. * Creates a function that performs a partial deep comparison between a given
  19324. * object and `source`, returning `true` if the given object has equivalent
  19325. * property values, else `false`.
  19326. *
  19327. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  19328. * partially applied.
  19329. *
  19330. * Partial comparisons will match empty array and empty object `source`
  19331. * values against any array or object value, respectively. See `_.isEqual`
  19332. * for a list of supported value comparisons.
  19333. *
  19334. * **Note:** Multiple values can be checked by combining several matchers
  19335. * using `_.overSome`
  19336. *
  19337. * @static
  19338. * @memberOf _
  19339. * @since 3.0.0
  19340. * @category Util
  19341. * @param {Object} source The object of property values to match.
  19342. * @returns {Function} Returns the new spec function.
  19343. * @example
  19344. *
  19345. * var objects = [
  19346. * { 'a': 1, 'b': 2, 'c': 3 },
  19347. * { 'a': 4, 'b': 5, 'c': 6 }
  19348. * ];
  19349. *
  19350. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  19351. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  19352. *
  19353. * // Checking for several possible values
  19354. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  19355. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  19356. */
  19357. function matches(source) {
  19358. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  19359. }
  19360. /**
  19361. * Creates a function that performs a partial deep comparison between the
  19362. * value at `path` of a given object to `srcValue`, returning `true` if the
  19363. * object value is equivalent, else `false`.
  19364. *
  19365. * **Note:** Partial comparisons will match empty array and empty object
  19366. * `srcValue` values against any array or object value, respectively. See
  19367. * `_.isEqual` for a list of supported value comparisons.
  19368. *
  19369. * **Note:** Multiple values can be checked by combining several matchers
  19370. * using `_.overSome`
  19371. *
  19372. * @static
  19373. * @memberOf _
  19374. * @since 3.2.0
  19375. * @category Util
  19376. * @param {Array|string} path The path of the property to get.
  19377. * @param {*} srcValue The value to match.
  19378. * @returns {Function} Returns the new spec function.
  19379. * @example
  19380. *
  19381. * var objects = [
  19382. * { 'a': 1, 'b': 2, 'c': 3 },
  19383. * { 'a': 4, 'b': 5, 'c': 6 }
  19384. * ];
  19385. *
  19386. * _.find(objects, _.matchesProperty('a', 4));
  19387. * // => { 'a': 4, 'b': 5, 'c': 6 }
  19388. *
  19389. * // Checking for several possible values
  19390. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  19391. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  19392. */
  19393. function matchesProperty(path, srcValue) {
  19394. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  19395. }
  19396. /**
  19397. * Creates a function that invokes the method at `path` of a given object.
  19398. * Any additional arguments are provided to the invoked method.
  19399. *
  19400. * @static
  19401. * @memberOf _
  19402. * @since 3.7.0
  19403. * @category Util
  19404. * @param {Array|string} path The path of the method to invoke.
  19405. * @param {...*} [args] The arguments to invoke the method with.
  19406. * @returns {Function} Returns the new invoker function.
  19407. * @example
  19408. *
  19409. * var objects = [
  19410. * { 'a': { 'b': _.constant(2) } },
  19411. * { 'a': { 'b': _.constant(1) } }
  19412. * ];
  19413. *
  19414. * _.map(objects, _.method('a.b'));
  19415. * // => [2, 1]
  19416. *
  19417. * _.map(objects, _.method(['a', 'b']));
  19418. * // => [2, 1]
  19419. */
  19420. var method = baseRest(function(path, args) {
  19421. return function(object) {
  19422. return baseInvoke(object, path, args);
  19423. };
  19424. });
  19425. /**
  19426. * The opposite of `_.method`; this method creates a function that invokes
  19427. * the method at a given path of `object`. Any additional arguments are
  19428. * provided to the invoked method.
  19429. *
  19430. * @static
  19431. * @memberOf _
  19432. * @since 3.7.0
  19433. * @category Util
  19434. * @param {Object} object The object to query.
  19435. * @param {...*} [args] The arguments to invoke the method with.
  19436. * @returns {Function} Returns the new invoker function.
  19437. * @example
  19438. *
  19439. * var array = _.times(3, _.constant),
  19440. * object = { 'a': array, 'b': array, 'c': array };
  19441. *
  19442. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  19443. * // => [2, 0]
  19444. *
  19445. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  19446. * // => [2, 0]
  19447. */
  19448. var methodOf = baseRest(function(object, args) {
  19449. return function(path) {
  19450. return baseInvoke(object, path, args);
  19451. };
  19452. });
  19453. /**
  19454. * Adds all own enumerable string keyed function properties of a source
  19455. * object to the destination object. If `object` is a function, then methods
  19456. * are added to its prototype as well.
  19457. *
  19458. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  19459. * avoid conflicts caused by modifying the original.
  19460. *
  19461. * @static
  19462. * @since 0.1.0
  19463. * @memberOf _
  19464. * @category Util
  19465. * @param {Function|Object} [object=lodash] The destination object.
  19466. * @param {Object} source The object of functions to add.
  19467. * @param {Object} [options={}] The options object.
  19468. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  19469. * @returns {Function|Object} Returns `object`.
  19470. * @example
  19471. *
  19472. * function vowels(string) {
  19473. * return _.filter(string, function(v) {
  19474. * return /[aeiou]/i.test(v);
  19475. * });
  19476. * }
  19477. *
  19478. * _.mixin({ 'vowels': vowels });
  19479. * _.vowels('fred');
  19480. * // => ['e']
  19481. *
  19482. * _('fred').vowels().value();
  19483. * // => ['e']
  19484. *
  19485. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  19486. * _('fred').vowels();
  19487. * // => ['e']
  19488. */
  19489. function mixin(object, source, options) {
  19490. var props = keys(source),
  19491. methodNames = baseFunctions(source, props);
  19492. if (options == null &&
  19493. !(isObject(source) && (methodNames.length || !props.length))) {
  19494. options = source;
  19495. source = object;
  19496. object = this;
  19497. methodNames = baseFunctions(source, keys(source));
  19498. }
  19499. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  19500. isFunc = isFunction(object);
  19501. arrayEach(methodNames, function(methodName) {
  19502. var func = source[methodName];
  19503. object[methodName] = func;
  19504. if (isFunc) {
  19505. object.prototype[methodName] = function() {
  19506. var chainAll = this.__chain__;
  19507. if (chain || chainAll) {
  19508. var result = object(this.__wrapped__),
  19509. actions = result.__actions__ = copyArray(this.__actions__);
  19510. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  19511. result.__chain__ = chainAll;
  19512. return result;
  19513. }
  19514. return func.apply(object, arrayPush([this.value()], arguments));
  19515. };
  19516. }
  19517. });
  19518. return object;
  19519. }
  19520. /**
  19521. * Reverts the `_` variable to its previous value and returns a reference to
  19522. * the `lodash` function.
  19523. *
  19524. * @static
  19525. * @since 0.1.0
  19526. * @memberOf _
  19527. * @category Util
  19528. * @returns {Function} Returns the `lodash` function.
  19529. * @example
  19530. *
  19531. * var lodash = _.noConflict();
  19532. */
  19533. function noConflict() {
  19534. if (root._ === this) {
  19535. root._ = oldDash;
  19536. }
  19537. return this;
  19538. }
  19539. /**
  19540. * This method returns `undefined`.
  19541. *
  19542. * @static
  19543. * @memberOf _
  19544. * @since 2.3.0
  19545. * @category Util
  19546. * @example
  19547. *
  19548. * _.times(2, _.noop);
  19549. * // => [undefined, undefined]
  19550. */
  19551. function noop() {
  19552. // No operation performed.
  19553. }
  19554. /**
  19555. * Creates a function that gets the argument at index `n`. If `n` is negative,
  19556. * the nth argument from the end is returned.
  19557. *
  19558. * @static
  19559. * @memberOf _
  19560. * @since 4.0.0
  19561. * @category Util
  19562. * @param {number} [n=0] The index of the argument to return.
  19563. * @returns {Function} Returns the new pass-thru function.
  19564. * @example
  19565. *
  19566. * var func = _.nthArg(1);
  19567. * func('a', 'b', 'c', 'd');
  19568. * // => 'b'
  19569. *
  19570. * var func = _.nthArg(-2);
  19571. * func('a', 'b', 'c', 'd');
  19572. * // => 'c'
  19573. */
  19574. function nthArg(n) {
  19575. n = toInteger(n);
  19576. return baseRest(function(args) {
  19577. return baseNth(args, n);
  19578. });
  19579. }
  19580. /**
  19581. * Creates a function that invokes `iteratees` with the arguments it receives
  19582. * and returns their results.
  19583. *
  19584. * @static
  19585. * @memberOf _
  19586. * @since 4.0.0
  19587. * @category Util
  19588. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  19589. * The iteratees to invoke.
  19590. * @returns {Function} Returns the new function.
  19591. * @example
  19592. *
  19593. * var func = _.over([Math.max, Math.min]);
  19594. *
  19595. * func(1, 2, 3, 4);
  19596. * // => [4, 1]
  19597. */
  19598. var over = createOver(arrayMap);
  19599. /**
  19600. * Creates a function that checks if **all** of the `predicates` return
  19601. * truthy when invoked with the arguments it receives.
  19602. *
  19603. * Following shorthands are possible for providing predicates.
  19604. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  19605. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  19606. *
  19607. * @static
  19608. * @memberOf _
  19609. * @since 4.0.0
  19610. * @category Util
  19611. * @param {...(Function|Function[])} [predicates=[_.identity]]
  19612. * The predicates to check.
  19613. * @returns {Function} Returns the new function.
  19614. * @example
  19615. *
  19616. * var func = _.overEvery([Boolean, isFinite]);
  19617. *
  19618. * func('1');
  19619. * // => true
  19620. *
  19621. * func(null);
  19622. * // => false
  19623. *
  19624. * func(NaN);
  19625. * // => false
  19626. */
  19627. var overEvery = createOver(arrayEvery);
  19628. /**
  19629. * Creates a function that checks if **any** of the `predicates` return
  19630. * truthy when invoked with the arguments it receives.
  19631. *
  19632. * Following shorthands are possible for providing predicates.
  19633. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  19634. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  19635. *
  19636. * @static
  19637. * @memberOf _
  19638. * @since 4.0.0
  19639. * @category Util
  19640. * @param {...(Function|Function[])} [predicates=[_.identity]]
  19641. * The predicates to check.
  19642. * @returns {Function} Returns the new function.
  19643. * @example
  19644. *
  19645. * var func = _.overSome([Boolean, isFinite]);
  19646. *
  19647. * func('1');
  19648. * // => true
  19649. *
  19650. * func(null);
  19651. * // => true
  19652. *
  19653. * func(NaN);
  19654. * // => false
  19655. *
  19656. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  19657. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  19658. */
  19659. var overSome = createOver(arraySome);
  19660. /**
  19661. * Creates a function that returns the value at `path` of a given object.
  19662. *
  19663. * @static
  19664. * @memberOf _
  19665. * @since 2.4.0
  19666. * @category Util
  19667. * @param {Array|string} path The path of the property to get.
  19668. * @returns {Function} Returns the new accessor function.
  19669. * @example
  19670. *
  19671. * var objects = [
  19672. * { 'a': { 'b': 2 } },
  19673. * { 'a': { 'b': 1 } }
  19674. * ];
  19675. *
  19676. * _.map(objects, _.property('a.b'));
  19677. * // => [2, 1]
  19678. *
  19679. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  19680. * // => [1, 2]
  19681. */
  19682. function property(path) {
  19683. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  19684. }
  19685. /**
  19686. * The opposite of `_.property`; this method creates a function that returns
  19687. * the value at a given path of `object`.
  19688. *
  19689. * @static
  19690. * @memberOf _
  19691. * @since 3.0.0
  19692. * @category Util
  19693. * @param {Object} object The object to query.
  19694. * @returns {Function} Returns the new accessor function.
  19695. * @example
  19696. *
  19697. * var array = [0, 1, 2],
  19698. * object = { 'a': array, 'b': array, 'c': array };
  19699. *
  19700. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  19701. * // => [2, 0]
  19702. *
  19703. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  19704. * // => [2, 0]
  19705. */
  19706. function propertyOf(object) {
  19707. return function(path) {
  19708. return object == null ? undefined : baseGet(object, path);
  19709. };
  19710. }
  19711. /**
  19712. * Creates an array of numbers (positive and/or negative) progressing from
  19713. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  19714. * `start` is specified without an `end` or `step`. If `end` is not specified,
  19715. * it's set to `start` with `start` then set to `0`.
  19716. *
  19717. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  19718. * floating-point values which can produce unexpected results.
  19719. *
  19720. * @static
  19721. * @since 0.1.0
  19722. * @memberOf _
  19723. * @category Util
  19724. * @param {number} [start=0] The start of the range.
  19725. * @param {number} end The end of the range.
  19726. * @param {number} [step=1] The value to increment or decrement by.
  19727. * @returns {Array} Returns the range of numbers.
  19728. * @see _.inRange, _.rangeRight
  19729. * @example
  19730. *
  19731. * _.range(4);
  19732. * // => [0, 1, 2, 3]
  19733. *
  19734. * _.range(-4);
  19735. * // => [0, -1, -2, -3]
  19736. *
  19737. * _.range(1, 5);
  19738. * // => [1, 2, 3, 4]
  19739. *
  19740. * _.range(0, 20, 5);
  19741. * // => [0, 5, 10, 15]
  19742. *
  19743. * _.range(0, -4, -1);
  19744. * // => [0, -1, -2, -3]
  19745. *
  19746. * _.range(1, 4, 0);
  19747. * // => [1, 1, 1]
  19748. *
  19749. * _.range(0);
  19750. * // => []
  19751. */
  19752. var range = createRange();
  19753. /**
  19754. * This method is like `_.range` except that it populates values in
  19755. * descending order.
  19756. *
  19757. * @static
  19758. * @memberOf _
  19759. * @since 4.0.0
  19760. * @category Util
  19761. * @param {number} [start=0] The start of the range.
  19762. * @param {number} end The end of the range.
  19763. * @param {number} [step=1] The value to increment or decrement by.
  19764. * @returns {Array} Returns the range of numbers.
  19765. * @see _.inRange, _.range
  19766. * @example
  19767. *
  19768. * _.rangeRight(4);
  19769. * // => [3, 2, 1, 0]
  19770. *
  19771. * _.rangeRight(-4);
  19772. * // => [-3, -2, -1, 0]
  19773. *
  19774. * _.rangeRight(1, 5);
  19775. * // => [4, 3, 2, 1]
  19776. *
  19777. * _.rangeRight(0, 20, 5);
  19778. * // => [15, 10, 5, 0]
  19779. *
  19780. * _.rangeRight(0, -4, -1);
  19781. * // => [-3, -2, -1, 0]
  19782. *
  19783. * _.rangeRight(1, 4, 0);
  19784. * // => [1, 1, 1]
  19785. *
  19786. * _.rangeRight(0);
  19787. * // => []
  19788. */
  19789. var rangeRight = createRange(true);
  19790. /**
  19791. * This method returns a new empty array.
  19792. *
  19793. * @static
  19794. * @memberOf _
  19795. * @since 4.13.0
  19796. * @category Util
  19797. * @returns {Array} Returns the new empty array.
  19798. * @example
  19799. *
  19800. * var arrays = _.times(2, _.stubArray);
  19801. *
  19802. * console.log(arrays);
  19803. * // => [[], []]
  19804. *
  19805. * console.log(arrays[0] === arrays[1]);
  19806. * // => false
  19807. */
  19808. function stubArray() {
  19809. return [];
  19810. }
  19811. /**
  19812. * This method returns `false`.
  19813. *
  19814. * @static
  19815. * @memberOf _
  19816. * @since 4.13.0
  19817. * @category Util
  19818. * @returns {boolean} Returns `false`.
  19819. * @example
  19820. *
  19821. * _.times(2, _.stubFalse);
  19822. * // => [false, false]
  19823. */
  19824. function stubFalse() {
  19825. return false;
  19826. }
  19827. /**
  19828. * This method returns a new empty object.
  19829. *
  19830. * @static
  19831. * @memberOf _
  19832. * @since 4.13.0
  19833. * @category Util
  19834. * @returns {Object} Returns the new empty object.
  19835. * @example
  19836. *
  19837. * var objects = _.times(2, _.stubObject);
  19838. *
  19839. * console.log(objects);
  19840. * // => [{}, {}]
  19841. *
  19842. * console.log(objects[0] === objects[1]);
  19843. * // => false
  19844. */
  19845. function stubObject() {
  19846. return {};
  19847. }
  19848. /**
  19849. * This method returns an empty string.
  19850. *
  19851. * @static
  19852. * @memberOf _
  19853. * @since 4.13.0
  19854. * @category Util
  19855. * @returns {string} Returns the empty string.
  19856. * @example
  19857. *
  19858. * _.times(2, _.stubString);
  19859. * // => ['', '']
  19860. */
  19861. function stubString() {
  19862. return '';
  19863. }
  19864. /**
  19865. * This method returns `true`.
  19866. *
  19867. * @static
  19868. * @memberOf _
  19869. * @since 4.13.0
  19870. * @category Util
  19871. * @returns {boolean} Returns `true`.
  19872. * @example
  19873. *
  19874. * _.times(2, _.stubTrue);
  19875. * // => [true, true]
  19876. */
  19877. function stubTrue() {
  19878. return true;
  19879. }
  19880. /**
  19881. * Invokes the iteratee `n` times, returning an array of the results of
  19882. * each invocation. The iteratee is invoked with one argument; (index).
  19883. *
  19884. * @static
  19885. * @since 0.1.0
  19886. * @memberOf _
  19887. * @category Util
  19888. * @param {number} n The number of times to invoke `iteratee`.
  19889. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  19890. * @returns {Array} Returns the array of results.
  19891. * @example
  19892. *
  19893. * _.times(3, String);
  19894. * // => ['0', '1', '2']
  19895. *
  19896. * _.times(4, _.constant(0));
  19897. * // => [0, 0, 0, 0]
  19898. */
  19899. function times(n, iteratee) {
  19900. n = toInteger(n);
  19901. if (n < 1 || n > MAX_SAFE_INTEGER) {
  19902. return [];
  19903. }
  19904. var index = MAX_ARRAY_LENGTH,
  19905. length = nativeMin(n, MAX_ARRAY_LENGTH);
  19906. iteratee = getIteratee(iteratee);
  19907. n -= MAX_ARRAY_LENGTH;
  19908. var result = baseTimes(length, iteratee);
  19909. while (++index < n) {
  19910. iteratee(index);
  19911. }
  19912. return result;
  19913. }
  19914. /**
  19915. * Converts `value` to a property path array.
  19916. *
  19917. * @static
  19918. * @memberOf _
  19919. * @since 4.0.0
  19920. * @category Util
  19921. * @param {*} value The value to convert.
  19922. * @returns {Array} Returns the new property path array.
  19923. * @example
  19924. *
  19925. * _.toPath('a.b.c');
  19926. * // => ['a', 'b', 'c']
  19927. *
  19928. * _.toPath('a[0].b.c');
  19929. * // => ['a', '0', 'b', 'c']
  19930. */
  19931. function toPath(value) {
  19932. if (isArray(value)) {
  19933. return arrayMap(value, toKey);
  19934. }
  19935. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  19936. }
  19937. /**
  19938. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  19939. *
  19940. * @static
  19941. * @since 0.1.0
  19942. * @memberOf _
  19943. * @category Util
  19944. * @param {string} [prefix=''] The value to prefix the ID with.
  19945. * @returns {string} Returns the unique ID.
  19946. * @example
  19947. *
  19948. * _.uniqueId('contact_');
  19949. * // => 'contact_104'
  19950. *
  19951. * _.uniqueId();
  19952. * // => '105'
  19953. */
  19954. function uniqueId(prefix) {
  19955. var id = ++idCounter;
  19956. return toString(prefix) + id;
  19957. }
  19958. /*------------------------------------------------------------------------*/
  19959. /**
  19960. * Adds two numbers.
  19961. *
  19962. * @static
  19963. * @memberOf _
  19964. * @since 3.4.0
  19965. * @category Math
  19966. * @param {number} augend The first number in an addition.
  19967. * @param {number} addend The second number in an addition.
  19968. * @returns {number} Returns the total.
  19969. * @example
  19970. *
  19971. * _.add(6, 4);
  19972. * // => 10
  19973. */
  19974. var add = createMathOperation(function(augend, addend) {
  19975. return augend + addend;
  19976. }, 0);
  19977. /**
  19978. * Computes `number` rounded up to `precision`.
  19979. *
  19980. * @static
  19981. * @memberOf _
  19982. * @since 3.10.0
  19983. * @category Math
  19984. * @param {number} number The number to round up.
  19985. * @param {number} [precision=0] The precision to round up to.
  19986. * @returns {number} Returns the rounded up number.
  19987. * @example
  19988. *
  19989. * _.ceil(4.006);
  19990. * // => 5
  19991. *
  19992. * _.ceil(6.004, 2);
  19993. * // => 6.01
  19994. *
  19995. * _.ceil(6040, -2);
  19996. * // => 6100
  19997. */
  19998. var ceil = createRound('ceil');
  19999. /**
  20000. * Divide two numbers.
  20001. *
  20002. * @static
  20003. * @memberOf _
  20004. * @since 4.7.0
  20005. * @category Math
  20006. * @param {number} dividend The first number in a division.
  20007. * @param {number} divisor The second number in a division.
  20008. * @returns {number} Returns the quotient.
  20009. * @example
  20010. *
  20011. * _.divide(6, 4);
  20012. * // => 1.5
  20013. */
  20014. var divide = createMathOperation(function(dividend, divisor) {
  20015. return dividend / divisor;
  20016. }, 1);
  20017. /**
  20018. * Computes `number` rounded down to `precision`.
  20019. *
  20020. * @static
  20021. * @memberOf _
  20022. * @since 3.10.0
  20023. * @category Math
  20024. * @param {number} number The number to round down.
  20025. * @param {number} [precision=0] The precision to round down to.
  20026. * @returns {number} Returns the rounded down number.
  20027. * @example
  20028. *
  20029. * _.floor(4.006);
  20030. * // => 4
  20031. *
  20032. * _.floor(0.046, 2);
  20033. * // => 0.04
  20034. *
  20035. * _.floor(4060, -2);
  20036. * // => 4000
  20037. */
  20038. var floor = createRound('floor');
  20039. /**
  20040. * Computes the maximum value of `array`. If `array` is empty or falsey,
  20041. * `undefined` is returned.
  20042. *
  20043. * @static
  20044. * @since 0.1.0
  20045. * @memberOf _
  20046. * @category Math
  20047. * @param {Array} array The array to iterate over.
  20048. * @returns {*} Returns the maximum value.
  20049. * @example
  20050. *
  20051. * _.max([4, 2, 8, 6]);
  20052. * // => 8
  20053. *
  20054. * _.max([]);
  20055. * // => undefined
  20056. */
  20057. function max(array) {
  20058. return (array && array.length)
  20059. ? baseExtremum(array, identity, baseGt)
  20060. : undefined;
  20061. }
  20062. /**
  20063. * This method is like `_.max` except that it accepts `iteratee` which is
  20064. * invoked for each element in `array` to generate the criterion by which
  20065. * the value is ranked. The iteratee is invoked with one argument: (value).
  20066. *
  20067. * @static
  20068. * @memberOf _
  20069. * @since 4.0.0
  20070. * @category Math
  20071. * @param {Array} array The array to iterate over.
  20072. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20073. * @returns {*} Returns the maximum value.
  20074. * @example
  20075. *
  20076. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  20077. *
  20078. * _.maxBy(objects, function(o) { return o.n; });
  20079. * // => { 'n': 2 }
  20080. *
  20081. * // The `_.property` iteratee shorthand.
  20082. * _.maxBy(objects, 'n');
  20083. * // => { 'n': 2 }
  20084. */
  20085. function maxBy(array, iteratee) {
  20086. return (array && array.length)
  20087. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  20088. : undefined;
  20089. }
  20090. /**
  20091. * Computes the mean of the values in `array`.
  20092. *
  20093. * @static
  20094. * @memberOf _
  20095. * @since 4.0.0
  20096. * @category Math
  20097. * @param {Array} array The array to iterate over.
  20098. * @returns {number} Returns the mean.
  20099. * @example
  20100. *
  20101. * _.mean([4, 2, 8, 6]);
  20102. * // => 5
  20103. */
  20104. function mean(array) {
  20105. return baseMean(array, identity);
  20106. }
  20107. /**
  20108. * This method is like `_.mean` except that it accepts `iteratee` which is
  20109. * invoked for each element in `array` to generate the value to be averaged.
  20110. * The iteratee is invoked with one argument: (value).
  20111. *
  20112. * @static
  20113. * @memberOf _
  20114. * @since 4.7.0
  20115. * @category Math
  20116. * @param {Array} array The array to iterate over.
  20117. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20118. * @returns {number} Returns the mean.
  20119. * @example
  20120. *
  20121. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  20122. *
  20123. * _.meanBy(objects, function(o) { return o.n; });
  20124. * // => 5
  20125. *
  20126. * // The `_.property` iteratee shorthand.
  20127. * _.meanBy(objects, 'n');
  20128. * // => 5
  20129. */
  20130. function meanBy(array, iteratee) {
  20131. return baseMean(array, getIteratee(iteratee, 2));
  20132. }
  20133. /**
  20134. * Computes the minimum value of `array`. If `array` is empty or falsey,
  20135. * `undefined` is returned.
  20136. *
  20137. * @static
  20138. * @since 0.1.0
  20139. * @memberOf _
  20140. * @category Math
  20141. * @param {Array} array The array to iterate over.
  20142. * @returns {*} Returns the minimum value.
  20143. * @example
  20144. *
  20145. * _.min([4, 2, 8, 6]);
  20146. * // => 2
  20147. *
  20148. * _.min([]);
  20149. * // => undefined
  20150. */
  20151. function min(array) {
  20152. return (array && array.length)
  20153. ? baseExtremum(array, identity, baseLt)
  20154. : undefined;
  20155. }
  20156. /**
  20157. * This method is like `_.min` except that it accepts `iteratee` which is
  20158. * invoked for each element in `array` to generate the criterion by which
  20159. * the value is ranked. The iteratee is invoked with one argument: (value).
  20160. *
  20161. * @static
  20162. * @memberOf _
  20163. * @since 4.0.0
  20164. * @category Math
  20165. * @param {Array} array The array to iterate over.
  20166. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20167. * @returns {*} Returns the minimum value.
  20168. * @example
  20169. *
  20170. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  20171. *
  20172. * _.minBy(objects, function(o) { return o.n; });
  20173. * // => { 'n': 1 }
  20174. *
  20175. * // The `_.property` iteratee shorthand.
  20176. * _.minBy(objects, 'n');
  20177. * // => { 'n': 1 }
  20178. */
  20179. function minBy(array, iteratee) {
  20180. return (array && array.length)
  20181. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  20182. : undefined;
  20183. }
  20184. /**
  20185. * Multiply two numbers.
  20186. *
  20187. * @static
  20188. * @memberOf _
  20189. * @since 4.7.0
  20190. * @category Math
  20191. * @param {number} multiplier The first number in a multiplication.
  20192. * @param {number} multiplicand The second number in a multiplication.
  20193. * @returns {number} Returns the product.
  20194. * @example
  20195. *
  20196. * _.multiply(6, 4);
  20197. * // => 24
  20198. */
  20199. var multiply = createMathOperation(function(multiplier, multiplicand) {
  20200. return multiplier * multiplicand;
  20201. }, 1);
  20202. /**
  20203. * Computes `number` rounded to `precision`.
  20204. *
  20205. * @static
  20206. * @memberOf _
  20207. * @since 3.10.0
  20208. * @category Math
  20209. * @param {number} number The number to round.
  20210. * @param {number} [precision=0] The precision to round to.
  20211. * @returns {number} Returns the rounded number.
  20212. * @example
  20213. *
  20214. * _.round(4.006);
  20215. * // => 4
  20216. *
  20217. * _.round(4.006, 2);
  20218. * // => 4.01
  20219. *
  20220. * _.round(4060, -2);
  20221. * // => 4100
  20222. */
  20223. var round = createRound('round');
  20224. /**
  20225. * Subtract two numbers.
  20226. *
  20227. * @static
  20228. * @memberOf _
  20229. * @since 4.0.0
  20230. * @category Math
  20231. * @param {number} minuend The first number in a subtraction.
  20232. * @param {number} subtrahend The second number in a subtraction.
  20233. * @returns {number} Returns the difference.
  20234. * @example
  20235. *
  20236. * _.subtract(6, 4);
  20237. * // => 2
  20238. */
  20239. var subtract = createMathOperation(function(minuend, subtrahend) {
  20240. return minuend - subtrahend;
  20241. }, 0);
  20242. /**
  20243. * Computes the sum of the values in `array`.
  20244. *
  20245. * @static
  20246. * @memberOf _
  20247. * @since 3.4.0
  20248. * @category Math
  20249. * @param {Array} array The array to iterate over.
  20250. * @returns {number} Returns the sum.
  20251. * @example
  20252. *
  20253. * _.sum([4, 2, 8, 6]);
  20254. * // => 20
  20255. */
  20256. function sum(array) {
  20257. return (array && array.length)
  20258. ? baseSum(array, identity)
  20259. : 0;
  20260. }
  20261. /**
  20262. * This method is like `_.sum` except that it accepts `iteratee` which is
  20263. * invoked for each element in `array` to generate the value to be summed.
  20264. * The iteratee is invoked with one argument: (value).
  20265. *
  20266. * @static
  20267. * @memberOf _
  20268. * @since 4.0.0
  20269. * @category Math
  20270. * @param {Array} array The array to iterate over.
  20271. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20272. * @returns {number} Returns the sum.
  20273. * @example
  20274. *
  20275. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  20276. *
  20277. * _.sumBy(objects, function(o) { return o.n; });
  20278. * // => 20
  20279. *
  20280. * // The `_.property` iteratee shorthand.
  20281. * _.sumBy(objects, 'n');
  20282. * // => 20
  20283. */
  20284. function sumBy(array, iteratee) {
  20285. return (array && array.length)
  20286. ? baseSum(array, getIteratee(iteratee, 2))
  20287. : 0;
  20288. }
  20289. /*------------------------------------------------------------------------*/
  20290. // Add methods that return wrapped values in chain sequences.
  20291. lodash.after = after;
  20292. lodash.ary = ary;
  20293. lodash.assign = assign;
  20294. lodash.assignIn = assignIn;
  20295. lodash.assignInWith = assignInWith;
  20296. lodash.assignWith = assignWith;
  20297. lodash.at = at;
  20298. lodash.before = before;
  20299. lodash.bind = bind;
  20300. lodash.bindAll = bindAll;
  20301. lodash.bindKey = bindKey;
  20302. lodash.castArray = castArray;
  20303. lodash.chain = chain;
  20304. lodash.chunk = chunk;
  20305. lodash.compact = compact;
  20306. lodash.concat = concat;
  20307. lodash.cond = cond;
  20308. lodash.conforms = conforms;
  20309. lodash.constant = constant;
  20310. lodash.countBy = countBy;
  20311. lodash.create = create;
  20312. lodash.curry = curry;
  20313. lodash.curryRight = curryRight;
  20314. lodash.debounce = debounce;
  20315. lodash.defaults = defaults;
  20316. lodash.defaultsDeep = defaultsDeep;
  20317. lodash.defer = defer;
  20318. lodash.delay = delay;
  20319. lodash.difference = difference;
  20320. lodash.differenceBy = differenceBy;
  20321. lodash.differenceWith = differenceWith;
  20322. lodash.drop = drop;
  20323. lodash.dropRight = dropRight;
  20324. lodash.dropRightWhile = dropRightWhile;
  20325. lodash.dropWhile = dropWhile;
  20326. lodash.fill = fill;
  20327. lodash.filter = filter;
  20328. lodash.flatMap = flatMap;
  20329. lodash.flatMapDeep = flatMapDeep;
  20330. lodash.flatMapDepth = flatMapDepth;
  20331. lodash.flatten = flatten;
  20332. lodash.flattenDeep = flattenDeep;
  20333. lodash.flattenDepth = flattenDepth;
  20334. lodash.flip = flip;
  20335. lodash.flow = flow;
  20336. lodash.flowRight = flowRight;
  20337. lodash.fromPairs = fromPairs;
  20338. lodash.functions = functions;
  20339. lodash.functionsIn = functionsIn;
  20340. lodash.groupBy = groupBy;
  20341. lodash.initial = initial;
  20342. lodash.intersection = intersection;
  20343. lodash.intersectionBy = intersectionBy;
  20344. lodash.intersectionWith = intersectionWith;
  20345. lodash.invert = invert;
  20346. lodash.invertBy = invertBy;
  20347. lodash.invokeMap = invokeMap;
  20348. lodash.iteratee = iteratee;
  20349. lodash.keyBy = keyBy;
  20350. lodash.keys = keys;
  20351. lodash.keysIn = keysIn;
  20352. lodash.map = map;
  20353. lodash.mapKeys = mapKeys;
  20354. lodash.mapValues = mapValues;
  20355. lodash.matches = matches;
  20356. lodash.matchesProperty = matchesProperty;
  20357. lodash.memoize = memoize;
  20358. lodash.merge = merge;
  20359. lodash.mergeWith = mergeWith;
  20360. lodash.method = method;
  20361. lodash.methodOf = methodOf;
  20362. lodash.mixin = mixin;
  20363. lodash.negate = negate;
  20364. lodash.nthArg = nthArg;
  20365. lodash.omit = omit;
  20366. lodash.omitBy = omitBy;
  20367. lodash.once = once;
  20368. lodash.orderBy = orderBy;
  20369. lodash.over = over;
  20370. lodash.overArgs = overArgs;
  20371. lodash.overEvery = overEvery;
  20372. lodash.overSome = overSome;
  20373. lodash.partial = partial;
  20374. lodash.partialRight = partialRight;
  20375. lodash.partition = partition;
  20376. lodash.pick = pick;
  20377. lodash.pickBy = pickBy;
  20378. lodash.property = property;
  20379. lodash.propertyOf = propertyOf;
  20380. lodash.pull = pull;
  20381. lodash.pullAll = pullAll;
  20382. lodash.pullAllBy = pullAllBy;
  20383. lodash.pullAllWith = pullAllWith;
  20384. lodash.pullAt = pullAt;
  20385. lodash.range = range;
  20386. lodash.rangeRight = rangeRight;
  20387. lodash.rearg = rearg;
  20388. lodash.reject = reject;
  20389. lodash.remove = remove;
  20390. lodash.rest = rest;
  20391. lodash.reverse = reverse;
  20392. lodash.sampleSize = sampleSize;
  20393. lodash.set = set;
  20394. lodash.setWith = setWith;
  20395. lodash.shuffle = shuffle;
  20396. lodash.slice = slice;
  20397. lodash.sortBy = sortBy;
  20398. lodash.sortedUniq = sortedUniq;
  20399. lodash.sortedUniqBy = sortedUniqBy;
  20400. lodash.split = split;
  20401. lodash.spread = spread;
  20402. lodash.tail = tail;
  20403. lodash.take = take;
  20404. lodash.takeRight = takeRight;
  20405. lodash.takeRightWhile = takeRightWhile;
  20406. lodash.takeWhile = takeWhile;
  20407. lodash.tap = tap;
  20408. lodash.throttle = throttle;
  20409. lodash.thru = thru;
  20410. lodash.toArray = toArray;
  20411. lodash.toPairs = toPairs;
  20412. lodash.toPairsIn = toPairsIn;
  20413. lodash.toPath = toPath;
  20414. lodash.toPlainObject = toPlainObject;
  20415. lodash.transform = transform;
  20416. lodash.unary = unary;
  20417. lodash.union = union;
  20418. lodash.unionBy = unionBy;
  20419. lodash.unionWith = unionWith;
  20420. lodash.uniq = uniq;
  20421. lodash.uniqBy = uniqBy;
  20422. lodash.uniqWith = uniqWith;
  20423. lodash.unset = unset;
  20424. lodash.unzip = unzip;
  20425. lodash.unzipWith = unzipWith;
  20426. lodash.update = update;
  20427. lodash.updateWith = updateWith;
  20428. lodash.values = values;
  20429. lodash.valuesIn = valuesIn;
  20430. lodash.without = without;
  20431. lodash.words = words;
  20432. lodash.wrap = wrap;
  20433. lodash.xor = xor;
  20434. lodash.xorBy = xorBy;
  20435. lodash.xorWith = xorWith;
  20436. lodash.zip = zip;
  20437. lodash.zipObject = zipObject;
  20438. lodash.zipObjectDeep = zipObjectDeep;
  20439. lodash.zipWith = zipWith;
  20440. // Add aliases.
  20441. lodash.entries = toPairs;
  20442. lodash.entriesIn = toPairsIn;
  20443. lodash.extend = assignIn;
  20444. lodash.extendWith = assignInWith;
  20445. // Add methods to `lodash.prototype`.
  20446. mixin(lodash, lodash);
  20447. /*------------------------------------------------------------------------*/
  20448. // Add methods that return unwrapped values in chain sequences.
  20449. lodash.add = add;
  20450. lodash.attempt = attempt;
  20451. lodash.camelCase = camelCase;
  20452. lodash.capitalize = capitalize;
  20453. lodash.ceil = ceil;
  20454. lodash.clamp = clamp;
  20455. lodash.clone = clone;
  20456. lodash.cloneDeep = cloneDeep;
  20457. lodash.cloneDeepWith = cloneDeepWith;
  20458. lodash.cloneWith = cloneWith;
  20459. lodash.conformsTo = conformsTo;
  20460. lodash.deburr = deburr;
  20461. lodash.defaultTo = defaultTo;
  20462. lodash.divide = divide;
  20463. lodash.endsWith = endsWith;
  20464. lodash.eq = eq;
  20465. lodash.escape = escape;
  20466. lodash.escapeRegExp = escapeRegExp;
  20467. lodash.every = every;
  20468. lodash.find = find;
  20469. lodash.findIndex = findIndex;
  20470. lodash.findKey = findKey;
  20471. lodash.findLast = findLast;
  20472. lodash.findLastIndex = findLastIndex;
  20473. lodash.findLastKey = findLastKey;
  20474. lodash.floor = floor;
  20475. lodash.forEach = forEach;
  20476. lodash.forEachRight = forEachRight;
  20477. lodash.forIn = forIn;
  20478. lodash.forInRight = forInRight;
  20479. lodash.forOwn = forOwn;
  20480. lodash.forOwnRight = forOwnRight;
  20481. lodash.get = get;
  20482. lodash.gt = gt;
  20483. lodash.gte = gte;
  20484. lodash.has = has;
  20485. lodash.hasIn = hasIn;
  20486. lodash.head = head;
  20487. lodash.identity = identity;
  20488. lodash.includes = includes;
  20489. lodash.indexOf = indexOf;
  20490. lodash.inRange = inRange;
  20491. lodash.invoke = invoke;
  20492. lodash.isArguments = isArguments;
  20493. lodash.isArray = isArray;
  20494. lodash.isArrayBuffer = isArrayBuffer;
  20495. lodash.isArrayLike = isArrayLike;
  20496. lodash.isArrayLikeObject = isArrayLikeObject;
  20497. lodash.isBoolean = isBoolean;
  20498. lodash.isBuffer = isBuffer;
  20499. lodash.isDate = isDate;
  20500. lodash.isElement = isElement;
  20501. lodash.isEmpty = isEmpty;
  20502. lodash.isEqual = isEqual;
  20503. lodash.isEqualWith = isEqualWith;
  20504. lodash.isError = isError;
  20505. lodash.isFinite = isFinite;
  20506. lodash.isFunction = isFunction;
  20507. lodash.isInteger = isInteger;
  20508. lodash.isLength = isLength;
  20509. lodash.isMap = isMap;
  20510. lodash.isMatch = isMatch;
  20511. lodash.isMatchWith = isMatchWith;
  20512. lodash.isNaN = isNaN;
  20513. lodash.isNative = isNative;
  20514. lodash.isNil = isNil;
  20515. lodash.isNull = isNull;
  20516. lodash.isNumber = isNumber;
  20517. lodash.isObject = isObject;
  20518. lodash.isObjectLike = isObjectLike;
  20519. lodash.isPlainObject = isPlainObject;
  20520. lodash.isRegExp = isRegExp;
  20521. lodash.isSafeInteger = isSafeInteger;
  20522. lodash.isSet = isSet;
  20523. lodash.isString = isString;
  20524. lodash.isSymbol = isSymbol;
  20525. lodash.isTypedArray = isTypedArray;
  20526. lodash.isUndefined = isUndefined;
  20527. lodash.isWeakMap = isWeakMap;
  20528. lodash.isWeakSet = isWeakSet;
  20529. lodash.join = join;
  20530. lodash.kebabCase = kebabCase;
  20531. lodash.last = last;
  20532. lodash.lastIndexOf = lastIndexOf;
  20533. lodash.lowerCase = lowerCase;
  20534. lodash.lowerFirst = lowerFirst;
  20535. lodash.lt = lt;
  20536. lodash.lte = lte;
  20537. lodash.max = max;
  20538. lodash.maxBy = maxBy;
  20539. lodash.mean = mean;
  20540. lodash.meanBy = meanBy;
  20541. lodash.min = min;
  20542. lodash.minBy = minBy;
  20543. lodash.stubArray = stubArray;
  20544. lodash.stubFalse = stubFalse;
  20545. lodash.stubObject = stubObject;
  20546. lodash.stubString = stubString;
  20547. lodash.stubTrue = stubTrue;
  20548. lodash.multiply = multiply;
  20549. lodash.nth = nth;
  20550. lodash.noConflict = noConflict;
  20551. lodash.noop = noop;
  20552. lodash.now = now;
  20553. lodash.pad = pad;
  20554. lodash.padEnd = padEnd;
  20555. lodash.padStart = padStart;
  20556. lodash.parseInt = parseInt;
  20557. lodash.random = random;
  20558. lodash.reduce = reduce;
  20559. lodash.reduceRight = reduceRight;
  20560. lodash.repeat = repeat;
  20561. lodash.replace = replace;
  20562. lodash.result = result;
  20563. lodash.round = round;
  20564. lodash.runInContext = runInContext;
  20565. lodash.sample = sample;
  20566. lodash.size = size;
  20567. lodash.snakeCase = snakeCase;
  20568. lodash.some = some;
  20569. lodash.sortedIndex = sortedIndex;
  20570. lodash.sortedIndexBy = sortedIndexBy;
  20571. lodash.sortedIndexOf = sortedIndexOf;
  20572. lodash.sortedLastIndex = sortedLastIndex;
  20573. lodash.sortedLastIndexBy = sortedLastIndexBy;
  20574. lodash.sortedLastIndexOf = sortedLastIndexOf;
  20575. lodash.startCase = startCase;
  20576. lodash.startsWith = startsWith;
  20577. lodash.subtract = subtract;
  20578. lodash.sum = sum;
  20579. lodash.sumBy = sumBy;
  20580. lodash.template = template;
  20581. lodash.times = times;
  20582. lodash.toFinite = toFinite;
  20583. lodash.toInteger = toInteger;
  20584. lodash.toLength = toLength;
  20585. lodash.toLower = toLower;
  20586. lodash.toNumber = toNumber;
  20587. lodash.toSafeInteger = toSafeInteger;
  20588. lodash.toString = toString;
  20589. lodash.toUpper = toUpper;
  20590. lodash.trim = trim;
  20591. lodash.trimEnd = trimEnd;
  20592. lodash.trimStart = trimStart;
  20593. lodash.truncate = truncate;
  20594. lodash.unescape = unescape;
  20595. lodash.uniqueId = uniqueId;
  20596. lodash.upperCase = upperCase;
  20597. lodash.upperFirst = upperFirst;
  20598. // Add aliases.
  20599. lodash.each = forEach;
  20600. lodash.eachRight = forEachRight;
  20601. lodash.first = head;
  20602. mixin(lodash, (function() {
  20603. var source = {};
  20604. baseForOwn(lodash, function(func, methodName) {
  20605. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  20606. source[methodName] = func;
  20607. }
  20608. });
  20609. return source;
  20610. }()), { 'chain': false });
  20611. /*------------------------------------------------------------------------*/
  20612. /**
  20613. * The semantic version number.
  20614. *
  20615. * @static
  20616. * @memberOf _
  20617. * @type {string}
  20618. */
  20619. lodash.VERSION = VERSION;
  20620. // Assign default placeholders.
  20621. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  20622. lodash[methodName].placeholder = lodash;
  20623. });
  20624. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  20625. arrayEach(['drop', 'take'], function(methodName, index) {
  20626. LazyWrapper.prototype[methodName] = function(n) {
  20627. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  20628. var result = (this.__filtered__ && !index)
  20629. ? new LazyWrapper(this)
  20630. : this.clone();
  20631. if (result.__filtered__) {
  20632. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  20633. } else {
  20634. result.__views__.push({
  20635. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  20636. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  20637. });
  20638. }
  20639. return result;
  20640. };
  20641. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  20642. return this.reverse()[methodName](n).reverse();
  20643. };
  20644. });
  20645. // Add `LazyWrapper` methods that accept an `iteratee` value.
  20646. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  20647. var type = index + 1,
  20648. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  20649. LazyWrapper.prototype[methodName] = function(iteratee) {
  20650. var result = this.clone();
  20651. result.__iteratees__.push({
  20652. 'iteratee': getIteratee(iteratee, 3),
  20653. 'type': type
  20654. });
  20655. result.__filtered__ = result.__filtered__ || isFilter;
  20656. return result;
  20657. };
  20658. });
  20659. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  20660. arrayEach(['head', 'last'], function(methodName, index) {
  20661. var takeName = 'take' + (index ? 'Right' : '');
  20662. LazyWrapper.prototype[methodName] = function() {
  20663. return this[takeName](1).value()[0];
  20664. };
  20665. });
  20666. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  20667. arrayEach(['initial', 'tail'], function(methodName, index) {
  20668. var dropName = 'drop' + (index ? '' : 'Right');
  20669. LazyWrapper.prototype[methodName] = function() {
  20670. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  20671. };
  20672. });
  20673. LazyWrapper.prototype.compact = function() {
  20674. return this.filter(identity);
  20675. };
  20676. LazyWrapper.prototype.find = function(predicate) {
  20677. return this.filter(predicate).head();
  20678. };
  20679. LazyWrapper.prototype.findLast = function(predicate) {
  20680. return this.reverse().find(predicate);
  20681. };
  20682. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  20683. if (typeof path == 'function') {
  20684. return new LazyWrapper(this);
  20685. }
  20686. return this.map(function(value) {
  20687. return baseInvoke(value, path, args);
  20688. });
  20689. });
  20690. LazyWrapper.prototype.reject = function(predicate) {
  20691. return this.filter(negate(getIteratee(predicate)));
  20692. };
  20693. LazyWrapper.prototype.slice = function(start, end) {
  20694. start = toInteger(start);
  20695. var result = this;
  20696. if (result.__filtered__ && (start > 0 || end < 0)) {
  20697. return new LazyWrapper(result);
  20698. }
  20699. if (start < 0) {
  20700. result = result.takeRight(-start);
  20701. } else if (start) {
  20702. result = result.drop(start);
  20703. }
  20704. if (end !== undefined) {
  20705. end = toInteger(end);
  20706. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  20707. }
  20708. return result;
  20709. };
  20710. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  20711. return this.reverse().takeWhile(predicate).reverse();
  20712. };
  20713. LazyWrapper.prototype.toArray = function() {
  20714. return this.take(MAX_ARRAY_LENGTH);
  20715. };
  20716. // Add `LazyWrapper` methods to `lodash.prototype`.
  20717. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  20718. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  20719. isTaker = /^(?:head|last)$/.test(methodName),
  20720. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  20721. retUnwrapped = isTaker || /^find/.test(methodName);
  20722. if (!lodashFunc) {
  20723. return;
  20724. }
  20725. lodash.prototype[methodName] = function() {
  20726. var value = this.__wrapped__,
  20727. args = isTaker ? [1] : arguments,
  20728. isLazy = value instanceof LazyWrapper,
  20729. iteratee = args[0],
  20730. useLazy = isLazy || isArray(value);
  20731. var interceptor = function(value) {
  20732. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  20733. return (isTaker && chainAll) ? result[0] : result;
  20734. };
  20735. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  20736. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  20737. isLazy = useLazy = false;
  20738. }
  20739. var chainAll = this.__chain__,
  20740. isHybrid = !!this.__actions__.length,
  20741. isUnwrapped = retUnwrapped && !chainAll,
  20742. onlyLazy = isLazy && !isHybrid;
  20743. if (!retUnwrapped && useLazy) {
  20744. value = onlyLazy ? value : new LazyWrapper(this);
  20745. var result = func.apply(value, args);
  20746. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  20747. return new LodashWrapper(result, chainAll);
  20748. }
  20749. if (isUnwrapped && onlyLazy) {
  20750. return func.apply(this, args);
  20751. }
  20752. result = this.thru(interceptor);
  20753. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  20754. };
  20755. });
  20756. // Add `Array` methods to `lodash.prototype`.
  20757. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  20758. var func = arrayProto[methodName],
  20759. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  20760. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  20761. lodash.prototype[methodName] = function() {
  20762. var args = arguments;
  20763. if (retUnwrapped && !this.__chain__) {
  20764. var value = this.value();
  20765. return func.apply(isArray(value) ? value : [], args);
  20766. }
  20767. return this[chainName](function(value) {
  20768. return func.apply(isArray(value) ? value : [], args);
  20769. });
  20770. };
  20771. });
  20772. // Map minified method names to their real names.
  20773. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  20774. var lodashFunc = lodash[methodName];
  20775. if (lodashFunc) {
  20776. var key = lodashFunc.name + '';
  20777. if (!hasOwnProperty.call(realNames, key)) {
  20778. realNames[key] = [];
  20779. }
  20780. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  20781. }
  20782. });
  20783. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  20784. 'name': 'wrapper',
  20785. 'func': undefined
  20786. }];
  20787. // Add methods to `LazyWrapper`.
  20788. LazyWrapper.prototype.clone = lazyClone;
  20789. LazyWrapper.prototype.reverse = lazyReverse;
  20790. LazyWrapper.prototype.value = lazyValue;
  20791. // Add chain sequence methods to the `lodash` wrapper.
  20792. lodash.prototype.at = wrapperAt;
  20793. lodash.prototype.chain = wrapperChain;
  20794. lodash.prototype.commit = wrapperCommit;
  20795. lodash.prototype.next = wrapperNext;
  20796. lodash.prototype.plant = wrapperPlant;
  20797. lodash.prototype.reverse = wrapperReverse;
  20798. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  20799. // Add lazy aliases.
  20800. lodash.prototype.first = lodash.prototype.head;
  20801. if (symIterator) {
  20802. lodash.prototype[symIterator] = wrapperToIterator;
  20803. }
  20804. return lodash;
  20805. });
  20806. /*--------------------------------------------------------------------------*/
  20807. // Export lodash.
  20808. var _ = runInContext();
  20809. // Some AMD build optimizers, like r.js, check for condition patterns like:
  20810. if (true) {
  20811. // Expose Lodash on the global object to prevent errors when Lodash is
  20812. // loaded by a script tag in the presence of an AMD loader.
  20813. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  20814. // Use `_.noConflict` to remove Lodash from the global object.
  20815. root._ = _;
  20816. // Define as an anonymous module so, through path mapping, it can be
  20817. // referenced as the "underscore" module.
  20818. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  20819. return _;
  20820. }).call(exports, __webpack_require__, exports, module),
  20821. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  20822. }
  20823. // Check for `exports` after `define` in case a build optimizer adds it.
  20824. else {}
  20825. }.call(this));
  20826. /***/ }),
  20827. /***/ "./resources/css/app.css":
  20828. /*!*******************************!*\
  20829. !*** ./resources/css/app.css ***!
  20830. \*******************************/
  20831. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  20832. "use strict";
  20833. __webpack_require__.r(__webpack_exports__);
  20834. // extracted by mini-css-extract-plugin
  20835. /***/ }),
  20836. /***/ "./node_modules/process/browser.js":
  20837. /*!*****************************************!*\
  20838. !*** ./node_modules/process/browser.js ***!
  20839. \*****************************************/
  20840. /***/ ((module) => {
  20841. // shim for using process in browser
  20842. var process = module.exports = {};
  20843. // cached from whatever global is present so that test runners that stub it
  20844. // don't break things. But we need to wrap it in a try catch in case it is
  20845. // wrapped in strict mode code which doesn't define any globals. It's inside a
  20846. // function because try/catches deoptimize in certain engines.
  20847. var cachedSetTimeout;
  20848. var cachedClearTimeout;
  20849. function defaultSetTimout() {
  20850. throw new Error('setTimeout has not been defined');
  20851. }
  20852. function defaultClearTimeout () {
  20853. throw new Error('clearTimeout has not been defined');
  20854. }
  20855. (function () {
  20856. try {
  20857. if (typeof setTimeout === 'function') {
  20858. cachedSetTimeout = setTimeout;
  20859. } else {
  20860. cachedSetTimeout = defaultSetTimout;
  20861. }
  20862. } catch (e) {
  20863. cachedSetTimeout = defaultSetTimout;
  20864. }
  20865. try {
  20866. if (typeof clearTimeout === 'function') {
  20867. cachedClearTimeout = clearTimeout;
  20868. } else {
  20869. cachedClearTimeout = defaultClearTimeout;
  20870. }
  20871. } catch (e) {
  20872. cachedClearTimeout = defaultClearTimeout;
  20873. }
  20874. } ())
  20875. function runTimeout(fun) {
  20876. if (cachedSetTimeout === setTimeout) {
  20877. //normal enviroments in sane situations
  20878. return setTimeout(fun, 0);
  20879. }
  20880. // if setTimeout wasn't available but was latter defined
  20881. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  20882. cachedSetTimeout = setTimeout;
  20883. return setTimeout(fun, 0);
  20884. }
  20885. try {
  20886. // when when somebody has screwed with setTimeout but no I.E. maddness
  20887. return cachedSetTimeout(fun, 0);
  20888. } catch(e){
  20889. try {
  20890. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  20891. return cachedSetTimeout.call(null, fun, 0);
  20892. } catch(e){
  20893. // 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
  20894. return cachedSetTimeout.call(this, fun, 0);
  20895. }
  20896. }
  20897. }
  20898. function runClearTimeout(marker) {
  20899. if (cachedClearTimeout === clearTimeout) {
  20900. //normal enviroments in sane situations
  20901. return clearTimeout(marker);
  20902. }
  20903. // if clearTimeout wasn't available but was latter defined
  20904. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  20905. cachedClearTimeout = clearTimeout;
  20906. return clearTimeout(marker);
  20907. }
  20908. try {
  20909. // when when somebody has screwed with setTimeout but no I.E. maddness
  20910. return cachedClearTimeout(marker);
  20911. } catch (e){
  20912. try {
  20913. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  20914. return cachedClearTimeout.call(null, marker);
  20915. } catch (e){
  20916. // 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.
  20917. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  20918. return cachedClearTimeout.call(this, marker);
  20919. }
  20920. }
  20921. }
  20922. var queue = [];
  20923. var draining = false;
  20924. var currentQueue;
  20925. var queueIndex = -1;
  20926. function cleanUpNextTick() {
  20927. if (!draining || !currentQueue) {
  20928. return;
  20929. }
  20930. draining = false;
  20931. if (currentQueue.length) {
  20932. queue = currentQueue.concat(queue);
  20933. } else {
  20934. queueIndex = -1;
  20935. }
  20936. if (queue.length) {
  20937. drainQueue();
  20938. }
  20939. }
  20940. function drainQueue() {
  20941. if (draining) {
  20942. return;
  20943. }
  20944. var timeout = runTimeout(cleanUpNextTick);
  20945. draining = true;
  20946. var len = queue.length;
  20947. while(len) {
  20948. currentQueue = queue;
  20949. queue = [];
  20950. while (++queueIndex < len) {
  20951. if (currentQueue) {
  20952. currentQueue[queueIndex].run();
  20953. }
  20954. }
  20955. queueIndex = -1;
  20956. len = queue.length;
  20957. }
  20958. currentQueue = null;
  20959. draining = false;
  20960. runClearTimeout(timeout);
  20961. }
  20962. process.nextTick = function (fun) {
  20963. var args = new Array(arguments.length - 1);
  20964. if (arguments.length > 1) {
  20965. for (var i = 1; i < arguments.length; i++) {
  20966. args[i - 1] = arguments[i];
  20967. }
  20968. }
  20969. queue.push(new Item(fun, args));
  20970. if (queue.length === 1 && !draining) {
  20971. runTimeout(drainQueue);
  20972. }
  20973. };
  20974. // v8 likes predictible objects
  20975. function Item(fun, array) {
  20976. this.fun = fun;
  20977. this.array = array;
  20978. }
  20979. Item.prototype.run = function () {
  20980. this.fun.apply(null, this.array);
  20981. };
  20982. process.title = 'browser';
  20983. process.browser = true;
  20984. process.env = {};
  20985. process.argv = [];
  20986. process.version = ''; // empty string to avoid regexp issues
  20987. process.versions = {};
  20988. function noop() {}
  20989. process.on = noop;
  20990. process.addListener = noop;
  20991. process.once = noop;
  20992. process.off = noop;
  20993. process.removeListener = noop;
  20994. process.removeAllListeners = noop;
  20995. process.emit = noop;
  20996. process.prependListener = noop;
  20997. process.prependOnceListener = noop;
  20998. process.listeners = function (name) { return [] }
  20999. process.binding = function (name) {
  21000. throw new Error('process.binding is not supported');
  21001. };
  21002. process.cwd = function () { return '/' };
  21003. process.chdir = function (dir) {
  21004. throw new Error('process.chdir is not supported');
  21005. };
  21006. process.umask = function() { return 0; };
  21007. /***/ })
  21008. /******/ });
  21009. /************************************************************************/
  21010. /******/ // The module cache
  21011. /******/ var __webpack_module_cache__ = {};
  21012. /******/
  21013. /******/ // The require function
  21014. /******/ function __webpack_require__(moduleId) {
  21015. /******/ // Check if module is in cache
  21016. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  21017. /******/ if (cachedModule !== undefined) {
  21018. /******/ return cachedModule.exports;
  21019. /******/ }
  21020. /******/ // Create a new module (and put it into the cache)
  21021. /******/ var module = __webpack_module_cache__[moduleId] = {
  21022. /******/ id: moduleId,
  21023. /******/ loaded: false,
  21024. /******/ exports: {}
  21025. /******/ };
  21026. /******/
  21027. /******/ // Execute the module function
  21028. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21029. /******/
  21030. /******/ // Flag the module as loaded
  21031. /******/ module.loaded = true;
  21032. /******/
  21033. /******/ // Return the exports of the module
  21034. /******/ return module.exports;
  21035. /******/ }
  21036. /******/
  21037. /******/ // expose the modules object (__webpack_modules__)
  21038. /******/ __webpack_require__.m = __webpack_modules__;
  21039. /******/
  21040. /************************************************************************/
  21041. /******/ /* webpack/runtime/chunk loaded */
  21042. /******/ (() => {
  21043. /******/ var deferred = [];
  21044. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  21045. /******/ if(chunkIds) {
  21046. /******/ priority = priority || 0;
  21047. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  21048. /******/ deferred[i] = [chunkIds, fn, priority];
  21049. /******/ return;
  21050. /******/ }
  21051. /******/ var notFulfilled = Infinity;
  21052. /******/ for (var i = 0; i < deferred.length; i++) {
  21053. /******/ var [chunkIds, fn, priority] = deferred[i];
  21054. /******/ var fulfilled = true;
  21055. /******/ for (var j = 0; j < chunkIds.length; j++) {
  21056. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  21057. /******/ chunkIds.splice(j--, 1);
  21058. /******/ } else {
  21059. /******/ fulfilled = false;
  21060. /******/ if(priority < notFulfilled) notFulfilled = priority;
  21061. /******/ }
  21062. /******/ }
  21063. /******/ if(fulfilled) {
  21064. /******/ deferred.splice(i--, 1)
  21065. /******/ var r = fn();
  21066. /******/ if (r !== undefined) result = r;
  21067. /******/ }
  21068. /******/ }
  21069. /******/ return result;
  21070. /******/ };
  21071. /******/ })();
  21072. /******/
  21073. /******/ /* webpack/runtime/define property getters */
  21074. /******/ (() => {
  21075. /******/ // define getter functions for harmony exports
  21076. /******/ __webpack_require__.d = (exports, definition) => {
  21077. /******/ for(var key in definition) {
  21078. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  21079. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  21080. /******/ }
  21081. /******/ }
  21082. /******/ };
  21083. /******/ })();
  21084. /******/
  21085. /******/ /* webpack/runtime/global */
  21086. /******/ (() => {
  21087. /******/ __webpack_require__.g = (function() {
  21088. /******/ if (typeof globalThis === 'object') return globalThis;
  21089. /******/ try {
  21090. /******/ return this || new Function('return this')();
  21091. /******/ } catch (e) {
  21092. /******/ if (typeof window === 'object') return window;
  21093. /******/ }
  21094. /******/ })();
  21095. /******/ })();
  21096. /******/
  21097. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  21098. /******/ (() => {
  21099. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  21100. /******/ })();
  21101. /******/
  21102. /******/ /* webpack/runtime/make namespace object */
  21103. /******/ (() => {
  21104. /******/ // define __esModule on exports
  21105. /******/ __webpack_require__.r = (exports) => {
  21106. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  21107. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  21108. /******/ }
  21109. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  21110. /******/ };
  21111. /******/ })();
  21112. /******/
  21113. /******/ /* webpack/runtime/node module decorator */
  21114. /******/ (() => {
  21115. /******/ __webpack_require__.nmd = (module) => {
  21116. /******/ module.paths = [];
  21117. /******/ if (!module.children) module.children = [];
  21118. /******/ return module;
  21119. /******/ };
  21120. /******/ })();
  21121. /******/
  21122. /******/ /* webpack/runtime/jsonp chunk loading */
  21123. /******/ (() => {
  21124. /******/ // no baseURI
  21125. /******/
  21126. /******/ // object to store loaded and loading chunks
  21127. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  21128. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  21129. /******/ var installedChunks = {
  21130. /******/ "/js/app": 0,
  21131. /******/ "css/app": 0
  21132. /******/ };
  21133. /******/
  21134. /******/ // no chunk on demand loading
  21135. /******/
  21136. /******/ // no prefetching
  21137. /******/
  21138. /******/ // no preloaded
  21139. /******/
  21140. /******/ // no HMR
  21141. /******/
  21142. /******/ // no HMR manifest
  21143. /******/
  21144. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  21145. /******/
  21146. /******/ // install a JSONP callback for chunk loading
  21147. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  21148. /******/ var [chunkIds, moreModules, runtime] = data;
  21149. /******/ // add "moreModules" to the modules object,
  21150. /******/ // then flag all "chunkIds" as loaded and fire callback
  21151. /******/ var moduleId, chunkId, i = 0;
  21152. /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
  21153. /******/ for(moduleId in moreModules) {
  21154. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  21155. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  21156. /******/ }
  21157. /******/ }
  21158. /******/ if(runtime) var result = runtime(__webpack_require__);
  21159. /******/ }
  21160. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  21161. /******/ for(;i < chunkIds.length; i++) {
  21162. /******/ chunkId = chunkIds[i];
  21163. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  21164. /******/ installedChunks[chunkId][0]();
  21165. /******/ }
  21166. /******/ installedChunks[chunkId] = 0;
  21167. /******/ }
  21168. /******/ return __webpack_require__.O(result);
  21169. /******/ }
  21170. /******/
  21171. /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
  21172. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  21173. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  21174. /******/ })();
  21175. /******/
  21176. /************************************************************************/
  21177. /******/
  21178. /******/ // startup
  21179. /******/ // Load entry module and return exports
  21180. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  21181. /******/ __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/js/app.js")))
  21182. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/css/app.css")))
  21183. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  21184. /******/
  21185. /******/ })()
  21186. ;