app.js 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  1574. /*!***************************************************************************************************************************************************************************!*\
  1575. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  1576. \***************************************************************************************************************************************************************************/
  1577. /*! exports provided: default */
  1578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1579. "use strict";
  1580. __webpack_require__.r(__webpack_exports__);
  1581. //
  1582. //
  1583. //
  1584. //
  1585. //
  1586. //
  1587. //
  1588. //
  1589. //
  1590. //
  1591. //
  1592. //
  1593. //
  1594. //
  1595. //
  1596. //
  1597. /* harmony default export */ __webpack_exports__["default"] = ({
  1598. mounted: function mounted() {
  1599. console.log('Component mounted.');
  1600. }
  1601. });
  1602. /***/ }),
  1603. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=script&lang=js&":
  1604. /*!*******************************************************************************************************************************************************************!*\
  1605. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/probdesc.vue?vue&type=script&lang=js& ***!
  1606. \*******************************************************************************************************************************************************************/
  1607. /*! exports provided: default */
  1608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1609. "use strict";
  1610. __webpack_require__.r(__webpack_exports__);
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. /* harmony default export */ __webpack_exports__["default"] = ({
  1618. data: function data() {
  1619. return {
  1620. probdesc: "",
  1621. suggested: ""
  1622. };
  1623. },
  1624. mounted: function mounted() {
  1625. var _this = this;
  1626. var url = window.location.href;
  1627. var id = url.substring(url.lastIndexOf('/') + 1);
  1628. axios.get('/api/workorder/' + id).then(function (response) {
  1629. _this.probdesc = response.data.probdesc;
  1630. _this.suggested = response.data.suggested;
  1631. });
  1632. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1633. _this.probdesc = e.probdesc;
  1634. _this.suggested = e.suggested;
  1635. console.log('Received Websocket Update');
  1636. });
  1637. }
  1638. });
  1639. /***/ }),
  1640. /***/ "./node_modules/base64-js/index.js":
  1641. /*!*****************************************!*\
  1642. !*** ./node_modules/base64-js/index.js ***!
  1643. \*****************************************/
  1644. /*! no static exports found */
  1645. /***/ (function(module, exports, __webpack_require__) {
  1646. "use strict";
  1647. exports.byteLength = byteLength
  1648. exports.toByteArray = toByteArray
  1649. exports.fromByteArray = fromByteArray
  1650. var lookup = []
  1651. var revLookup = []
  1652. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1653. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1654. for (var i = 0, len = code.length; i < len; ++i) {
  1655. lookup[i] = code[i]
  1656. revLookup[code.charCodeAt(i)] = i
  1657. }
  1658. // Support decoding URL-safe base64 strings, as Node.js does.
  1659. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1660. revLookup['-'.charCodeAt(0)] = 62
  1661. revLookup['_'.charCodeAt(0)] = 63
  1662. function getLens (b64) {
  1663. var len = b64.length
  1664. if (len % 4 > 0) {
  1665. throw new Error('Invalid string. Length must be a multiple of 4')
  1666. }
  1667. // Trim off extra bytes after placeholder bytes are found
  1668. // See: https://github.com/beatgammit/base64-js/issues/42
  1669. var validLen = b64.indexOf('=')
  1670. if (validLen === -1) validLen = len
  1671. var placeHoldersLen = validLen === len
  1672. ? 0
  1673. : 4 - (validLen % 4)
  1674. return [validLen, placeHoldersLen]
  1675. }
  1676. // base64 is 4/3 + up to two characters of the original data
  1677. function byteLength (b64) {
  1678. var lens = getLens(b64)
  1679. var validLen = lens[0]
  1680. var placeHoldersLen = lens[1]
  1681. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1682. }
  1683. function _byteLength (b64, validLen, placeHoldersLen) {
  1684. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1685. }
  1686. function toByteArray (b64) {
  1687. var tmp
  1688. var lens = getLens(b64)
  1689. var validLen = lens[0]
  1690. var placeHoldersLen = lens[1]
  1691. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1692. var curByte = 0
  1693. // if there are placeholders, only get up to the last complete 4 chars
  1694. var len = placeHoldersLen > 0
  1695. ? validLen - 4
  1696. : validLen
  1697. var i
  1698. for (i = 0; i < len; i += 4) {
  1699. tmp =
  1700. (revLookup[b64.charCodeAt(i)] << 18) |
  1701. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1702. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1703. revLookup[b64.charCodeAt(i + 3)]
  1704. arr[curByte++] = (tmp >> 16) & 0xFF
  1705. arr[curByte++] = (tmp >> 8) & 0xFF
  1706. arr[curByte++] = tmp & 0xFF
  1707. }
  1708. if (placeHoldersLen === 2) {
  1709. tmp =
  1710. (revLookup[b64.charCodeAt(i)] << 2) |
  1711. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1712. arr[curByte++] = tmp & 0xFF
  1713. }
  1714. if (placeHoldersLen === 1) {
  1715. tmp =
  1716. (revLookup[b64.charCodeAt(i)] << 10) |
  1717. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1718. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1719. arr[curByte++] = (tmp >> 8) & 0xFF
  1720. arr[curByte++] = tmp & 0xFF
  1721. }
  1722. return arr
  1723. }
  1724. function tripletToBase64 (num) {
  1725. return lookup[num >> 18 & 0x3F] +
  1726. lookup[num >> 12 & 0x3F] +
  1727. lookup[num >> 6 & 0x3F] +
  1728. lookup[num & 0x3F]
  1729. }
  1730. function encodeChunk (uint8, start, end) {
  1731. var tmp
  1732. var output = []
  1733. for (var i = start; i < end; i += 3) {
  1734. tmp =
  1735. ((uint8[i] << 16) & 0xFF0000) +
  1736. ((uint8[i + 1] << 8) & 0xFF00) +
  1737. (uint8[i + 2] & 0xFF)
  1738. output.push(tripletToBase64(tmp))
  1739. }
  1740. return output.join('')
  1741. }
  1742. function fromByteArray (uint8) {
  1743. var tmp
  1744. var len = uint8.length
  1745. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1746. var parts = []
  1747. var maxChunkLength = 16383 // must be multiple of 3
  1748. // go through the array every three bytes, we'll deal with trailing stuff later
  1749. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1750. parts.push(encodeChunk(
  1751. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1752. ))
  1753. }
  1754. // pad the end with zeros, but make sure to not forget the extra bytes
  1755. if (extraBytes === 1) {
  1756. tmp = uint8[len - 1]
  1757. parts.push(
  1758. lookup[tmp >> 2] +
  1759. lookup[(tmp << 4) & 0x3F] +
  1760. '=='
  1761. )
  1762. } else if (extraBytes === 2) {
  1763. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1764. parts.push(
  1765. lookup[tmp >> 10] +
  1766. lookup[(tmp >> 4) & 0x3F] +
  1767. lookup[(tmp << 2) & 0x3F] +
  1768. '='
  1769. )
  1770. }
  1771. return parts.join('')
  1772. }
  1773. /***/ }),
  1774. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1775. /*!*****************************************************!*\
  1776. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1777. \*****************************************************/
  1778. /*! no static exports found */
  1779. /***/ (function(module, exports, __webpack_require__) {
  1780. /*!
  1781. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1782. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1783. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1784. */
  1785. (function (global, factory) {
  1786. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1787. undefined;
  1788. }(this, (function (exports, $, Popper) { 'use strict';
  1789. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1790. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1791. function _defineProperties(target, props) {
  1792. for (var i = 0; i < props.length; i++) {
  1793. var descriptor = props[i];
  1794. descriptor.enumerable = descriptor.enumerable || false;
  1795. descriptor.configurable = true;
  1796. if ("value" in descriptor) descriptor.writable = true;
  1797. Object.defineProperty(target, descriptor.key, descriptor);
  1798. }
  1799. }
  1800. function _createClass(Constructor, protoProps, staticProps) {
  1801. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1802. if (staticProps) _defineProperties(Constructor, staticProps);
  1803. return Constructor;
  1804. }
  1805. function _defineProperty(obj, key, value) {
  1806. if (key in obj) {
  1807. Object.defineProperty(obj, key, {
  1808. value: value,
  1809. enumerable: true,
  1810. configurable: true,
  1811. writable: true
  1812. });
  1813. } else {
  1814. obj[key] = value;
  1815. }
  1816. return obj;
  1817. }
  1818. function ownKeys(object, enumerableOnly) {
  1819. var keys = Object.keys(object);
  1820. if (Object.getOwnPropertySymbols) {
  1821. var symbols = Object.getOwnPropertySymbols(object);
  1822. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1823. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1824. });
  1825. keys.push.apply(keys, symbols);
  1826. }
  1827. return keys;
  1828. }
  1829. function _objectSpread2(target) {
  1830. for (var i = 1; i < arguments.length; i++) {
  1831. var source = arguments[i] != null ? arguments[i] : {};
  1832. if (i % 2) {
  1833. ownKeys(Object(source), true).forEach(function (key) {
  1834. _defineProperty(target, key, source[key]);
  1835. });
  1836. } else if (Object.getOwnPropertyDescriptors) {
  1837. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1838. } else {
  1839. ownKeys(Object(source)).forEach(function (key) {
  1840. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1841. });
  1842. }
  1843. }
  1844. return target;
  1845. }
  1846. function _inheritsLoose(subClass, superClass) {
  1847. subClass.prototype = Object.create(superClass.prototype);
  1848. subClass.prototype.constructor = subClass;
  1849. subClass.__proto__ = superClass;
  1850. }
  1851. /**
  1852. * --------------------------------------------------------------------------
  1853. * Bootstrap (v4.4.1): util.js
  1854. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1855. * --------------------------------------------------------------------------
  1856. */
  1857. /**
  1858. * ------------------------------------------------------------------------
  1859. * Private TransitionEnd Helpers
  1860. * ------------------------------------------------------------------------
  1861. */
  1862. var TRANSITION_END = 'transitionend';
  1863. var MAX_UID = 1000000;
  1864. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1865. function toType(obj) {
  1866. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1867. }
  1868. function getSpecialTransitionEndEvent() {
  1869. return {
  1870. bindType: TRANSITION_END,
  1871. delegateType: TRANSITION_END,
  1872. handle: function handle(event) {
  1873. if ($(event.target).is(this)) {
  1874. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1875. }
  1876. return undefined; // eslint-disable-line no-undefined
  1877. }
  1878. };
  1879. }
  1880. function transitionEndEmulator(duration) {
  1881. var _this = this;
  1882. var called = false;
  1883. $(this).one(Util.TRANSITION_END, function () {
  1884. called = true;
  1885. });
  1886. setTimeout(function () {
  1887. if (!called) {
  1888. Util.triggerTransitionEnd(_this);
  1889. }
  1890. }, duration);
  1891. return this;
  1892. }
  1893. function setTransitionEndSupport() {
  1894. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1895. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1896. }
  1897. /**
  1898. * --------------------------------------------------------------------------
  1899. * Public Util Api
  1900. * --------------------------------------------------------------------------
  1901. */
  1902. var Util = {
  1903. TRANSITION_END: 'bsTransitionEnd',
  1904. getUID: function getUID(prefix) {
  1905. do {
  1906. // eslint-disable-next-line no-bitwise
  1907. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1908. } while (document.getElementById(prefix));
  1909. return prefix;
  1910. },
  1911. getSelectorFromElement: function getSelectorFromElement(element) {
  1912. var selector = element.getAttribute('data-target');
  1913. if (!selector || selector === '#') {
  1914. var hrefAttr = element.getAttribute('href');
  1915. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1916. }
  1917. try {
  1918. return document.querySelector(selector) ? selector : null;
  1919. } catch (err) {
  1920. return null;
  1921. }
  1922. },
  1923. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1924. if (!element) {
  1925. return 0;
  1926. } // Get transition-duration of the element
  1927. var transitionDuration = $(element).css('transition-duration');
  1928. var transitionDelay = $(element).css('transition-delay');
  1929. var floatTransitionDuration = parseFloat(transitionDuration);
  1930. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1931. if (!floatTransitionDuration && !floatTransitionDelay) {
  1932. return 0;
  1933. } // If multiple durations are defined, take the first
  1934. transitionDuration = transitionDuration.split(',')[0];
  1935. transitionDelay = transitionDelay.split(',')[0];
  1936. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1937. },
  1938. reflow: function reflow(element) {
  1939. return element.offsetHeight;
  1940. },
  1941. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1942. $(element).trigger(TRANSITION_END);
  1943. },
  1944. // TODO: Remove in v5
  1945. supportsTransitionEnd: function supportsTransitionEnd() {
  1946. return Boolean(TRANSITION_END);
  1947. },
  1948. isElement: function isElement(obj) {
  1949. return (obj[0] || obj).nodeType;
  1950. },
  1951. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1952. for (var property in configTypes) {
  1953. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1954. var expectedTypes = configTypes[property];
  1955. var value = config[property];
  1956. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1957. if (!new RegExp(expectedTypes).test(valueType)) {
  1958. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1959. }
  1960. }
  1961. }
  1962. },
  1963. findShadowRoot: function findShadowRoot(element) {
  1964. if (!document.documentElement.attachShadow) {
  1965. return null;
  1966. } // Can find the shadow root otherwise it'll return the document
  1967. if (typeof element.getRootNode === 'function') {
  1968. var root = element.getRootNode();
  1969. return root instanceof ShadowRoot ? root : null;
  1970. }
  1971. if (element instanceof ShadowRoot) {
  1972. return element;
  1973. } // when we don't find a shadow root
  1974. if (!element.parentNode) {
  1975. return null;
  1976. }
  1977. return Util.findShadowRoot(element.parentNode);
  1978. },
  1979. jQueryDetection: function jQueryDetection() {
  1980. if (typeof $ === 'undefined') {
  1981. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  1982. }
  1983. var version = $.fn.jquery.split(' ')[0].split('.');
  1984. var minMajor = 1;
  1985. var ltMajor = 2;
  1986. var minMinor = 9;
  1987. var minPatch = 1;
  1988. var maxMajor = 4;
  1989. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  1990. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  1991. }
  1992. }
  1993. };
  1994. Util.jQueryDetection();
  1995. setTransitionEndSupport();
  1996. /**
  1997. * ------------------------------------------------------------------------
  1998. * Constants
  1999. * ------------------------------------------------------------------------
  2000. */
  2001. var NAME = 'alert';
  2002. var VERSION = '4.4.1';
  2003. var DATA_KEY = 'bs.alert';
  2004. var EVENT_KEY = "." + DATA_KEY;
  2005. var DATA_API_KEY = '.data-api';
  2006. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2007. var Selector = {
  2008. DISMISS: '[data-dismiss="alert"]'
  2009. };
  2010. var Event = {
  2011. CLOSE: "close" + EVENT_KEY,
  2012. CLOSED: "closed" + EVENT_KEY,
  2013. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2014. };
  2015. var ClassName = {
  2016. ALERT: 'alert',
  2017. FADE: 'fade',
  2018. SHOW: 'show'
  2019. };
  2020. /**
  2021. * ------------------------------------------------------------------------
  2022. * Class Definition
  2023. * ------------------------------------------------------------------------
  2024. */
  2025. var Alert =
  2026. /*#__PURE__*/
  2027. function () {
  2028. function Alert(element) {
  2029. this._element = element;
  2030. } // Getters
  2031. var _proto = Alert.prototype;
  2032. // Public
  2033. _proto.close = function close(element) {
  2034. var rootElement = this._element;
  2035. if (element) {
  2036. rootElement = this._getRootElement(element);
  2037. }
  2038. var customEvent = this._triggerCloseEvent(rootElement);
  2039. if (customEvent.isDefaultPrevented()) {
  2040. return;
  2041. }
  2042. this._removeElement(rootElement);
  2043. };
  2044. _proto.dispose = function dispose() {
  2045. $.removeData(this._element, DATA_KEY);
  2046. this._element = null;
  2047. } // Private
  2048. ;
  2049. _proto._getRootElement = function _getRootElement(element) {
  2050. var selector = Util.getSelectorFromElement(element);
  2051. var parent = false;
  2052. if (selector) {
  2053. parent = document.querySelector(selector);
  2054. }
  2055. if (!parent) {
  2056. parent = $(element).closest("." + ClassName.ALERT)[0];
  2057. }
  2058. return parent;
  2059. };
  2060. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2061. var closeEvent = $.Event(Event.CLOSE);
  2062. $(element).trigger(closeEvent);
  2063. return closeEvent;
  2064. };
  2065. _proto._removeElement = function _removeElement(element) {
  2066. var _this = this;
  2067. $(element).removeClass(ClassName.SHOW);
  2068. if (!$(element).hasClass(ClassName.FADE)) {
  2069. this._destroyElement(element);
  2070. return;
  2071. }
  2072. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2073. $(element).one(Util.TRANSITION_END, function (event) {
  2074. return _this._destroyElement(element, event);
  2075. }).emulateTransitionEnd(transitionDuration);
  2076. };
  2077. _proto._destroyElement = function _destroyElement(element) {
  2078. $(element).detach().trigger(Event.CLOSED).remove();
  2079. } // Static
  2080. ;
  2081. Alert._jQueryInterface = function _jQueryInterface(config) {
  2082. return this.each(function () {
  2083. var $element = $(this);
  2084. var data = $element.data(DATA_KEY);
  2085. if (!data) {
  2086. data = new Alert(this);
  2087. $element.data(DATA_KEY, data);
  2088. }
  2089. if (config === 'close') {
  2090. data[config](this);
  2091. }
  2092. });
  2093. };
  2094. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2095. return function (event) {
  2096. if (event) {
  2097. event.preventDefault();
  2098. }
  2099. alertInstance.close(this);
  2100. };
  2101. };
  2102. _createClass(Alert, null, [{
  2103. key: "VERSION",
  2104. get: function get() {
  2105. return VERSION;
  2106. }
  2107. }]);
  2108. return Alert;
  2109. }();
  2110. /**
  2111. * ------------------------------------------------------------------------
  2112. * Data Api implementation
  2113. * ------------------------------------------------------------------------
  2114. */
  2115. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2116. /**
  2117. * ------------------------------------------------------------------------
  2118. * jQuery
  2119. * ------------------------------------------------------------------------
  2120. */
  2121. $.fn[NAME] = Alert._jQueryInterface;
  2122. $.fn[NAME].Constructor = Alert;
  2123. $.fn[NAME].noConflict = function () {
  2124. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2125. return Alert._jQueryInterface;
  2126. };
  2127. /**
  2128. * ------------------------------------------------------------------------
  2129. * Constants
  2130. * ------------------------------------------------------------------------
  2131. */
  2132. var NAME$1 = 'button';
  2133. var VERSION$1 = '4.4.1';
  2134. var DATA_KEY$1 = 'bs.button';
  2135. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2136. var DATA_API_KEY$1 = '.data-api';
  2137. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2138. var ClassName$1 = {
  2139. ACTIVE: 'active',
  2140. BUTTON: 'btn',
  2141. FOCUS: 'focus'
  2142. };
  2143. var Selector$1 = {
  2144. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2145. DATA_TOGGLES: '[data-toggle="buttons"]',
  2146. DATA_TOGGLE: '[data-toggle="button"]',
  2147. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2148. INPUT: 'input:not([type="hidden"])',
  2149. ACTIVE: '.active',
  2150. BUTTON: '.btn'
  2151. };
  2152. var Event$1 = {
  2153. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2154. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2155. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2156. };
  2157. /**
  2158. * ------------------------------------------------------------------------
  2159. * Class Definition
  2160. * ------------------------------------------------------------------------
  2161. */
  2162. var Button =
  2163. /*#__PURE__*/
  2164. function () {
  2165. function Button(element) {
  2166. this._element = element;
  2167. } // Getters
  2168. var _proto = Button.prototype;
  2169. // Public
  2170. _proto.toggle = function toggle() {
  2171. var triggerChangeEvent = true;
  2172. var addAriaPressed = true;
  2173. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2174. if (rootElement) {
  2175. var input = this._element.querySelector(Selector$1.INPUT);
  2176. if (input) {
  2177. if (input.type === 'radio') {
  2178. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2179. triggerChangeEvent = false;
  2180. } else {
  2181. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2182. if (activeElement) {
  2183. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2184. }
  2185. }
  2186. } else if (input.type === 'checkbox') {
  2187. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2188. triggerChangeEvent = false;
  2189. }
  2190. } else {
  2191. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2192. triggerChangeEvent = false;
  2193. }
  2194. if (triggerChangeEvent) {
  2195. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2196. $(input).trigger('change');
  2197. }
  2198. input.focus();
  2199. addAriaPressed = false;
  2200. }
  2201. }
  2202. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2203. if (addAriaPressed) {
  2204. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2205. }
  2206. if (triggerChangeEvent) {
  2207. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2208. }
  2209. }
  2210. };
  2211. _proto.dispose = function dispose() {
  2212. $.removeData(this._element, DATA_KEY$1);
  2213. this._element = null;
  2214. } // Static
  2215. ;
  2216. Button._jQueryInterface = function _jQueryInterface(config) {
  2217. return this.each(function () {
  2218. var data = $(this).data(DATA_KEY$1);
  2219. if (!data) {
  2220. data = new Button(this);
  2221. $(this).data(DATA_KEY$1, data);
  2222. }
  2223. if (config === 'toggle') {
  2224. data[config]();
  2225. }
  2226. });
  2227. };
  2228. _createClass(Button, null, [{
  2229. key: "VERSION",
  2230. get: function get() {
  2231. return VERSION$1;
  2232. }
  2233. }]);
  2234. return Button;
  2235. }();
  2236. /**
  2237. * ------------------------------------------------------------------------
  2238. * Data Api implementation
  2239. * ------------------------------------------------------------------------
  2240. */
  2241. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2242. var button = event.target;
  2243. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2244. button = $(button).closest(Selector$1.BUTTON)[0];
  2245. }
  2246. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2247. event.preventDefault(); // work around Firefox bug #1540995
  2248. } else {
  2249. var inputBtn = button.querySelector(Selector$1.INPUT);
  2250. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2251. event.preventDefault(); // work around Firefox bug #1540995
  2252. return;
  2253. }
  2254. Button._jQueryInterface.call($(button), 'toggle');
  2255. }
  2256. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2257. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2258. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2259. });
  2260. $(window).on(Event$1.LOAD_DATA_API, function () {
  2261. // ensure correct active class is set to match the controls' actual values/states
  2262. // find all checkboxes/readio buttons inside data-toggle groups
  2263. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2264. for (var i = 0, len = buttons.length; i < len; i++) {
  2265. var button = buttons[i];
  2266. var input = button.querySelector(Selector$1.INPUT);
  2267. if (input.checked || input.hasAttribute('checked')) {
  2268. button.classList.add(ClassName$1.ACTIVE);
  2269. } else {
  2270. button.classList.remove(ClassName$1.ACTIVE);
  2271. }
  2272. } // find all button toggles
  2273. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2274. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2275. var _button = buttons[_i];
  2276. if (_button.getAttribute('aria-pressed') === 'true') {
  2277. _button.classList.add(ClassName$1.ACTIVE);
  2278. } else {
  2279. _button.classList.remove(ClassName$1.ACTIVE);
  2280. }
  2281. }
  2282. });
  2283. /**
  2284. * ------------------------------------------------------------------------
  2285. * jQuery
  2286. * ------------------------------------------------------------------------
  2287. */
  2288. $.fn[NAME$1] = Button._jQueryInterface;
  2289. $.fn[NAME$1].Constructor = Button;
  2290. $.fn[NAME$1].noConflict = function () {
  2291. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2292. return Button._jQueryInterface;
  2293. };
  2294. /**
  2295. * ------------------------------------------------------------------------
  2296. * Constants
  2297. * ------------------------------------------------------------------------
  2298. */
  2299. var NAME$2 = 'carousel';
  2300. var VERSION$2 = '4.4.1';
  2301. var DATA_KEY$2 = 'bs.carousel';
  2302. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2303. var DATA_API_KEY$2 = '.data-api';
  2304. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2305. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2306. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2307. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2308. var SWIPE_THRESHOLD = 40;
  2309. var Default = {
  2310. interval: 5000,
  2311. keyboard: true,
  2312. slide: false,
  2313. pause: 'hover',
  2314. wrap: true,
  2315. touch: true
  2316. };
  2317. var DefaultType = {
  2318. interval: '(number|boolean)',
  2319. keyboard: 'boolean',
  2320. slide: '(boolean|string)',
  2321. pause: '(string|boolean)',
  2322. wrap: 'boolean',
  2323. touch: 'boolean'
  2324. };
  2325. var Direction = {
  2326. NEXT: 'next',
  2327. PREV: 'prev',
  2328. LEFT: 'left',
  2329. RIGHT: 'right'
  2330. };
  2331. var Event$2 = {
  2332. SLIDE: "slide" + EVENT_KEY$2,
  2333. SLID: "slid" + EVENT_KEY$2,
  2334. KEYDOWN: "keydown" + EVENT_KEY$2,
  2335. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2336. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2337. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2338. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2339. TOUCHEND: "touchend" + EVENT_KEY$2,
  2340. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2341. POINTERUP: "pointerup" + EVENT_KEY$2,
  2342. DRAG_START: "dragstart" + EVENT_KEY$2,
  2343. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2344. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2345. };
  2346. var ClassName$2 = {
  2347. CAROUSEL: 'carousel',
  2348. ACTIVE: 'active',
  2349. SLIDE: 'slide',
  2350. RIGHT: 'carousel-item-right',
  2351. LEFT: 'carousel-item-left',
  2352. NEXT: 'carousel-item-next',
  2353. PREV: 'carousel-item-prev',
  2354. ITEM: 'carousel-item',
  2355. POINTER_EVENT: 'pointer-event'
  2356. };
  2357. var Selector$2 = {
  2358. ACTIVE: '.active',
  2359. ACTIVE_ITEM: '.active.carousel-item',
  2360. ITEM: '.carousel-item',
  2361. ITEM_IMG: '.carousel-item img',
  2362. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2363. INDICATORS: '.carousel-indicators',
  2364. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2365. DATA_RIDE: '[data-ride="carousel"]'
  2366. };
  2367. var PointerType = {
  2368. TOUCH: 'touch',
  2369. PEN: 'pen'
  2370. };
  2371. /**
  2372. * ------------------------------------------------------------------------
  2373. * Class Definition
  2374. * ------------------------------------------------------------------------
  2375. */
  2376. var Carousel =
  2377. /*#__PURE__*/
  2378. function () {
  2379. function Carousel(element, config) {
  2380. this._items = null;
  2381. this._interval = null;
  2382. this._activeElement = null;
  2383. this._isPaused = false;
  2384. this._isSliding = false;
  2385. this.touchTimeout = null;
  2386. this.touchStartX = 0;
  2387. this.touchDeltaX = 0;
  2388. this._config = this._getConfig(config);
  2389. this._element = element;
  2390. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2391. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2392. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2393. this._addEventListeners();
  2394. } // Getters
  2395. var _proto = Carousel.prototype;
  2396. // Public
  2397. _proto.next = function next() {
  2398. if (!this._isSliding) {
  2399. this._slide(Direction.NEXT);
  2400. }
  2401. };
  2402. _proto.nextWhenVisible = function nextWhenVisible() {
  2403. // Don't call next when the page isn't visible
  2404. // or the carousel or its parent isn't visible
  2405. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2406. this.next();
  2407. }
  2408. };
  2409. _proto.prev = function prev() {
  2410. if (!this._isSliding) {
  2411. this._slide(Direction.PREV);
  2412. }
  2413. };
  2414. _proto.pause = function pause(event) {
  2415. if (!event) {
  2416. this._isPaused = true;
  2417. }
  2418. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2419. Util.triggerTransitionEnd(this._element);
  2420. this.cycle(true);
  2421. }
  2422. clearInterval(this._interval);
  2423. this._interval = null;
  2424. };
  2425. _proto.cycle = function cycle(event) {
  2426. if (!event) {
  2427. this._isPaused = false;
  2428. }
  2429. if (this._interval) {
  2430. clearInterval(this._interval);
  2431. this._interval = null;
  2432. }
  2433. if (this._config.interval && !this._isPaused) {
  2434. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2435. }
  2436. };
  2437. _proto.to = function to(index) {
  2438. var _this = this;
  2439. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2440. var activeIndex = this._getItemIndex(this._activeElement);
  2441. if (index > this._items.length - 1 || index < 0) {
  2442. return;
  2443. }
  2444. if (this._isSliding) {
  2445. $(this._element).one(Event$2.SLID, function () {
  2446. return _this.to(index);
  2447. });
  2448. return;
  2449. }
  2450. if (activeIndex === index) {
  2451. this.pause();
  2452. this.cycle();
  2453. return;
  2454. }
  2455. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2456. this._slide(direction, this._items[index]);
  2457. };
  2458. _proto.dispose = function dispose() {
  2459. $(this._element).off(EVENT_KEY$2);
  2460. $.removeData(this._element, DATA_KEY$2);
  2461. this._items = null;
  2462. this._config = null;
  2463. this._element = null;
  2464. this._interval = null;
  2465. this._isPaused = null;
  2466. this._isSliding = null;
  2467. this._activeElement = null;
  2468. this._indicatorsElement = null;
  2469. } // Private
  2470. ;
  2471. _proto._getConfig = function _getConfig(config) {
  2472. config = _objectSpread2({}, Default, {}, config);
  2473. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2474. return config;
  2475. };
  2476. _proto._handleSwipe = function _handleSwipe() {
  2477. var absDeltax = Math.abs(this.touchDeltaX);
  2478. if (absDeltax <= SWIPE_THRESHOLD) {
  2479. return;
  2480. }
  2481. var direction = absDeltax / this.touchDeltaX;
  2482. this.touchDeltaX = 0; // swipe left
  2483. if (direction > 0) {
  2484. this.prev();
  2485. } // swipe right
  2486. if (direction < 0) {
  2487. this.next();
  2488. }
  2489. };
  2490. _proto._addEventListeners = function _addEventListeners() {
  2491. var _this2 = this;
  2492. if (this._config.keyboard) {
  2493. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2494. return _this2._keydown(event);
  2495. });
  2496. }
  2497. if (this._config.pause === 'hover') {
  2498. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2499. return _this2.pause(event);
  2500. }).on(Event$2.MOUSELEAVE, function (event) {
  2501. return _this2.cycle(event);
  2502. });
  2503. }
  2504. if (this._config.touch) {
  2505. this._addTouchEventListeners();
  2506. }
  2507. };
  2508. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2509. var _this3 = this;
  2510. if (!this._touchSupported) {
  2511. return;
  2512. }
  2513. var start = function start(event) {
  2514. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2515. _this3.touchStartX = event.originalEvent.clientX;
  2516. } else if (!_this3._pointerEvent) {
  2517. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2518. }
  2519. };
  2520. var move = function move(event) {
  2521. // ensure swiping with one touch and not pinching
  2522. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2523. _this3.touchDeltaX = 0;
  2524. } else {
  2525. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2526. }
  2527. };
  2528. var end = function end(event) {
  2529. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2530. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2531. }
  2532. _this3._handleSwipe();
  2533. if (_this3._config.pause === 'hover') {
  2534. // If it's a touch-enabled device, mouseenter/leave are fired as
  2535. // part of the mouse compatibility events on first tap - the carousel
  2536. // would stop cycling until user tapped out of it;
  2537. // here, we listen for touchend, explicitly pause the carousel
  2538. // (as if it's the second time we tap on it, mouseenter compat event
  2539. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2540. // events to fire) we explicitly restart cycling
  2541. _this3.pause();
  2542. if (_this3.touchTimeout) {
  2543. clearTimeout(_this3.touchTimeout);
  2544. }
  2545. _this3.touchTimeout = setTimeout(function (event) {
  2546. return _this3.cycle(event);
  2547. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2548. }
  2549. };
  2550. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2551. return e.preventDefault();
  2552. });
  2553. if (this._pointerEvent) {
  2554. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2555. return start(event);
  2556. });
  2557. $(this._element).on(Event$2.POINTERUP, function (event) {
  2558. return end(event);
  2559. });
  2560. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2561. } else {
  2562. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2563. return start(event);
  2564. });
  2565. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2566. return move(event);
  2567. });
  2568. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2569. return end(event);
  2570. });
  2571. }
  2572. };
  2573. _proto._keydown = function _keydown(event) {
  2574. if (/input|textarea/i.test(event.target.tagName)) {
  2575. return;
  2576. }
  2577. switch (event.which) {
  2578. case ARROW_LEFT_KEYCODE:
  2579. event.preventDefault();
  2580. this.prev();
  2581. break;
  2582. case ARROW_RIGHT_KEYCODE:
  2583. event.preventDefault();
  2584. this.next();
  2585. break;
  2586. }
  2587. };
  2588. _proto._getItemIndex = function _getItemIndex(element) {
  2589. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2590. return this._items.indexOf(element);
  2591. };
  2592. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2593. var isNextDirection = direction === Direction.NEXT;
  2594. var isPrevDirection = direction === Direction.PREV;
  2595. var activeIndex = this._getItemIndex(activeElement);
  2596. var lastItemIndex = this._items.length - 1;
  2597. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2598. if (isGoingToWrap && !this._config.wrap) {
  2599. return activeElement;
  2600. }
  2601. var delta = direction === Direction.PREV ? -1 : 1;
  2602. var itemIndex = (activeIndex + delta) % this._items.length;
  2603. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2604. };
  2605. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2606. var targetIndex = this._getItemIndex(relatedTarget);
  2607. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2608. var slideEvent = $.Event(Event$2.SLIDE, {
  2609. relatedTarget: relatedTarget,
  2610. direction: eventDirectionName,
  2611. from: fromIndex,
  2612. to: targetIndex
  2613. });
  2614. $(this._element).trigger(slideEvent);
  2615. return slideEvent;
  2616. };
  2617. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2618. if (this._indicatorsElement) {
  2619. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2620. $(indicators).removeClass(ClassName$2.ACTIVE);
  2621. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2622. if (nextIndicator) {
  2623. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2624. }
  2625. }
  2626. };
  2627. _proto._slide = function _slide(direction, element) {
  2628. var _this4 = this;
  2629. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2630. var activeElementIndex = this._getItemIndex(activeElement);
  2631. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2632. var nextElementIndex = this._getItemIndex(nextElement);
  2633. var isCycling = Boolean(this._interval);
  2634. var directionalClassName;
  2635. var orderClassName;
  2636. var eventDirectionName;
  2637. if (direction === Direction.NEXT) {
  2638. directionalClassName = ClassName$2.LEFT;
  2639. orderClassName = ClassName$2.NEXT;
  2640. eventDirectionName = Direction.LEFT;
  2641. } else {
  2642. directionalClassName = ClassName$2.RIGHT;
  2643. orderClassName = ClassName$2.PREV;
  2644. eventDirectionName = Direction.RIGHT;
  2645. }
  2646. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2647. this._isSliding = false;
  2648. return;
  2649. }
  2650. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2651. if (slideEvent.isDefaultPrevented()) {
  2652. return;
  2653. }
  2654. if (!activeElement || !nextElement) {
  2655. // Some weirdness is happening, so we bail
  2656. return;
  2657. }
  2658. this._isSliding = true;
  2659. if (isCycling) {
  2660. this.pause();
  2661. }
  2662. this._setActiveIndicatorElement(nextElement);
  2663. var slidEvent = $.Event(Event$2.SLID, {
  2664. relatedTarget: nextElement,
  2665. direction: eventDirectionName,
  2666. from: activeElementIndex,
  2667. to: nextElementIndex
  2668. });
  2669. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2670. $(nextElement).addClass(orderClassName);
  2671. Util.reflow(nextElement);
  2672. $(activeElement).addClass(directionalClassName);
  2673. $(nextElement).addClass(directionalClassName);
  2674. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2675. if (nextElementInterval) {
  2676. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2677. this._config.interval = nextElementInterval;
  2678. } else {
  2679. this._config.interval = this._config.defaultInterval || this._config.interval;
  2680. }
  2681. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2682. $(activeElement).one(Util.TRANSITION_END, function () {
  2683. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2684. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2685. _this4._isSliding = false;
  2686. setTimeout(function () {
  2687. return $(_this4._element).trigger(slidEvent);
  2688. }, 0);
  2689. }).emulateTransitionEnd(transitionDuration);
  2690. } else {
  2691. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2692. $(nextElement).addClass(ClassName$2.ACTIVE);
  2693. this._isSliding = false;
  2694. $(this._element).trigger(slidEvent);
  2695. }
  2696. if (isCycling) {
  2697. this.cycle();
  2698. }
  2699. } // Static
  2700. ;
  2701. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2702. return this.each(function () {
  2703. var data = $(this).data(DATA_KEY$2);
  2704. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2705. if (typeof config === 'object') {
  2706. _config = _objectSpread2({}, _config, {}, config);
  2707. }
  2708. var action = typeof config === 'string' ? config : _config.slide;
  2709. if (!data) {
  2710. data = new Carousel(this, _config);
  2711. $(this).data(DATA_KEY$2, data);
  2712. }
  2713. if (typeof config === 'number') {
  2714. data.to(config);
  2715. } else if (typeof action === 'string') {
  2716. if (typeof data[action] === 'undefined') {
  2717. throw new TypeError("No method named \"" + action + "\"");
  2718. }
  2719. data[action]();
  2720. } else if (_config.interval && _config.ride) {
  2721. data.pause();
  2722. data.cycle();
  2723. }
  2724. });
  2725. };
  2726. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2727. var selector = Util.getSelectorFromElement(this);
  2728. if (!selector) {
  2729. return;
  2730. }
  2731. var target = $(selector)[0];
  2732. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2733. return;
  2734. }
  2735. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2736. var slideIndex = this.getAttribute('data-slide-to');
  2737. if (slideIndex) {
  2738. config.interval = false;
  2739. }
  2740. Carousel._jQueryInterface.call($(target), config);
  2741. if (slideIndex) {
  2742. $(target).data(DATA_KEY$2).to(slideIndex);
  2743. }
  2744. event.preventDefault();
  2745. };
  2746. _createClass(Carousel, null, [{
  2747. key: "VERSION",
  2748. get: function get() {
  2749. return VERSION$2;
  2750. }
  2751. }, {
  2752. key: "Default",
  2753. get: function get() {
  2754. return Default;
  2755. }
  2756. }]);
  2757. return Carousel;
  2758. }();
  2759. /**
  2760. * ------------------------------------------------------------------------
  2761. * Data Api implementation
  2762. * ------------------------------------------------------------------------
  2763. */
  2764. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2765. $(window).on(Event$2.LOAD_DATA_API, function () {
  2766. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2767. for (var i = 0, len = carousels.length; i < len; i++) {
  2768. var $carousel = $(carousels[i]);
  2769. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2770. }
  2771. });
  2772. /**
  2773. * ------------------------------------------------------------------------
  2774. * jQuery
  2775. * ------------------------------------------------------------------------
  2776. */
  2777. $.fn[NAME$2] = Carousel._jQueryInterface;
  2778. $.fn[NAME$2].Constructor = Carousel;
  2779. $.fn[NAME$2].noConflict = function () {
  2780. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2781. return Carousel._jQueryInterface;
  2782. };
  2783. /**
  2784. * ------------------------------------------------------------------------
  2785. * Constants
  2786. * ------------------------------------------------------------------------
  2787. */
  2788. var NAME$3 = 'collapse';
  2789. var VERSION$3 = '4.4.1';
  2790. var DATA_KEY$3 = 'bs.collapse';
  2791. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2792. var DATA_API_KEY$3 = '.data-api';
  2793. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2794. var Default$1 = {
  2795. toggle: true,
  2796. parent: ''
  2797. };
  2798. var DefaultType$1 = {
  2799. toggle: 'boolean',
  2800. parent: '(string|element)'
  2801. };
  2802. var Event$3 = {
  2803. SHOW: "show" + EVENT_KEY$3,
  2804. SHOWN: "shown" + EVENT_KEY$3,
  2805. HIDE: "hide" + EVENT_KEY$3,
  2806. HIDDEN: "hidden" + EVENT_KEY$3,
  2807. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2808. };
  2809. var ClassName$3 = {
  2810. SHOW: 'show',
  2811. COLLAPSE: 'collapse',
  2812. COLLAPSING: 'collapsing',
  2813. COLLAPSED: 'collapsed'
  2814. };
  2815. var Dimension = {
  2816. WIDTH: 'width',
  2817. HEIGHT: 'height'
  2818. };
  2819. var Selector$3 = {
  2820. ACTIVES: '.show, .collapsing',
  2821. DATA_TOGGLE: '[data-toggle="collapse"]'
  2822. };
  2823. /**
  2824. * ------------------------------------------------------------------------
  2825. * Class Definition
  2826. * ------------------------------------------------------------------------
  2827. */
  2828. var Collapse =
  2829. /*#__PURE__*/
  2830. function () {
  2831. function Collapse(element, config) {
  2832. this._isTransitioning = false;
  2833. this._element = element;
  2834. this._config = this._getConfig(config);
  2835. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2836. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2837. for (var i = 0, len = toggleList.length; i < len; i++) {
  2838. var elem = toggleList[i];
  2839. var selector = Util.getSelectorFromElement(elem);
  2840. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2841. return foundElem === element;
  2842. });
  2843. if (selector !== null && filterElement.length > 0) {
  2844. this._selector = selector;
  2845. this._triggerArray.push(elem);
  2846. }
  2847. }
  2848. this._parent = this._config.parent ? this._getParent() : null;
  2849. if (!this._config.parent) {
  2850. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2851. }
  2852. if (this._config.toggle) {
  2853. this.toggle();
  2854. }
  2855. } // Getters
  2856. var _proto = Collapse.prototype;
  2857. // Public
  2858. _proto.toggle = function toggle() {
  2859. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2860. this.hide();
  2861. } else {
  2862. this.show();
  2863. }
  2864. };
  2865. _proto.show = function show() {
  2866. var _this = this;
  2867. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2868. return;
  2869. }
  2870. var actives;
  2871. var activesData;
  2872. if (this._parent) {
  2873. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2874. if (typeof _this._config.parent === 'string') {
  2875. return elem.getAttribute('data-parent') === _this._config.parent;
  2876. }
  2877. return elem.classList.contains(ClassName$3.COLLAPSE);
  2878. });
  2879. if (actives.length === 0) {
  2880. actives = null;
  2881. }
  2882. }
  2883. if (actives) {
  2884. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2885. if (activesData && activesData._isTransitioning) {
  2886. return;
  2887. }
  2888. }
  2889. var startEvent = $.Event(Event$3.SHOW);
  2890. $(this._element).trigger(startEvent);
  2891. if (startEvent.isDefaultPrevented()) {
  2892. return;
  2893. }
  2894. if (actives) {
  2895. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2896. if (!activesData) {
  2897. $(actives).data(DATA_KEY$3, null);
  2898. }
  2899. }
  2900. var dimension = this._getDimension();
  2901. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2902. this._element.style[dimension] = 0;
  2903. if (this._triggerArray.length) {
  2904. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2905. }
  2906. this.setTransitioning(true);
  2907. var complete = function complete() {
  2908. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2909. _this._element.style[dimension] = '';
  2910. _this.setTransitioning(false);
  2911. $(_this._element).trigger(Event$3.SHOWN);
  2912. };
  2913. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2914. var scrollSize = "scroll" + capitalizedDimension;
  2915. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2916. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2917. this._element.style[dimension] = this._element[scrollSize] + "px";
  2918. };
  2919. _proto.hide = function hide() {
  2920. var _this2 = this;
  2921. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2922. return;
  2923. }
  2924. var startEvent = $.Event(Event$3.HIDE);
  2925. $(this._element).trigger(startEvent);
  2926. if (startEvent.isDefaultPrevented()) {
  2927. return;
  2928. }
  2929. var dimension = this._getDimension();
  2930. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2931. Util.reflow(this._element);
  2932. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2933. var triggerArrayLength = this._triggerArray.length;
  2934. if (triggerArrayLength > 0) {
  2935. for (var i = 0; i < triggerArrayLength; i++) {
  2936. var trigger = this._triggerArray[i];
  2937. var selector = Util.getSelectorFromElement(trigger);
  2938. if (selector !== null) {
  2939. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2940. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2941. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2942. }
  2943. }
  2944. }
  2945. }
  2946. this.setTransitioning(true);
  2947. var complete = function complete() {
  2948. _this2.setTransitioning(false);
  2949. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2950. };
  2951. this._element.style[dimension] = '';
  2952. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2953. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2954. };
  2955. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2956. this._isTransitioning = isTransitioning;
  2957. };
  2958. _proto.dispose = function dispose() {
  2959. $.removeData(this._element, DATA_KEY$3);
  2960. this._config = null;
  2961. this._parent = null;
  2962. this._element = null;
  2963. this._triggerArray = null;
  2964. this._isTransitioning = null;
  2965. } // Private
  2966. ;
  2967. _proto._getConfig = function _getConfig(config) {
  2968. config = _objectSpread2({}, Default$1, {}, config);
  2969. config.toggle = Boolean(config.toggle); // Coerce string values
  2970. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2971. return config;
  2972. };
  2973. _proto._getDimension = function _getDimension() {
  2974. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  2975. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  2976. };
  2977. _proto._getParent = function _getParent() {
  2978. var _this3 = this;
  2979. var parent;
  2980. if (Util.isElement(this._config.parent)) {
  2981. parent = this._config.parent; // It's a jQuery object
  2982. if (typeof this._config.parent.jquery !== 'undefined') {
  2983. parent = this._config.parent[0];
  2984. }
  2985. } else {
  2986. parent = document.querySelector(this._config.parent);
  2987. }
  2988. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  2989. var children = [].slice.call(parent.querySelectorAll(selector));
  2990. $(children).each(function (i, element) {
  2991. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  2992. });
  2993. return parent;
  2994. };
  2995. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  2996. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  2997. if (triggerArray.length) {
  2998. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  2999. }
  3000. } // Static
  3001. ;
  3002. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3003. var selector = Util.getSelectorFromElement(element);
  3004. return selector ? document.querySelector(selector) : null;
  3005. };
  3006. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3007. return this.each(function () {
  3008. var $this = $(this);
  3009. var data = $this.data(DATA_KEY$3);
  3010. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3011. if (!data && _config.toggle && /show|hide/.test(config)) {
  3012. _config.toggle = false;
  3013. }
  3014. if (!data) {
  3015. data = new Collapse(this, _config);
  3016. $this.data(DATA_KEY$3, data);
  3017. }
  3018. if (typeof config === 'string') {
  3019. if (typeof data[config] === 'undefined') {
  3020. throw new TypeError("No method named \"" + config + "\"");
  3021. }
  3022. data[config]();
  3023. }
  3024. });
  3025. };
  3026. _createClass(Collapse, null, [{
  3027. key: "VERSION",
  3028. get: function get() {
  3029. return VERSION$3;
  3030. }
  3031. }, {
  3032. key: "Default",
  3033. get: function get() {
  3034. return Default$1;
  3035. }
  3036. }]);
  3037. return Collapse;
  3038. }();
  3039. /**
  3040. * ------------------------------------------------------------------------
  3041. * Data Api implementation
  3042. * ------------------------------------------------------------------------
  3043. */
  3044. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3045. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3046. if (event.currentTarget.tagName === 'A') {
  3047. event.preventDefault();
  3048. }
  3049. var $trigger = $(this);
  3050. var selector = Util.getSelectorFromElement(this);
  3051. var selectors = [].slice.call(document.querySelectorAll(selector));
  3052. $(selectors).each(function () {
  3053. var $target = $(this);
  3054. var data = $target.data(DATA_KEY$3);
  3055. var config = data ? 'toggle' : $trigger.data();
  3056. Collapse._jQueryInterface.call($target, config);
  3057. });
  3058. });
  3059. /**
  3060. * ------------------------------------------------------------------------
  3061. * jQuery
  3062. * ------------------------------------------------------------------------
  3063. */
  3064. $.fn[NAME$3] = Collapse._jQueryInterface;
  3065. $.fn[NAME$3].Constructor = Collapse;
  3066. $.fn[NAME$3].noConflict = function () {
  3067. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3068. return Collapse._jQueryInterface;
  3069. };
  3070. /**
  3071. * ------------------------------------------------------------------------
  3072. * Constants
  3073. * ------------------------------------------------------------------------
  3074. */
  3075. var NAME$4 = 'dropdown';
  3076. var VERSION$4 = '4.4.1';
  3077. var DATA_KEY$4 = 'bs.dropdown';
  3078. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3079. var DATA_API_KEY$4 = '.data-api';
  3080. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3081. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3082. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3083. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3084. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3085. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3086. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3087. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3088. var Event$4 = {
  3089. HIDE: "hide" + EVENT_KEY$4,
  3090. HIDDEN: "hidden" + EVENT_KEY$4,
  3091. SHOW: "show" + EVENT_KEY$4,
  3092. SHOWN: "shown" + EVENT_KEY$4,
  3093. CLICK: "click" + EVENT_KEY$4,
  3094. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3095. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3096. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3097. };
  3098. var ClassName$4 = {
  3099. DISABLED: 'disabled',
  3100. SHOW: 'show',
  3101. DROPUP: 'dropup',
  3102. DROPRIGHT: 'dropright',
  3103. DROPLEFT: 'dropleft',
  3104. MENURIGHT: 'dropdown-menu-right',
  3105. MENULEFT: 'dropdown-menu-left',
  3106. POSITION_STATIC: 'position-static'
  3107. };
  3108. var Selector$4 = {
  3109. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3110. FORM_CHILD: '.dropdown form',
  3111. MENU: '.dropdown-menu',
  3112. NAVBAR_NAV: '.navbar-nav',
  3113. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3114. };
  3115. var AttachmentMap = {
  3116. TOP: 'top-start',
  3117. TOPEND: 'top-end',
  3118. BOTTOM: 'bottom-start',
  3119. BOTTOMEND: 'bottom-end',
  3120. RIGHT: 'right-start',
  3121. RIGHTEND: 'right-end',
  3122. LEFT: 'left-start',
  3123. LEFTEND: 'left-end'
  3124. };
  3125. var Default$2 = {
  3126. offset: 0,
  3127. flip: true,
  3128. boundary: 'scrollParent',
  3129. reference: 'toggle',
  3130. display: 'dynamic',
  3131. popperConfig: null
  3132. };
  3133. var DefaultType$2 = {
  3134. offset: '(number|string|function)',
  3135. flip: 'boolean',
  3136. boundary: '(string|element)',
  3137. reference: '(string|element)',
  3138. display: 'string',
  3139. popperConfig: '(null|object)'
  3140. };
  3141. /**
  3142. * ------------------------------------------------------------------------
  3143. * Class Definition
  3144. * ------------------------------------------------------------------------
  3145. */
  3146. var Dropdown =
  3147. /*#__PURE__*/
  3148. function () {
  3149. function Dropdown(element, config) {
  3150. this._element = element;
  3151. this._popper = null;
  3152. this._config = this._getConfig(config);
  3153. this._menu = this._getMenuElement();
  3154. this._inNavbar = this._detectNavbar();
  3155. this._addEventListeners();
  3156. } // Getters
  3157. var _proto = Dropdown.prototype;
  3158. // Public
  3159. _proto.toggle = function toggle() {
  3160. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3161. return;
  3162. }
  3163. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3164. Dropdown._clearMenus();
  3165. if (isActive) {
  3166. return;
  3167. }
  3168. this.show(true);
  3169. };
  3170. _proto.show = function show(usePopper) {
  3171. if (usePopper === void 0) {
  3172. usePopper = false;
  3173. }
  3174. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3175. return;
  3176. }
  3177. var relatedTarget = {
  3178. relatedTarget: this._element
  3179. };
  3180. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3181. var parent = Dropdown._getParentFromElement(this._element);
  3182. $(parent).trigger(showEvent);
  3183. if (showEvent.isDefaultPrevented()) {
  3184. return;
  3185. } // Disable totally Popper.js for Dropdown in Navbar
  3186. if (!this._inNavbar && usePopper) {
  3187. /**
  3188. * Check for Popper dependency
  3189. * Popper - https://popper.js.org
  3190. */
  3191. if (typeof Popper === 'undefined') {
  3192. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3193. }
  3194. var referenceElement = this._element;
  3195. if (this._config.reference === 'parent') {
  3196. referenceElement = parent;
  3197. } else if (Util.isElement(this._config.reference)) {
  3198. referenceElement = this._config.reference; // Check if it's jQuery element
  3199. if (typeof this._config.reference.jquery !== 'undefined') {
  3200. referenceElement = this._config.reference[0];
  3201. }
  3202. } // If boundary is not `scrollParent`, then set position to `static`
  3203. // to allow the menu to "escape" the scroll parent's boundaries
  3204. // https://github.com/twbs/bootstrap/issues/24251
  3205. if (this._config.boundary !== 'scrollParent') {
  3206. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3207. }
  3208. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3209. } // If this is a touch-enabled device we add extra
  3210. // empty mouseover listeners to the body's immediate children;
  3211. // only needed because of broken event delegation on iOS
  3212. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3213. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3214. $(document.body).children().on('mouseover', null, $.noop);
  3215. }
  3216. this._element.focus();
  3217. this._element.setAttribute('aria-expanded', true);
  3218. $(this._menu).toggleClass(ClassName$4.SHOW);
  3219. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3220. };
  3221. _proto.hide = function hide() {
  3222. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3223. return;
  3224. }
  3225. var relatedTarget = {
  3226. relatedTarget: this._element
  3227. };
  3228. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3229. var parent = Dropdown._getParentFromElement(this._element);
  3230. $(parent).trigger(hideEvent);
  3231. if (hideEvent.isDefaultPrevented()) {
  3232. return;
  3233. }
  3234. if (this._popper) {
  3235. this._popper.destroy();
  3236. }
  3237. $(this._menu).toggleClass(ClassName$4.SHOW);
  3238. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3239. };
  3240. _proto.dispose = function dispose() {
  3241. $.removeData(this._element, DATA_KEY$4);
  3242. $(this._element).off(EVENT_KEY$4);
  3243. this._element = null;
  3244. this._menu = null;
  3245. if (this._popper !== null) {
  3246. this._popper.destroy();
  3247. this._popper = null;
  3248. }
  3249. };
  3250. _proto.update = function update() {
  3251. this._inNavbar = this._detectNavbar();
  3252. if (this._popper !== null) {
  3253. this._popper.scheduleUpdate();
  3254. }
  3255. } // Private
  3256. ;
  3257. _proto._addEventListeners = function _addEventListeners() {
  3258. var _this = this;
  3259. $(this._element).on(Event$4.CLICK, function (event) {
  3260. event.preventDefault();
  3261. event.stopPropagation();
  3262. _this.toggle();
  3263. });
  3264. };
  3265. _proto._getConfig = function _getConfig(config) {
  3266. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3267. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3268. return config;
  3269. };
  3270. _proto._getMenuElement = function _getMenuElement() {
  3271. if (!this._menu) {
  3272. var parent = Dropdown._getParentFromElement(this._element);
  3273. if (parent) {
  3274. this._menu = parent.querySelector(Selector$4.MENU);
  3275. }
  3276. }
  3277. return this._menu;
  3278. };
  3279. _proto._getPlacement = function _getPlacement() {
  3280. var $parentDropdown = $(this._element.parentNode);
  3281. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3282. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3283. placement = AttachmentMap.TOP;
  3284. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3285. placement = AttachmentMap.TOPEND;
  3286. }
  3287. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3288. placement = AttachmentMap.RIGHT;
  3289. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3290. placement = AttachmentMap.LEFT;
  3291. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3292. placement = AttachmentMap.BOTTOMEND;
  3293. }
  3294. return placement;
  3295. };
  3296. _proto._detectNavbar = function _detectNavbar() {
  3297. return $(this._element).closest('.navbar').length > 0;
  3298. };
  3299. _proto._getOffset = function _getOffset() {
  3300. var _this2 = this;
  3301. var offset = {};
  3302. if (typeof this._config.offset === 'function') {
  3303. offset.fn = function (data) {
  3304. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3305. return data;
  3306. };
  3307. } else {
  3308. offset.offset = this._config.offset;
  3309. }
  3310. return offset;
  3311. };
  3312. _proto._getPopperConfig = function _getPopperConfig() {
  3313. var popperConfig = {
  3314. placement: this._getPlacement(),
  3315. modifiers: {
  3316. offset: this._getOffset(),
  3317. flip: {
  3318. enabled: this._config.flip
  3319. },
  3320. preventOverflow: {
  3321. boundariesElement: this._config.boundary
  3322. }
  3323. }
  3324. }; // Disable Popper.js if we have a static display
  3325. if (this._config.display === 'static') {
  3326. popperConfig.modifiers.applyStyle = {
  3327. enabled: false
  3328. };
  3329. }
  3330. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3331. } // Static
  3332. ;
  3333. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3334. return this.each(function () {
  3335. var data = $(this).data(DATA_KEY$4);
  3336. var _config = typeof config === 'object' ? config : null;
  3337. if (!data) {
  3338. data = new Dropdown(this, _config);
  3339. $(this).data(DATA_KEY$4, data);
  3340. }
  3341. if (typeof config === 'string') {
  3342. if (typeof data[config] === 'undefined') {
  3343. throw new TypeError("No method named \"" + config + "\"");
  3344. }
  3345. data[config]();
  3346. }
  3347. });
  3348. };
  3349. Dropdown._clearMenus = function _clearMenus(event) {
  3350. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3351. return;
  3352. }
  3353. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3354. for (var i = 0, len = toggles.length; i < len; i++) {
  3355. var parent = Dropdown._getParentFromElement(toggles[i]);
  3356. var context = $(toggles[i]).data(DATA_KEY$4);
  3357. var relatedTarget = {
  3358. relatedTarget: toggles[i]
  3359. };
  3360. if (event && event.type === 'click') {
  3361. relatedTarget.clickEvent = event;
  3362. }
  3363. if (!context) {
  3364. continue;
  3365. }
  3366. var dropdownMenu = context._menu;
  3367. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3368. continue;
  3369. }
  3370. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3371. continue;
  3372. }
  3373. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3374. $(parent).trigger(hideEvent);
  3375. if (hideEvent.isDefaultPrevented()) {
  3376. continue;
  3377. } // If this is a touch-enabled device we remove the extra
  3378. // empty mouseover listeners we added for iOS support
  3379. if ('ontouchstart' in document.documentElement) {
  3380. $(document.body).children().off('mouseover', null, $.noop);
  3381. }
  3382. toggles[i].setAttribute('aria-expanded', 'false');
  3383. if (context._popper) {
  3384. context._popper.destroy();
  3385. }
  3386. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3387. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3388. }
  3389. };
  3390. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3391. var parent;
  3392. var selector = Util.getSelectorFromElement(element);
  3393. if (selector) {
  3394. parent = document.querySelector(selector);
  3395. }
  3396. return parent || element.parentNode;
  3397. } // eslint-disable-next-line complexity
  3398. ;
  3399. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3400. // If not input/textarea:
  3401. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3402. // If input/textarea:
  3403. // - If space key => not a dropdown command
  3404. // - If key is other than escape
  3405. // - If key is not up or down => not a dropdown command
  3406. // - If trigger inside the menu => not a dropdown command
  3407. if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  3408. return;
  3409. }
  3410. event.preventDefault();
  3411. event.stopPropagation();
  3412. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3413. return;
  3414. }
  3415. var parent = Dropdown._getParentFromElement(this);
  3416. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3417. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3418. return;
  3419. }
  3420. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3421. if (event.which === ESCAPE_KEYCODE) {
  3422. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3423. $(toggle).trigger('focus');
  3424. }
  3425. $(this).trigger('click');
  3426. return;
  3427. }
  3428. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3429. return $(item).is(':visible');
  3430. });
  3431. if (items.length === 0) {
  3432. return;
  3433. }
  3434. var index = items.indexOf(event.target);
  3435. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3436. // Up
  3437. index--;
  3438. }
  3439. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3440. // Down
  3441. index++;
  3442. }
  3443. if (index < 0) {
  3444. index = 0;
  3445. }
  3446. items[index].focus();
  3447. };
  3448. _createClass(Dropdown, null, [{
  3449. key: "VERSION",
  3450. get: function get() {
  3451. return VERSION$4;
  3452. }
  3453. }, {
  3454. key: "Default",
  3455. get: function get() {
  3456. return Default$2;
  3457. }
  3458. }, {
  3459. key: "DefaultType",
  3460. get: function get() {
  3461. return DefaultType$2;
  3462. }
  3463. }]);
  3464. return Dropdown;
  3465. }();
  3466. /**
  3467. * ------------------------------------------------------------------------
  3468. * Data Api implementation
  3469. * ------------------------------------------------------------------------
  3470. */
  3471. $(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
  3472. event.preventDefault();
  3473. event.stopPropagation();
  3474. Dropdown._jQueryInterface.call($(this), 'toggle');
  3475. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3476. e.stopPropagation();
  3477. });
  3478. /**
  3479. * ------------------------------------------------------------------------
  3480. * jQuery
  3481. * ------------------------------------------------------------------------
  3482. */
  3483. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3484. $.fn[NAME$4].Constructor = Dropdown;
  3485. $.fn[NAME$4].noConflict = function () {
  3486. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3487. return Dropdown._jQueryInterface;
  3488. };
  3489. /**
  3490. * ------------------------------------------------------------------------
  3491. * Constants
  3492. * ------------------------------------------------------------------------
  3493. */
  3494. var NAME$5 = 'modal';
  3495. var VERSION$5 = '4.4.1';
  3496. var DATA_KEY$5 = 'bs.modal';
  3497. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3498. var DATA_API_KEY$5 = '.data-api';
  3499. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3500. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3501. var Default$3 = {
  3502. backdrop: true,
  3503. keyboard: true,
  3504. focus: true,
  3505. show: true
  3506. };
  3507. var DefaultType$3 = {
  3508. backdrop: '(boolean|string)',
  3509. keyboard: 'boolean',
  3510. focus: 'boolean',
  3511. show: 'boolean'
  3512. };
  3513. var Event$5 = {
  3514. HIDE: "hide" + EVENT_KEY$5,
  3515. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3516. HIDDEN: "hidden" + EVENT_KEY$5,
  3517. SHOW: "show" + EVENT_KEY$5,
  3518. SHOWN: "shown" + EVENT_KEY$5,
  3519. FOCUSIN: "focusin" + EVENT_KEY$5,
  3520. RESIZE: "resize" + EVENT_KEY$5,
  3521. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3522. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3523. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3524. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3525. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3526. };
  3527. var ClassName$5 = {
  3528. SCROLLABLE: 'modal-dialog-scrollable',
  3529. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3530. BACKDROP: 'modal-backdrop',
  3531. OPEN: 'modal-open',
  3532. FADE: 'fade',
  3533. SHOW: 'show',
  3534. STATIC: 'modal-static'
  3535. };
  3536. var Selector$5 = {
  3537. DIALOG: '.modal-dialog',
  3538. MODAL_BODY: '.modal-body',
  3539. DATA_TOGGLE: '[data-toggle="modal"]',
  3540. DATA_DISMISS: '[data-dismiss="modal"]',
  3541. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3542. STICKY_CONTENT: '.sticky-top'
  3543. };
  3544. /**
  3545. * ------------------------------------------------------------------------
  3546. * Class Definition
  3547. * ------------------------------------------------------------------------
  3548. */
  3549. var Modal =
  3550. /*#__PURE__*/
  3551. function () {
  3552. function Modal(element, config) {
  3553. this._config = this._getConfig(config);
  3554. this._element = element;
  3555. this._dialog = element.querySelector(Selector$5.DIALOG);
  3556. this._backdrop = null;
  3557. this._isShown = false;
  3558. this._isBodyOverflowing = false;
  3559. this._ignoreBackdropClick = false;
  3560. this._isTransitioning = false;
  3561. this._scrollbarWidth = 0;
  3562. } // Getters
  3563. var _proto = Modal.prototype;
  3564. // Public
  3565. _proto.toggle = function toggle(relatedTarget) {
  3566. return this._isShown ? this.hide() : this.show(relatedTarget);
  3567. };
  3568. _proto.show = function show(relatedTarget) {
  3569. var _this = this;
  3570. if (this._isShown || this._isTransitioning) {
  3571. return;
  3572. }
  3573. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3574. this._isTransitioning = true;
  3575. }
  3576. var showEvent = $.Event(Event$5.SHOW, {
  3577. relatedTarget: relatedTarget
  3578. });
  3579. $(this._element).trigger(showEvent);
  3580. if (this._isShown || showEvent.isDefaultPrevented()) {
  3581. return;
  3582. }
  3583. this._isShown = true;
  3584. this._checkScrollbar();
  3585. this._setScrollbar();
  3586. this._adjustDialog();
  3587. this._setEscapeEvent();
  3588. this._setResizeEvent();
  3589. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3590. return _this.hide(event);
  3591. });
  3592. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3593. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3594. if ($(event.target).is(_this._element)) {
  3595. _this._ignoreBackdropClick = true;
  3596. }
  3597. });
  3598. });
  3599. this._showBackdrop(function () {
  3600. return _this._showElement(relatedTarget);
  3601. });
  3602. };
  3603. _proto.hide = function hide(event) {
  3604. var _this2 = this;
  3605. if (event) {
  3606. event.preventDefault();
  3607. }
  3608. if (!this._isShown || this._isTransitioning) {
  3609. return;
  3610. }
  3611. var hideEvent = $.Event(Event$5.HIDE);
  3612. $(this._element).trigger(hideEvent);
  3613. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3614. return;
  3615. }
  3616. this._isShown = false;
  3617. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3618. if (transition) {
  3619. this._isTransitioning = true;
  3620. }
  3621. this._setEscapeEvent();
  3622. this._setResizeEvent();
  3623. $(document).off(Event$5.FOCUSIN);
  3624. $(this._element).removeClass(ClassName$5.SHOW);
  3625. $(this._element).off(Event$5.CLICK_DISMISS);
  3626. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3627. if (transition) {
  3628. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3629. $(this._element).one(Util.TRANSITION_END, function (event) {
  3630. return _this2._hideModal(event);
  3631. }).emulateTransitionEnd(transitionDuration);
  3632. } else {
  3633. this._hideModal();
  3634. }
  3635. };
  3636. _proto.dispose = function dispose() {
  3637. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3638. return $(htmlElement).off(EVENT_KEY$5);
  3639. });
  3640. /**
  3641. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3642. * Do not move `document` in `htmlElements` array
  3643. * It will remove `Event.CLICK_DATA_API` event that should remain
  3644. */
  3645. $(document).off(Event$5.FOCUSIN);
  3646. $.removeData(this._element, DATA_KEY$5);
  3647. this._config = null;
  3648. this._element = null;
  3649. this._dialog = null;
  3650. this._backdrop = null;
  3651. this._isShown = null;
  3652. this._isBodyOverflowing = null;
  3653. this._ignoreBackdropClick = null;
  3654. this._isTransitioning = null;
  3655. this._scrollbarWidth = null;
  3656. };
  3657. _proto.handleUpdate = function handleUpdate() {
  3658. this._adjustDialog();
  3659. } // Private
  3660. ;
  3661. _proto._getConfig = function _getConfig(config) {
  3662. config = _objectSpread2({}, Default$3, {}, config);
  3663. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3664. return config;
  3665. };
  3666. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3667. var _this3 = this;
  3668. if (this._config.backdrop === 'static') {
  3669. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3670. $(this._element).trigger(hideEventPrevented);
  3671. if (hideEventPrevented.defaultPrevented) {
  3672. return;
  3673. }
  3674. this._element.classList.add(ClassName$5.STATIC);
  3675. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3676. $(this._element).one(Util.TRANSITION_END, function () {
  3677. _this3._element.classList.remove(ClassName$5.STATIC);
  3678. }).emulateTransitionEnd(modalTransitionDuration);
  3679. this._element.focus();
  3680. } else {
  3681. this.hide();
  3682. }
  3683. };
  3684. _proto._showElement = function _showElement(relatedTarget) {
  3685. var _this4 = this;
  3686. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3687. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3688. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3689. // Don't move modal's DOM position
  3690. document.body.appendChild(this._element);
  3691. }
  3692. this._element.style.display = 'block';
  3693. this._element.removeAttribute('aria-hidden');
  3694. this._element.setAttribute('aria-modal', true);
  3695. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3696. modalBody.scrollTop = 0;
  3697. } else {
  3698. this._element.scrollTop = 0;
  3699. }
  3700. if (transition) {
  3701. Util.reflow(this._element);
  3702. }
  3703. $(this._element).addClass(ClassName$5.SHOW);
  3704. if (this._config.focus) {
  3705. this._enforceFocus();
  3706. }
  3707. var shownEvent = $.Event(Event$5.SHOWN, {
  3708. relatedTarget: relatedTarget
  3709. });
  3710. var transitionComplete = function transitionComplete() {
  3711. if (_this4._config.focus) {
  3712. _this4._element.focus();
  3713. }
  3714. _this4._isTransitioning = false;
  3715. $(_this4._element).trigger(shownEvent);
  3716. };
  3717. if (transition) {
  3718. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3719. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3720. } else {
  3721. transitionComplete();
  3722. }
  3723. };
  3724. _proto._enforceFocus = function _enforceFocus() {
  3725. var _this5 = this;
  3726. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3727. .on(Event$5.FOCUSIN, function (event) {
  3728. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3729. _this5._element.focus();
  3730. }
  3731. });
  3732. };
  3733. _proto._setEscapeEvent = function _setEscapeEvent() {
  3734. var _this6 = this;
  3735. if (this._isShown && this._config.keyboard) {
  3736. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3737. if (event.which === ESCAPE_KEYCODE$1) {
  3738. _this6._triggerBackdropTransition();
  3739. }
  3740. });
  3741. } else if (!this._isShown) {
  3742. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3743. }
  3744. };
  3745. _proto._setResizeEvent = function _setResizeEvent() {
  3746. var _this7 = this;
  3747. if (this._isShown) {
  3748. $(window).on(Event$5.RESIZE, function (event) {
  3749. return _this7.handleUpdate(event);
  3750. });
  3751. } else {
  3752. $(window).off(Event$5.RESIZE);
  3753. }
  3754. };
  3755. _proto._hideModal = function _hideModal() {
  3756. var _this8 = this;
  3757. this._element.style.display = 'none';
  3758. this._element.setAttribute('aria-hidden', true);
  3759. this._element.removeAttribute('aria-modal');
  3760. this._isTransitioning = false;
  3761. this._showBackdrop(function () {
  3762. $(document.body).removeClass(ClassName$5.OPEN);
  3763. _this8._resetAdjustments();
  3764. _this8._resetScrollbar();
  3765. $(_this8._element).trigger(Event$5.HIDDEN);
  3766. });
  3767. };
  3768. _proto._removeBackdrop = function _removeBackdrop() {
  3769. if (this._backdrop) {
  3770. $(this._backdrop).remove();
  3771. this._backdrop = null;
  3772. }
  3773. };
  3774. _proto._showBackdrop = function _showBackdrop(callback) {
  3775. var _this9 = this;
  3776. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3777. if (this._isShown && this._config.backdrop) {
  3778. this._backdrop = document.createElement('div');
  3779. this._backdrop.className = ClassName$5.BACKDROP;
  3780. if (animate) {
  3781. this._backdrop.classList.add(animate);
  3782. }
  3783. $(this._backdrop).appendTo(document.body);
  3784. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3785. if (_this9._ignoreBackdropClick) {
  3786. _this9._ignoreBackdropClick = false;
  3787. return;
  3788. }
  3789. if (event.target !== event.currentTarget) {
  3790. return;
  3791. }
  3792. _this9._triggerBackdropTransition();
  3793. });
  3794. if (animate) {
  3795. Util.reflow(this._backdrop);
  3796. }
  3797. $(this._backdrop).addClass(ClassName$5.SHOW);
  3798. if (!callback) {
  3799. return;
  3800. }
  3801. if (!animate) {
  3802. callback();
  3803. return;
  3804. }
  3805. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3806. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3807. } else if (!this._isShown && this._backdrop) {
  3808. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3809. var callbackRemove = function callbackRemove() {
  3810. _this9._removeBackdrop();
  3811. if (callback) {
  3812. callback();
  3813. }
  3814. };
  3815. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3816. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3817. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3818. } else {
  3819. callbackRemove();
  3820. }
  3821. } else if (callback) {
  3822. callback();
  3823. }
  3824. } // ----------------------------------------------------------------------
  3825. // the following methods are used to handle overflowing modals
  3826. // todo (fat): these should probably be refactored out of modal.js
  3827. // ----------------------------------------------------------------------
  3828. ;
  3829. _proto._adjustDialog = function _adjustDialog() {
  3830. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3831. if (!this._isBodyOverflowing && isModalOverflowing) {
  3832. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3833. }
  3834. if (this._isBodyOverflowing && !isModalOverflowing) {
  3835. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3836. }
  3837. };
  3838. _proto._resetAdjustments = function _resetAdjustments() {
  3839. this._element.style.paddingLeft = '';
  3840. this._element.style.paddingRight = '';
  3841. };
  3842. _proto._checkScrollbar = function _checkScrollbar() {
  3843. var rect = document.body.getBoundingClientRect();
  3844. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3845. this._scrollbarWidth = this._getScrollbarWidth();
  3846. };
  3847. _proto._setScrollbar = function _setScrollbar() {
  3848. var _this10 = this;
  3849. if (this._isBodyOverflowing) {
  3850. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3851. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3852. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3853. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3854. $(fixedContent).each(function (index, element) {
  3855. var actualPadding = element.style.paddingRight;
  3856. var calculatedPadding = $(element).css('padding-right');
  3857. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3858. }); // Adjust sticky content margin
  3859. $(stickyContent).each(function (index, element) {
  3860. var actualMargin = element.style.marginRight;
  3861. var calculatedMargin = $(element).css('margin-right');
  3862. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3863. }); // Adjust body padding
  3864. var actualPadding = document.body.style.paddingRight;
  3865. var calculatedPadding = $(document.body).css('padding-right');
  3866. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3867. }
  3868. $(document.body).addClass(ClassName$5.OPEN);
  3869. };
  3870. _proto._resetScrollbar = function _resetScrollbar() {
  3871. // Restore fixed content padding
  3872. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3873. $(fixedContent).each(function (index, element) {
  3874. var padding = $(element).data('padding-right');
  3875. $(element).removeData('padding-right');
  3876. element.style.paddingRight = padding ? padding : '';
  3877. }); // Restore sticky content
  3878. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3879. $(elements).each(function (index, element) {
  3880. var margin = $(element).data('margin-right');
  3881. if (typeof margin !== 'undefined') {
  3882. $(element).css('margin-right', margin).removeData('margin-right');
  3883. }
  3884. }); // Restore body padding
  3885. var padding = $(document.body).data('padding-right');
  3886. $(document.body).removeData('padding-right');
  3887. document.body.style.paddingRight = padding ? padding : '';
  3888. };
  3889. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3890. // thx d.walsh
  3891. var scrollDiv = document.createElement('div');
  3892. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3893. document.body.appendChild(scrollDiv);
  3894. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3895. document.body.removeChild(scrollDiv);
  3896. return scrollbarWidth;
  3897. } // Static
  3898. ;
  3899. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3900. return this.each(function () {
  3901. var data = $(this).data(DATA_KEY$5);
  3902. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3903. if (!data) {
  3904. data = new Modal(this, _config);
  3905. $(this).data(DATA_KEY$5, data);
  3906. }
  3907. if (typeof config === 'string') {
  3908. if (typeof data[config] === 'undefined') {
  3909. throw new TypeError("No method named \"" + config + "\"");
  3910. }
  3911. data[config](relatedTarget);
  3912. } else if (_config.show) {
  3913. data.show(relatedTarget);
  3914. }
  3915. });
  3916. };
  3917. _createClass(Modal, null, [{
  3918. key: "VERSION",
  3919. get: function get() {
  3920. return VERSION$5;
  3921. }
  3922. }, {
  3923. key: "Default",
  3924. get: function get() {
  3925. return Default$3;
  3926. }
  3927. }]);
  3928. return Modal;
  3929. }();
  3930. /**
  3931. * ------------------------------------------------------------------------
  3932. * Data Api implementation
  3933. * ------------------------------------------------------------------------
  3934. */
  3935. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3936. var _this11 = this;
  3937. var target;
  3938. var selector = Util.getSelectorFromElement(this);
  3939. if (selector) {
  3940. target = document.querySelector(selector);
  3941. }
  3942. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3943. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3944. event.preventDefault();
  3945. }
  3946. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3947. if (showEvent.isDefaultPrevented()) {
  3948. // Only register focus restorer if modal will actually get shown
  3949. return;
  3950. }
  3951. $target.one(Event$5.HIDDEN, function () {
  3952. if ($(_this11).is(':visible')) {
  3953. _this11.focus();
  3954. }
  3955. });
  3956. });
  3957. Modal._jQueryInterface.call($(target), config, this);
  3958. });
  3959. /**
  3960. * ------------------------------------------------------------------------
  3961. * jQuery
  3962. * ------------------------------------------------------------------------
  3963. */
  3964. $.fn[NAME$5] = Modal._jQueryInterface;
  3965. $.fn[NAME$5].Constructor = Modal;
  3966. $.fn[NAME$5].noConflict = function () {
  3967. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3968. return Modal._jQueryInterface;
  3969. };
  3970. /**
  3971. * --------------------------------------------------------------------------
  3972. * Bootstrap (v4.4.1): tools/sanitizer.js
  3973. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  3974. * --------------------------------------------------------------------------
  3975. */
  3976. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  3977. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  3978. var DefaultWhitelist = {
  3979. // Global attributes allowed on any supplied element below.
  3980. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  3981. a: ['target', 'href', 'title', 'rel'],
  3982. area: [],
  3983. b: [],
  3984. br: [],
  3985. col: [],
  3986. code: [],
  3987. div: [],
  3988. em: [],
  3989. hr: [],
  3990. h1: [],
  3991. h2: [],
  3992. h3: [],
  3993. h4: [],
  3994. h5: [],
  3995. h6: [],
  3996. i: [],
  3997. img: ['src', 'alt', 'title', 'width', 'height'],
  3998. li: [],
  3999. ol: [],
  4000. p: [],
  4001. pre: [],
  4002. s: [],
  4003. small: [],
  4004. span: [],
  4005. sub: [],
  4006. sup: [],
  4007. strong: [],
  4008. u: [],
  4009. ul: []
  4010. };
  4011. /**
  4012. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4013. *
  4014. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4015. */
  4016. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4017. /**
  4018. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4019. *
  4020. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4021. */
  4022. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
  4023. function allowedAttribute(attr, allowedAttributeList) {
  4024. var attrName = attr.nodeName.toLowerCase();
  4025. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4026. if (uriAttrs.indexOf(attrName) !== -1) {
  4027. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4028. }
  4029. return true;
  4030. }
  4031. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4032. return attrRegex instanceof RegExp;
  4033. }); // Check if a regular expression validates the attribute.
  4034. for (var i = 0, l = regExp.length; i < l; i++) {
  4035. if (attrName.match(regExp[i])) {
  4036. return true;
  4037. }
  4038. }
  4039. return false;
  4040. }
  4041. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4042. if (unsafeHtml.length === 0) {
  4043. return unsafeHtml;
  4044. }
  4045. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4046. return sanitizeFn(unsafeHtml);
  4047. }
  4048. var domParser = new window.DOMParser();
  4049. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4050. var whitelistKeys = Object.keys(whiteList);
  4051. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4052. var _loop = function _loop(i, len) {
  4053. var el = elements[i];
  4054. var elName = el.nodeName.toLowerCase();
  4055. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4056. el.parentNode.removeChild(el);
  4057. return "continue";
  4058. }
  4059. var attributeList = [].slice.call(el.attributes);
  4060. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4061. attributeList.forEach(function (attr) {
  4062. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4063. el.removeAttribute(attr.nodeName);
  4064. }
  4065. });
  4066. };
  4067. for (var i = 0, len = elements.length; i < len; i++) {
  4068. var _ret = _loop(i);
  4069. if (_ret === "continue") continue;
  4070. }
  4071. return createdDocument.body.innerHTML;
  4072. }
  4073. /**
  4074. * ------------------------------------------------------------------------
  4075. * Constants
  4076. * ------------------------------------------------------------------------
  4077. */
  4078. var NAME$6 = 'tooltip';
  4079. var VERSION$6 = '4.4.1';
  4080. var DATA_KEY$6 = 'bs.tooltip';
  4081. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4082. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4083. var CLASS_PREFIX = 'bs-tooltip';
  4084. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4085. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4086. var DefaultType$4 = {
  4087. animation: 'boolean',
  4088. template: 'string',
  4089. title: '(string|element|function)',
  4090. trigger: 'string',
  4091. delay: '(number|object)',
  4092. html: 'boolean',
  4093. selector: '(string|boolean)',
  4094. placement: '(string|function)',
  4095. offset: '(number|string|function)',
  4096. container: '(string|element|boolean)',
  4097. fallbackPlacement: '(string|array)',
  4098. boundary: '(string|element)',
  4099. sanitize: 'boolean',
  4100. sanitizeFn: '(null|function)',
  4101. whiteList: 'object',
  4102. popperConfig: '(null|object)'
  4103. };
  4104. var AttachmentMap$1 = {
  4105. AUTO: 'auto',
  4106. TOP: 'top',
  4107. RIGHT: 'right',
  4108. BOTTOM: 'bottom',
  4109. LEFT: 'left'
  4110. };
  4111. var Default$4 = {
  4112. animation: true,
  4113. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4114. trigger: 'hover focus',
  4115. title: '',
  4116. delay: 0,
  4117. html: false,
  4118. selector: false,
  4119. placement: 'top',
  4120. offset: 0,
  4121. container: false,
  4122. fallbackPlacement: 'flip',
  4123. boundary: 'scrollParent',
  4124. sanitize: true,
  4125. sanitizeFn: null,
  4126. whiteList: DefaultWhitelist,
  4127. popperConfig: null
  4128. };
  4129. var HoverState = {
  4130. SHOW: 'show',
  4131. OUT: 'out'
  4132. };
  4133. var Event$6 = {
  4134. HIDE: "hide" + EVENT_KEY$6,
  4135. HIDDEN: "hidden" + EVENT_KEY$6,
  4136. SHOW: "show" + EVENT_KEY$6,
  4137. SHOWN: "shown" + EVENT_KEY$6,
  4138. INSERTED: "inserted" + EVENT_KEY$6,
  4139. CLICK: "click" + EVENT_KEY$6,
  4140. FOCUSIN: "focusin" + EVENT_KEY$6,
  4141. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4142. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4143. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4144. };
  4145. var ClassName$6 = {
  4146. FADE: 'fade',
  4147. SHOW: 'show'
  4148. };
  4149. var Selector$6 = {
  4150. TOOLTIP: '.tooltip',
  4151. TOOLTIP_INNER: '.tooltip-inner',
  4152. ARROW: '.arrow'
  4153. };
  4154. var Trigger = {
  4155. HOVER: 'hover',
  4156. FOCUS: 'focus',
  4157. CLICK: 'click',
  4158. MANUAL: 'manual'
  4159. };
  4160. /**
  4161. * ------------------------------------------------------------------------
  4162. * Class Definition
  4163. * ------------------------------------------------------------------------
  4164. */
  4165. var Tooltip =
  4166. /*#__PURE__*/
  4167. function () {
  4168. function Tooltip(element, config) {
  4169. if (typeof Popper === 'undefined') {
  4170. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4171. } // private
  4172. this._isEnabled = true;
  4173. this._timeout = 0;
  4174. this._hoverState = '';
  4175. this._activeTrigger = {};
  4176. this._popper = null; // Protected
  4177. this.element = element;
  4178. this.config = this._getConfig(config);
  4179. this.tip = null;
  4180. this._setListeners();
  4181. } // Getters
  4182. var _proto = Tooltip.prototype;
  4183. // Public
  4184. _proto.enable = function enable() {
  4185. this._isEnabled = true;
  4186. };
  4187. _proto.disable = function disable() {
  4188. this._isEnabled = false;
  4189. };
  4190. _proto.toggleEnabled = function toggleEnabled() {
  4191. this._isEnabled = !this._isEnabled;
  4192. };
  4193. _proto.toggle = function toggle(event) {
  4194. if (!this._isEnabled) {
  4195. return;
  4196. }
  4197. if (event) {
  4198. var dataKey = this.constructor.DATA_KEY;
  4199. var context = $(event.currentTarget).data(dataKey);
  4200. if (!context) {
  4201. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4202. $(event.currentTarget).data(dataKey, context);
  4203. }
  4204. context._activeTrigger.click = !context._activeTrigger.click;
  4205. if (context._isWithActiveTrigger()) {
  4206. context._enter(null, context);
  4207. } else {
  4208. context._leave(null, context);
  4209. }
  4210. } else {
  4211. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4212. this._leave(null, this);
  4213. return;
  4214. }
  4215. this._enter(null, this);
  4216. }
  4217. };
  4218. _proto.dispose = function dispose() {
  4219. clearTimeout(this._timeout);
  4220. $.removeData(this.element, this.constructor.DATA_KEY);
  4221. $(this.element).off(this.constructor.EVENT_KEY);
  4222. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4223. if (this.tip) {
  4224. $(this.tip).remove();
  4225. }
  4226. this._isEnabled = null;
  4227. this._timeout = null;
  4228. this._hoverState = null;
  4229. this._activeTrigger = null;
  4230. if (this._popper) {
  4231. this._popper.destroy();
  4232. }
  4233. this._popper = null;
  4234. this.element = null;
  4235. this.config = null;
  4236. this.tip = null;
  4237. };
  4238. _proto.show = function show() {
  4239. var _this = this;
  4240. if ($(this.element).css('display') === 'none') {
  4241. throw new Error('Please use show on visible elements');
  4242. }
  4243. var showEvent = $.Event(this.constructor.Event.SHOW);
  4244. if (this.isWithContent() && this._isEnabled) {
  4245. $(this.element).trigger(showEvent);
  4246. var shadowRoot = Util.findShadowRoot(this.element);
  4247. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4248. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4249. return;
  4250. }
  4251. var tip = this.getTipElement();
  4252. var tipId = Util.getUID(this.constructor.NAME);
  4253. tip.setAttribute('id', tipId);
  4254. this.element.setAttribute('aria-describedby', tipId);
  4255. this.setContent();
  4256. if (this.config.animation) {
  4257. $(tip).addClass(ClassName$6.FADE);
  4258. }
  4259. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4260. var attachment = this._getAttachment(placement);
  4261. this.addAttachmentClass(attachment);
  4262. var container = this._getContainer();
  4263. $(tip).data(this.constructor.DATA_KEY, this);
  4264. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4265. $(tip).appendTo(container);
  4266. }
  4267. $(this.element).trigger(this.constructor.Event.INSERTED);
  4268. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4269. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4270. // empty mouseover listeners to the body's immediate children;
  4271. // only needed because of broken event delegation on iOS
  4272. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4273. if ('ontouchstart' in document.documentElement) {
  4274. $(document.body).children().on('mouseover', null, $.noop);
  4275. }
  4276. var complete = function complete() {
  4277. if (_this.config.animation) {
  4278. _this._fixTransition();
  4279. }
  4280. var prevHoverState = _this._hoverState;
  4281. _this._hoverState = null;
  4282. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4283. if (prevHoverState === HoverState.OUT) {
  4284. _this._leave(null, _this);
  4285. }
  4286. };
  4287. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4288. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4289. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4290. } else {
  4291. complete();
  4292. }
  4293. }
  4294. };
  4295. _proto.hide = function hide(callback) {
  4296. var _this2 = this;
  4297. var tip = this.getTipElement();
  4298. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4299. var complete = function complete() {
  4300. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4301. tip.parentNode.removeChild(tip);
  4302. }
  4303. _this2._cleanTipClass();
  4304. _this2.element.removeAttribute('aria-describedby');
  4305. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4306. if (_this2._popper !== null) {
  4307. _this2._popper.destroy();
  4308. }
  4309. if (callback) {
  4310. callback();
  4311. }
  4312. };
  4313. $(this.element).trigger(hideEvent);
  4314. if (hideEvent.isDefaultPrevented()) {
  4315. return;
  4316. }
  4317. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4318. // empty mouseover listeners we added for iOS support
  4319. if ('ontouchstart' in document.documentElement) {
  4320. $(document.body).children().off('mouseover', null, $.noop);
  4321. }
  4322. this._activeTrigger[Trigger.CLICK] = false;
  4323. this._activeTrigger[Trigger.FOCUS] = false;
  4324. this._activeTrigger[Trigger.HOVER] = false;
  4325. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4326. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4327. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4328. } else {
  4329. complete();
  4330. }
  4331. this._hoverState = '';
  4332. };
  4333. _proto.update = function update() {
  4334. if (this._popper !== null) {
  4335. this._popper.scheduleUpdate();
  4336. }
  4337. } // Protected
  4338. ;
  4339. _proto.isWithContent = function isWithContent() {
  4340. return Boolean(this.getTitle());
  4341. };
  4342. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4343. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4344. };
  4345. _proto.getTipElement = function getTipElement() {
  4346. this.tip = this.tip || $(this.config.template)[0];
  4347. return this.tip;
  4348. };
  4349. _proto.setContent = function setContent() {
  4350. var tip = this.getTipElement();
  4351. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4352. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4353. };
  4354. _proto.setElementContent = function setElementContent($element, content) {
  4355. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4356. // Content is a DOM node or a jQuery
  4357. if (this.config.html) {
  4358. if (!$(content).parent().is($element)) {
  4359. $element.empty().append(content);
  4360. }
  4361. } else {
  4362. $element.text($(content).text());
  4363. }
  4364. return;
  4365. }
  4366. if (this.config.html) {
  4367. if (this.config.sanitize) {
  4368. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4369. }
  4370. $element.html(content);
  4371. } else {
  4372. $element.text(content);
  4373. }
  4374. };
  4375. _proto.getTitle = function getTitle() {
  4376. var title = this.element.getAttribute('data-original-title');
  4377. if (!title) {
  4378. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4379. }
  4380. return title;
  4381. } // Private
  4382. ;
  4383. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4384. var _this3 = this;
  4385. var defaultBsConfig = {
  4386. placement: attachment,
  4387. modifiers: {
  4388. offset: this._getOffset(),
  4389. flip: {
  4390. behavior: this.config.fallbackPlacement
  4391. },
  4392. arrow: {
  4393. element: Selector$6.ARROW
  4394. },
  4395. preventOverflow: {
  4396. boundariesElement: this.config.boundary
  4397. }
  4398. },
  4399. onCreate: function onCreate(data) {
  4400. if (data.originalPlacement !== data.placement) {
  4401. _this3._handlePopperPlacementChange(data);
  4402. }
  4403. },
  4404. onUpdate: function onUpdate(data) {
  4405. return _this3._handlePopperPlacementChange(data);
  4406. }
  4407. };
  4408. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4409. };
  4410. _proto._getOffset = function _getOffset() {
  4411. var _this4 = this;
  4412. var offset = {};
  4413. if (typeof this.config.offset === 'function') {
  4414. offset.fn = function (data) {
  4415. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4416. return data;
  4417. };
  4418. } else {
  4419. offset.offset = this.config.offset;
  4420. }
  4421. return offset;
  4422. };
  4423. _proto._getContainer = function _getContainer() {
  4424. if (this.config.container === false) {
  4425. return document.body;
  4426. }
  4427. if (Util.isElement(this.config.container)) {
  4428. return $(this.config.container);
  4429. }
  4430. return $(document).find(this.config.container);
  4431. };
  4432. _proto._getAttachment = function _getAttachment(placement) {
  4433. return AttachmentMap$1[placement.toUpperCase()];
  4434. };
  4435. _proto._setListeners = function _setListeners() {
  4436. var _this5 = this;
  4437. var triggers = this.config.trigger.split(' ');
  4438. triggers.forEach(function (trigger) {
  4439. if (trigger === 'click') {
  4440. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4441. return _this5.toggle(event);
  4442. });
  4443. } else if (trigger !== Trigger.MANUAL) {
  4444. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4445. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4446. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4447. return _this5._enter(event);
  4448. }).on(eventOut, _this5.config.selector, function (event) {
  4449. return _this5._leave(event);
  4450. });
  4451. }
  4452. });
  4453. this._hideModalHandler = function () {
  4454. if (_this5.element) {
  4455. _this5.hide();
  4456. }
  4457. };
  4458. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4459. if (this.config.selector) {
  4460. this.config = _objectSpread2({}, this.config, {
  4461. trigger: 'manual',
  4462. selector: ''
  4463. });
  4464. } else {
  4465. this._fixTitle();
  4466. }
  4467. };
  4468. _proto._fixTitle = function _fixTitle() {
  4469. var titleType = typeof this.element.getAttribute('data-original-title');
  4470. if (this.element.getAttribute('title') || titleType !== 'string') {
  4471. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4472. this.element.setAttribute('title', '');
  4473. }
  4474. };
  4475. _proto._enter = function _enter(event, context) {
  4476. var dataKey = this.constructor.DATA_KEY;
  4477. context = context || $(event.currentTarget).data(dataKey);
  4478. if (!context) {
  4479. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4480. $(event.currentTarget).data(dataKey, context);
  4481. }
  4482. if (event) {
  4483. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4484. }
  4485. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4486. context._hoverState = HoverState.SHOW;
  4487. return;
  4488. }
  4489. clearTimeout(context._timeout);
  4490. context._hoverState = HoverState.SHOW;
  4491. if (!context.config.delay || !context.config.delay.show) {
  4492. context.show();
  4493. return;
  4494. }
  4495. context._timeout = setTimeout(function () {
  4496. if (context._hoverState === HoverState.SHOW) {
  4497. context.show();
  4498. }
  4499. }, context.config.delay.show);
  4500. };
  4501. _proto._leave = function _leave(event, context) {
  4502. var dataKey = this.constructor.DATA_KEY;
  4503. context = context || $(event.currentTarget).data(dataKey);
  4504. if (!context) {
  4505. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4506. $(event.currentTarget).data(dataKey, context);
  4507. }
  4508. if (event) {
  4509. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4510. }
  4511. if (context._isWithActiveTrigger()) {
  4512. return;
  4513. }
  4514. clearTimeout(context._timeout);
  4515. context._hoverState = HoverState.OUT;
  4516. if (!context.config.delay || !context.config.delay.hide) {
  4517. context.hide();
  4518. return;
  4519. }
  4520. context._timeout = setTimeout(function () {
  4521. if (context._hoverState === HoverState.OUT) {
  4522. context.hide();
  4523. }
  4524. }, context.config.delay.hide);
  4525. };
  4526. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4527. for (var trigger in this._activeTrigger) {
  4528. if (this._activeTrigger[trigger]) {
  4529. return true;
  4530. }
  4531. }
  4532. return false;
  4533. };
  4534. _proto._getConfig = function _getConfig(config) {
  4535. var dataAttributes = $(this.element).data();
  4536. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4537. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4538. delete dataAttributes[dataAttr];
  4539. }
  4540. });
  4541. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4542. if (typeof config.delay === 'number') {
  4543. config.delay = {
  4544. show: config.delay,
  4545. hide: config.delay
  4546. };
  4547. }
  4548. if (typeof config.title === 'number') {
  4549. config.title = config.title.toString();
  4550. }
  4551. if (typeof config.content === 'number') {
  4552. config.content = config.content.toString();
  4553. }
  4554. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4555. if (config.sanitize) {
  4556. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4557. }
  4558. return config;
  4559. };
  4560. _proto._getDelegateConfig = function _getDelegateConfig() {
  4561. var config = {};
  4562. if (this.config) {
  4563. for (var key in this.config) {
  4564. if (this.constructor.Default[key] !== this.config[key]) {
  4565. config[key] = this.config[key];
  4566. }
  4567. }
  4568. }
  4569. return config;
  4570. };
  4571. _proto._cleanTipClass = function _cleanTipClass() {
  4572. var $tip = $(this.getTipElement());
  4573. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4574. if (tabClass !== null && tabClass.length) {
  4575. $tip.removeClass(tabClass.join(''));
  4576. }
  4577. };
  4578. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4579. var popperInstance = popperData.instance;
  4580. this.tip = popperInstance.popper;
  4581. this._cleanTipClass();
  4582. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4583. };
  4584. _proto._fixTransition = function _fixTransition() {
  4585. var tip = this.getTipElement();
  4586. var initConfigAnimation = this.config.animation;
  4587. if (tip.getAttribute('x-placement') !== null) {
  4588. return;
  4589. }
  4590. $(tip).removeClass(ClassName$6.FADE);
  4591. this.config.animation = false;
  4592. this.hide();
  4593. this.show();
  4594. this.config.animation = initConfigAnimation;
  4595. } // Static
  4596. ;
  4597. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4598. return this.each(function () {
  4599. var data = $(this).data(DATA_KEY$6);
  4600. var _config = typeof config === 'object' && config;
  4601. if (!data && /dispose|hide/.test(config)) {
  4602. return;
  4603. }
  4604. if (!data) {
  4605. data = new Tooltip(this, _config);
  4606. $(this).data(DATA_KEY$6, data);
  4607. }
  4608. if (typeof config === 'string') {
  4609. if (typeof data[config] === 'undefined') {
  4610. throw new TypeError("No method named \"" + config + "\"");
  4611. }
  4612. data[config]();
  4613. }
  4614. });
  4615. };
  4616. _createClass(Tooltip, null, [{
  4617. key: "VERSION",
  4618. get: function get() {
  4619. return VERSION$6;
  4620. }
  4621. }, {
  4622. key: "Default",
  4623. get: function get() {
  4624. return Default$4;
  4625. }
  4626. }, {
  4627. key: "NAME",
  4628. get: function get() {
  4629. return NAME$6;
  4630. }
  4631. }, {
  4632. key: "DATA_KEY",
  4633. get: function get() {
  4634. return DATA_KEY$6;
  4635. }
  4636. }, {
  4637. key: "Event",
  4638. get: function get() {
  4639. return Event$6;
  4640. }
  4641. }, {
  4642. key: "EVENT_KEY",
  4643. get: function get() {
  4644. return EVENT_KEY$6;
  4645. }
  4646. }, {
  4647. key: "DefaultType",
  4648. get: function get() {
  4649. return DefaultType$4;
  4650. }
  4651. }]);
  4652. return Tooltip;
  4653. }();
  4654. /**
  4655. * ------------------------------------------------------------------------
  4656. * jQuery
  4657. * ------------------------------------------------------------------------
  4658. */
  4659. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4660. $.fn[NAME$6].Constructor = Tooltip;
  4661. $.fn[NAME$6].noConflict = function () {
  4662. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4663. return Tooltip._jQueryInterface;
  4664. };
  4665. /**
  4666. * ------------------------------------------------------------------------
  4667. * Constants
  4668. * ------------------------------------------------------------------------
  4669. */
  4670. var NAME$7 = 'popover';
  4671. var VERSION$7 = '4.4.1';
  4672. var DATA_KEY$7 = 'bs.popover';
  4673. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4674. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4675. var CLASS_PREFIX$1 = 'bs-popover';
  4676. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4677. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4678. placement: 'right',
  4679. trigger: 'click',
  4680. content: '',
  4681. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4682. });
  4683. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4684. content: '(string|element|function)'
  4685. });
  4686. var ClassName$7 = {
  4687. FADE: 'fade',
  4688. SHOW: 'show'
  4689. };
  4690. var Selector$7 = {
  4691. TITLE: '.popover-header',
  4692. CONTENT: '.popover-body'
  4693. };
  4694. var Event$7 = {
  4695. HIDE: "hide" + EVENT_KEY$7,
  4696. HIDDEN: "hidden" + EVENT_KEY$7,
  4697. SHOW: "show" + EVENT_KEY$7,
  4698. SHOWN: "shown" + EVENT_KEY$7,
  4699. INSERTED: "inserted" + EVENT_KEY$7,
  4700. CLICK: "click" + EVENT_KEY$7,
  4701. FOCUSIN: "focusin" + EVENT_KEY$7,
  4702. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4703. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4704. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4705. };
  4706. /**
  4707. * ------------------------------------------------------------------------
  4708. * Class Definition
  4709. * ------------------------------------------------------------------------
  4710. */
  4711. var Popover =
  4712. /*#__PURE__*/
  4713. function (_Tooltip) {
  4714. _inheritsLoose(Popover, _Tooltip);
  4715. function Popover() {
  4716. return _Tooltip.apply(this, arguments) || this;
  4717. }
  4718. var _proto = Popover.prototype;
  4719. // Overrides
  4720. _proto.isWithContent = function isWithContent() {
  4721. return this.getTitle() || this._getContent();
  4722. };
  4723. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4724. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4725. };
  4726. _proto.getTipElement = function getTipElement() {
  4727. this.tip = this.tip || $(this.config.template)[0];
  4728. return this.tip;
  4729. };
  4730. _proto.setContent = function setContent() {
  4731. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4732. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4733. var content = this._getContent();
  4734. if (typeof content === 'function') {
  4735. content = content.call(this.element);
  4736. }
  4737. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4738. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4739. } // Private
  4740. ;
  4741. _proto._getContent = function _getContent() {
  4742. return this.element.getAttribute('data-content') || this.config.content;
  4743. };
  4744. _proto._cleanTipClass = function _cleanTipClass() {
  4745. var $tip = $(this.getTipElement());
  4746. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4747. if (tabClass !== null && tabClass.length > 0) {
  4748. $tip.removeClass(tabClass.join(''));
  4749. }
  4750. } // Static
  4751. ;
  4752. Popover._jQueryInterface = function _jQueryInterface(config) {
  4753. return this.each(function () {
  4754. var data = $(this).data(DATA_KEY$7);
  4755. var _config = typeof config === 'object' ? config : null;
  4756. if (!data && /dispose|hide/.test(config)) {
  4757. return;
  4758. }
  4759. if (!data) {
  4760. data = new Popover(this, _config);
  4761. $(this).data(DATA_KEY$7, data);
  4762. }
  4763. if (typeof config === 'string') {
  4764. if (typeof data[config] === 'undefined') {
  4765. throw new TypeError("No method named \"" + config + "\"");
  4766. }
  4767. data[config]();
  4768. }
  4769. });
  4770. };
  4771. _createClass(Popover, null, [{
  4772. key: "VERSION",
  4773. // Getters
  4774. get: function get() {
  4775. return VERSION$7;
  4776. }
  4777. }, {
  4778. key: "Default",
  4779. get: function get() {
  4780. return Default$5;
  4781. }
  4782. }, {
  4783. key: "NAME",
  4784. get: function get() {
  4785. return NAME$7;
  4786. }
  4787. }, {
  4788. key: "DATA_KEY",
  4789. get: function get() {
  4790. return DATA_KEY$7;
  4791. }
  4792. }, {
  4793. key: "Event",
  4794. get: function get() {
  4795. return Event$7;
  4796. }
  4797. }, {
  4798. key: "EVENT_KEY",
  4799. get: function get() {
  4800. return EVENT_KEY$7;
  4801. }
  4802. }, {
  4803. key: "DefaultType",
  4804. get: function get() {
  4805. return DefaultType$5;
  4806. }
  4807. }]);
  4808. return Popover;
  4809. }(Tooltip);
  4810. /**
  4811. * ------------------------------------------------------------------------
  4812. * jQuery
  4813. * ------------------------------------------------------------------------
  4814. */
  4815. $.fn[NAME$7] = Popover._jQueryInterface;
  4816. $.fn[NAME$7].Constructor = Popover;
  4817. $.fn[NAME$7].noConflict = function () {
  4818. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4819. return Popover._jQueryInterface;
  4820. };
  4821. /**
  4822. * ------------------------------------------------------------------------
  4823. * Constants
  4824. * ------------------------------------------------------------------------
  4825. */
  4826. var NAME$8 = 'scrollspy';
  4827. var VERSION$8 = '4.4.1';
  4828. var DATA_KEY$8 = 'bs.scrollspy';
  4829. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4830. var DATA_API_KEY$6 = '.data-api';
  4831. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4832. var Default$6 = {
  4833. offset: 10,
  4834. method: 'auto',
  4835. target: ''
  4836. };
  4837. var DefaultType$6 = {
  4838. offset: 'number',
  4839. method: 'string',
  4840. target: '(string|element)'
  4841. };
  4842. var Event$8 = {
  4843. ACTIVATE: "activate" + EVENT_KEY$8,
  4844. SCROLL: "scroll" + EVENT_KEY$8,
  4845. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4846. };
  4847. var ClassName$8 = {
  4848. DROPDOWN_ITEM: 'dropdown-item',
  4849. DROPDOWN_MENU: 'dropdown-menu',
  4850. ACTIVE: 'active'
  4851. };
  4852. var Selector$8 = {
  4853. DATA_SPY: '[data-spy="scroll"]',
  4854. ACTIVE: '.active',
  4855. NAV_LIST_GROUP: '.nav, .list-group',
  4856. NAV_LINKS: '.nav-link',
  4857. NAV_ITEMS: '.nav-item',
  4858. LIST_ITEMS: '.list-group-item',
  4859. DROPDOWN: '.dropdown',
  4860. DROPDOWN_ITEMS: '.dropdown-item',
  4861. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4862. };
  4863. var OffsetMethod = {
  4864. OFFSET: 'offset',
  4865. POSITION: 'position'
  4866. };
  4867. /**
  4868. * ------------------------------------------------------------------------
  4869. * Class Definition
  4870. * ------------------------------------------------------------------------
  4871. */
  4872. var ScrollSpy =
  4873. /*#__PURE__*/
  4874. function () {
  4875. function ScrollSpy(element, config) {
  4876. var _this = this;
  4877. this._element = element;
  4878. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4879. this._config = this._getConfig(config);
  4880. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4881. this._offsets = [];
  4882. this._targets = [];
  4883. this._activeTarget = null;
  4884. this._scrollHeight = 0;
  4885. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4886. return _this._process(event);
  4887. });
  4888. this.refresh();
  4889. this._process();
  4890. } // Getters
  4891. var _proto = ScrollSpy.prototype;
  4892. // Public
  4893. _proto.refresh = function refresh() {
  4894. var _this2 = this;
  4895. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4896. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4897. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4898. this._offsets = [];
  4899. this._targets = [];
  4900. this._scrollHeight = this._getScrollHeight();
  4901. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4902. targets.map(function (element) {
  4903. var target;
  4904. var targetSelector = Util.getSelectorFromElement(element);
  4905. if (targetSelector) {
  4906. target = document.querySelector(targetSelector);
  4907. }
  4908. if (target) {
  4909. var targetBCR = target.getBoundingClientRect();
  4910. if (targetBCR.width || targetBCR.height) {
  4911. // TODO (fat): remove sketch reliance on jQuery position/offset
  4912. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4913. }
  4914. }
  4915. return null;
  4916. }).filter(function (item) {
  4917. return item;
  4918. }).sort(function (a, b) {
  4919. return a[0] - b[0];
  4920. }).forEach(function (item) {
  4921. _this2._offsets.push(item[0]);
  4922. _this2._targets.push(item[1]);
  4923. });
  4924. };
  4925. _proto.dispose = function dispose() {
  4926. $.removeData(this._element, DATA_KEY$8);
  4927. $(this._scrollElement).off(EVENT_KEY$8);
  4928. this._element = null;
  4929. this._scrollElement = null;
  4930. this._config = null;
  4931. this._selector = null;
  4932. this._offsets = null;
  4933. this._targets = null;
  4934. this._activeTarget = null;
  4935. this._scrollHeight = null;
  4936. } // Private
  4937. ;
  4938. _proto._getConfig = function _getConfig(config) {
  4939. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4940. if (typeof config.target !== 'string') {
  4941. var id = $(config.target).attr('id');
  4942. if (!id) {
  4943. id = Util.getUID(NAME$8);
  4944. $(config.target).attr('id', id);
  4945. }
  4946. config.target = "#" + id;
  4947. }
  4948. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4949. return config;
  4950. };
  4951. _proto._getScrollTop = function _getScrollTop() {
  4952. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4953. };
  4954. _proto._getScrollHeight = function _getScrollHeight() {
  4955. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4956. };
  4957. _proto._getOffsetHeight = function _getOffsetHeight() {
  4958. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4959. };
  4960. _proto._process = function _process() {
  4961. var scrollTop = this._getScrollTop() + this._config.offset;
  4962. var scrollHeight = this._getScrollHeight();
  4963. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4964. if (this._scrollHeight !== scrollHeight) {
  4965. this.refresh();
  4966. }
  4967. if (scrollTop >= maxScroll) {
  4968. var target = this._targets[this._targets.length - 1];
  4969. if (this._activeTarget !== target) {
  4970. this._activate(target);
  4971. }
  4972. return;
  4973. }
  4974. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  4975. this._activeTarget = null;
  4976. this._clear();
  4977. return;
  4978. }
  4979. var offsetLength = this._offsets.length;
  4980. for (var i = offsetLength; i--;) {
  4981. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  4982. if (isActiveTarget) {
  4983. this._activate(this._targets[i]);
  4984. }
  4985. }
  4986. };
  4987. _proto._activate = function _activate(target) {
  4988. this._activeTarget = target;
  4989. this._clear();
  4990. var queries = this._selector.split(',').map(function (selector) {
  4991. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  4992. });
  4993. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  4994. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  4995. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  4996. $link.addClass(ClassName$8.ACTIVE);
  4997. } else {
  4998. // Set triggered link as active
  4999. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5000. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5001. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); // Handle special case when .nav-link is inside .nav-item
  5002. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5003. }
  5004. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5005. relatedTarget: target
  5006. });
  5007. };
  5008. _proto._clear = function _clear() {
  5009. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5010. return node.classList.contains(ClassName$8.ACTIVE);
  5011. }).forEach(function (node) {
  5012. return node.classList.remove(ClassName$8.ACTIVE);
  5013. });
  5014. } // Static
  5015. ;
  5016. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5017. return this.each(function () {
  5018. var data = $(this).data(DATA_KEY$8);
  5019. var _config = typeof config === 'object' && config;
  5020. if (!data) {
  5021. data = new ScrollSpy(this, _config);
  5022. $(this).data(DATA_KEY$8, data);
  5023. }
  5024. if (typeof config === 'string') {
  5025. if (typeof data[config] === 'undefined') {
  5026. throw new TypeError("No method named \"" + config + "\"");
  5027. }
  5028. data[config]();
  5029. }
  5030. });
  5031. };
  5032. _createClass(ScrollSpy, null, [{
  5033. key: "VERSION",
  5034. get: function get() {
  5035. return VERSION$8;
  5036. }
  5037. }, {
  5038. key: "Default",
  5039. get: function get() {
  5040. return Default$6;
  5041. }
  5042. }]);
  5043. return ScrollSpy;
  5044. }();
  5045. /**
  5046. * ------------------------------------------------------------------------
  5047. * Data Api implementation
  5048. * ------------------------------------------------------------------------
  5049. */
  5050. $(window).on(Event$8.LOAD_DATA_API, function () {
  5051. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5052. var scrollSpysLength = scrollSpys.length;
  5053. for (var i = scrollSpysLength; i--;) {
  5054. var $spy = $(scrollSpys[i]);
  5055. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5056. }
  5057. });
  5058. /**
  5059. * ------------------------------------------------------------------------
  5060. * jQuery
  5061. * ------------------------------------------------------------------------
  5062. */
  5063. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5064. $.fn[NAME$8].Constructor = ScrollSpy;
  5065. $.fn[NAME$8].noConflict = function () {
  5066. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5067. return ScrollSpy._jQueryInterface;
  5068. };
  5069. /**
  5070. * ------------------------------------------------------------------------
  5071. * Constants
  5072. * ------------------------------------------------------------------------
  5073. */
  5074. var NAME$9 = 'tab';
  5075. var VERSION$9 = '4.4.1';
  5076. var DATA_KEY$9 = 'bs.tab';
  5077. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5078. var DATA_API_KEY$7 = '.data-api';
  5079. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5080. var Event$9 = {
  5081. HIDE: "hide" + EVENT_KEY$9,
  5082. HIDDEN: "hidden" + EVENT_KEY$9,
  5083. SHOW: "show" + EVENT_KEY$9,
  5084. SHOWN: "shown" + EVENT_KEY$9,
  5085. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5086. };
  5087. var ClassName$9 = {
  5088. DROPDOWN_MENU: 'dropdown-menu',
  5089. ACTIVE: 'active',
  5090. DISABLED: 'disabled',
  5091. FADE: 'fade',
  5092. SHOW: 'show'
  5093. };
  5094. var Selector$9 = {
  5095. DROPDOWN: '.dropdown',
  5096. NAV_LIST_GROUP: '.nav, .list-group',
  5097. ACTIVE: '.active',
  5098. ACTIVE_UL: '> li > .active',
  5099. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5100. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5101. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5102. };
  5103. /**
  5104. * ------------------------------------------------------------------------
  5105. * Class Definition
  5106. * ------------------------------------------------------------------------
  5107. */
  5108. var Tab =
  5109. /*#__PURE__*/
  5110. function () {
  5111. function Tab(element) {
  5112. this._element = element;
  5113. } // Getters
  5114. var _proto = Tab.prototype;
  5115. // Public
  5116. _proto.show = function show() {
  5117. var _this = this;
  5118. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5119. return;
  5120. }
  5121. var target;
  5122. var previous;
  5123. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5124. var selector = Util.getSelectorFromElement(this._element);
  5125. if (listElement) {
  5126. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5127. previous = $.makeArray($(listElement).find(itemSelector));
  5128. previous = previous[previous.length - 1];
  5129. }
  5130. var hideEvent = $.Event(Event$9.HIDE, {
  5131. relatedTarget: this._element
  5132. });
  5133. var showEvent = $.Event(Event$9.SHOW, {
  5134. relatedTarget: previous
  5135. });
  5136. if (previous) {
  5137. $(previous).trigger(hideEvent);
  5138. }
  5139. $(this._element).trigger(showEvent);
  5140. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5141. return;
  5142. }
  5143. if (selector) {
  5144. target = document.querySelector(selector);
  5145. }
  5146. this._activate(this._element, listElement);
  5147. var complete = function complete() {
  5148. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5149. relatedTarget: _this._element
  5150. });
  5151. var shownEvent = $.Event(Event$9.SHOWN, {
  5152. relatedTarget: previous
  5153. });
  5154. $(previous).trigger(hiddenEvent);
  5155. $(_this._element).trigger(shownEvent);
  5156. };
  5157. if (target) {
  5158. this._activate(target, target.parentNode, complete);
  5159. } else {
  5160. complete();
  5161. }
  5162. };
  5163. _proto.dispose = function dispose() {
  5164. $.removeData(this._element, DATA_KEY$9);
  5165. this._element = null;
  5166. } // Private
  5167. ;
  5168. _proto._activate = function _activate(element, container, callback) {
  5169. var _this2 = this;
  5170. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5171. var active = activeElements[0];
  5172. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5173. var complete = function complete() {
  5174. return _this2._transitionComplete(element, active, callback);
  5175. };
  5176. if (active && isTransitioning) {
  5177. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5178. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5179. } else {
  5180. complete();
  5181. }
  5182. };
  5183. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5184. if (active) {
  5185. $(active).removeClass(ClassName$9.ACTIVE);
  5186. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5187. if (dropdownChild) {
  5188. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5189. }
  5190. if (active.getAttribute('role') === 'tab') {
  5191. active.setAttribute('aria-selected', false);
  5192. }
  5193. }
  5194. $(element).addClass(ClassName$9.ACTIVE);
  5195. if (element.getAttribute('role') === 'tab') {
  5196. element.setAttribute('aria-selected', true);
  5197. }
  5198. Util.reflow(element);
  5199. if (element.classList.contains(ClassName$9.FADE)) {
  5200. element.classList.add(ClassName$9.SHOW);
  5201. }
  5202. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5203. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5204. if (dropdownElement) {
  5205. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5206. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5207. }
  5208. element.setAttribute('aria-expanded', true);
  5209. }
  5210. if (callback) {
  5211. callback();
  5212. }
  5213. } // Static
  5214. ;
  5215. Tab._jQueryInterface = function _jQueryInterface(config) {
  5216. return this.each(function () {
  5217. var $this = $(this);
  5218. var data = $this.data(DATA_KEY$9);
  5219. if (!data) {
  5220. data = new Tab(this);
  5221. $this.data(DATA_KEY$9, data);
  5222. }
  5223. if (typeof config === 'string') {
  5224. if (typeof data[config] === 'undefined') {
  5225. throw new TypeError("No method named \"" + config + "\"");
  5226. }
  5227. data[config]();
  5228. }
  5229. });
  5230. };
  5231. _createClass(Tab, null, [{
  5232. key: "VERSION",
  5233. get: function get() {
  5234. return VERSION$9;
  5235. }
  5236. }]);
  5237. return Tab;
  5238. }();
  5239. /**
  5240. * ------------------------------------------------------------------------
  5241. * Data Api implementation
  5242. * ------------------------------------------------------------------------
  5243. */
  5244. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5245. event.preventDefault();
  5246. Tab._jQueryInterface.call($(this), 'show');
  5247. });
  5248. /**
  5249. * ------------------------------------------------------------------------
  5250. * jQuery
  5251. * ------------------------------------------------------------------------
  5252. */
  5253. $.fn[NAME$9] = Tab._jQueryInterface;
  5254. $.fn[NAME$9].Constructor = Tab;
  5255. $.fn[NAME$9].noConflict = function () {
  5256. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5257. return Tab._jQueryInterface;
  5258. };
  5259. /**
  5260. * ------------------------------------------------------------------------
  5261. * Constants
  5262. * ------------------------------------------------------------------------
  5263. */
  5264. var NAME$a = 'toast';
  5265. var VERSION$a = '4.4.1';
  5266. var DATA_KEY$a = 'bs.toast';
  5267. var EVENT_KEY$a = "." + DATA_KEY$a;
  5268. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5269. var Event$a = {
  5270. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5271. HIDE: "hide" + EVENT_KEY$a,
  5272. HIDDEN: "hidden" + EVENT_KEY$a,
  5273. SHOW: "show" + EVENT_KEY$a,
  5274. SHOWN: "shown" + EVENT_KEY$a
  5275. };
  5276. var ClassName$a = {
  5277. FADE: 'fade',
  5278. HIDE: 'hide',
  5279. SHOW: 'show',
  5280. SHOWING: 'showing'
  5281. };
  5282. var DefaultType$7 = {
  5283. animation: 'boolean',
  5284. autohide: 'boolean',
  5285. delay: 'number'
  5286. };
  5287. var Default$7 = {
  5288. animation: true,
  5289. autohide: true,
  5290. delay: 500
  5291. };
  5292. var Selector$a = {
  5293. DATA_DISMISS: '[data-dismiss="toast"]'
  5294. };
  5295. /**
  5296. * ------------------------------------------------------------------------
  5297. * Class Definition
  5298. * ------------------------------------------------------------------------
  5299. */
  5300. var Toast =
  5301. /*#__PURE__*/
  5302. function () {
  5303. function Toast(element, config) {
  5304. this._element = element;
  5305. this._config = this._getConfig(config);
  5306. this._timeout = null;
  5307. this._setListeners();
  5308. } // Getters
  5309. var _proto = Toast.prototype;
  5310. // Public
  5311. _proto.show = function show() {
  5312. var _this = this;
  5313. var showEvent = $.Event(Event$a.SHOW);
  5314. $(this._element).trigger(showEvent);
  5315. if (showEvent.isDefaultPrevented()) {
  5316. return;
  5317. }
  5318. if (this._config.animation) {
  5319. this._element.classList.add(ClassName$a.FADE);
  5320. }
  5321. var complete = function complete() {
  5322. _this._element.classList.remove(ClassName$a.SHOWING);
  5323. _this._element.classList.add(ClassName$a.SHOW);
  5324. $(_this._element).trigger(Event$a.SHOWN);
  5325. if (_this._config.autohide) {
  5326. _this._timeout = setTimeout(function () {
  5327. _this.hide();
  5328. }, _this._config.delay);
  5329. }
  5330. };
  5331. this._element.classList.remove(ClassName$a.HIDE);
  5332. Util.reflow(this._element);
  5333. this._element.classList.add(ClassName$a.SHOWING);
  5334. if (this._config.animation) {
  5335. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5336. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5337. } else {
  5338. complete();
  5339. }
  5340. };
  5341. _proto.hide = function hide() {
  5342. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5343. return;
  5344. }
  5345. var hideEvent = $.Event(Event$a.HIDE);
  5346. $(this._element).trigger(hideEvent);
  5347. if (hideEvent.isDefaultPrevented()) {
  5348. return;
  5349. }
  5350. this._close();
  5351. };
  5352. _proto.dispose = function dispose() {
  5353. clearTimeout(this._timeout);
  5354. this._timeout = null;
  5355. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5356. this._element.classList.remove(ClassName$a.SHOW);
  5357. }
  5358. $(this._element).off(Event$a.CLICK_DISMISS);
  5359. $.removeData(this._element, DATA_KEY$a);
  5360. this._element = null;
  5361. this._config = null;
  5362. } // Private
  5363. ;
  5364. _proto._getConfig = function _getConfig(config) {
  5365. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5366. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5367. return config;
  5368. };
  5369. _proto._setListeners = function _setListeners() {
  5370. var _this2 = this;
  5371. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5372. return _this2.hide();
  5373. });
  5374. };
  5375. _proto._close = function _close() {
  5376. var _this3 = this;
  5377. var complete = function complete() {
  5378. _this3._element.classList.add(ClassName$a.HIDE);
  5379. $(_this3._element).trigger(Event$a.HIDDEN);
  5380. };
  5381. this._element.classList.remove(ClassName$a.SHOW);
  5382. if (this._config.animation) {
  5383. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5384. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5385. } else {
  5386. complete();
  5387. }
  5388. } // Static
  5389. ;
  5390. Toast._jQueryInterface = function _jQueryInterface(config) {
  5391. return this.each(function () {
  5392. var $element = $(this);
  5393. var data = $element.data(DATA_KEY$a);
  5394. var _config = typeof config === 'object' && config;
  5395. if (!data) {
  5396. data = new Toast(this, _config);
  5397. $element.data(DATA_KEY$a, data);
  5398. }
  5399. if (typeof config === 'string') {
  5400. if (typeof data[config] === 'undefined') {
  5401. throw new TypeError("No method named \"" + config + "\"");
  5402. }
  5403. data[config](this);
  5404. }
  5405. });
  5406. };
  5407. _createClass(Toast, null, [{
  5408. key: "VERSION",
  5409. get: function get() {
  5410. return VERSION$a;
  5411. }
  5412. }, {
  5413. key: "DefaultType",
  5414. get: function get() {
  5415. return DefaultType$7;
  5416. }
  5417. }, {
  5418. key: "Default",
  5419. get: function get() {
  5420. return Default$7;
  5421. }
  5422. }]);
  5423. return Toast;
  5424. }();
  5425. /**
  5426. * ------------------------------------------------------------------------
  5427. * jQuery
  5428. * ------------------------------------------------------------------------
  5429. */
  5430. $.fn[NAME$a] = Toast._jQueryInterface;
  5431. $.fn[NAME$a].Constructor = Toast;
  5432. $.fn[NAME$a].noConflict = function () {
  5433. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5434. return Toast._jQueryInterface;
  5435. };
  5436. exports.Alert = Alert;
  5437. exports.Button = Button;
  5438. exports.Carousel = Carousel;
  5439. exports.Collapse = Collapse;
  5440. exports.Dropdown = Dropdown;
  5441. exports.Modal = Modal;
  5442. exports.Popover = Popover;
  5443. exports.Scrollspy = ScrollSpy;
  5444. exports.Tab = Tab;
  5445. exports.Toast = Toast;
  5446. exports.Tooltip = Tooltip;
  5447. exports.Util = Util;
  5448. Object.defineProperty(exports, '__esModule', { value: true });
  5449. })));
  5450. //# sourceMappingURL=bootstrap.js.map
  5451. /***/ }),
  5452. /***/ "./node_modules/buffer/index.js":
  5453. /*!**************************************!*\
  5454. !*** ./node_modules/buffer/index.js ***!
  5455. \**************************************/
  5456. /*! no static exports found */
  5457. /***/ (function(module, exports, __webpack_require__) {
  5458. "use strict";
  5459. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5460. * The buffer module from node.js, for the browser.
  5461. *
  5462. * @author Feross Aboukhadijeh <http://feross.org>
  5463. * @license MIT
  5464. */
  5465. /* eslint-disable no-proto */
  5466. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5467. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5468. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5469. exports.Buffer = Buffer
  5470. exports.SlowBuffer = SlowBuffer
  5471. exports.INSPECT_MAX_BYTES = 50
  5472. /**
  5473. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5474. * === true Use Uint8Array implementation (fastest)
  5475. * === false Use Object implementation (most compatible, even IE6)
  5476. *
  5477. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5478. * Opera 11.6+, iOS 4.2+.
  5479. *
  5480. * Due to various browser bugs, sometimes the Object implementation will be used even
  5481. * when the browser supports typed arrays.
  5482. *
  5483. * Note:
  5484. *
  5485. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5486. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5487. *
  5488. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5489. *
  5490. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5491. * incorrect length in some situations.
  5492. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5493. * get the Object implementation, which is slower but behaves correctly.
  5494. */
  5495. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5496. ? global.TYPED_ARRAY_SUPPORT
  5497. : typedArraySupport()
  5498. /*
  5499. * Export kMaxLength after typed array support is determined.
  5500. */
  5501. exports.kMaxLength = kMaxLength()
  5502. function typedArraySupport () {
  5503. try {
  5504. var arr = new Uint8Array(1)
  5505. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5506. return arr.foo() === 42 && // typed array instances can be augmented
  5507. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5508. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5509. } catch (e) {
  5510. return false
  5511. }
  5512. }
  5513. function kMaxLength () {
  5514. return Buffer.TYPED_ARRAY_SUPPORT
  5515. ? 0x7fffffff
  5516. : 0x3fffffff
  5517. }
  5518. function createBuffer (that, length) {
  5519. if (kMaxLength() < length) {
  5520. throw new RangeError('Invalid typed array length')
  5521. }
  5522. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5523. // Return an augmented `Uint8Array` instance, for best performance
  5524. that = new Uint8Array(length)
  5525. that.__proto__ = Buffer.prototype
  5526. } else {
  5527. // Fallback: Return an object instance of the Buffer class
  5528. if (that === null) {
  5529. that = new Buffer(length)
  5530. }
  5531. that.length = length
  5532. }
  5533. return that
  5534. }
  5535. /**
  5536. * The Buffer constructor returns instances of `Uint8Array` that have their
  5537. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5538. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5539. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5540. * returns a single octet.
  5541. *
  5542. * The `Uint8Array` prototype remains unmodified.
  5543. */
  5544. function Buffer (arg, encodingOrOffset, length) {
  5545. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5546. return new Buffer(arg, encodingOrOffset, length)
  5547. }
  5548. // Common case.
  5549. if (typeof arg === 'number') {
  5550. if (typeof encodingOrOffset === 'string') {
  5551. throw new Error(
  5552. 'If encoding is specified then the first argument must be a string'
  5553. )
  5554. }
  5555. return allocUnsafe(this, arg)
  5556. }
  5557. return from(this, arg, encodingOrOffset, length)
  5558. }
  5559. Buffer.poolSize = 8192 // not used by this implementation
  5560. // TODO: Legacy, not needed anymore. Remove in next major version.
  5561. Buffer._augment = function (arr) {
  5562. arr.__proto__ = Buffer.prototype
  5563. return arr
  5564. }
  5565. function from (that, value, encodingOrOffset, length) {
  5566. if (typeof value === 'number') {
  5567. throw new TypeError('"value" argument must not be a number')
  5568. }
  5569. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5570. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5571. }
  5572. if (typeof value === 'string') {
  5573. return fromString(that, value, encodingOrOffset)
  5574. }
  5575. return fromObject(that, value)
  5576. }
  5577. /**
  5578. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5579. * if value is a number.
  5580. * Buffer.from(str[, encoding])
  5581. * Buffer.from(array)
  5582. * Buffer.from(buffer)
  5583. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5584. **/
  5585. Buffer.from = function (value, encodingOrOffset, length) {
  5586. return from(null, value, encodingOrOffset, length)
  5587. }
  5588. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5589. Buffer.prototype.__proto__ = Uint8Array.prototype
  5590. Buffer.__proto__ = Uint8Array
  5591. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5592. Buffer[Symbol.species] === Buffer) {
  5593. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5594. Object.defineProperty(Buffer, Symbol.species, {
  5595. value: null,
  5596. configurable: true
  5597. })
  5598. }
  5599. }
  5600. function assertSize (size) {
  5601. if (typeof size !== 'number') {
  5602. throw new TypeError('"size" argument must be a number')
  5603. } else if (size < 0) {
  5604. throw new RangeError('"size" argument must not be negative')
  5605. }
  5606. }
  5607. function alloc (that, size, fill, encoding) {
  5608. assertSize(size)
  5609. if (size <= 0) {
  5610. return createBuffer(that, size)
  5611. }
  5612. if (fill !== undefined) {
  5613. // Only pay attention to encoding if it's a string. This
  5614. // prevents accidentally sending in a number that would
  5615. // be interpretted as a start offset.
  5616. return typeof encoding === 'string'
  5617. ? createBuffer(that, size).fill(fill, encoding)
  5618. : createBuffer(that, size).fill(fill)
  5619. }
  5620. return createBuffer(that, size)
  5621. }
  5622. /**
  5623. * Creates a new filled Buffer instance.
  5624. * alloc(size[, fill[, encoding]])
  5625. **/
  5626. Buffer.alloc = function (size, fill, encoding) {
  5627. return alloc(null, size, fill, encoding)
  5628. }
  5629. function allocUnsafe (that, size) {
  5630. assertSize(size)
  5631. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5632. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5633. for (var i = 0; i < size; ++i) {
  5634. that[i] = 0
  5635. }
  5636. }
  5637. return that
  5638. }
  5639. /**
  5640. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5641. * */
  5642. Buffer.allocUnsafe = function (size) {
  5643. return allocUnsafe(null, size)
  5644. }
  5645. /**
  5646. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5647. */
  5648. Buffer.allocUnsafeSlow = function (size) {
  5649. return allocUnsafe(null, size)
  5650. }
  5651. function fromString (that, string, encoding) {
  5652. if (typeof encoding !== 'string' || encoding === '') {
  5653. encoding = 'utf8'
  5654. }
  5655. if (!Buffer.isEncoding(encoding)) {
  5656. throw new TypeError('"encoding" must be a valid string encoding')
  5657. }
  5658. var length = byteLength(string, encoding) | 0
  5659. that = createBuffer(that, length)
  5660. var actual = that.write(string, encoding)
  5661. if (actual !== length) {
  5662. // Writing a hex string, for example, that contains invalid characters will
  5663. // cause everything after the first invalid character to be ignored. (e.g.
  5664. // 'abxxcd' will be treated as 'ab')
  5665. that = that.slice(0, actual)
  5666. }
  5667. return that
  5668. }
  5669. function fromArrayLike (that, array) {
  5670. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5671. that = createBuffer(that, length)
  5672. for (var i = 0; i < length; i += 1) {
  5673. that[i] = array[i] & 255
  5674. }
  5675. return that
  5676. }
  5677. function fromArrayBuffer (that, array, byteOffset, length) {
  5678. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5679. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5680. throw new RangeError('\'offset\' is out of bounds')
  5681. }
  5682. if (array.byteLength < byteOffset + (length || 0)) {
  5683. throw new RangeError('\'length\' is out of bounds')
  5684. }
  5685. if (byteOffset === undefined && length === undefined) {
  5686. array = new Uint8Array(array)
  5687. } else if (length === undefined) {
  5688. array = new Uint8Array(array, byteOffset)
  5689. } else {
  5690. array = new Uint8Array(array, byteOffset, length)
  5691. }
  5692. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5693. // Return an augmented `Uint8Array` instance, for best performance
  5694. that = array
  5695. that.__proto__ = Buffer.prototype
  5696. } else {
  5697. // Fallback: Return an object instance of the Buffer class
  5698. that = fromArrayLike(that, array)
  5699. }
  5700. return that
  5701. }
  5702. function fromObject (that, obj) {
  5703. if (Buffer.isBuffer(obj)) {
  5704. var len = checked(obj.length) | 0
  5705. that = createBuffer(that, len)
  5706. if (that.length === 0) {
  5707. return that
  5708. }
  5709. obj.copy(that, 0, 0, len)
  5710. return that
  5711. }
  5712. if (obj) {
  5713. if ((typeof ArrayBuffer !== 'undefined' &&
  5714. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5715. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5716. return createBuffer(that, 0)
  5717. }
  5718. return fromArrayLike(that, obj)
  5719. }
  5720. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5721. return fromArrayLike(that, obj.data)
  5722. }
  5723. }
  5724. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5725. }
  5726. function checked (length) {
  5727. // Note: cannot use `length < kMaxLength()` here because that fails when
  5728. // length is NaN (which is otherwise coerced to zero.)
  5729. if (length >= kMaxLength()) {
  5730. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5731. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5732. }
  5733. return length | 0
  5734. }
  5735. function SlowBuffer (length) {
  5736. if (+length != length) { // eslint-disable-line eqeqeq
  5737. length = 0
  5738. }
  5739. return Buffer.alloc(+length)
  5740. }
  5741. Buffer.isBuffer = function isBuffer (b) {
  5742. return !!(b != null && b._isBuffer)
  5743. }
  5744. Buffer.compare = function compare (a, b) {
  5745. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5746. throw new TypeError('Arguments must be Buffers')
  5747. }
  5748. if (a === b) return 0
  5749. var x = a.length
  5750. var y = b.length
  5751. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5752. if (a[i] !== b[i]) {
  5753. x = a[i]
  5754. y = b[i]
  5755. break
  5756. }
  5757. }
  5758. if (x < y) return -1
  5759. if (y < x) return 1
  5760. return 0
  5761. }
  5762. Buffer.isEncoding = function isEncoding (encoding) {
  5763. switch (String(encoding).toLowerCase()) {
  5764. case 'hex':
  5765. case 'utf8':
  5766. case 'utf-8':
  5767. case 'ascii':
  5768. case 'latin1':
  5769. case 'binary':
  5770. case 'base64':
  5771. case 'ucs2':
  5772. case 'ucs-2':
  5773. case 'utf16le':
  5774. case 'utf-16le':
  5775. return true
  5776. default:
  5777. return false
  5778. }
  5779. }
  5780. Buffer.concat = function concat (list, length) {
  5781. if (!isArray(list)) {
  5782. throw new TypeError('"list" argument must be an Array of Buffers')
  5783. }
  5784. if (list.length === 0) {
  5785. return Buffer.alloc(0)
  5786. }
  5787. var i
  5788. if (length === undefined) {
  5789. length = 0
  5790. for (i = 0; i < list.length; ++i) {
  5791. length += list[i].length
  5792. }
  5793. }
  5794. var buffer = Buffer.allocUnsafe(length)
  5795. var pos = 0
  5796. for (i = 0; i < list.length; ++i) {
  5797. var buf = list[i]
  5798. if (!Buffer.isBuffer(buf)) {
  5799. throw new TypeError('"list" argument must be an Array of Buffers')
  5800. }
  5801. buf.copy(buffer, pos)
  5802. pos += buf.length
  5803. }
  5804. return buffer
  5805. }
  5806. function byteLength (string, encoding) {
  5807. if (Buffer.isBuffer(string)) {
  5808. return string.length
  5809. }
  5810. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5811. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5812. return string.byteLength
  5813. }
  5814. if (typeof string !== 'string') {
  5815. string = '' + string
  5816. }
  5817. var len = string.length
  5818. if (len === 0) return 0
  5819. // Use a for loop to avoid recursion
  5820. var loweredCase = false
  5821. for (;;) {
  5822. switch (encoding) {
  5823. case 'ascii':
  5824. case 'latin1':
  5825. case 'binary':
  5826. return len
  5827. case 'utf8':
  5828. case 'utf-8':
  5829. case undefined:
  5830. return utf8ToBytes(string).length
  5831. case 'ucs2':
  5832. case 'ucs-2':
  5833. case 'utf16le':
  5834. case 'utf-16le':
  5835. return len * 2
  5836. case 'hex':
  5837. return len >>> 1
  5838. case 'base64':
  5839. return base64ToBytes(string).length
  5840. default:
  5841. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5842. encoding = ('' + encoding).toLowerCase()
  5843. loweredCase = true
  5844. }
  5845. }
  5846. }
  5847. Buffer.byteLength = byteLength
  5848. function slowToString (encoding, start, end) {
  5849. var loweredCase = false
  5850. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5851. // property of a typed array.
  5852. // This behaves neither like String nor Uint8Array in that we set start/end
  5853. // to their upper/lower bounds if the value passed is out of range.
  5854. // undefined is handled specially as per ECMA-262 6th Edition,
  5855. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5856. if (start === undefined || start < 0) {
  5857. start = 0
  5858. }
  5859. // Return early if start > this.length. Done here to prevent potential uint32
  5860. // coercion fail below.
  5861. if (start > this.length) {
  5862. return ''
  5863. }
  5864. if (end === undefined || end > this.length) {
  5865. end = this.length
  5866. }
  5867. if (end <= 0) {
  5868. return ''
  5869. }
  5870. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5871. end >>>= 0
  5872. start >>>= 0
  5873. if (end <= start) {
  5874. return ''
  5875. }
  5876. if (!encoding) encoding = 'utf8'
  5877. while (true) {
  5878. switch (encoding) {
  5879. case 'hex':
  5880. return hexSlice(this, start, end)
  5881. case 'utf8':
  5882. case 'utf-8':
  5883. return utf8Slice(this, start, end)
  5884. case 'ascii':
  5885. return asciiSlice(this, start, end)
  5886. case 'latin1':
  5887. case 'binary':
  5888. return latin1Slice(this, start, end)
  5889. case 'base64':
  5890. return base64Slice(this, start, end)
  5891. case 'ucs2':
  5892. case 'ucs-2':
  5893. case 'utf16le':
  5894. case 'utf-16le':
  5895. return utf16leSlice(this, start, end)
  5896. default:
  5897. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5898. encoding = (encoding + '').toLowerCase()
  5899. loweredCase = true
  5900. }
  5901. }
  5902. }
  5903. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5904. // Buffer instances.
  5905. Buffer.prototype._isBuffer = true
  5906. function swap (b, n, m) {
  5907. var i = b[n]
  5908. b[n] = b[m]
  5909. b[m] = i
  5910. }
  5911. Buffer.prototype.swap16 = function swap16 () {
  5912. var len = this.length
  5913. if (len % 2 !== 0) {
  5914. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5915. }
  5916. for (var i = 0; i < len; i += 2) {
  5917. swap(this, i, i + 1)
  5918. }
  5919. return this
  5920. }
  5921. Buffer.prototype.swap32 = function swap32 () {
  5922. var len = this.length
  5923. if (len % 4 !== 0) {
  5924. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5925. }
  5926. for (var i = 0; i < len; i += 4) {
  5927. swap(this, i, i + 3)
  5928. swap(this, i + 1, i + 2)
  5929. }
  5930. return this
  5931. }
  5932. Buffer.prototype.swap64 = function swap64 () {
  5933. var len = this.length
  5934. if (len % 8 !== 0) {
  5935. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5936. }
  5937. for (var i = 0; i < len; i += 8) {
  5938. swap(this, i, i + 7)
  5939. swap(this, i + 1, i + 6)
  5940. swap(this, i + 2, i + 5)
  5941. swap(this, i + 3, i + 4)
  5942. }
  5943. return this
  5944. }
  5945. Buffer.prototype.toString = function toString () {
  5946. var length = this.length | 0
  5947. if (length === 0) return ''
  5948. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5949. return slowToString.apply(this, arguments)
  5950. }
  5951. Buffer.prototype.equals = function equals (b) {
  5952. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5953. if (this === b) return true
  5954. return Buffer.compare(this, b) === 0
  5955. }
  5956. Buffer.prototype.inspect = function inspect () {
  5957. var str = ''
  5958. var max = exports.INSPECT_MAX_BYTES
  5959. if (this.length > 0) {
  5960. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5961. if (this.length > max) str += ' ... '
  5962. }
  5963. return '<Buffer ' + str + '>'
  5964. }
  5965. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  5966. if (!Buffer.isBuffer(target)) {
  5967. throw new TypeError('Argument must be a Buffer')
  5968. }
  5969. if (start === undefined) {
  5970. start = 0
  5971. }
  5972. if (end === undefined) {
  5973. end = target ? target.length : 0
  5974. }
  5975. if (thisStart === undefined) {
  5976. thisStart = 0
  5977. }
  5978. if (thisEnd === undefined) {
  5979. thisEnd = this.length
  5980. }
  5981. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  5982. throw new RangeError('out of range index')
  5983. }
  5984. if (thisStart >= thisEnd && start >= end) {
  5985. return 0
  5986. }
  5987. if (thisStart >= thisEnd) {
  5988. return -1
  5989. }
  5990. if (start >= end) {
  5991. return 1
  5992. }
  5993. start >>>= 0
  5994. end >>>= 0
  5995. thisStart >>>= 0
  5996. thisEnd >>>= 0
  5997. if (this === target) return 0
  5998. var x = thisEnd - thisStart
  5999. var y = end - start
  6000. var len = Math.min(x, y)
  6001. var thisCopy = this.slice(thisStart, thisEnd)
  6002. var targetCopy = target.slice(start, end)
  6003. for (var i = 0; i < len; ++i) {
  6004. if (thisCopy[i] !== targetCopy[i]) {
  6005. x = thisCopy[i]
  6006. y = targetCopy[i]
  6007. break
  6008. }
  6009. }
  6010. if (x < y) return -1
  6011. if (y < x) return 1
  6012. return 0
  6013. }
  6014. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6015. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6016. //
  6017. // Arguments:
  6018. // - buffer - a Buffer to search
  6019. // - val - a string, Buffer, or number
  6020. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6021. // - encoding - an optional encoding, relevant is val is a string
  6022. // - dir - true for indexOf, false for lastIndexOf
  6023. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6024. // Empty buffer means no match
  6025. if (buffer.length === 0) return -1
  6026. // Normalize byteOffset
  6027. if (typeof byteOffset === 'string') {
  6028. encoding = byteOffset
  6029. byteOffset = 0
  6030. } else if (byteOffset > 0x7fffffff) {
  6031. byteOffset = 0x7fffffff
  6032. } else if (byteOffset < -0x80000000) {
  6033. byteOffset = -0x80000000
  6034. }
  6035. byteOffset = +byteOffset // Coerce to Number.
  6036. if (isNaN(byteOffset)) {
  6037. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6038. byteOffset = dir ? 0 : (buffer.length - 1)
  6039. }
  6040. // Normalize byteOffset: negative offsets start from the end of the buffer
  6041. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6042. if (byteOffset >= buffer.length) {
  6043. if (dir) return -1
  6044. else byteOffset = buffer.length - 1
  6045. } else if (byteOffset < 0) {
  6046. if (dir) byteOffset = 0
  6047. else return -1
  6048. }
  6049. // Normalize val
  6050. if (typeof val === 'string') {
  6051. val = Buffer.from(val, encoding)
  6052. }
  6053. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6054. if (Buffer.isBuffer(val)) {
  6055. // Special case: looking for empty string/buffer always fails
  6056. if (val.length === 0) {
  6057. return -1
  6058. }
  6059. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6060. } else if (typeof val === 'number') {
  6061. val = val & 0xFF // Search for a byte value [0-255]
  6062. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6063. typeof Uint8Array.prototype.indexOf === 'function') {
  6064. if (dir) {
  6065. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6066. } else {
  6067. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6068. }
  6069. }
  6070. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6071. }
  6072. throw new TypeError('val must be string, number or Buffer')
  6073. }
  6074. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6075. var indexSize = 1
  6076. var arrLength = arr.length
  6077. var valLength = val.length
  6078. if (encoding !== undefined) {
  6079. encoding = String(encoding).toLowerCase()
  6080. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6081. encoding === 'utf16le' || encoding === 'utf-16le') {
  6082. if (arr.length < 2 || val.length < 2) {
  6083. return -1
  6084. }
  6085. indexSize = 2
  6086. arrLength /= 2
  6087. valLength /= 2
  6088. byteOffset /= 2
  6089. }
  6090. }
  6091. function read (buf, i) {
  6092. if (indexSize === 1) {
  6093. return buf[i]
  6094. } else {
  6095. return buf.readUInt16BE(i * indexSize)
  6096. }
  6097. }
  6098. var i
  6099. if (dir) {
  6100. var foundIndex = -1
  6101. for (i = byteOffset; i < arrLength; i++) {
  6102. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6103. if (foundIndex === -1) foundIndex = i
  6104. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6105. } else {
  6106. if (foundIndex !== -1) i -= i - foundIndex
  6107. foundIndex = -1
  6108. }
  6109. }
  6110. } else {
  6111. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6112. for (i = byteOffset; i >= 0; i--) {
  6113. var found = true
  6114. for (var j = 0; j < valLength; j++) {
  6115. if (read(arr, i + j) !== read(val, j)) {
  6116. found = false
  6117. break
  6118. }
  6119. }
  6120. if (found) return i
  6121. }
  6122. }
  6123. return -1
  6124. }
  6125. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6126. return this.indexOf(val, byteOffset, encoding) !== -1
  6127. }
  6128. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6129. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6130. }
  6131. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6132. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6133. }
  6134. function hexWrite (buf, string, offset, length) {
  6135. offset = Number(offset) || 0
  6136. var remaining = buf.length - offset
  6137. if (!length) {
  6138. length = remaining
  6139. } else {
  6140. length = Number(length)
  6141. if (length > remaining) {
  6142. length = remaining
  6143. }
  6144. }
  6145. // must be an even number of digits
  6146. var strLen = string.length
  6147. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6148. if (length > strLen / 2) {
  6149. length = strLen / 2
  6150. }
  6151. for (var i = 0; i < length; ++i) {
  6152. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6153. if (isNaN(parsed)) return i
  6154. buf[offset + i] = parsed
  6155. }
  6156. return i
  6157. }
  6158. function utf8Write (buf, string, offset, length) {
  6159. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6160. }
  6161. function asciiWrite (buf, string, offset, length) {
  6162. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6163. }
  6164. function latin1Write (buf, string, offset, length) {
  6165. return asciiWrite(buf, string, offset, length)
  6166. }
  6167. function base64Write (buf, string, offset, length) {
  6168. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6169. }
  6170. function ucs2Write (buf, string, offset, length) {
  6171. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6172. }
  6173. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6174. // Buffer#write(string)
  6175. if (offset === undefined) {
  6176. encoding = 'utf8'
  6177. length = this.length
  6178. offset = 0
  6179. // Buffer#write(string, encoding)
  6180. } else if (length === undefined && typeof offset === 'string') {
  6181. encoding = offset
  6182. length = this.length
  6183. offset = 0
  6184. // Buffer#write(string, offset[, length][, encoding])
  6185. } else if (isFinite(offset)) {
  6186. offset = offset | 0
  6187. if (isFinite(length)) {
  6188. length = length | 0
  6189. if (encoding === undefined) encoding = 'utf8'
  6190. } else {
  6191. encoding = length
  6192. length = undefined
  6193. }
  6194. // legacy write(string, encoding, offset, length) - remove in v0.13
  6195. } else {
  6196. throw new Error(
  6197. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6198. )
  6199. }
  6200. var remaining = this.length - offset
  6201. if (length === undefined || length > remaining) length = remaining
  6202. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6203. throw new RangeError('Attempt to write outside buffer bounds')
  6204. }
  6205. if (!encoding) encoding = 'utf8'
  6206. var loweredCase = false
  6207. for (;;) {
  6208. switch (encoding) {
  6209. case 'hex':
  6210. return hexWrite(this, string, offset, length)
  6211. case 'utf8':
  6212. case 'utf-8':
  6213. return utf8Write(this, string, offset, length)
  6214. case 'ascii':
  6215. return asciiWrite(this, string, offset, length)
  6216. case 'latin1':
  6217. case 'binary':
  6218. return latin1Write(this, string, offset, length)
  6219. case 'base64':
  6220. // Warning: maxLength not taken into account in base64Write
  6221. return base64Write(this, string, offset, length)
  6222. case 'ucs2':
  6223. case 'ucs-2':
  6224. case 'utf16le':
  6225. case 'utf-16le':
  6226. return ucs2Write(this, string, offset, length)
  6227. default:
  6228. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6229. encoding = ('' + encoding).toLowerCase()
  6230. loweredCase = true
  6231. }
  6232. }
  6233. }
  6234. Buffer.prototype.toJSON = function toJSON () {
  6235. return {
  6236. type: 'Buffer',
  6237. data: Array.prototype.slice.call(this._arr || this, 0)
  6238. }
  6239. }
  6240. function base64Slice (buf, start, end) {
  6241. if (start === 0 && end === buf.length) {
  6242. return base64.fromByteArray(buf)
  6243. } else {
  6244. return base64.fromByteArray(buf.slice(start, end))
  6245. }
  6246. }
  6247. function utf8Slice (buf, start, end) {
  6248. end = Math.min(buf.length, end)
  6249. var res = []
  6250. var i = start
  6251. while (i < end) {
  6252. var firstByte = buf[i]
  6253. var codePoint = null
  6254. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6255. : (firstByte > 0xDF) ? 3
  6256. : (firstByte > 0xBF) ? 2
  6257. : 1
  6258. if (i + bytesPerSequence <= end) {
  6259. var secondByte, thirdByte, fourthByte, tempCodePoint
  6260. switch (bytesPerSequence) {
  6261. case 1:
  6262. if (firstByte < 0x80) {
  6263. codePoint = firstByte
  6264. }
  6265. break
  6266. case 2:
  6267. secondByte = buf[i + 1]
  6268. if ((secondByte & 0xC0) === 0x80) {
  6269. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6270. if (tempCodePoint > 0x7F) {
  6271. codePoint = tempCodePoint
  6272. }
  6273. }
  6274. break
  6275. case 3:
  6276. secondByte = buf[i + 1]
  6277. thirdByte = buf[i + 2]
  6278. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6279. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6280. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6281. codePoint = tempCodePoint
  6282. }
  6283. }
  6284. break
  6285. case 4:
  6286. secondByte = buf[i + 1]
  6287. thirdByte = buf[i + 2]
  6288. fourthByte = buf[i + 3]
  6289. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6290. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6291. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6292. codePoint = tempCodePoint
  6293. }
  6294. }
  6295. }
  6296. }
  6297. if (codePoint === null) {
  6298. // we did not generate a valid codePoint so insert a
  6299. // replacement char (U+FFFD) and advance only 1 byte
  6300. codePoint = 0xFFFD
  6301. bytesPerSequence = 1
  6302. } else if (codePoint > 0xFFFF) {
  6303. // encode to utf16 (surrogate pair dance)
  6304. codePoint -= 0x10000
  6305. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6306. codePoint = 0xDC00 | codePoint & 0x3FF
  6307. }
  6308. res.push(codePoint)
  6309. i += bytesPerSequence
  6310. }
  6311. return decodeCodePointsArray(res)
  6312. }
  6313. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6314. // the lowest limit is Chrome, with 0x10000 args.
  6315. // We go 1 magnitude less, for safety
  6316. var MAX_ARGUMENTS_LENGTH = 0x1000
  6317. function decodeCodePointsArray (codePoints) {
  6318. var len = codePoints.length
  6319. if (len <= MAX_ARGUMENTS_LENGTH) {
  6320. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6321. }
  6322. // Decode in chunks to avoid "call stack size exceeded".
  6323. var res = ''
  6324. var i = 0
  6325. while (i < len) {
  6326. res += String.fromCharCode.apply(
  6327. String,
  6328. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6329. )
  6330. }
  6331. return res
  6332. }
  6333. function asciiSlice (buf, start, end) {
  6334. var ret = ''
  6335. end = Math.min(buf.length, end)
  6336. for (var i = start; i < end; ++i) {
  6337. ret += String.fromCharCode(buf[i] & 0x7F)
  6338. }
  6339. return ret
  6340. }
  6341. function latin1Slice (buf, start, end) {
  6342. var ret = ''
  6343. end = Math.min(buf.length, end)
  6344. for (var i = start; i < end; ++i) {
  6345. ret += String.fromCharCode(buf[i])
  6346. }
  6347. return ret
  6348. }
  6349. function hexSlice (buf, start, end) {
  6350. var len = buf.length
  6351. if (!start || start < 0) start = 0
  6352. if (!end || end < 0 || end > len) end = len
  6353. var out = ''
  6354. for (var i = start; i < end; ++i) {
  6355. out += toHex(buf[i])
  6356. }
  6357. return out
  6358. }
  6359. function utf16leSlice (buf, start, end) {
  6360. var bytes = buf.slice(start, end)
  6361. var res = ''
  6362. for (var i = 0; i < bytes.length; i += 2) {
  6363. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6364. }
  6365. return res
  6366. }
  6367. Buffer.prototype.slice = function slice (start, end) {
  6368. var len = this.length
  6369. start = ~~start
  6370. end = end === undefined ? len : ~~end
  6371. if (start < 0) {
  6372. start += len
  6373. if (start < 0) start = 0
  6374. } else if (start > len) {
  6375. start = len
  6376. }
  6377. if (end < 0) {
  6378. end += len
  6379. if (end < 0) end = 0
  6380. } else if (end > len) {
  6381. end = len
  6382. }
  6383. if (end < start) end = start
  6384. var newBuf
  6385. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6386. newBuf = this.subarray(start, end)
  6387. newBuf.__proto__ = Buffer.prototype
  6388. } else {
  6389. var sliceLen = end - start
  6390. newBuf = new Buffer(sliceLen, undefined)
  6391. for (var i = 0; i < sliceLen; ++i) {
  6392. newBuf[i] = this[i + start]
  6393. }
  6394. }
  6395. return newBuf
  6396. }
  6397. /*
  6398. * Need to make sure that buffer isn't trying to write out of bounds.
  6399. */
  6400. function checkOffset (offset, ext, length) {
  6401. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6402. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6403. }
  6404. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6405. offset = offset | 0
  6406. byteLength = byteLength | 0
  6407. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6408. var val = this[offset]
  6409. var mul = 1
  6410. var i = 0
  6411. while (++i < byteLength && (mul *= 0x100)) {
  6412. val += this[offset + i] * mul
  6413. }
  6414. return val
  6415. }
  6416. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6417. offset = offset | 0
  6418. byteLength = byteLength | 0
  6419. if (!noAssert) {
  6420. checkOffset(offset, byteLength, this.length)
  6421. }
  6422. var val = this[offset + --byteLength]
  6423. var mul = 1
  6424. while (byteLength > 0 && (mul *= 0x100)) {
  6425. val += this[offset + --byteLength] * mul
  6426. }
  6427. return val
  6428. }
  6429. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6430. if (!noAssert) checkOffset(offset, 1, this.length)
  6431. return this[offset]
  6432. }
  6433. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6434. if (!noAssert) checkOffset(offset, 2, this.length)
  6435. return this[offset] | (this[offset + 1] << 8)
  6436. }
  6437. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6438. if (!noAssert) checkOffset(offset, 2, this.length)
  6439. return (this[offset] << 8) | this[offset + 1]
  6440. }
  6441. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6442. if (!noAssert) checkOffset(offset, 4, this.length)
  6443. return ((this[offset]) |
  6444. (this[offset + 1] << 8) |
  6445. (this[offset + 2] << 16)) +
  6446. (this[offset + 3] * 0x1000000)
  6447. }
  6448. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6449. if (!noAssert) checkOffset(offset, 4, this.length)
  6450. return (this[offset] * 0x1000000) +
  6451. ((this[offset + 1] << 16) |
  6452. (this[offset + 2] << 8) |
  6453. this[offset + 3])
  6454. }
  6455. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6456. offset = offset | 0
  6457. byteLength = byteLength | 0
  6458. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6459. var val = this[offset]
  6460. var mul = 1
  6461. var i = 0
  6462. while (++i < byteLength && (mul *= 0x100)) {
  6463. val += this[offset + i] * mul
  6464. }
  6465. mul *= 0x80
  6466. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6467. return val
  6468. }
  6469. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6470. offset = offset | 0
  6471. byteLength = byteLength | 0
  6472. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6473. var i = byteLength
  6474. var mul = 1
  6475. var val = this[offset + --i]
  6476. while (i > 0 && (mul *= 0x100)) {
  6477. val += this[offset + --i] * mul
  6478. }
  6479. mul *= 0x80
  6480. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6481. return val
  6482. }
  6483. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6484. if (!noAssert) checkOffset(offset, 1, this.length)
  6485. if (!(this[offset] & 0x80)) return (this[offset])
  6486. return ((0xff - this[offset] + 1) * -1)
  6487. }
  6488. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6489. if (!noAssert) checkOffset(offset, 2, this.length)
  6490. var val = this[offset] | (this[offset + 1] << 8)
  6491. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6492. }
  6493. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6494. if (!noAssert) checkOffset(offset, 2, this.length)
  6495. var val = this[offset + 1] | (this[offset] << 8)
  6496. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6497. }
  6498. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6499. if (!noAssert) checkOffset(offset, 4, this.length)
  6500. return (this[offset]) |
  6501. (this[offset + 1] << 8) |
  6502. (this[offset + 2] << 16) |
  6503. (this[offset + 3] << 24)
  6504. }
  6505. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6506. if (!noAssert) checkOffset(offset, 4, this.length)
  6507. return (this[offset] << 24) |
  6508. (this[offset + 1] << 16) |
  6509. (this[offset + 2] << 8) |
  6510. (this[offset + 3])
  6511. }
  6512. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6513. if (!noAssert) checkOffset(offset, 4, this.length)
  6514. return ieee754.read(this, offset, true, 23, 4)
  6515. }
  6516. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6517. if (!noAssert) checkOffset(offset, 4, this.length)
  6518. return ieee754.read(this, offset, false, 23, 4)
  6519. }
  6520. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6521. if (!noAssert) checkOffset(offset, 8, this.length)
  6522. return ieee754.read(this, offset, true, 52, 8)
  6523. }
  6524. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6525. if (!noAssert) checkOffset(offset, 8, this.length)
  6526. return ieee754.read(this, offset, false, 52, 8)
  6527. }
  6528. function checkInt (buf, value, offset, ext, max, min) {
  6529. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6530. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6531. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6532. }
  6533. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6534. value = +value
  6535. offset = offset | 0
  6536. byteLength = byteLength | 0
  6537. if (!noAssert) {
  6538. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6539. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6540. }
  6541. var mul = 1
  6542. var i = 0
  6543. this[offset] = value & 0xFF
  6544. while (++i < byteLength && (mul *= 0x100)) {
  6545. this[offset + i] = (value / mul) & 0xFF
  6546. }
  6547. return offset + byteLength
  6548. }
  6549. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6550. value = +value
  6551. offset = offset | 0
  6552. byteLength = byteLength | 0
  6553. if (!noAssert) {
  6554. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6555. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6556. }
  6557. var i = byteLength - 1
  6558. var mul = 1
  6559. this[offset + i] = value & 0xFF
  6560. while (--i >= 0 && (mul *= 0x100)) {
  6561. this[offset + i] = (value / mul) & 0xFF
  6562. }
  6563. return offset + byteLength
  6564. }
  6565. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6566. value = +value
  6567. offset = offset | 0
  6568. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6569. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6570. this[offset] = (value & 0xff)
  6571. return offset + 1
  6572. }
  6573. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6574. if (value < 0) value = 0xffff + value + 1
  6575. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6576. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6577. (littleEndian ? i : 1 - i) * 8
  6578. }
  6579. }
  6580. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6581. value = +value
  6582. offset = offset | 0
  6583. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6584. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6585. this[offset] = (value & 0xff)
  6586. this[offset + 1] = (value >>> 8)
  6587. } else {
  6588. objectWriteUInt16(this, value, offset, true)
  6589. }
  6590. return offset + 2
  6591. }
  6592. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6593. value = +value
  6594. offset = offset | 0
  6595. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6596. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6597. this[offset] = (value >>> 8)
  6598. this[offset + 1] = (value & 0xff)
  6599. } else {
  6600. objectWriteUInt16(this, value, offset, false)
  6601. }
  6602. return offset + 2
  6603. }
  6604. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6605. if (value < 0) value = 0xffffffff + value + 1
  6606. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6607. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6608. }
  6609. }
  6610. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6611. value = +value
  6612. offset = offset | 0
  6613. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6614. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6615. this[offset + 3] = (value >>> 24)
  6616. this[offset + 2] = (value >>> 16)
  6617. this[offset + 1] = (value >>> 8)
  6618. this[offset] = (value & 0xff)
  6619. } else {
  6620. objectWriteUInt32(this, value, offset, true)
  6621. }
  6622. return offset + 4
  6623. }
  6624. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6625. value = +value
  6626. offset = offset | 0
  6627. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6628. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6629. this[offset] = (value >>> 24)
  6630. this[offset + 1] = (value >>> 16)
  6631. this[offset + 2] = (value >>> 8)
  6632. this[offset + 3] = (value & 0xff)
  6633. } else {
  6634. objectWriteUInt32(this, value, offset, false)
  6635. }
  6636. return offset + 4
  6637. }
  6638. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6639. value = +value
  6640. offset = offset | 0
  6641. if (!noAssert) {
  6642. var limit = Math.pow(2, 8 * byteLength - 1)
  6643. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6644. }
  6645. var i = 0
  6646. var mul = 1
  6647. var sub = 0
  6648. this[offset] = value & 0xFF
  6649. while (++i < byteLength && (mul *= 0x100)) {
  6650. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6651. sub = 1
  6652. }
  6653. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6654. }
  6655. return offset + byteLength
  6656. }
  6657. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6658. value = +value
  6659. offset = offset | 0
  6660. if (!noAssert) {
  6661. var limit = Math.pow(2, 8 * byteLength - 1)
  6662. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6663. }
  6664. var i = byteLength - 1
  6665. var mul = 1
  6666. var sub = 0
  6667. this[offset + i] = value & 0xFF
  6668. while (--i >= 0 && (mul *= 0x100)) {
  6669. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6670. sub = 1
  6671. }
  6672. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6673. }
  6674. return offset + byteLength
  6675. }
  6676. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6677. value = +value
  6678. offset = offset | 0
  6679. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6680. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6681. if (value < 0) value = 0xff + value + 1
  6682. this[offset] = (value & 0xff)
  6683. return offset + 1
  6684. }
  6685. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6686. value = +value
  6687. offset = offset | 0
  6688. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6689. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6690. this[offset] = (value & 0xff)
  6691. this[offset + 1] = (value >>> 8)
  6692. } else {
  6693. objectWriteUInt16(this, value, offset, true)
  6694. }
  6695. return offset + 2
  6696. }
  6697. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6698. value = +value
  6699. offset = offset | 0
  6700. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6701. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6702. this[offset] = (value >>> 8)
  6703. this[offset + 1] = (value & 0xff)
  6704. } else {
  6705. objectWriteUInt16(this, value, offset, false)
  6706. }
  6707. return offset + 2
  6708. }
  6709. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6710. value = +value
  6711. offset = offset | 0
  6712. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6713. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6714. this[offset] = (value & 0xff)
  6715. this[offset + 1] = (value >>> 8)
  6716. this[offset + 2] = (value >>> 16)
  6717. this[offset + 3] = (value >>> 24)
  6718. } else {
  6719. objectWriteUInt32(this, value, offset, true)
  6720. }
  6721. return offset + 4
  6722. }
  6723. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6724. value = +value
  6725. offset = offset | 0
  6726. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6727. if (value < 0) value = 0xffffffff + value + 1
  6728. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6729. this[offset] = (value >>> 24)
  6730. this[offset + 1] = (value >>> 16)
  6731. this[offset + 2] = (value >>> 8)
  6732. this[offset + 3] = (value & 0xff)
  6733. } else {
  6734. objectWriteUInt32(this, value, offset, false)
  6735. }
  6736. return offset + 4
  6737. }
  6738. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6739. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6740. if (offset < 0) throw new RangeError('Index out of range')
  6741. }
  6742. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6743. if (!noAssert) {
  6744. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6745. }
  6746. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6747. return offset + 4
  6748. }
  6749. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6750. return writeFloat(this, value, offset, true, noAssert)
  6751. }
  6752. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6753. return writeFloat(this, value, offset, false, noAssert)
  6754. }
  6755. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6756. if (!noAssert) {
  6757. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6758. }
  6759. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6760. return offset + 8
  6761. }
  6762. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6763. return writeDouble(this, value, offset, true, noAssert)
  6764. }
  6765. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6766. return writeDouble(this, value, offset, false, noAssert)
  6767. }
  6768. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6769. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6770. if (!start) start = 0
  6771. if (!end && end !== 0) end = this.length
  6772. if (targetStart >= target.length) targetStart = target.length
  6773. if (!targetStart) targetStart = 0
  6774. if (end > 0 && end < start) end = start
  6775. // Copy 0 bytes; we're done
  6776. if (end === start) return 0
  6777. if (target.length === 0 || this.length === 0) return 0
  6778. // Fatal error conditions
  6779. if (targetStart < 0) {
  6780. throw new RangeError('targetStart out of bounds')
  6781. }
  6782. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6783. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6784. // Are we oob?
  6785. if (end > this.length) end = this.length
  6786. if (target.length - targetStart < end - start) {
  6787. end = target.length - targetStart + start
  6788. }
  6789. var len = end - start
  6790. var i
  6791. if (this === target && start < targetStart && targetStart < end) {
  6792. // descending copy from end
  6793. for (i = len - 1; i >= 0; --i) {
  6794. target[i + targetStart] = this[i + start]
  6795. }
  6796. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6797. // ascending copy from start
  6798. for (i = 0; i < len; ++i) {
  6799. target[i + targetStart] = this[i + start]
  6800. }
  6801. } else {
  6802. Uint8Array.prototype.set.call(
  6803. target,
  6804. this.subarray(start, start + len),
  6805. targetStart
  6806. )
  6807. }
  6808. return len
  6809. }
  6810. // Usage:
  6811. // buffer.fill(number[, offset[, end]])
  6812. // buffer.fill(buffer[, offset[, end]])
  6813. // buffer.fill(string[, offset[, end]][, encoding])
  6814. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6815. // Handle string cases:
  6816. if (typeof val === 'string') {
  6817. if (typeof start === 'string') {
  6818. encoding = start
  6819. start = 0
  6820. end = this.length
  6821. } else if (typeof end === 'string') {
  6822. encoding = end
  6823. end = this.length
  6824. }
  6825. if (val.length === 1) {
  6826. var code = val.charCodeAt(0)
  6827. if (code < 256) {
  6828. val = code
  6829. }
  6830. }
  6831. if (encoding !== undefined && typeof encoding !== 'string') {
  6832. throw new TypeError('encoding must be a string')
  6833. }
  6834. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6835. throw new TypeError('Unknown encoding: ' + encoding)
  6836. }
  6837. } else if (typeof val === 'number') {
  6838. val = val & 255
  6839. }
  6840. // Invalid ranges are not set to a default, so can range check early.
  6841. if (start < 0 || this.length < start || this.length < end) {
  6842. throw new RangeError('Out of range index')
  6843. }
  6844. if (end <= start) {
  6845. return this
  6846. }
  6847. start = start >>> 0
  6848. end = end === undefined ? this.length : end >>> 0
  6849. if (!val) val = 0
  6850. var i
  6851. if (typeof val === 'number') {
  6852. for (i = start; i < end; ++i) {
  6853. this[i] = val
  6854. }
  6855. } else {
  6856. var bytes = Buffer.isBuffer(val)
  6857. ? val
  6858. : utf8ToBytes(new Buffer(val, encoding).toString())
  6859. var len = bytes.length
  6860. for (i = 0; i < end - start; ++i) {
  6861. this[i + start] = bytes[i % len]
  6862. }
  6863. }
  6864. return this
  6865. }
  6866. // HELPER FUNCTIONS
  6867. // ================
  6868. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6869. function base64clean (str) {
  6870. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6871. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6872. // Node converts strings with length < 2 to ''
  6873. if (str.length < 2) return ''
  6874. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6875. while (str.length % 4 !== 0) {
  6876. str = str + '='
  6877. }
  6878. return str
  6879. }
  6880. function stringtrim (str) {
  6881. if (str.trim) return str.trim()
  6882. return str.replace(/^\s+|\s+$/g, '')
  6883. }
  6884. function toHex (n) {
  6885. if (n < 16) return '0' + n.toString(16)
  6886. return n.toString(16)
  6887. }
  6888. function utf8ToBytes (string, units) {
  6889. units = units || Infinity
  6890. var codePoint
  6891. var length = string.length
  6892. var leadSurrogate = null
  6893. var bytes = []
  6894. for (var i = 0; i < length; ++i) {
  6895. codePoint = string.charCodeAt(i)
  6896. // is surrogate component
  6897. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6898. // last char was a lead
  6899. if (!leadSurrogate) {
  6900. // no lead yet
  6901. if (codePoint > 0xDBFF) {
  6902. // unexpected trail
  6903. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6904. continue
  6905. } else if (i + 1 === length) {
  6906. // unpaired lead
  6907. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6908. continue
  6909. }
  6910. // valid lead
  6911. leadSurrogate = codePoint
  6912. continue
  6913. }
  6914. // 2 leads in a row
  6915. if (codePoint < 0xDC00) {
  6916. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6917. leadSurrogate = codePoint
  6918. continue
  6919. }
  6920. // valid surrogate pair
  6921. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6922. } else if (leadSurrogate) {
  6923. // valid bmp char, but last char was a lead
  6924. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6925. }
  6926. leadSurrogate = null
  6927. // encode utf8
  6928. if (codePoint < 0x80) {
  6929. if ((units -= 1) < 0) break
  6930. bytes.push(codePoint)
  6931. } else if (codePoint < 0x800) {
  6932. if ((units -= 2) < 0) break
  6933. bytes.push(
  6934. codePoint >> 0x6 | 0xC0,
  6935. codePoint & 0x3F | 0x80
  6936. )
  6937. } else if (codePoint < 0x10000) {
  6938. if ((units -= 3) < 0) break
  6939. bytes.push(
  6940. codePoint >> 0xC | 0xE0,
  6941. codePoint >> 0x6 & 0x3F | 0x80,
  6942. codePoint & 0x3F | 0x80
  6943. )
  6944. } else if (codePoint < 0x110000) {
  6945. if ((units -= 4) < 0) break
  6946. bytes.push(
  6947. codePoint >> 0x12 | 0xF0,
  6948. codePoint >> 0xC & 0x3F | 0x80,
  6949. codePoint >> 0x6 & 0x3F | 0x80,
  6950. codePoint & 0x3F | 0x80
  6951. )
  6952. } else {
  6953. throw new Error('Invalid code point')
  6954. }
  6955. }
  6956. return bytes
  6957. }
  6958. function asciiToBytes (str) {
  6959. var byteArray = []
  6960. for (var i = 0; i < str.length; ++i) {
  6961. // Node's code seems to be doing this and not & 0x7F..
  6962. byteArray.push(str.charCodeAt(i) & 0xFF)
  6963. }
  6964. return byteArray
  6965. }
  6966. function utf16leToBytes (str, units) {
  6967. var c, hi, lo
  6968. var byteArray = []
  6969. for (var i = 0; i < str.length; ++i) {
  6970. if ((units -= 2) < 0) break
  6971. c = str.charCodeAt(i)
  6972. hi = c >> 8
  6973. lo = c % 256
  6974. byteArray.push(lo)
  6975. byteArray.push(hi)
  6976. }
  6977. return byteArray
  6978. }
  6979. function base64ToBytes (str) {
  6980. return base64.toByteArray(base64clean(str))
  6981. }
  6982. function blitBuffer (src, dst, offset, length) {
  6983. for (var i = 0; i < length; ++i) {
  6984. if ((i + offset >= dst.length) || (i >= src.length)) break
  6985. dst[i + offset] = src[i]
  6986. }
  6987. return i
  6988. }
  6989. function isnan (val) {
  6990. return val !== val // eslint-disable-line no-self-compare
  6991. }
  6992. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  6993. /***/ }),
  6994. /***/ "./node_modules/ieee754/index.js":
  6995. /*!***************************************!*\
  6996. !*** ./node_modules/ieee754/index.js ***!
  6997. \***************************************/
  6998. /*! no static exports found */
  6999. /***/ (function(module, exports) {
  7000. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7001. var e, m
  7002. var eLen = (nBytes * 8) - mLen - 1
  7003. var eMax = (1 << eLen) - 1
  7004. var eBias = eMax >> 1
  7005. var nBits = -7
  7006. var i = isLE ? (nBytes - 1) : 0
  7007. var d = isLE ? -1 : 1
  7008. var s = buffer[offset + i]
  7009. i += d
  7010. e = s & ((1 << (-nBits)) - 1)
  7011. s >>= (-nBits)
  7012. nBits += eLen
  7013. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7014. m = e & ((1 << (-nBits)) - 1)
  7015. e >>= (-nBits)
  7016. nBits += mLen
  7017. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7018. if (e === 0) {
  7019. e = 1 - eBias
  7020. } else if (e === eMax) {
  7021. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7022. } else {
  7023. m = m + Math.pow(2, mLen)
  7024. e = e - eBias
  7025. }
  7026. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7027. }
  7028. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7029. var e, m, c
  7030. var eLen = (nBytes * 8) - mLen - 1
  7031. var eMax = (1 << eLen) - 1
  7032. var eBias = eMax >> 1
  7033. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7034. var i = isLE ? 0 : (nBytes - 1)
  7035. var d = isLE ? 1 : -1
  7036. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7037. value = Math.abs(value)
  7038. if (isNaN(value) || value === Infinity) {
  7039. m = isNaN(value) ? 1 : 0
  7040. e = eMax
  7041. } else {
  7042. e = Math.floor(Math.log(value) / Math.LN2)
  7043. if (value * (c = Math.pow(2, -e)) < 1) {
  7044. e--
  7045. c *= 2
  7046. }
  7047. if (e + eBias >= 1) {
  7048. value += rt / c
  7049. } else {
  7050. value += rt * Math.pow(2, 1 - eBias)
  7051. }
  7052. if (value * c >= 2) {
  7053. e++
  7054. c /= 2
  7055. }
  7056. if (e + eBias >= eMax) {
  7057. m = 0
  7058. e = eMax
  7059. } else if (e + eBias >= 1) {
  7060. m = ((value * c) - 1) * Math.pow(2, mLen)
  7061. e = e + eBias
  7062. } else {
  7063. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7064. e = 0
  7065. }
  7066. }
  7067. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7068. e = (e << mLen) | m
  7069. eLen += mLen
  7070. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7071. buffer[offset + i - d] |= s * 128
  7072. }
  7073. /***/ }),
  7074. /***/ "./node_modules/isarray/index.js":
  7075. /*!***************************************!*\
  7076. !*** ./node_modules/isarray/index.js ***!
  7077. \***************************************/
  7078. /*! no static exports found */
  7079. /***/ (function(module, exports) {
  7080. var toString = {}.toString;
  7081. module.exports = Array.isArray || function (arr) {
  7082. return toString.call(arr) == '[object Array]';
  7083. };
  7084. /***/ }),
  7085. /***/ "./node_modules/jquery/dist/jquery.js":
  7086. /*!********************************************!*\
  7087. !*** ./node_modules/jquery/dist/jquery.js ***!
  7088. \********************************************/
  7089. /*! no static exports found */
  7090. /***/ (function(module, exports, __webpack_require__) {
  7091. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7092. * jQuery JavaScript Library v3.4.1
  7093. * https://jquery.com/
  7094. *
  7095. * Includes Sizzle.js
  7096. * https://sizzlejs.com/
  7097. *
  7098. * Copyright JS Foundation and other contributors
  7099. * Released under the MIT license
  7100. * https://jquery.org/license
  7101. *
  7102. * Date: 2019-05-01T21:04Z
  7103. */
  7104. ( function( global, factory ) {
  7105. "use strict";
  7106. if ( true && typeof module.exports === "object" ) {
  7107. // For CommonJS and CommonJS-like environments where a proper `window`
  7108. // is present, execute the factory and get jQuery.
  7109. // For environments that do not have a `window` with a `document`
  7110. // (such as Node.js), expose a factory as module.exports.
  7111. // This accentuates the need for the creation of a real `window`.
  7112. // e.g. var jQuery = require("jquery")(window);
  7113. // See ticket #14549 for more info.
  7114. module.exports = global.document ?
  7115. factory( global, true ) :
  7116. function( w ) {
  7117. if ( !w.document ) {
  7118. throw new Error( "jQuery requires a window with a document" );
  7119. }
  7120. return factory( w );
  7121. };
  7122. } else {
  7123. factory( global );
  7124. }
  7125. // Pass this if window is not defined yet
  7126. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7127. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7128. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7129. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7130. // enough that all such attempts are guarded in a try block.
  7131. "use strict";
  7132. var arr = [];
  7133. var document = window.document;
  7134. var getProto = Object.getPrototypeOf;
  7135. var slice = arr.slice;
  7136. var concat = arr.concat;
  7137. var push = arr.push;
  7138. var indexOf = arr.indexOf;
  7139. var class2type = {};
  7140. var toString = class2type.toString;
  7141. var hasOwn = class2type.hasOwnProperty;
  7142. var fnToString = hasOwn.toString;
  7143. var ObjectFunctionString = fnToString.call( Object );
  7144. var support = {};
  7145. var isFunction = function isFunction( obj ) {
  7146. // Support: Chrome <=57, Firefox <=52
  7147. // In some browsers, typeof returns "function" for HTML <object> elements
  7148. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7149. // We don't want to classify *any* DOM node as a function.
  7150. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7151. };
  7152. var isWindow = function isWindow( obj ) {
  7153. return obj != null && obj === obj.window;
  7154. };
  7155. var preservedScriptAttributes = {
  7156. type: true,
  7157. src: true,
  7158. nonce: true,
  7159. noModule: true
  7160. };
  7161. function DOMEval( code, node, doc ) {
  7162. doc = doc || document;
  7163. var i, val,
  7164. script = doc.createElement( "script" );
  7165. script.text = code;
  7166. if ( node ) {
  7167. for ( i in preservedScriptAttributes ) {
  7168. // Support: Firefox 64+, Edge 18+
  7169. // Some browsers don't support the "nonce" property on scripts.
  7170. // On the other hand, just using `getAttribute` is not enough as
  7171. // the `nonce` attribute is reset to an empty string whenever it
  7172. // becomes browsing-context connected.
  7173. // See https://github.com/whatwg/html/issues/2369
  7174. // See https://html.spec.whatwg.org/#nonce-attributes
  7175. // The `node.getAttribute` check was added for the sake of
  7176. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7177. // via an object.
  7178. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7179. if ( val ) {
  7180. script.setAttribute( i, val );
  7181. }
  7182. }
  7183. }
  7184. doc.head.appendChild( script ).parentNode.removeChild( script );
  7185. }
  7186. function toType( obj ) {
  7187. if ( obj == null ) {
  7188. return obj + "";
  7189. }
  7190. // Support: Android <=2.3 only (functionish RegExp)
  7191. return typeof obj === "object" || typeof obj === "function" ?
  7192. class2type[ toString.call( obj ) ] || "object" :
  7193. typeof obj;
  7194. }
  7195. /* global Symbol */
  7196. // Defining this global in .eslintrc.json would create a danger of using the global
  7197. // unguarded in another place, it seems safer to define global only for this module
  7198. var
  7199. version = "3.4.1",
  7200. // Define a local copy of jQuery
  7201. jQuery = function( selector, context ) {
  7202. // The jQuery object is actually just the init constructor 'enhanced'
  7203. // Need init if jQuery is called (just allow error to be thrown if not included)
  7204. return new jQuery.fn.init( selector, context );
  7205. },
  7206. // Support: Android <=4.0 only
  7207. // Make sure we trim BOM and NBSP
  7208. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7209. jQuery.fn = jQuery.prototype = {
  7210. // The current version of jQuery being used
  7211. jquery: version,
  7212. constructor: jQuery,
  7213. // The default length of a jQuery object is 0
  7214. length: 0,
  7215. toArray: function() {
  7216. return slice.call( this );
  7217. },
  7218. // Get the Nth element in the matched element set OR
  7219. // Get the whole matched element set as a clean array
  7220. get: function( num ) {
  7221. // Return all the elements in a clean array
  7222. if ( num == null ) {
  7223. return slice.call( this );
  7224. }
  7225. // Return just the one element from the set
  7226. return num < 0 ? this[ num + this.length ] : this[ num ];
  7227. },
  7228. // Take an array of elements and push it onto the stack
  7229. // (returning the new matched element set)
  7230. pushStack: function( elems ) {
  7231. // Build a new jQuery matched element set
  7232. var ret = jQuery.merge( this.constructor(), elems );
  7233. // Add the old object onto the stack (as a reference)
  7234. ret.prevObject = this;
  7235. // Return the newly-formed element set
  7236. return ret;
  7237. },
  7238. // Execute a callback for every element in the matched set.
  7239. each: function( callback ) {
  7240. return jQuery.each( this, callback );
  7241. },
  7242. map: function( callback ) {
  7243. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7244. return callback.call( elem, i, elem );
  7245. } ) );
  7246. },
  7247. slice: function() {
  7248. return this.pushStack( slice.apply( this, arguments ) );
  7249. },
  7250. first: function() {
  7251. return this.eq( 0 );
  7252. },
  7253. last: function() {
  7254. return this.eq( -1 );
  7255. },
  7256. eq: function( i ) {
  7257. var len = this.length,
  7258. j = +i + ( i < 0 ? len : 0 );
  7259. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7260. },
  7261. end: function() {
  7262. return this.prevObject || this.constructor();
  7263. },
  7264. // For internal use only.
  7265. // Behaves like an Array's method, not like a jQuery method.
  7266. push: push,
  7267. sort: arr.sort,
  7268. splice: arr.splice
  7269. };
  7270. jQuery.extend = jQuery.fn.extend = function() {
  7271. var options, name, src, copy, copyIsArray, clone,
  7272. target = arguments[ 0 ] || {},
  7273. i = 1,
  7274. length = arguments.length,
  7275. deep = false;
  7276. // Handle a deep copy situation
  7277. if ( typeof target === "boolean" ) {
  7278. deep = target;
  7279. // Skip the boolean and the target
  7280. target = arguments[ i ] || {};
  7281. i++;
  7282. }
  7283. // Handle case when target is a string or something (possible in deep copy)
  7284. if ( typeof target !== "object" && !isFunction( target ) ) {
  7285. target = {};
  7286. }
  7287. // Extend jQuery itself if only one argument is passed
  7288. if ( i === length ) {
  7289. target = this;
  7290. i--;
  7291. }
  7292. for ( ; i < length; i++ ) {
  7293. // Only deal with non-null/undefined values
  7294. if ( ( options = arguments[ i ] ) != null ) {
  7295. // Extend the base object
  7296. for ( name in options ) {
  7297. copy = options[ name ];
  7298. // Prevent Object.prototype pollution
  7299. // Prevent never-ending loop
  7300. if ( name === "__proto__" || target === copy ) {
  7301. continue;
  7302. }
  7303. // Recurse if we're merging plain objects or arrays
  7304. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7305. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7306. src = target[ name ];
  7307. // Ensure proper type for the source value
  7308. if ( copyIsArray && !Array.isArray( src ) ) {
  7309. clone = [];
  7310. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7311. clone = {};
  7312. } else {
  7313. clone = src;
  7314. }
  7315. copyIsArray = false;
  7316. // Never move original objects, clone them
  7317. target[ name ] = jQuery.extend( deep, clone, copy );
  7318. // Don't bring in undefined values
  7319. } else if ( copy !== undefined ) {
  7320. target[ name ] = copy;
  7321. }
  7322. }
  7323. }
  7324. }
  7325. // Return the modified object
  7326. return target;
  7327. };
  7328. jQuery.extend( {
  7329. // Unique for each copy of jQuery on the page
  7330. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7331. // Assume jQuery is ready without the ready module
  7332. isReady: true,
  7333. error: function( msg ) {
  7334. throw new Error( msg );
  7335. },
  7336. noop: function() {},
  7337. isPlainObject: function( obj ) {
  7338. var proto, Ctor;
  7339. // Detect obvious negatives
  7340. // Use toString instead of jQuery.type to catch host objects
  7341. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7342. return false;
  7343. }
  7344. proto = getProto( obj );
  7345. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7346. if ( !proto ) {
  7347. return true;
  7348. }
  7349. // Objects with prototype are plain iff they were constructed by a global Object function
  7350. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7351. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7352. },
  7353. isEmptyObject: function( obj ) {
  7354. var name;
  7355. for ( name in obj ) {
  7356. return false;
  7357. }
  7358. return true;
  7359. },
  7360. // Evaluates a script in a global context
  7361. globalEval: function( code, options ) {
  7362. DOMEval( code, { nonce: options && options.nonce } );
  7363. },
  7364. each: function( obj, callback ) {
  7365. var length, i = 0;
  7366. if ( isArrayLike( obj ) ) {
  7367. length = obj.length;
  7368. for ( ; i < length; i++ ) {
  7369. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7370. break;
  7371. }
  7372. }
  7373. } else {
  7374. for ( i in obj ) {
  7375. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7376. break;
  7377. }
  7378. }
  7379. }
  7380. return obj;
  7381. },
  7382. // Support: Android <=4.0 only
  7383. trim: function( text ) {
  7384. return text == null ?
  7385. "" :
  7386. ( text + "" ).replace( rtrim, "" );
  7387. },
  7388. // results is for internal usage only
  7389. makeArray: function( arr, results ) {
  7390. var ret = results || [];
  7391. if ( arr != null ) {
  7392. if ( isArrayLike( Object( arr ) ) ) {
  7393. jQuery.merge( ret,
  7394. typeof arr === "string" ?
  7395. [ arr ] : arr
  7396. );
  7397. } else {
  7398. push.call( ret, arr );
  7399. }
  7400. }
  7401. return ret;
  7402. },
  7403. inArray: function( elem, arr, i ) {
  7404. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7405. },
  7406. // Support: Android <=4.0 only, PhantomJS 1 only
  7407. // push.apply(_, arraylike) throws on ancient WebKit
  7408. merge: function( first, second ) {
  7409. var len = +second.length,
  7410. j = 0,
  7411. i = first.length;
  7412. for ( ; j < len; j++ ) {
  7413. first[ i++ ] = second[ j ];
  7414. }
  7415. first.length = i;
  7416. return first;
  7417. },
  7418. grep: function( elems, callback, invert ) {
  7419. var callbackInverse,
  7420. matches = [],
  7421. i = 0,
  7422. length = elems.length,
  7423. callbackExpect = !invert;
  7424. // Go through the array, only saving the items
  7425. // that pass the validator function
  7426. for ( ; i < length; i++ ) {
  7427. callbackInverse = !callback( elems[ i ], i );
  7428. if ( callbackInverse !== callbackExpect ) {
  7429. matches.push( elems[ i ] );
  7430. }
  7431. }
  7432. return matches;
  7433. },
  7434. // arg is for internal usage only
  7435. map: function( elems, callback, arg ) {
  7436. var length, value,
  7437. i = 0,
  7438. ret = [];
  7439. // Go through the array, translating each of the items to their new values
  7440. if ( isArrayLike( elems ) ) {
  7441. length = elems.length;
  7442. for ( ; i < length; i++ ) {
  7443. value = callback( elems[ i ], i, arg );
  7444. if ( value != null ) {
  7445. ret.push( value );
  7446. }
  7447. }
  7448. // Go through every key on the object,
  7449. } else {
  7450. for ( i in elems ) {
  7451. value = callback( elems[ i ], i, arg );
  7452. if ( value != null ) {
  7453. ret.push( value );
  7454. }
  7455. }
  7456. }
  7457. // Flatten any nested arrays
  7458. return concat.apply( [], ret );
  7459. },
  7460. // A global GUID counter for objects
  7461. guid: 1,
  7462. // jQuery.support is not used in Core but other projects attach their
  7463. // properties to it so it needs to exist.
  7464. support: support
  7465. } );
  7466. if ( typeof Symbol === "function" ) {
  7467. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7468. }
  7469. // Populate the class2type map
  7470. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7471. function( i, name ) {
  7472. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7473. } );
  7474. function isArrayLike( obj ) {
  7475. // Support: real iOS 8.2 only (not reproducible in simulator)
  7476. // `in` check used to prevent JIT error (gh-2145)
  7477. // hasOwn isn't used here due to false negatives
  7478. // regarding Nodelist length in IE
  7479. var length = !!obj && "length" in obj && obj.length,
  7480. type = toType( obj );
  7481. if ( isFunction( obj ) || isWindow( obj ) ) {
  7482. return false;
  7483. }
  7484. return type === "array" || length === 0 ||
  7485. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7486. }
  7487. var Sizzle =
  7488. /*!
  7489. * Sizzle CSS Selector Engine v2.3.4
  7490. * https://sizzlejs.com/
  7491. *
  7492. * Copyright JS Foundation and other contributors
  7493. * Released under the MIT license
  7494. * https://js.foundation/
  7495. *
  7496. * Date: 2019-04-08
  7497. */
  7498. (function( window ) {
  7499. var i,
  7500. support,
  7501. Expr,
  7502. getText,
  7503. isXML,
  7504. tokenize,
  7505. compile,
  7506. select,
  7507. outermostContext,
  7508. sortInput,
  7509. hasDuplicate,
  7510. // Local document vars
  7511. setDocument,
  7512. document,
  7513. docElem,
  7514. documentIsHTML,
  7515. rbuggyQSA,
  7516. rbuggyMatches,
  7517. matches,
  7518. contains,
  7519. // Instance-specific data
  7520. expando = "sizzle" + 1 * new Date(),
  7521. preferredDoc = window.document,
  7522. dirruns = 0,
  7523. done = 0,
  7524. classCache = createCache(),
  7525. tokenCache = createCache(),
  7526. compilerCache = createCache(),
  7527. nonnativeSelectorCache = createCache(),
  7528. sortOrder = function( a, b ) {
  7529. if ( a === b ) {
  7530. hasDuplicate = true;
  7531. }
  7532. return 0;
  7533. },
  7534. // Instance methods
  7535. hasOwn = ({}).hasOwnProperty,
  7536. arr = [],
  7537. pop = arr.pop,
  7538. push_native = arr.push,
  7539. push = arr.push,
  7540. slice = arr.slice,
  7541. // Use a stripped-down indexOf as it's faster than native
  7542. // https://jsperf.com/thor-indexof-vs-for/5
  7543. indexOf = function( list, elem ) {
  7544. var i = 0,
  7545. len = list.length;
  7546. for ( ; i < len; i++ ) {
  7547. if ( list[i] === elem ) {
  7548. return i;
  7549. }
  7550. }
  7551. return -1;
  7552. },
  7553. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7554. // Regular expressions
  7555. // http://www.w3.org/TR/css3-selectors/#whitespace
  7556. whitespace = "[\\x20\\t\\r\\n\\f]",
  7557. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7558. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7559. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7560. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7561. // Operator (capture 2)
  7562. "*([*^$|!~]?=)" + whitespace +
  7563. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7564. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7565. "*\\]",
  7566. pseudos = ":(" + identifier + ")(?:\\((" +
  7567. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7568. // 1. quoted (capture 3; capture 4 or capture 5)
  7569. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7570. // 2. simple (capture 6)
  7571. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7572. // 3. anything else (capture 2)
  7573. ".*" +
  7574. ")\\)|)",
  7575. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7576. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7577. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7578. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7579. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7580. rdescend = new RegExp( whitespace + "|>" ),
  7581. rpseudo = new RegExp( pseudos ),
  7582. ridentifier = new RegExp( "^" + identifier + "$" ),
  7583. matchExpr = {
  7584. "ID": new RegExp( "^#(" + identifier + ")" ),
  7585. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7586. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7587. "ATTR": new RegExp( "^" + attributes ),
  7588. "PSEUDO": new RegExp( "^" + pseudos ),
  7589. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7590. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7591. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7592. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7593. // For use in libraries implementing .is()
  7594. // We use this for POS matching in `select`
  7595. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7596. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7597. },
  7598. rhtml = /HTML$/i,
  7599. rinputs = /^(?:input|select|textarea|button)$/i,
  7600. rheader = /^h\d$/i,
  7601. rnative = /^[^{]+\{\s*\[native \w/,
  7602. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7603. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7604. rsibling = /[+~]/,
  7605. // CSS escapes
  7606. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7607. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7608. funescape = function( _, escaped, escapedWhitespace ) {
  7609. var high = "0x" + escaped - 0x10000;
  7610. // NaN means non-codepoint
  7611. // Support: Firefox<24
  7612. // Workaround erroneous numeric interpretation of +"0x"
  7613. return high !== high || escapedWhitespace ?
  7614. escaped :
  7615. high < 0 ?
  7616. // BMP codepoint
  7617. String.fromCharCode( high + 0x10000 ) :
  7618. // Supplemental Plane codepoint (surrogate pair)
  7619. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7620. },
  7621. // CSS string/identifier serialization
  7622. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7623. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7624. fcssescape = function( ch, asCodePoint ) {
  7625. if ( asCodePoint ) {
  7626. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7627. if ( ch === "\0" ) {
  7628. return "\uFFFD";
  7629. }
  7630. // Control characters and (dependent upon position) numbers get escaped as code points
  7631. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7632. }
  7633. // Other potentially-special ASCII characters get backslash-escaped
  7634. return "\\" + ch;
  7635. },
  7636. // Used for iframes
  7637. // See setDocument()
  7638. // Removing the function wrapper causes a "Permission Denied"
  7639. // error in IE
  7640. unloadHandler = function() {
  7641. setDocument();
  7642. },
  7643. inDisabledFieldset = addCombinator(
  7644. function( elem ) {
  7645. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7646. },
  7647. { dir: "parentNode", next: "legend" }
  7648. );
  7649. // Optimize for push.apply( _, NodeList )
  7650. try {
  7651. push.apply(
  7652. (arr = slice.call( preferredDoc.childNodes )),
  7653. preferredDoc.childNodes
  7654. );
  7655. // Support: Android<4.0
  7656. // Detect silently failing push.apply
  7657. arr[ preferredDoc.childNodes.length ].nodeType;
  7658. } catch ( e ) {
  7659. push = { apply: arr.length ?
  7660. // Leverage slice if possible
  7661. function( target, els ) {
  7662. push_native.apply( target, slice.call(els) );
  7663. } :
  7664. // Support: IE<9
  7665. // Otherwise append directly
  7666. function( target, els ) {
  7667. var j = target.length,
  7668. i = 0;
  7669. // Can't trust NodeList.length
  7670. while ( (target[j++] = els[i++]) ) {}
  7671. target.length = j - 1;
  7672. }
  7673. };
  7674. }
  7675. function Sizzle( selector, context, results, seed ) {
  7676. var m, i, elem, nid, match, groups, newSelector,
  7677. newContext = context && context.ownerDocument,
  7678. // nodeType defaults to 9, since context defaults to document
  7679. nodeType = context ? context.nodeType : 9;
  7680. results = results || [];
  7681. // Return early from calls with invalid selector or context
  7682. if ( typeof selector !== "string" || !selector ||
  7683. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7684. return results;
  7685. }
  7686. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7687. if ( !seed ) {
  7688. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7689. setDocument( context );
  7690. }
  7691. context = context || document;
  7692. if ( documentIsHTML ) {
  7693. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7694. // (excepting DocumentFragment context, where the methods don't exist)
  7695. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7696. // ID selector
  7697. if ( (m = match[1]) ) {
  7698. // Document context
  7699. if ( nodeType === 9 ) {
  7700. if ( (elem = context.getElementById( m )) ) {
  7701. // Support: IE, Opera, Webkit
  7702. // TODO: identify versions
  7703. // getElementById can match elements by name instead of ID
  7704. if ( elem.id === m ) {
  7705. results.push( elem );
  7706. return results;
  7707. }
  7708. } else {
  7709. return results;
  7710. }
  7711. // Element context
  7712. } else {
  7713. // Support: IE, Opera, Webkit
  7714. // TODO: identify versions
  7715. // getElementById can match elements by name instead of ID
  7716. if ( newContext && (elem = newContext.getElementById( m )) &&
  7717. contains( context, elem ) &&
  7718. elem.id === m ) {
  7719. results.push( elem );
  7720. return results;
  7721. }
  7722. }
  7723. // Type selector
  7724. } else if ( match[2] ) {
  7725. push.apply( results, context.getElementsByTagName( selector ) );
  7726. return results;
  7727. // Class selector
  7728. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7729. context.getElementsByClassName ) {
  7730. push.apply( results, context.getElementsByClassName( m ) );
  7731. return results;
  7732. }
  7733. }
  7734. // Take advantage of querySelectorAll
  7735. if ( support.qsa &&
  7736. !nonnativeSelectorCache[ selector + " " ] &&
  7737. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7738. // Support: IE 8 only
  7739. // Exclude object elements
  7740. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7741. newSelector = selector;
  7742. newContext = context;
  7743. // qSA considers elements outside a scoping root when evaluating child or
  7744. // descendant combinators, which is not what we want.
  7745. // In such cases, we work around the behavior by prefixing every selector in the
  7746. // list with an ID selector referencing the scope context.
  7747. // Thanks to Andrew Dupont for this technique.
  7748. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7749. // Capture the context ID, setting it first if necessary
  7750. if ( (nid = context.getAttribute( "id" )) ) {
  7751. nid = nid.replace( rcssescape, fcssescape );
  7752. } else {
  7753. context.setAttribute( "id", (nid = expando) );
  7754. }
  7755. // Prefix every selector in the list
  7756. groups = tokenize( selector );
  7757. i = groups.length;
  7758. while ( i-- ) {
  7759. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7760. }
  7761. newSelector = groups.join( "," );
  7762. // Expand context for sibling selectors
  7763. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7764. context;
  7765. }
  7766. try {
  7767. push.apply( results,
  7768. newContext.querySelectorAll( newSelector )
  7769. );
  7770. return results;
  7771. } catch ( qsaError ) {
  7772. nonnativeSelectorCache( selector, true );
  7773. } finally {
  7774. if ( nid === expando ) {
  7775. context.removeAttribute( "id" );
  7776. }
  7777. }
  7778. }
  7779. }
  7780. }
  7781. // All others
  7782. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7783. }
  7784. /**
  7785. * Create key-value caches of limited size
  7786. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7787. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7788. * deleting the oldest entry
  7789. */
  7790. function createCache() {
  7791. var keys = [];
  7792. function cache( key, value ) {
  7793. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7794. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7795. // Only keep the most recent entries
  7796. delete cache[ keys.shift() ];
  7797. }
  7798. return (cache[ key + " " ] = value);
  7799. }
  7800. return cache;
  7801. }
  7802. /**
  7803. * Mark a function for special use by Sizzle
  7804. * @param {Function} fn The function to mark
  7805. */
  7806. function markFunction( fn ) {
  7807. fn[ expando ] = true;
  7808. return fn;
  7809. }
  7810. /**
  7811. * Support testing using an element
  7812. * @param {Function} fn Passed the created element and returns a boolean result
  7813. */
  7814. function assert( fn ) {
  7815. var el = document.createElement("fieldset");
  7816. try {
  7817. return !!fn( el );
  7818. } catch (e) {
  7819. return false;
  7820. } finally {
  7821. // Remove from its parent by default
  7822. if ( el.parentNode ) {
  7823. el.parentNode.removeChild( el );
  7824. }
  7825. // release memory in IE
  7826. el = null;
  7827. }
  7828. }
  7829. /**
  7830. * Adds the same handler for all of the specified attrs
  7831. * @param {String} attrs Pipe-separated list of attributes
  7832. * @param {Function} handler The method that will be applied
  7833. */
  7834. function addHandle( attrs, handler ) {
  7835. var arr = attrs.split("|"),
  7836. i = arr.length;
  7837. while ( i-- ) {
  7838. Expr.attrHandle[ arr[i] ] = handler;
  7839. }
  7840. }
  7841. /**
  7842. * Checks document order of two siblings
  7843. * @param {Element} a
  7844. * @param {Element} b
  7845. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7846. */
  7847. function siblingCheck( a, b ) {
  7848. var cur = b && a,
  7849. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7850. a.sourceIndex - b.sourceIndex;
  7851. // Use IE sourceIndex if available on both nodes
  7852. if ( diff ) {
  7853. return diff;
  7854. }
  7855. // Check if b follows a
  7856. if ( cur ) {
  7857. while ( (cur = cur.nextSibling) ) {
  7858. if ( cur === b ) {
  7859. return -1;
  7860. }
  7861. }
  7862. }
  7863. return a ? 1 : -1;
  7864. }
  7865. /**
  7866. * Returns a function to use in pseudos for input types
  7867. * @param {String} type
  7868. */
  7869. function createInputPseudo( type ) {
  7870. return function( elem ) {
  7871. var name = elem.nodeName.toLowerCase();
  7872. return name === "input" && elem.type === type;
  7873. };
  7874. }
  7875. /**
  7876. * Returns a function to use in pseudos for buttons
  7877. * @param {String} type
  7878. */
  7879. function createButtonPseudo( type ) {
  7880. return function( elem ) {
  7881. var name = elem.nodeName.toLowerCase();
  7882. return (name === "input" || name === "button") && elem.type === type;
  7883. };
  7884. }
  7885. /**
  7886. * Returns a function to use in pseudos for :enabled/:disabled
  7887. * @param {Boolean} disabled true for :disabled; false for :enabled
  7888. */
  7889. function createDisabledPseudo( disabled ) {
  7890. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7891. return function( elem ) {
  7892. // Only certain elements can match :enabled or :disabled
  7893. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7894. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7895. if ( "form" in elem ) {
  7896. // Check for inherited disabledness on relevant non-disabled elements:
  7897. // * listed form-associated elements in a disabled fieldset
  7898. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7899. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7900. // * option elements in a disabled optgroup
  7901. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7902. // All such elements have a "form" property.
  7903. if ( elem.parentNode && elem.disabled === false ) {
  7904. // Option elements defer to a parent optgroup if present
  7905. if ( "label" in elem ) {
  7906. if ( "label" in elem.parentNode ) {
  7907. return elem.parentNode.disabled === disabled;
  7908. } else {
  7909. return elem.disabled === disabled;
  7910. }
  7911. }
  7912. // Support: IE 6 - 11
  7913. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7914. return elem.isDisabled === disabled ||
  7915. // Where there is no isDisabled, check manually
  7916. /* jshint -W018 */
  7917. elem.isDisabled !== !disabled &&
  7918. inDisabledFieldset( elem ) === disabled;
  7919. }
  7920. return elem.disabled === disabled;
  7921. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7922. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7923. // even exist on them, let alone have a boolean value.
  7924. } else if ( "label" in elem ) {
  7925. return elem.disabled === disabled;
  7926. }
  7927. // Remaining elements are neither :enabled nor :disabled
  7928. return false;
  7929. };
  7930. }
  7931. /**
  7932. * Returns a function to use in pseudos for positionals
  7933. * @param {Function} fn
  7934. */
  7935. function createPositionalPseudo( fn ) {
  7936. return markFunction(function( argument ) {
  7937. argument = +argument;
  7938. return markFunction(function( seed, matches ) {
  7939. var j,
  7940. matchIndexes = fn( [], seed.length, argument ),
  7941. i = matchIndexes.length;
  7942. // Match elements found at the specified indexes
  7943. while ( i-- ) {
  7944. if ( seed[ (j = matchIndexes[i]) ] ) {
  7945. seed[j] = !(matches[j] = seed[j]);
  7946. }
  7947. }
  7948. });
  7949. });
  7950. }
  7951. /**
  7952. * Checks a node for validity as a Sizzle context
  7953. * @param {Element|Object=} context
  7954. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7955. */
  7956. function testContext( context ) {
  7957. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7958. }
  7959. // Expose support vars for convenience
  7960. support = Sizzle.support = {};
  7961. /**
  7962. * Detects XML nodes
  7963. * @param {Element|Object} elem An element or a document
  7964. * @returns {Boolean} True iff elem is a non-HTML XML node
  7965. */
  7966. isXML = Sizzle.isXML = function( elem ) {
  7967. var namespace = elem.namespaceURI,
  7968. docElem = (elem.ownerDocument || elem).documentElement;
  7969. // Support: IE <=8
  7970. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  7971. // https://bugs.jquery.com/ticket/4833
  7972. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  7973. };
  7974. /**
  7975. * Sets document-related variables once based on the current document
  7976. * @param {Element|Object} [doc] An element or document object to use to set the document
  7977. * @returns {Object} Returns the current document
  7978. */
  7979. setDocument = Sizzle.setDocument = function( node ) {
  7980. var hasCompare, subWindow,
  7981. doc = node ? node.ownerDocument || node : preferredDoc;
  7982. // Return early if doc is invalid or already selected
  7983. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  7984. return document;
  7985. }
  7986. // Update global variables
  7987. document = doc;
  7988. docElem = document.documentElement;
  7989. documentIsHTML = !isXML( document );
  7990. // Support: IE 9-11, Edge
  7991. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  7992. if ( preferredDoc !== document &&
  7993. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  7994. // Support: IE 11, Edge
  7995. if ( subWindow.addEventListener ) {
  7996. subWindow.addEventListener( "unload", unloadHandler, false );
  7997. // Support: IE 9 - 10 only
  7998. } else if ( subWindow.attachEvent ) {
  7999. subWindow.attachEvent( "onunload", unloadHandler );
  8000. }
  8001. }
  8002. /* Attributes
  8003. ---------------------------------------------------------------------- */
  8004. // Support: IE<8
  8005. // Verify that getAttribute really returns attributes and not properties
  8006. // (excepting IE8 booleans)
  8007. support.attributes = assert(function( el ) {
  8008. el.className = "i";
  8009. return !el.getAttribute("className");
  8010. });
  8011. /* getElement(s)By*
  8012. ---------------------------------------------------------------------- */
  8013. // Check if getElementsByTagName("*") returns only elements
  8014. support.getElementsByTagName = assert(function( el ) {
  8015. el.appendChild( document.createComment("") );
  8016. return !el.getElementsByTagName("*").length;
  8017. });
  8018. // Support: IE<9
  8019. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8020. // Support: IE<10
  8021. // Check if getElementById returns elements by name
  8022. // The broken getElementById methods don't pick up programmatically-set names,
  8023. // so use a roundabout getElementsByName test
  8024. support.getById = assert(function( el ) {
  8025. docElem.appendChild( el ).id = expando;
  8026. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8027. });
  8028. // ID filter and find
  8029. if ( support.getById ) {
  8030. Expr.filter["ID"] = function( id ) {
  8031. var attrId = id.replace( runescape, funescape );
  8032. return function( elem ) {
  8033. return elem.getAttribute("id") === attrId;
  8034. };
  8035. };
  8036. Expr.find["ID"] = function( id, context ) {
  8037. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8038. var elem = context.getElementById( id );
  8039. return elem ? [ elem ] : [];
  8040. }
  8041. };
  8042. } else {
  8043. Expr.filter["ID"] = function( id ) {
  8044. var attrId = id.replace( runescape, funescape );
  8045. return function( elem ) {
  8046. var node = typeof elem.getAttributeNode !== "undefined" &&
  8047. elem.getAttributeNode("id");
  8048. return node && node.value === attrId;
  8049. };
  8050. };
  8051. // Support: IE 6 - 7 only
  8052. // getElementById is not reliable as a find shortcut
  8053. Expr.find["ID"] = function( id, context ) {
  8054. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8055. var node, i, elems,
  8056. elem = context.getElementById( id );
  8057. if ( elem ) {
  8058. // Verify the id attribute
  8059. node = elem.getAttributeNode("id");
  8060. if ( node && node.value === id ) {
  8061. return [ elem ];
  8062. }
  8063. // Fall back on getElementsByName
  8064. elems = context.getElementsByName( id );
  8065. i = 0;
  8066. while ( (elem = elems[i++]) ) {
  8067. node = elem.getAttributeNode("id");
  8068. if ( node && node.value === id ) {
  8069. return [ elem ];
  8070. }
  8071. }
  8072. }
  8073. return [];
  8074. }
  8075. };
  8076. }
  8077. // Tag
  8078. Expr.find["TAG"] = support.getElementsByTagName ?
  8079. function( tag, context ) {
  8080. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8081. return context.getElementsByTagName( tag );
  8082. // DocumentFragment nodes don't have gEBTN
  8083. } else if ( support.qsa ) {
  8084. return context.querySelectorAll( tag );
  8085. }
  8086. } :
  8087. function( tag, context ) {
  8088. var elem,
  8089. tmp = [],
  8090. i = 0,
  8091. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8092. results = context.getElementsByTagName( tag );
  8093. // Filter out possible comments
  8094. if ( tag === "*" ) {
  8095. while ( (elem = results[i++]) ) {
  8096. if ( elem.nodeType === 1 ) {
  8097. tmp.push( elem );
  8098. }
  8099. }
  8100. return tmp;
  8101. }
  8102. return results;
  8103. };
  8104. // Class
  8105. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8106. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8107. return context.getElementsByClassName( className );
  8108. }
  8109. };
  8110. /* QSA/matchesSelector
  8111. ---------------------------------------------------------------------- */
  8112. // QSA and matchesSelector support
  8113. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8114. rbuggyMatches = [];
  8115. // qSa(:focus) reports false when true (Chrome 21)
  8116. // We allow this because of a bug in IE8/9 that throws an error
  8117. // whenever `document.activeElement` is accessed on an iframe
  8118. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8119. // See https://bugs.jquery.com/ticket/13378
  8120. rbuggyQSA = [];
  8121. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8122. // Build QSA regex
  8123. // Regex strategy adopted from Diego Perini
  8124. assert(function( el ) {
  8125. // Select is set to empty string on purpose
  8126. // This is to test IE's treatment of not explicitly
  8127. // setting a boolean content attribute,
  8128. // since its presence should be enough
  8129. // https://bugs.jquery.com/ticket/12359
  8130. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8131. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8132. "<option selected=''></option></select>";
  8133. // Support: IE8, Opera 11-12.16
  8134. // Nothing should be selected when empty strings follow ^= or $= or *=
  8135. // The test attribute must be unknown in Opera but "safe" for WinRT
  8136. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8137. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8138. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8139. }
  8140. // Support: IE8
  8141. // Boolean attributes and "value" are not treated correctly
  8142. if ( !el.querySelectorAll("[selected]").length ) {
  8143. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8144. }
  8145. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8146. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8147. rbuggyQSA.push("~=");
  8148. }
  8149. // Webkit/Opera - :checked should return selected option elements
  8150. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8151. // IE8 throws error here and will not see later tests
  8152. if ( !el.querySelectorAll(":checked").length ) {
  8153. rbuggyQSA.push(":checked");
  8154. }
  8155. // Support: Safari 8+, iOS 8+
  8156. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8157. // In-page `selector#id sibling-combinator selector` fails
  8158. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8159. rbuggyQSA.push(".#.+[+~]");
  8160. }
  8161. });
  8162. assert(function( el ) {
  8163. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8164. "<select disabled='disabled'><option/></select>";
  8165. // Support: Windows 8 Native Apps
  8166. // The type and name attributes are restricted during .innerHTML assignment
  8167. var input = document.createElement("input");
  8168. input.setAttribute( "type", "hidden" );
  8169. el.appendChild( input ).setAttribute( "name", "D" );
  8170. // Support: IE8
  8171. // Enforce case-sensitivity of name attribute
  8172. if ( el.querySelectorAll("[name=d]").length ) {
  8173. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8174. }
  8175. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8176. // IE8 throws error here and will not see later tests
  8177. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8178. rbuggyQSA.push( ":enabled", ":disabled" );
  8179. }
  8180. // Support: IE9-11+
  8181. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8182. docElem.appendChild( el ).disabled = true;
  8183. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8184. rbuggyQSA.push( ":enabled", ":disabled" );
  8185. }
  8186. // Opera 10-11 does not throw on post-comma invalid pseudos
  8187. el.querySelectorAll("*,:x");
  8188. rbuggyQSA.push(",.*:");
  8189. });
  8190. }
  8191. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8192. docElem.webkitMatchesSelector ||
  8193. docElem.mozMatchesSelector ||
  8194. docElem.oMatchesSelector ||
  8195. docElem.msMatchesSelector) )) ) {
  8196. assert(function( el ) {
  8197. // Check to see if it's possible to do matchesSelector
  8198. // on a disconnected node (IE 9)
  8199. support.disconnectedMatch = matches.call( el, "*" );
  8200. // This should fail with an exception
  8201. // Gecko does not error, returns false instead
  8202. matches.call( el, "[s!='']:x" );
  8203. rbuggyMatches.push( "!=", pseudos );
  8204. });
  8205. }
  8206. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8207. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8208. /* Contains
  8209. ---------------------------------------------------------------------- */
  8210. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8211. // Element contains another
  8212. // Purposefully self-exclusive
  8213. // As in, an element does not contain itself
  8214. contains = hasCompare || rnative.test( docElem.contains ) ?
  8215. function( a, b ) {
  8216. var adown = a.nodeType === 9 ? a.documentElement : a,
  8217. bup = b && b.parentNode;
  8218. return a === bup || !!( bup && bup.nodeType === 1 && (
  8219. adown.contains ?
  8220. adown.contains( bup ) :
  8221. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8222. ));
  8223. } :
  8224. function( a, b ) {
  8225. if ( b ) {
  8226. while ( (b = b.parentNode) ) {
  8227. if ( b === a ) {
  8228. return true;
  8229. }
  8230. }
  8231. }
  8232. return false;
  8233. };
  8234. /* Sorting
  8235. ---------------------------------------------------------------------- */
  8236. // Document order sorting
  8237. sortOrder = hasCompare ?
  8238. function( a, b ) {
  8239. // Flag for duplicate removal
  8240. if ( a === b ) {
  8241. hasDuplicate = true;
  8242. return 0;
  8243. }
  8244. // Sort on method existence if only one input has compareDocumentPosition
  8245. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8246. if ( compare ) {
  8247. return compare;
  8248. }
  8249. // Calculate position if both inputs belong to the same document
  8250. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8251. a.compareDocumentPosition( b ) :
  8252. // Otherwise we know they are disconnected
  8253. 1;
  8254. // Disconnected nodes
  8255. if ( compare & 1 ||
  8256. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8257. // Choose the first element that is related to our preferred document
  8258. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8259. return -1;
  8260. }
  8261. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8262. return 1;
  8263. }
  8264. // Maintain original order
  8265. return sortInput ?
  8266. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8267. 0;
  8268. }
  8269. return compare & 4 ? -1 : 1;
  8270. } :
  8271. function( a, b ) {
  8272. // Exit early if the nodes are identical
  8273. if ( a === b ) {
  8274. hasDuplicate = true;
  8275. return 0;
  8276. }
  8277. var cur,
  8278. i = 0,
  8279. aup = a.parentNode,
  8280. bup = b.parentNode,
  8281. ap = [ a ],
  8282. bp = [ b ];
  8283. // Parentless nodes are either documents or disconnected
  8284. if ( !aup || !bup ) {
  8285. return a === document ? -1 :
  8286. b === document ? 1 :
  8287. aup ? -1 :
  8288. bup ? 1 :
  8289. sortInput ?
  8290. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8291. 0;
  8292. // If the nodes are siblings, we can do a quick check
  8293. } else if ( aup === bup ) {
  8294. return siblingCheck( a, b );
  8295. }
  8296. // Otherwise we need full lists of their ancestors for comparison
  8297. cur = a;
  8298. while ( (cur = cur.parentNode) ) {
  8299. ap.unshift( cur );
  8300. }
  8301. cur = b;
  8302. while ( (cur = cur.parentNode) ) {
  8303. bp.unshift( cur );
  8304. }
  8305. // Walk down the tree looking for a discrepancy
  8306. while ( ap[i] === bp[i] ) {
  8307. i++;
  8308. }
  8309. return i ?
  8310. // Do a sibling check if the nodes have a common ancestor
  8311. siblingCheck( ap[i], bp[i] ) :
  8312. // Otherwise nodes in our document sort first
  8313. ap[i] === preferredDoc ? -1 :
  8314. bp[i] === preferredDoc ? 1 :
  8315. 0;
  8316. };
  8317. return document;
  8318. };
  8319. Sizzle.matches = function( expr, elements ) {
  8320. return Sizzle( expr, null, null, elements );
  8321. };
  8322. Sizzle.matchesSelector = function( elem, expr ) {
  8323. // Set document vars if needed
  8324. if ( ( elem.ownerDocument || elem ) !== document ) {
  8325. setDocument( elem );
  8326. }
  8327. if ( support.matchesSelector && documentIsHTML &&
  8328. !nonnativeSelectorCache[ expr + " " ] &&
  8329. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8330. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8331. try {
  8332. var ret = matches.call( elem, expr );
  8333. // IE 9's matchesSelector returns false on disconnected nodes
  8334. if ( ret || support.disconnectedMatch ||
  8335. // As well, disconnected nodes are said to be in a document
  8336. // fragment in IE 9
  8337. elem.document && elem.document.nodeType !== 11 ) {
  8338. return ret;
  8339. }
  8340. } catch (e) {
  8341. nonnativeSelectorCache( expr, true );
  8342. }
  8343. }
  8344. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8345. };
  8346. Sizzle.contains = function( context, elem ) {
  8347. // Set document vars if needed
  8348. if ( ( context.ownerDocument || context ) !== document ) {
  8349. setDocument( context );
  8350. }
  8351. return contains( context, elem );
  8352. };
  8353. Sizzle.attr = function( elem, name ) {
  8354. // Set document vars if needed
  8355. if ( ( elem.ownerDocument || elem ) !== document ) {
  8356. setDocument( elem );
  8357. }
  8358. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8359. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8360. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8361. fn( elem, name, !documentIsHTML ) :
  8362. undefined;
  8363. return val !== undefined ?
  8364. val :
  8365. support.attributes || !documentIsHTML ?
  8366. elem.getAttribute( name ) :
  8367. (val = elem.getAttributeNode(name)) && val.specified ?
  8368. val.value :
  8369. null;
  8370. };
  8371. Sizzle.escape = function( sel ) {
  8372. return (sel + "").replace( rcssescape, fcssescape );
  8373. };
  8374. Sizzle.error = function( msg ) {
  8375. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8376. };
  8377. /**
  8378. * Document sorting and removing duplicates
  8379. * @param {ArrayLike} results
  8380. */
  8381. Sizzle.uniqueSort = function( results ) {
  8382. var elem,
  8383. duplicates = [],
  8384. j = 0,
  8385. i = 0;
  8386. // Unless we *know* we can detect duplicates, assume their presence
  8387. hasDuplicate = !support.detectDuplicates;
  8388. sortInput = !support.sortStable && results.slice( 0 );
  8389. results.sort( sortOrder );
  8390. if ( hasDuplicate ) {
  8391. while ( (elem = results[i++]) ) {
  8392. if ( elem === results[ i ] ) {
  8393. j = duplicates.push( i );
  8394. }
  8395. }
  8396. while ( j-- ) {
  8397. results.splice( duplicates[ j ], 1 );
  8398. }
  8399. }
  8400. // Clear input after sorting to release objects
  8401. // See https://github.com/jquery/sizzle/pull/225
  8402. sortInput = null;
  8403. return results;
  8404. };
  8405. /**
  8406. * Utility function for retrieving the text value of an array of DOM nodes
  8407. * @param {Array|Element} elem
  8408. */
  8409. getText = Sizzle.getText = function( elem ) {
  8410. var node,
  8411. ret = "",
  8412. i = 0,
  8413. nodeType = elem.nodeType;
  8414. if ( !nodeType ) {
  8415. // If no nodeType, this is expected to be an array
  8416. while ( (node = elem[i++]) ) {
  8417. // Do not traverse comment nodes
  8418. ret += getText( node );
  8419. }
  8420. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8421. // Use textContent for elements
  8422. // innerText usage removed for consistency of new lines (jQuery #11153)
  8423. if ( typeof elem.textContent === "string" ) {
  8424. return elem.textContent;
  8425. } else {
  8426. // Traverse its children
  8427. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8428. ret += getText( elem );
  8429. }
  8430. }
  8431. } else if ( nodeType === 3 || nodeType === 4 ) {
  8432. return elem.nodeValue;
  8433. }
  8434. // Do not include comment or processing instruction nodes
  8435. return ret;
  8436. };
  8437. Expr = Sizzle.selectors = {
  8438. // Can be adjusted by the user
  8439. cacheLength: 50,
  8440. createPseudo: markFunction,
  8441. match: matchExpr,
  8442. attrHandle: {},
  8443. find: {},
  8444. relative: {
  8445. ">": { dir: "parentNode", first: true },
  8446. " ": { dir: "parentNode" },
  8447. "+": { dir: "previousSibling", first: true },
  8448. "~": { dir: "previousSibling" }
  8449. },
  8450. preFilter: {
  8451. "ATTR": function( match ) {
  8452. match[1] = match[1].replace( runescape, funescape );
  8453. // Move the given value to match[3] whether quoted or unquoted
  8454. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8455. if ( match[2] === "~=" ) {
  8456. match[3] = " " + match[3] + " ";
  8457. }
  8458. return match.slice( 0, 4 );
  8459. },
  8460. "CHILD": function( match ) {
  8461. /* matches from matchExpr["CHILD"]
  8462. 1 type (only|nth|...)
  8463. 2 what (child|of-type)
  8464. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8465. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8466. 5 sign of xn-component
  8467. 6 x of xn-component
  8468. 7 sign of y-component
  8469. 8 y of y-component
  8470. */
  8471. match[1] = match[1].toLowerCase();
  8472. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8473. // nth-* requires argument
  8474. if ( !match[3] ) {
  8475. Sizzle.error( match[0] );
  8476. }
  8477. // numeric x and y parameters for Expr.filter.CHILD
  8478. // remember that false/true cast respectively to 0/1
  8479. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8480. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8481. // other types prohibit arguments
  8482. } else if ( match[3] ) {
  8483. Sizzle.error( match[0] );
  8484. }
  8485. return match;
  8486. },
  8487. "PSEUDO": function( match ) {
  8488. var excess,
  8489. unquoted = !match[6] && match[2];
  8490. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8491. return null;
  8492. }
  8493. // Accept quoted arguments as-is
  8494. if ( match[3] ) {
  8495. match[2] = match[4] || match[5] || "";
  8496. // Strip excess characters from unquoted arguments
  8497. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8498. // Get excess from tokenize (recursively)
  8499. (excess = tokenize( unquoted, true )) &&
  8500. // advance to the next closing parenthesis
  8501. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8502. // excess is a negative index
  8503. match[0] = match[0].slice( 0, excess );
  8504. match[2] = unquoted.slice( 0, excess );
  8505. }
  8506. // Return only captures needed by the pseudo filter method (type and argument)
  8507. return match.slice( 0, 3 );
  8508. }
  8509. },
  8510. filter: {
  8511. "TAG": function( nodeNameSelector ) {
  8512. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8513. return nodeNameSelector === "*" ?
  8514. function() { return true; } :
  8515. function( elem ) {
  8516. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8517. };
  8518. },
  8519. "CLASS": function( className ) {
  8520. var pattern = classCache[ className + " " ];
  8521. return pattern ||
  8522. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8523. classCache( className, function( elem ) {
  8524. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8525. });
  8526. },
  8527. "ATTR": function( name, operator, check ) {
  8528. return function( elem ) {
  8529. var result = Sizzle.attr( elem, name );
  8530. if ( result == null ) {
  8531. return operator === "!=";
  8532. }
  8533. if ( !operator ) {
  8534. return true;
  8535. }
  8536. result += "";
  8537. return operator === "=" ? result === check :
  8538. operator === "!=" ? result !== check :
  8539. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8540. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8541. operator === "$=" ? check && result.slice( -check.length ) === check :
  8542. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8543. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8544. false;
  8545. };
  8546. },
  8547. "CHILD": function( type, what, argument, first, last ) {
  8548. var simple = type.slice( 0, 3 ) !== "nth",
  8549. forward = type.slice( -4 ) !== "last",
  8550. ofType = what === "of-type";
  8551. return first === 1 && last === 0 ?
  8552. // Shortcut for :nth-*(n)
  8553. function( elem ) {
  8554. return !!elem.parentNode;
  8555. } :
  8556. function( elem, context, xml ) {
  8557. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8558. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8559. parent = elem.parentNode,
  8560. name = ofType && elem.nodeName.toLowerCase(),
  8561. useCache = !xml && !ofType,
  8562. diff = false;
  8563. if ( parent ) {
  8564. // :(first|last|only)-(child|of-type)
  8565. if ( simple ) {
  8566. while ( dir ) {
  8567. node = elem;
  8568. while ( (node = node[ dir ]) ) {
  8569. if ( ofType ?
  8570. node.nodeName.toLowerCase() === name :
  8571. node.nodeType === 1 ) {
  8572. return false;
  8573. }
  8574. }
  8575. // Reverse direction for :only-* (if we haven't yet done so)
  8576. start = dir = type === "only" && !start && "nextSibling";
  8577. }
  8578. return true;
  8579. }
  8580. start = [ forward ? parent.firstChild : parent.lastChild ];
  8581. // non-xml :nth-child(...) stores cache data on `parent`
  8582. if ( forward && useCache ) {
  8583. // Seek `elem` from a previously-cached index
  8584. // ...in a gzip-friendly way
  8585. node = parent;
  8586. outerCache = node[ expando ] || (node[ expando ] = {});
  8587. // Support: IE <9 only
  8588. // Defend against cloned attroperties (jQuery gh-1709)
  8589. uniqueCache = outerCache[ node.uniqueID ] ||
  8590. (outerCache[ node.uniqueID ] = {});
  8591. cache = uniqueCache[ type ] || [];
  8592. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8593. diff = nodeIndex && cache[ 2 ];
  8594. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8595. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8596. // Fallback to seeking `elem` from the start
  8597. (diff = nodeIndex = 0) || start.pop()) ) {
  8598. // When found, cache indexes on `parent` and break
  8599. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8600. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8601. break;
  8602. }
  8603. }
  8604. } else {
  8605. // Use previously-cached element index if available
  8606. if ( useCache ) {
  8607. // ...in a gzip-friendly way
  8608. node = elem;
  8609. outerCache = node[ expando ] || (node[ expando ] = {});
  8610. // Support: IE <9 only
  8611. // Defend against cloned attroperties (jQuery gh-1709)
  8612. uniqueCache = outerCache[ node.uniqueID ] ||
  8613. (outerCache[ node.uniqueID ] = {});
  8614. cache = uniqueCache[ type ] || [];
  8615. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8616. diff = nodeIndex;
  8617. }
  8618. // xml :nth-child(...)
  8619. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8620. if ( diff === false ) {
  8621. // Use the same loop as above to seek `elem` from the start
  8622. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8623. (diff = nodeIndex = 0) || start.pop()) ) {
  8624. if ( ( ofType ?
  8625. node.nodeName.toLowerCase() === name :
  8626. node.nodeType === 1 ) &&
  8627. ++diff ) {
  8628. // Cache the index of each encountered element
  8629. if ( useCache ) {
  8630. outerCache = node[ expando ] || (node[ expando ] = {});
  8631. // Support: IE <9 only
  8632. // Defend against cloned attroperties (jQuery gh-1709)
  8633. uniqueCache = outerCache[ node.uniqueID ] ||
  8634. (outerCache[ node.uniqueID ] = {});
  8635. uniqueCache[ type ] = [ dirruns, diff ];
  8636. }
  8637. if ( node === elem ) {
  8638. break;
  8639. }
  8640. }
  8641. }
  8642. }
  8643. }
  8644. // Incorporate the offset, then check against cycle size
  8645. diff -= last;
  8646. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8647. }
  8648. };
  8649. },
  8650. "PSEUDO": function( pseudo, argument ) {
  8651. // pseudo-class names are case-insensitive
  8652. // http://www.w3.org/TR/selectors/#pseudo-classes
  8653. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8654. // Remember that setFilters inherits from pseudos
  8655. var args,
  8656. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8657. Sizzle.error( "unsupported pseudo: " + pseudo );
  8658. // The user may use createPseudo to indicate that
  8659. // arguments are needed to create the filter function
  8660. // just as Sizzle does
  8661. if ( fn[ expando ] ) {
  8662. return fn( argument );
  8663. }
  8664. // But maintain support for old signatures
  8665. if ( fn.length > 1 ) {
  8666. args = [ pseudo, pseudo, "", argument ];
  8667. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8668. markFunction(function( seed, matches ) {
  8669. var idx,
  8670. matched = fn( seed, argument ),
  8671. i = matched.length;
  8672. while ( i-- ) {
  8673. idx = indexOf( seed, matched[i] );
  8674. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8675. }
  8676. }) :
  8677. function( elem ) {
  8678. return fn( elem, 0, args );
  8679. };
  8680. }
  8681. return fn;
  8682. }
  8683. },
  8684. pseudos: {
  8685. // Potentially complex pseudos
  8686. "not": markFunction(function( selector ) {
  8687. // Trim the selector passed to compile
  8688. // to avoid treating leading and trailing
  8689. // spaces as combinators
  8690. var input = [],
  8691. results = [],
  8692. matcher = compile( selector.replace( rtrim, "$1" ) );
  8693. return matcher[ expando ] ?
  8694. markFunction(function( seed, matches, context, xml ) {
  8695. var elem,
  8696. unmatched = matcher( seed, null, xml, [] ),
  8697. i = seed.length;
  8698. // Match elements unmatched by `matcher`
  8699. while ( i-- ) {
  8700. if ( (elem = unmatched[i]) ) {
  8701. seed[i] = !(matches[i] = elem);
  8702. }
  8703. }
  8704. }) :
  8705. function( elem, context, xml ) {
  8706. input[0] = elem;
  8707. matcher( input, null, xml, results );
  8708. // Don't keep the element (issue #299)
  8709. input[0] = null;
  8710. return !results.pop();
  8711. };
  8712. }),
  8713. "has": markFunction(function( selector ) {
  8714. return function( elem ) {
  8715. return Sizzle( selector, elem ).length > 0;
  8716. };
  8717. }),
  8718. "contains": markFunction(function( text ) {
  8719. text = text.replace( runescape, funescape );
  8720. return function( elem ) {
  8721. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8722. };
  8723. }),
  8724. // "Whether an element is represented by a :lang() selector
  8725. // is based solely on the element's language value
  8726. // being equal to the identifier C,
  8727. // or beginning with the identifier C immediately followed by "-".
  8728. // The matching of C against the element's language value is performed case-insensitively.
  8729. // The identifier C does not have to be a valid language name."
  8730. // http://www.w3.org/TR/selectors/#lang-pseudo
  8731. "lang": markFunction( function( lang ) {
  8732. // lang value must be a valid identifier
  8733. if ( !ridentifier.test(lang || "") ) {
  8734. Sizzle.error( "unsupported lang: " + lang );
  8735. }
  8736. lang = lang.replace( runescape, funescape ).toLowerCase();
  8737. return function( elem ) {
  8738. var elemLang;
  8739. do {
  8740. if ( (elemLang = documentIsHTML ?
  8741. elem.lang :
  8742. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8743. elemLang = elemLang.toLowerCase();
  8744. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8745. }
  8746. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8747. return false;
  8748. };
  8749. }),
  8750. // Miscellaneous
  8751. "target": function( elem ) {
  8752. var hash = window.location && window.location.hash;
  8753. return hash && hash.slice( 1 ) === elem.id;
  8754. },
  8755. "root": function( elem ) {
  8756. return elem === docElem;
  8757. },
  8758. "focus": function( elem ) {
  8759. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8760. },
  8761. // Boolean properties
  8762. "enabled": createDisabledPseudo( false ),
  8763. "disabled": createDisabledPseudo( true ),
  8764. "checked": function( elem ) {
  8765. // In CSS3, :checked should return both checked and selected elements
  8766. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8767. var nodeName = elem.nodeName.toLowerCase();
  8768. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8769. },
  8770. "selected": function( elem ) {
  8771. // Accessing this property makes selected-by-default
  8772. // options in Safari work properly
  8773. if ( elem.parentNode ) {
  8774. elem.parentNode.selectedIndex;
  8775. }
  8776. return elem.selected === true;
  8777. },
  8778. // Contents
  8779. "empty": function( elem ) {
  8780. // http://www.w3.org/TR/selectors/#empty-pseudo
  8781. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8782. // but not by others (comment: 8; processing instruction: 7; etc.)
  8783. // nodeType < 6 works because attributes (2) do not appear as children
  8784. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8785. if ( elem.nodeType < 6 ) {
  8786. return false;
  8787. }
  8788. }
  8789. return true;
  8790. },
  8791. "parent": function( elem ) {
  8792. return !Expr.pseudos["empty"]( elem );
  8793. },
  8794. // Element/input types
  8795. "header": function( elem ) {
  8796. return rheader.test( elem.nodeName );
  8797. },
  8798. "input": function( elem ) {
  8799. return rinputs.test( elem.nodeName );
  8800. },
  8801. "button": function( elem ) {
  8802. var name = elem.nodeName.toLowerCase();
  8803. return name === "input" && elem.type === "button" || name === "button";
  8804. },
  8805. "text": function( elem ) {
  8806. var attr;
  8807. return elem.nodeName.toLowerCase() === "input" &&
  8808. elem.type === "text" &&
  8809. // Support: IE<8
  8810. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8811. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8812. },
  8813. // Position-in-collection
  8814. "first": createPositionalPseudo(function() {
  8815. return [ 0 ];
  8816. }),
  8817. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8818. return [ length - 1 ];
  8819. }),
  8820. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8821. return [ argument < 0 ? argument + length : argument ];
  8822. }),
  8823. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8824. var i = 0;
  8825. for ( ; i < length; i += 2 ) {
  8826. matchIndexes.push( i );
  8827. }
  8828. return matchIndexes;
  8829. }),
  8830. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8831. var i = 1;
  8832. for ( ; i < length; i += 2 ) {
  8833. matchIndexes.push( i );
  8834. }
  8835. return matchIndexes;
  8836. }),
  8837. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8838. var i = argument < 0 ?
  8839. argument + length :
  8840. argument > length ?
  8841. length :
  8842. argument;
  8843. for ( ; --i >= 0; ) {
  8844. matchIndexes.push( i );
  8845. }
  8846. return matchIndexes;
  8847. }),
  8848. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8849. var i = argument < 0 ? argument + length : argument;
  8850. for ( ; ++i < length; ) {
  8851. matchIndexes.push( i );
  8852. }
  8853. return matchIndexes;
  8854. })
  8855. }
  8856. };
  8857. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8858. // Add button/input type pseudos
  8859. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8860. Expr.pseudos[ i ] = createInputPseudo( i );
  8861. }
  8862. for ( i in { submit: true, reset: true } ) {
  8863. Expr.pseudos[ i ] = createButtonPseudo( i );
  8864. }
  8865. // Easy API for creating new setFilters
  8866. function setFilters() {}
  8867. setFilters.prototype = Expr.filters = Expr.pseudos;
  8868. Expr.setFilters = new setFilters();
  8869. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8870. var matched, match, tokens, type,
  8871. soFar, groups, preFilters,
  8872. cached = tokenCache[ selector + " " ];
  8873. if ( cached ) {
  8874. return parseOnly ? 0 : cached.slice( 0 );
  8875. }
  8876. soFar = selector;
  8877. groups = [];
  8878. preFilters = Expr.preFilter;
  8879. while ( soFar ) {
  8880. // Comma and first run
  8881. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8882. if ( match ) {
  8883. // Don't consume trailing commas as valid
  8884. soFar = soFar.slice( match[0].length ) || soFar;
  8885. }
  8886. groups.push( (tokens = []) );
  8887. }
  8888. matched = false;
  8889. // Combinators
  8890. if ( (match = rcombinators.exec( soFar )) ) {
  8891. matched = match.shift();
  8892. tokens.push({
  8893. value: matched,
  8894. // Cast descendant combinators to space
  8895. type: match[0].replace( rtrim, " " )
  8896. });
  8897. soFar = soFar.slice( matched.length );
  8898. }
  8899. // Filters
  8900. for ( type in Expr.filter ) {
  8901. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8902. (match = preFilters[ type ]( match ))) ) {
  8903. matched = match.shift();
  8904. tokens.push({
  8905. value: matched,
  8906. type: type,
  8907. matches: match
  8908. });
  8909. soFar = soFar.slice( matched.length );
  8910. }
  8911. }
  8912. if ( !matched ) {
  8913. break;
  8914. }
  8915. }
  8916. // Return the length of the invalid excess
  8917. // if we're just parsing
  8918. // Otherwise, throw an error or return tokens
  8919. return parseOnly ?
  8920. soFar.length :
  8921. soFar ?
  8922. Sizzle.error( selector ) :
  8923. // Cache the tokens
  8924. tokenCache( selector, groups ).slice( 0 );
  8925. };
  8926. function toSelector( tokens ) {
  8927. var i = 0,
  8928. len = tokens.length,
  8929. selector = "";
  8930. for ( ; i < len; i++ ) {
  8931. selector += tokens[i].value;
  8932. }
  8933. return selector;
  8934. }
  8935. function addCombinator( matcher, combinator, base ) {
  8936. var dir = combinator.dir,
  8937. skip = combinator.next,
  8938. key = skip || dir,
  8939. checkNonElements = base && key === "parentNode",
  8940. doneName = done++;
  8941. return combinator.first ?
  8942. // Check against closest ancestor/preceding element
  8943. function( elem, context, xml ) {
  8944. while ( (elem = elem[ dir ]) ) {
  8945. if ( elem.nodeType === 1 || checkNonElements ) {
  8946. return matcher( elem, context, xml );
  8947. }
  8948. }
  8949. return false;
  8950. } :
  8951. // Check against all ancestor/preceding elements
  8952. function( elem, context, xml ) {
  8953. var oldCache, uniqueCache, outerCache,
  8954. newCache = [ dirruns, doneName ];
  8955. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8956. if ( xml ) {
  8957. while ( (elem = elem[ dir ]) ) {
  8958. if ( elem.nodeType === 1 || checkNonElements ) {
  8959. if ( matcher( elem, context, xml ) ) {
  8960. return true;
  8961. }
  8962. }
  8963. }
  8964. } else {
  8965. while ( (elem = elem[ dir ]) ) {
  8966. if ( elem.nodeType === 1 || checkNonElements ) {
  8967. outerCache = elem[ expando ] || (elem[ expando ] = {});
  8968. // Support: IE <9 only
  8969. // Defend against cloned attroperties (jQuery gh-1709)
  8970. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  8971. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  8972. elem = elem[ dir ] || elem;
  8973. } else if ( (oldCache = uniqueCache[ key ]) &&
  8974. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  8975. // Assign to newCache so results back-propagate to previous elements
  8976. return (newCache[ 2 ] = oldCache[ 2 ]);
  8977. } else {
  8978. // Reuse newcache so results back-propagate to previous elements
  8979. uniqueCache[ key ] = newCache;
  8980. // A match means we're done; a fail means we have to keep checking
  8981. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  8982. return true;
  8983. }
  8984. }
  8985. }
  8986. }
  8987. }
  8988. return false;
  8989. };
  8990. }
  8991. function elementMatcher( matchers ) {
  8992. return matchers.length > 1 ?
  8993. function( elem, context, xml ) {
  8994. var i = matchers.length;
  8995. while ( i-- ) {
  8996. if ( !matchers[i]( elem, context, xml ) ) {
  8997. return false;
  8998. }
  8999. }
  9000. return true;
  9001. } :
  9002. matchers[0];
  9003. }
  9004. function multipleContexts( selector, contexts, results ) {
  9005. var i = 0,
  9006. len = contexts.length;
  9007. for ( ; i < len; i++ ) {
  9008. Sizzle( selector, contexts[i], results );
  9009. }
  9010. return results;
  9011. }
  9012. function condense( unmatched, map, filter, context, xml ) {
  9013. var elem,
  9014. newUnmatched = [],
  9015. i = 0,
  9016. len = unmatched.length,
  9017. mapped = map != null;
  9018. for ( ; i < len; i++ ) {
  9019. if ( (elem = unmatched[i]) ) {
  9020. if ( !filter || filter( elem, context, xml ) ) {
  9021. newUnmatched.push( elem );
  9022. if ( mapped ) {
  9023. map.push( i );
  9024. }
  9025. }
  9026. }
  9027. }
  9028. return newUnmatched;
  9029. }
  9030. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9031. if ( postFilter && !postFilter[ expando ] ) {
  9032. postFilter = setMatcher( postFilter );
  9033. }
  9034. if ( postFinder && !postFinder[ expando ] ) {
  9035. postFinder = setMatcher( postFinder, postSelector );
  9036. }
  9037. return markFunction(function( seed, results, context, xml ) {
  9038. var temp, i, elem,
  9039. preMap = [],
  9040. postMap = [],
  9041. preexisting = results.length,
  9042. // Get initial elements from seed or context
  9043. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9044. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9045. matcherIn = preFilter && ( seed || !selector ) ?
  9046. condense( elems, preMap, preFilter, context, xml ) :
  9047. elems,
  9048. matcherOut = matcher ?
  9049. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9050. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9051. // ...intermediate processing is necessary
  9052. [] :
  9053. // ...otherwise use results directly
  9054. results :
  9055. matcherIn;
  9056. // Find primary matches
  9057. if ( matcher ) {
  9058. matcher( matcherIn, matcherOut, context, xml );
  9059. }
  9060. // Apply postFilter
  9061. if ( postFilter ) {
  9062. temp = condense( matcherOut, postMap );
  9063. postFilter( temp, [], context, xml );
  9064. // Un-match failing elements by moving them back to matcherIn
  9065. i = temp.length;
  9066. while ( i-- ) {
  9067. if ( (elem = temp[i]) ) {
  9068. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9069. }
  9070. }
  9071. }
  9072. if ( seed ) {
  9073. if ( postFinder || preFilter ) {
  9074. if ( postFinder ) {
  9075. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9076. temp = [];
  9077. i = matcherOut.length;
  9078. while ( i-- ) {
  9079. if ( (elem = matcherOut[i]) ) {
  9080. // Restore matcherIn since elem is not yet a final match
  9081. temp.push( (matcherIn[i] = elem) );
  9082. }
  9083. }
  9084. postFinder( null, (matcherOut = []), temp, xml );
  9085. }
  9086. // Move matched elements from seed to results to keep them synchronized
  9087. i = matcherOut.length;
  9088. while ( i-- ) {
  9089. if ( (elem = matcherOut[i]) &&
  9090. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9091. seed[temp] = !(results[temp] = elem);
  9092. }
  9093. }
  9094. }
  9095. // Add elements to results, through postFinder if defined
  9096. } else {
  9097. matcherOut = condense(
  9098. matcherOut === results ?
  9099. matcherOut.splice( preexisting, matcherOut.length ) :
  9100. matcherOut
  9101. );
  9102. if ( postFinder ) {
  9103. postFinder( null, results, matcherOut, xml );
  9104. } else {
  9105. push.apply( results, matcherOut );
  9106. }
  9107. }
  9108. });
  9109. }
  9110. function matcherFromTokens( tokens ) {
  9111. var checkContext, matcher, j,
  9112. len = tokens.length,
  9113. leadingRelative = Expr.relative[ tokens[0].type ],
  9114. implicitRelative = leadingRelative || Expr.relative[" "],
  9115. i = leadingRelative ? 1 : 0,
  9116. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9117. matchContext = addCombinator( function( elem ) {
  9118. return elem === checkContext;
  9119. }, implicitRelative, true ),
  9120. matchAnyContext = addCombinator( function( elem ) {
  9121. return indexOf( checkContext, elem ) > -1;
  9122. }, implicitRelative, true ),
  9123. matchers = [ function( elem, context, xml ) {
  9124. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9125. (checkContext = context).nodeType ?
  9126. matchContext( elem, context, xml ) :
  9127. matchAnyContext( elem, context, xml ) );
  9128. // Avoid hanging onto element (issue #299)
  9129. checkContext = null;
  9130. return ret;
  9131. } ];
  9132. for ( ; i < len; i++ ) {
  9133. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9134. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9135. } else {
  9136. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9137. // Return special upon seeing a positional matcher
  9138. if ( matcher[ expando ] ) {
  9139. // Find the next relative operator (if any) for proper handling
  9140. j = ++i;
  9141. for ( ; j < len; j++ ) {
  9142. if ( Expr.relative[ tokens[j].type ] ) {
  9143. break;
  9144. }
  9145. }
  9146. return setMatcher(
  9147. i > 1 && elementMatcher( matchers ),
  9148. i > 1 && toSelector(
  9149. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9150. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9151. ).replace( rtrim, "$1" ),
  9152. matcher,
  9153. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9154. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9155. j < len && toSelector( tokens )
  9156. );
  9157. }
  9158. matchers.push( matcher );
  9159. }
  9160. }
  9161. return elementMatcher( matchers );
  9162. }
  9163. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9164. var bySet = setMatchers.length > 0,
  9165. byElement = elementMatchers.length > 0,
  9166. superMatcher = function( seed, context, xml, results, outermost ) {
  9167. var elem, j, matcher,
  9168. matchedCount = 0,
  9169. i = "0",
  9170. unmatched = seed && [],
  9171. setMatched = [],
  9172. contextBackup = outermostContext,
  9173. // We must always have either seed elements or outermost context
  9174. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9175. // Use integer dirruns iff this is the outermost matcher
  9176. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9177. len = elems.length;
  9178. if ( outermost ) {
  9179. outermostContext = context === document || context || outermost;
  9180. }
  9181. // Add elements passing elementMatchers directly to results
  9182. // Support: IE<9, Safari
  9183. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9184. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9185. if ( byElement && elem ) {
  9186. j = 0;
  9187. if ( !context && elem.ownerDocument !== document ) {
  9188. setDocument( elem );
  9189. xml = !documentIsHTML;
  9190. }
  9191. while ( (matcher = elementMatchers[j++]) ) {
  9192. if ( matcher( elem, context || document, xml) ) {
  9193. results.push( elem );
  9194. break;
  9195. }
  9196. }
  9197. if ( outermost ) {
  9198. dirruns = dirrunsUnique;
  9199. }
  9200. }
  9201. // Track unmatched elements for set filters
  9202. if ( bySet ) {
  9203. // They will have gone through all possible matchers
  9204. if ( (elem = !matcher && elem) ) {
  9205. matchedCount--;
  9206. }
  9207. // Lengthen the array for every element, matched or not
  9208. if ( seed ) {
  9209. unmatched.push( elem );
  9210. }
  9211. }
  9212. }
  9213. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9214. // makes the latter nonnegative.
  9215. matchedCount += i;
  9216. // Apply set filters to unmatched elements
  9217. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9218. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9219. // no element matchers and no seed.
  9220. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9221. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9222. // numerically zero.
  9223. if ( bySet && i !== matchedCount ) {
  9224. j = 0;
  9225. while ( (matcher = setMatchers[j++]) ) {
  9226. matcher( unmatched, setMatched, context, xml );
  9227. }
  9228. if ( seed ) {
  9229. // Reintegrate element matches to eliminate the need for sorting
  9230. if ( matchedCount > 0 ) {
  9231. while ( i-- ) {
  9232. if ( !(unmatched[i] || setMatched[i]) ) {
  9233. setMatched[i] = pop.call( results );
  9234. }
  9235. }
  9236. }
  9237. // Discard index placeholder values to get only actual matches
  9238. setMatched = condense( setMatched );
  9239. }
  9240. // Add matches to results
  9241. push.apply( results, setMatched );
  9242. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9243. if ( outermost && !seed && setMatched.length > 0 &&
  9244. ( matchedCount + setMatchers.length ) > 1 ) {
  9245. Sizzle.uniqueSort( results );
  9246. }
  9247. }
  9248. // Override manipulation of globals by nested matchers
  9249. if ( outermost ) {
  9250. dirruns = dirrunsUnique;
  9251. outermostContext = contextBackup;
  9252. }
  9253. return unmatched;
  9254. };
  9255. return bySet ?
  9256. markFunction( superMatcher ) :
  9257. superMatcher;
  9258. }
  9259. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9260. var i,
  9261. setMatchers = [],
  9262. elementMatchers = [],
  9263. cached = compilerCache[ selector + " " ];
  9264. if ( !cached ) {
  9265. // Generate a function of recursive functions that can be used to check each element
  9266. if ( !match ) {
  9267. match = tokenize( selector );
  9268. }
  9269. i = match.length;
  9270. while ( i-- ) {
  9271. cached = matcherFromTokens( match[i] );
  9272. if ( cached[ expando ] ) {
  9273. setMatchers.push( cached );
  9274. } else {
  9275. elementMatchers.push( cached );
  9276. }
  9277. }
  9278. // Cache the compiled function
  9279. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9280. // Save selector and tokenization
  9281. cached.selector = selector;
  9282. }
  9283. return cached;
  9284. };
  9285. /**
  9286. * A low-level selection function that works with Sizzle's compiled
  9287. * selector functions
  9288. * @param {String|Function} selector A selector or a pre-compiled
  9289. * selector function built with Sizzle.compile
  9290. * @param {Element} context
  9291. * @param {Array} [results]
  9292. * @param {Array} [seed] A set of elements to match against
  9293. */
  9294. select = Sizzle.select = function( selector, context, results, seed ) {
  9295. var i, tokens, token, type, find,
  9296. compiled = typeof selector === "function" && selector,
  9297. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9298. results = results || [];
  9299. // Try to minimize operations if there is only one selector in the list and no seed
  9300. // (the latter of which guarantees us context)
  9301. if ( match.length === 1 ) {
  9302. // Reduce context if the leading compound selector is an ID
  9303. tokens = match[0] = match[0].slice( 0 );
  9304. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9305. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9306. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9307. if ( !context ) {
  9308. return results;
  9309. // Precompiled matchers will still verify ancestry, so step up a level
  9310. } else if ( compiled ) {
  9311. context = context.parentNode;
  9312. }
  9313. selector = selector.slice( tokens.shift().value.length );
  9314. }
  9315. // Fetch a seed set for right-to-left matching
  9316. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9317. while ( i-- ) {
  9318. token = tokens[i];
  9319. // Abort if we hit a combinator
  9320. if ( Expr.relative[ (type = token.type) ] ) {
  9321. break;
  9322. }
  9323. if ( (find = Expr.find[ type ]) ) {
  9324. // Search, expanding context for leading sibling combinators
  9325. if ( (seed = find(
  9326. token.matches[0].replace( runescape, funescape ),
  9327. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9328. )) ) {
  9329. // If seed is empty or no tokens remain, we can return early
  9330. tokens.splice( i, 1 );
  9331. selector = seed.length && toSelector( tokens );
  9332. if ( !selector ) {
  9333. push.apply( results, seed );
  9334. return results;
  9335. }
  9336. break;
  9337. }
  9338. }
  9339. }
  9340. }
  9341. // Compile and execute a filtering function if one is not provided
  9342. // Provide `match` to avoid retokenization if we modified the selector above
  9343. ( compiled || compile( selector, match ) )(
  9344. seed,
  9345. context,
  9346. !documentIsHTML,
  9347. results,
  9348. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9349. );
  9350. return results;
  9351. };
  9352. // One-time assignments
  9353. // Sort stability
  9354. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9355. // Support: Chrome 14-35+
  9356. // Always assume duplicates if they aren't passed to the comparison function
  9357. support.detectDuplicates = !!hasDuplicate;
  9358. // Initialize against the default document
  9359. setDocument();
  9360. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9361. // Detached nodes confoundingly follow *each other*
  9362. support.sortDetached = assert(function( el ) {
  9363. // Should return 1, but returns 4 (following)
  9364. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9365. });
  9366. // Support: IE<8
  9367. // Prevent attribute/property "interpolation"
  9368. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9369. if ( !assert(function( el ) {
  9370. el.innerHTML = "<a href='#'></a>";
  9371. return el.firstChild.getAttribute("href") === "#" ;
  9372. }) ) {
  9373. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9374. if ( !isXML ) {
  9375. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9376. }
  9377. });
  9378. }
  9379. // Support: IE<9
  9380. // Use defaultValue in place of getAttribute("value")
  9381. if ( !support.attributes || !assert(function( el ) {
  9382. el.innerHTML = "<input/>";
  9383. el.firstChild.setAttribute( "value", "" );
  9384. return el.firstChild.getAttribute( "value" ) === "";
  9385. }) ) {
  9386. addHandle( "value", function( elem, name, isXML ) {
  9387. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9388. return elem.defaultValue;
  9389. }
  9390. });
  9391. }
  9392. // Support: IE<9
  9393. // Use getAttributeNode to fetch booleans when getAttribute lies
  9394. if ( !assert(function( el ) {
  9395. return el.getAttribute("disabled") == null;
  9396. }) ) {
  9397. addHandle( booleans, function( elem, name, isXML ) {
  9398. var val;
  9399. if ( !isXML ) {
  9400. return elem[ name ] === true ? name.toLowerCase() :
  9401. (val = elem.getAttributeNode( name )) && val.specified ?
  9402. val.value :
  9403. null;
  9404. }
  9405. });
  9406. }
  9407. return Sizzle;
  9408. })( window );
  9409. jQuery.find = Sizzle;
  9410. jQuery.expr = Sizzle.selectors;
  9411. // Deprecated
  9412. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9413. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9414. jQuery.text = Sizzle.getText;
  9415. jQuery.isXMLDoc = Sizzle.isXML;
  9416. jQuery.contains = Sizzle.contains;
  9417. jQuery.escapeSelector = Sizzle.escape;
  9418. var dir = function( elem, dir, until ) {
  9419. var matched = [],
  9420. truncate = until !== undefined;
  9421. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9422. if ( elem.nodeType === 1 ) {
  9423. if ( truncate && jQuery( elem ).is( until ) ) {
  9424. break;
  9425. }
  9426. matched.push( elem );
  9427. }
  9428. }
  9429. return matched;
  9430. };
  9431. var siblings = function( n, elem ) {
  9432. var matched = [];
  9433. for ( ; n; n = n.nextSibling ) {
  9434. if ( n.nodeType === 1 && n !== elem ) {
  9435. matched.push( n );
  9436. }
  9437. }
  9438. return matched;
  9439. };
  9440. var rneedsContext = jQuery.expr.match.needsContext;
  9441. function nodeName( elem, name ) {
  9442. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9443. };
  9444. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9445. // Implement the identical functionality for filter and not
  9446. function winnow( elements, qualifier, not ) {
  9447. if ( isFunction( qualifier ) ) {
  9448. return jQuery.grep( elements, function( elem, i ) {
  9449. return !!qualifier.call( elem, i, elem ) !== not;
  9450. } );
  9451. }
  9452. // Single element
  9453. if ( qualifier.nodeType ) {
  9454. return jQuery.grep( elements, function( elem ) {
  9455. return ( elem === qualifier ) !== not;
  9456. } );
  9457. }
  9458. // Arraylike of elements (jQuery, arguments, Array)
  9459. if ( typeof qualifier !== "string" ) {
  9460. return jQuery.grep( elements, function( elem ) {
  9461. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9462. } );
  9463. }
  9464. // Filtered directly for both simple and complex selectors
  9465. return jQuery.filter( qualifier, elements, not );
  9466. }
  9467. jQuery.filter = function( expr, elems, not ) {
  9468. var elem = elems[ 0 ];
  9469. if ( not ) {
  9470. expr = ":not(" + expr + ")";
  9471. }
  9472. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9473. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9474. }
  9475. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9476. return elem.nodeType === 1;
  9477. } ) );
  9478. };
  9479. jQuery.fn.extend( {
  9480. find: function( selector ) {
  9481. var i, ret,
  9482. len = this.length,
  9483. self = this;
  9484. if ( typeof selector !== "string" ) {
  9485. return this.pushStack( jQuery( selector ).filter( function() {
  9486. for ( i = 0; i < len; i++ ) {
  9487. if ( jQuery.contains( self[ i ], this ) ) {
  9488. return true;
  9489. }
  9490. }
  9491. } ) );
  9492. }
  9493. ret = this.pushStack( [] );
  9494. for ( i = 0; i < len; i++ ) {
  9495. jQuery.find( selector, self[ i ], ret );
  9496. }
  9497. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9498. },
  9499. filter: function( selector ) {
  9500. return this.pushStack( winnow( this, selector || [], false ) );
  9501. },
  9502. not: function( selector ) {
  9503. return this.pushStack( winnow( this, selector || [], true ) );
  9504. },
  9505. is: function( selector ) {
  9506. return !!winnow(
  9507. this,
  9508. // If this is a positional/relative selector, check membership in the returned set
  9509. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9510. typeof selector === "string" && rneedsContext.test( selector ) ?
  9511. jQuery( selector ) :
  9512. selector || [],
  9513. false
  9514. ).length;
  9515. }
  9516. } );
  9517. // Initialize a jQuery object
  9518. // A central reference to the root jQuery(document)
  9519. var rootjQuery,
  9520. // A simple way to check for HTML strings
  9521. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9522. // Strict HTML recognition (#11290: must start with <)
  9523. // Shortcut simple #id case for speed
  9524. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9525. init = jQuery.fn.init = function( selector, context, root ) {
  9526. var match, elem;
  9527. // HANDLE: $(""), $(null), $(undefined), $(false)
  9528. if ( !selector ) {
  9529. return this;
  9530. }
  9531. // Method init() accepts an alternate rootjQuery
  9532. // so migrate can support jQuery.sub (gh-2101)
  9533. root = root || rootjQuery;
  9534. // Handle HTML strings
  9535. if ( typeof selector === "string" ) {
  9536. if ( selector[ 0 ] === "<" &&
  9537. selector[ selector.length - 1 ] === ">" &&
  9538. selector.length >= 3 ) {
  9539. // Assume that strings that start and end with <> are HTML and skip the regex check
  9540. match = [ null, selector, null ];
  9541. } else {
  9542. match = rquickExpr.exec( selector );
  9543. }
  9544. // Match html or make sure no context is specified for #id
  9545. if ( match && ( match[ 1 ] || !context ) ) {
  9546. // HANDLE: $(html) -> $(array)
  9547. if ( match[ 1 ] ) {
  9548. context = context instanceof jQuery ? context[ 0 ] : context;
  9549. // Option to run scripts is true for back-compat
  9550. // Intentionally let the error be thrown if parseHTML is not present
  9551. jQuery.merge( this, jQuery.parseHTML(
  9552. match[ 1 ],
  9553. context && context.nodeType ? context.ownerDocument || context : document,
  9554. true
  9555. ) );
  9556. // HANDLE: $(html, props)
  9557. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9558. for ( match in context ) {
  9559. // Properties of context are called as methods if possible
  9560. if ( isFunction( this[ match ] ) ) {
  9561. this[ match ]( context[ match ] );
  9562. // ...and otherwise set as attributes
  9563. } else {
  9564. this.attr( match, context[ match ] );
  9565. }
  9566. }
  9567. }
  9568. return this;
  9569. // HANDLE: $(#id)
  9570. } else {
  9571. elem = document.getElementById( match[ 2 ] );
  9572. if ( elem ) {
  9573. // Inject the element directly into the jQuery object
  9574. this[ 0 ] = elem;
  9575. this.length = 1;
  9576. }
  9577. return this;
  9578. }
  9579. // HANDLE: $(expr, $(...))
  9580. } else if ( !context || context.jquery ) {
  9581. return ( context || root ).find( selector );
  9582. // HANDLE: $(expr, context)
  9583. // (which is just equivalent to: $(context).find(expr)
  9584. } else {
  9585. return this.constructor( context ).find( selector );
  9586. }
  9587. // HANDLE: $(DOMElement)
  9588. } else if ( selector.nodeType ) {
  9589. this[ 0 ] = selector;
  9590. this.length = 1;
  9591. return this;
  9592. // HANDLE: $(function)
  9593. // Shortcut for document ready
  9594. } else if ( isFunction( selector ) ) {
  9595. return root.ready !== undefined ?
  9596. root.ready( selector ) :
  9597. // Execute immediately if ready is not present
  9598. selector( jQuery );
  9599. }
  9600. return jQuery.makeArray( selector, this );
  9601. };
  9602. // Give the init function the jQuery prototype for later instantiation
  9603. init.prototype = jQuery.fn;
  9604. // Initialize central reference
  9605. rootjQuery = jQuery( document );
  9606. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9607. // Methods guaranteed to produce a unique set when starting from a unique set
  9608. guaranteedUnique = {
  9609. children: true,
  9610. contents: true,
  9611. next: true,
  9612. prev: true
  9613. };
  9614. jQuery.fn.extend( {
  9615. has: function( target ) {
  9616. var targets = jQuery( target, this ),
  9617. l = targets.length;
  9618. return this.filter( function() {
  9619. var i = 0;
  9620. for ( ; i < l; i++ ) {
  9621. if ( jQuery.contains( this, targets[ i ] ) ) {
  9622. return true;
  9623. }
  9624. }
  9625. } );
  9626. },
  9627. closest: function( selectors, context ) {
  9628. var cur,
  9629. i = 0,
  9630. l = this.length,
  9631. matched = [],
  9632. targets = typeof selectors !== "string" && jQuery( selectors );
  9633. // Positional selectors never match, since there's no _selection_ context
  9634. if ( !rneedsContext.test( selectors ) ) {
  9635. for ( ; i < l; i++ ) {
  9636. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9637. // Always skip document fragments
  9638. if ( cur.nodeType < 11 && ( targets ?
  9639. targets.index( cur ) > -1 :
  9640. // Don't pass non-elements to Sizzle
  9641. cur.nodeType === 1 &&
  9642. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9643. matched.push( cur );
  9644. break;
  9645. }
  9646. }
  9647. }
  9648. }
  9649. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9650. },
  9651. // Determine the position of an element within the set
  9652. index: function( elem ) {
  9653. // No argument, return index in parent
  9654. if ( !elem ) {
  9655. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9656. }
  9657. // Index in selector
  9658. if ( typeof elem === "string" ) {
  9659. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9660. }
  9661. // Locate the position of the desired element
  9662. return indexOf.call( this,
  9663. // If it receives a jQuery object, the first element is used
  9664. elem.jquery ? elem[ 0 ] : elem
  9665. );
  9666. },
  9667. add: function( selector, context ) {
  9668. return this.pushStack(
  9669. jQuery.uniqueSort(
  9670. jQuery.merge( this.get(), jQuery( selector, context ) )
  9671. )
  9672. );
  9673. },
  9674. addBack: function( selector ) {
  9675. return this.add( selector == null ?
  9676. this.prevObject : this.prevObject.filter( selector )
  9677. );
  9678. }
  9679. } );
  9680. function sibling( cur, dir ) {
  9681. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9682. return cur;
  9683. }
  9684. jQuery.each( {
  9685. parent: function( elem ) {
  9686. var parent = elem.parentNode;
  9687. return parent && parent.nodeType !== 11 ? parent : null;
  9688. },
  9689. parents: function( elem ) {
  9690. return dir( elem, "parentNode" );
  9691. },
  9692. parentsUntil: function( elem, i, until ) {
  9693. return dir( elem, "parentNode", until );
  9694. },
  9695. next: function( elem ) {
  9696. return sibling( elem, "nextSibling" );
  9697. },
  9698. prev: function( elem ) {
  9699. return sibling( elem, "previousSibling" );
  9700. },
  9701. nextAll: function( elem ) {
  9702. return dir( elem, "nextSibling" );
  9703. },
  9704. prevAll: function( elem ) {
  9705. return dir( elem, "previousSibling" );
  9706. },
  9707. nextUntil: function( elem, i, until ) {
  9708. return dir( elem, "nextSibling", until );
  9709. },
  9710. prevUntil: function( elem, i, until ) {
  9711. return dir( elem, "previousSibling", until );
  9712. },
  9713. siblings: function( elem ) {
  9714. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9715. },
  9716. children: function( elem ) {
  9717. return siblings( elem.firstChild );
  9718. },
  9719. contents: function( elem ) {
  9720. if ( typeof elem.contentDocument !== "undefined" ) {
  9721. return elem.contentDocument;
  9722. }
  9723. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9724. // Treat the template element as a regular one in browsers that
  9725. // don't support it.
  9726. if ( nodeName( elem, "template" ) ) {
  9727. elem = elem.content || elem;
  9728. }
  9729. return jQuery.merge( [], elem.childNodes );
  9730. }
  9731. }, function( name, fn ) {
  9732. jQuery.fn[ name ] = function( until, selector ) {
  9733. var matched = jQuery.map( this, fn, until );
  9734. if ( name.slice( -5 ) !== "Until" ) {
  9735. selector = until;
  9736. }
  9737. if ( selector && typeof selector === "string" ) {
  9738. matched = jQuery.filter( selector, matched );
  9739. }
  9740. if ( this.length > 1 ) {
  9741. // Remove duplicates
  9742. if ( !guaranteedUnique[ name ] ) {
  9743. jQuery.uniqueSort( matched );
  9744. }
  9745. // Reverse order for parents* and prev-derivatives
  9746. if ( rparentsprev.test( name ) ) {
  9747. matched.reverse();
  9748. }
  9749. }
  9750. return this.pushStack( matched );
  9751. };
  9752. } );
  9753. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9754. // Convert String-formatted options into Object-formatted ones
  9755. function createOptions( options ) {
  9756. var object = {};
  9757. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9758. object[ flag ] = true;
  9759. } );
  9760. return object;
  9761. }
  9762. /*
  9763. * Create a callback list using the following parameters:
  9764. *
  9765. * options: an optional list of space-separated options that will change how
  9766. * the callback list behaves or a more traditional option object
  9767. *
  9768. * By default a callback list will act like an event callback list and can be
  9769. * "fired" multiple times.
  9770. *
  9771. * Possible options:
  9772. *
  9773. * once: will ensure the callback list can only be fired once (like a Deferred)
  9774. *
  9775. * memory: will keep track of previous values and will call any callback added
  9776. * after the list has been fired right away with the latest "memorized"
  9777. * values (like a Deferred)
  9778. *
  9779. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9780. *
  9781. * stopOnFalse: interrupt callings when a callback returns false
  9782. *
  9783. */
  9784. jQuery.Callbacks = function( options ) {
  9785. // Convert options from String-formatted to Object-formatted if needed
  9786. // (we check in cache first)
  9787. options = typeof options === "string" ?
  9788. createOptions( options ) :
  9789. jQuery.extend( {}, options );
  9790. var // Flag to know if list is currently firing
  9791. firing,
  9792. // Last fire value for non-forgettable lists
  9793. memory,
  9794. // Flag to know if list was already fired
  9795. fired,
  9796. // Flag to prevent firing
  9797. locked,
  9798. // Actual callback list
  9799. list = [],
  9800. // Queue of execution data for repeatable lists
  9801. queue = [],
  9802. // Index of currently firing callback (modified by add/remove as needed)
  9803. firingIndex = -1,
  9804. // Fire callbacks
  9805. fire = function() {
  9806. // Enforce single-firing
  9807. locked = locked || options.once;
  9808. // Execute callbacks for all pending executions,
  9809. // respecting firingIndex overrides and runtime changes
  9810. fired = firing = true;
  9811. for ( ; queue.length; firingIndex = -1 ) {
  9812. memory = queue.shift();
  9813. while ( ++firingIndex < list.length ) {
  9814. // Run callback and check for early termination
  9815. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9816. options.stopOnFalse ) {
  9817. // Jump to end and forget the data so .add doesn't re-fire
  9818. firingIndex = list.length;
  9819. memory = false;
  9820. }
  9821. }
  9822. }
  9823. // Forget the data if we're done with it
  9824. if ( !options.memory ) {
  9825. memory = false;
  9826. }
  9827. firing = false;
  9828. // Clean up if we're done firing for good
  9829. if ( locked ) {
  9830. // Keep an empty list if we have data for future add calls
  9831. if ( memory ) {
  9832. list = [];
  9833. // Otherwise, this object is spent
  9834. } else {
  9835. list = "";
  9836. }
  9837. }
  9838. },
  9839. // Actual Callbacks object
  9840. self = {
  9841. // Add a callback or a collection of callbacks to the list
  9842. add: function() {
  9843. if ( list ) {
  9844. // If we have memory from a past run, we should fire after adding
  9845. if ( memory && !firing ) {
  9846. firingIndex = list.length - 1;
  9847. queue.push( memory );
  9848. }
  9849. ( function add( args ) {
  9850. jQuery.each( args, function( _, arg ) {
  9851. if ( isFunction( arg ) ) {
  9852. if ( !options.unique || !self.has( arg ) ) {
  9853. list.push( arg );
  9854. }
  9855. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9856. // Inspect recursively
  9857. add( arg );
  9858. }
  9859. } );
  9860. } )( arguments );
  9861. if ( memory && !firing ) {
  9862. fire();
  9863. }
  9864. }
  9865. return this;
  9866. },
  9867. // Remove a callback from the list
  9868. remove: function() {
  9869. jQuery.each( arguments, function( _, arg ) {
  9870. var index;
  9871. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9872. list.splice( index, 1 );
  9873. // Handle firing indexes
  9874. if ( index <= firingIndex ) {
  9875. firingIndex--;
  9876. }
  9877. }
  9878. } );
  9879. return this;
  9880. },
  9881. // Check if a given callback is in the list.
  9882. // If no argument is given, return whether or not list has callbacks attached.
  9883. has: function( fn ) {
  9884. return fn ?
  9885. jQuery.inArray( fn, list ) > -1 :
  9886. list.length > 0;
  9887. },
  9888. // Remove all callbacks from the list
  9889. empty: function() {
  9890. if ( list ) {
  9891. list = [];
  9892. }
  9893. return this;
  9894. },
  9895. // Disable .fire and .add
  9896. // Abort any current/pending executions
  9897. // Clear all callbacks and values
  9898. disable: function() {
  9899. locked = queue = [];
  9900. list = memory = "";
  9901. return this;
  9902. },
  9903. disabled: function() {
  9904. return !list;
  9905. },
  9906. // Disable .fire
  9907. // Also disable .add unless we have memory (since it would have no effect)
  9908. // Abort any pending executions
  9909. lock: function() {
  9910. locked = queue = [];
  9911. if ( !memory && !firing ) {
  9912. list = memory = "";
  9913. }
  9914. return this;
  9915. },
  9916. locked: function() {
  9917. return !!locked;
  9918. },
  9919. // Call all callbacks with the given context and arguments
  9920. fireWith: function( context, args ) {
  9921. if ( !locked ) {
  9922. args = args || [];
  9923. args = [ context, args.slice ? args.slice() : args ];
  9924. queue.push( args );
  9925. if ( !firing ) {
  9926. fire();
  9927. }
  9928. }
  9929. return this;
  9930. },
  9931. // Call all the callbacks with the given arguments
  9932. fire: function() {
  9933. self.fireWith( this, arguments );
  9934. return this;
  9935. },
  9936. // To know if the callbacks have already been called at least once
  9937. fired: function() {
  9938. return !!fired;
  9939. }
  9940. };
  9941. return self;
  9942. };
  9943. function Identity( v ) {
  9944. return v;
  9945. }
  9946. function Thrower( ex ) {
  9947. throw ex;
  9948. }
  9949. function adoptValue( value, resolve, reject, noValue ) {
  9950. var method;
  9951. try {
  9952. // Check for promise aspect first to privilege synchronous behavior
  9953. if ( value && isFunction( ( method = value.promise ) ) ) {
  9954. method.call( value ).done( resolve ).fail( reject );
  9955. // Other thenables
  9956. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9957. method.call( value, resolve, reject );
  9958. // Other non-thenables
  9959. } else {
  9960. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9961. // * false: [ value ].slice( 0 ) => resolve( value )
  9962. // * true: [ value ].slice( 1 ) => resolve()
  9963. resolve.apply( undefined, [ value ].slice( noValue ) );
  9964. }
  9965. // For Promises/A+, convert exceptions into rejections
  9966. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  9967. // Deferred#then to conditionally suppress rejection.
  9968. } catch ( value ) {
  9969. // Support: Android 4.0 only
  9970. // Strict mode functions invoked without .call/.apply get global-object context
  9971. reject.apply( undefined, [ value ] );
  9972. }
  9973. }
  9974. jQuery.extend( {
  9975. Deferred: function( func ) {
  9976. var tuples = [
  9977. // action, add listener, callbacks,
  9978. // ... .then handlers, argument index, [final state]
  9979. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  9980. jQuery.Callbacks( "memory" ), 2 ],
  9981. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  9982. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  9983. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  9984. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  9985. ],
  9986. state = "pending",
  9987. promise = {
  9988. state: function() {
  9989. return state;
  9990. },
  9991. always: function() {
  9992. deferred.done( arguments ).fail( arguments );
  9993. return this;
  9994. },
  9995. "catch": function( fn ) {
  9996. return promise.then( null, fn );
  9997. },
  9998. // Keep pipe for back-compat
  9999. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10000. var fns = arguments;
  10001. return jQuery.Deferred( function( newDefer ) {
  10002. jQuery.each( tuples, function( i, tuple ) {
  10003. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10004. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10005. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10006. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10007. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10008. deferred[ tuple[ 1 ] ]( function() {
  10009. var returned = fn && fn.apply( this, arguments );
  10010. if ( returned && isFunction( returned.promise ) ) {
  10011. returned.promise()
  10012. .progress( newDefer.notify )
  10013. .done( newDefer.resolve )
  10014. .fail( newDefer.reject );
  10015. } else {
  10016. newDefer[ tuple[ 0 ] + "With" ](
  10017. this,
  10018. fn ? [ returned ] : arguments
  10019. );
  10020. }
  10021. } );
  10022. } );
  10023. fns = null;
  10024. } ).promise();
  10025. },
  10026. then: function( onFulfilled, onRejected, onProgress ) {
  10027. var maxDepth = 0;
  10028. function resolve( depth, deferred, handler, special ) {
  10029. return function() {
  10030. var that = this,
  10031. args = arguments,
  10032. mightThrow = function() {
  10033. var returned, then;
  10034. // Support: Promises/A+ section 2.3.3.3.3
  10035. // https://promisesaplus.com/#point-59
  10036. // Ignore double-resolution attempts
  10037. if ( depth < maxDepth ) {
  10038. return;
  10039. }
  10040. returned = handler.apply( that, args );
  10041. // Support: Promises/A+ section 2.3.1
  10042. // https://promisesaplus.com/#point-48
  10043. if ( returned === deferred.promise() ) {
  10044. throw new TypeError( "Thenable self-resolution" );
  10045. }
  10046. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10047. // https://promisesaplus.com/#point-54
  10048. // https://promisesaplus.com/#point-75
  10049. // Retrieve `then` only once
  10050. then = returned &&
  10051. // Support: Promises/A+ section 2.3.4
  10052. // https://promisesaplus.com/#point-64
  10053. // Only check objects and functions for thenability
  10054. ( typeof returned === "object" ||
  10055. typeof returned === "function" ) &&
  10056. returned.then;
  10057. // Handle a returned thenable
  10058. if ( isFunction( then ) ) {
  10059. // Special processors (notify) just wait for resolution
  10060. if ( special ) {
  10061. then.call(
  10062. returned,
  10063. resolve( maxDepth, deferred, Identity, special ),
  10064. resolve( maxDepth, deferred, Thrower, special )
  10065. );
  10066. // Normal processors (resolve) also hook into progress
  10067. } else {
  10068. // ...and disregard older resolution values
  10069. maxDepth++;
  10070. then.call(
  10071. returned,
  10072. resolve( maxDepth, deferred, Identity, special ),
  10073. resolve( maxDepth, deferred, Thrower, special ),
  10074. resolve( maxDepth, deferred, Identity,
  10075. deferred.notifyWith )
  10076. );
  10077. }
  10078. // Handle all other returned values
  10079. } else {
  10080. // Only substitute handlers pass on context
  10081. // and multiple values (non-spec behavior)
  10082. if ( handler !== Identity ) {
  10083. that = undefined;
  10084. args = [ returned ];
  10085. }
  10086. // Process the value(s)
  10087. // Default process is resolve
  10088. ( special || deferred.resolveWith )( that, args );
  10089. }
  10090. },
  10091. // Only normal processors (resolve) catch and reject exceptions
  10092. process = special ?
  10093. mightThrow :
  10094. function() {
  10095. try {
  10096. mightThrow();
  10097. } catch ( e ) {
  10098. if ( jQuery.Deferred.exceptionHook ) {
  10099. jQuery.Deferred.exceptionHook( e,
  10100. process.stackTrace );
  10101. }
  10102. // Support: Promises/A+ section 2.3.3.3.4.1
  10103. // https://promisesaplus.com/#point-61
  10104. // Ignore post-resolution exceptions
  10105. if ( depth + 1 >= maxDepth ) {
  10106. // Only substitute handlers pass on context
  10107. // and multiple values (non-spec behavior)
  10108. if ( handler !== Thrower ) {
  10109. that = undefined;
  10110. args = [ e ];
  10111. }
  10112. deferred.rejectWith( that, args );
  10113. }
  10114. }
  10115. };
  10116. // Support: Promises/A+ section 2.3.3.3.1
  10117. // https://promisesaplus.com/#point-57
  10118. // Re-resolve promises immediately to dodge false rejection from
  10119. // subsequent errors
  10120. if ( depth ) {
  10121. process();
  10122. } else {
  10123. // Call an optional hook to record the stack, in case of exception
  10124. // since it's otherwise lost when execution goes async
  10125. if ( jQuery.Deferred.getStackHook ) {
  10126. process.stackTrace = jQuery.Deferred.getStackHook();
  10127. }
  10128. window.setTimeout( process );
  10129. }
  10130. };
  10131. }
  10132. return jQuery.Deferred( function( newDefer ) {
  10133. // progress_handlers.add( ... )
  10134. tuples[ 0 ][ 3 ].add(
  10135. resolve(
  10136. 0,
  10137. newDefer,
  10138. isFunction( onProgress ) ?
  10139. onProgress :
  10140. Identity,
  10141. newDefer.notifyWith
  10142. )
  10143. );
  10144. // fulfilled_handlers.add( ... )
  10145. tuples[ 1 ][ 3 ].add(
  10146. resolve(
  10147. 0,
  10148. newDefer,
  10149. isFunction( onFulfilled ) ?
  10150. onFulfilled :
  10151. Identity
  10152. )
  10153. );
  10154. // rejected_handlers.add( ... )
  10155. tuples[ 2 ][ 3 ].add(
  10156. resolve(
  10157. 0,
  10158. newDefer,
  10159. isFunction( onRejected ) ?
  10160. onRejected :
  10161. Thrower
  10162. )
  10163. );
  10164. } ).promise();
  10165. },
  10166. // Get a promise for this deferred
  10167. // If obj is provided, the promise aspect is added to the object
  10168. promise: function( obj ) {
  10169. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10170. }
  10171. },
  10172. deferred = {};
  10173. // Add list-specific methods
  10174. jQuery.each( tuples, function( i, tuple ) {
  10175. var list = tuple[ 2 ],
  10176. stateString = tuple[ 5 ];
  10177. // promise.progress = list.add
  10178. // promise.done = list.add
  10179. // promise.fail = list.add
  10180. promise[ tuple[ 1 ] ] = list.add;
  10181. // Handle state
  10182. if ( stateString ) {
  10183. list.add(
  10184. function() {
  10185. // state = "resolved" (i.e., fulfilled)
  10186. // state = "rejected"
  10187. state = stateString;
  10188. },
  10189. // rejected_callbacks.disable
  10190. // fulfilled_callbacks.disable
  10191. tuples[ 3 - i ][ 2 ].disable,
  10192. // rejected_handlers.disable
  10193. // fulfilled_handlers.disable
  10194. tuples[ 3 - i ][ 3 ].disable,
  10195. // progress_callbacks.lock
  10196. tuples[ 0 ][ 2 ].lock,
  10197. // progress_handlers.lock
  10198. tuples[ 0 ][ 3 ].lock
  10199. );
  10200. }
  10201. // progress_handlers.fire
  10202. // fulfilled_handlers.fire
  10203. // rejected_handlers.fire
  10204. list.add( tuple[ 3 ].fire );
  10205. // deferred.notify = function() { deferred.notifyWith(...) }
  10206. // deferred.resolve = function() { deferred.resolveWith(...) }
  10207. // deferred.reject = function() { deferred.rejectWith(...) }
  10208. deferred[ tuple[ 0 ] ] = function() {
  10209. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10210. return this;
  10211. };
  10212. // deferred.notifyWith = list.fireWith
  10213. // deferred.resolveWith = list.fireWith
  10214. // deferred.rejectWith = list.fireWith
  10215. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10216. } );
  10217. // Make the deferred a promise
  10218. promise.promise( deferred );
  10219. // Call given func if any
  10220. if ( func ) {
  10221. func.call( deferred, deferred );
  10222. }
  10223. // All done!
  10224. return deferred;
  10225. },
  10226. // Deferred helper
  10227. when: function( singleValue ) {
  10228. var
  10229. // count of uncompleted subordinates
  10230. remaining = arguments.length,
  10231. // count of unprocessed arguments
  10232. i = remaining,
  10233. // subordinate fulfillment data
  10234. resolveContexts = Array( i ),
  10235. resolveValues = slice.call( arguments ),
  10236. // the master Deferred
  10237. master = jQuery.Deferred(),
  10238. // subordinate callback factory
  10239. updateFunc = function( i ) {
  10240. return function( value ) {
  10241. resolveContexts[ i ] = this;
  10242. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10243. if ( !( --remaining ) ) {
  10244. master.resolveWith( resolveContexts, resolveValues );
  10245. }
  10246. };
  10247. };
  10248. // Single- and empty arguments are adopted like Promise.resolve
  10249. if ( remaining <= 1 ) {
  10250. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10251. !remaining );
  10252. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10253. if ( master.state() === "pending" ||
  10254. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10255. return master.then();
  10256. }
  10257. }
  10258. // Multiple arguments are aggregated like Promise.all array elements
  10259. while ( i-- ) {
  10260. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10261. }
  10262. return master.promise();
  10263. }
  10264. } );
  10265. // These usually indicate a programmer mistake during development,
  10266. // warn about them ASAP rather than swallowing them by default.
  10267. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10268. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10269. // Support: IE 8 - 9 only
  10270. // Console exists when dev tools are open, which can happen at any time
  10271. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10272. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10273. }
  10274. };
  10275. jQuery.readyException = function( error ) {
  10276. window.setTimeout( function() {
  10277. throw error;
  10278. } );
  10279. };
  10280. // The deferred used on DOM ready
  10281. var readyList = jQuery.Deferred();
  10282. jQuery.fn.ready = function( fn ) {
  10283. readyList
  10284. .then( fn )
  10285. // Wrap jQuery.readyException in a function so that the lookup
  10286. // happens at the time of error handling instead of callback
  10287. // registration.
  10288. .catch( function( error ) {
  10289. jQuery.readyException( error );
  10290. } );
  10291. return this;
  10292. };
  10293. jQuery.extend( {
  10294. // Is the DOM ready to be used? Set to true once it occurs.
  10295. isReady: false,
  10296. // A counter to track how many items to wait for before
  10297. // the ready event fires. See #6781
  10298. readyWait: 1,
  10299. // Handle when the DOM is ready
  10300. ready: function( wait ) {
  10301. // Abort if there are pending holds or we're already ready
  10302. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10303. return;
  10304. }
  10305. // Remember that the DOM is ready
  10306. jQuery.isReady = true;
  10307. // If a normal DOM Ready event fired, decrement, and wait if need be
  10308. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10309. return;
  10310. }
  10311. // If there are functions bound, to execute
  10312. readyList.resolveWith( document, [ jQuery ] );
  10313. }
  10314. } );
  10315. jQuery.ready.then = readyList.then;
  10316. // The ready event handler and self cleanup method
  10317. function completed() {
  10318. document.removeEventListener( "DOMContentLoaded", completed );
  10319. window.removeEventListener( "load", completed );
  10320. jQuery.ready();
  10321. }
  10322. // Catch cases where $(document).ready() is called
  10323. // after the browser event has already occurred.
  10324. // Support: IE <=9 - 10 only
  10325. // Older IE sometimes signals "interactive" too soon
  10326. if ( document.readyState === "complete" ||
  10327. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10328. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10329. window.setTimeout( jQuery.ready );
  10330. } else {
  10331. // Use the handy event callback
  10332. document.addEventListener( "DOMContentLoaded", completed );
  10333. // A fallback to window.onload, that will always work
  10334. window.addEventListener( "load", completed );
  10335. }
  10336. // Multifunctional method to get and set values of a collection
  10337. // The value/s can optionally be executed if it's a function
  10338. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10339. var i = 0,
  10340. len = elems.length,
  10341. bulk = key == null;
  10342. // Sets many values
  10343. if ( toType( key ) === "object" ) {
  10344. chainable = true;
  10345. for ( i in key ) {
  10346. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10347. }
  10348. // Sets one value
  10349. } else if ( value !== undefined ) {
  10350. chainable = true;
  10351. if ( !isFunction( value ) ) {
  10352. raw = true;
  10353. }
  10354. if ( bulk ) {
  10355. // Bulk operations run against the entire set
  10356. if ( raw ) {
  10357. fn.call( elems, value );
  10358. fn = null;
  10359. // ...except when executing function values
  10360. } else {
  10361. bulk = fn;
  10362. fn = function( elem, key, value ) {
  10363. return bulk.call( jQuery( elem ), value );
  10364. };
  10365. }
  10366. }
  10367. if ( fn ) {
  10368. for ( ; i < len; i++ ) {
  10369. fn(
  10370. elems[ i ], key, raw ?
  10371. value :
  10372. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10373. );
  10374. }
  10375. }
  10376. }
  10377. if ( chainable ) {
  10378. return elems;
  10379. }
  10380. // Gets
  10381. if ( bulk ) {
  10382. return fn.call( elems );
  10383. }
  10384. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10385. };
  10386. // Matches dashed string for camelizing
  10387. var rmsPrefix = /^-ms-/,
  10388. rdashAlpha = /-([a-z])/g;
  10389. // Used by camelCase as callback to replace()
  10390. function fcamelCase( all, letter ) {
  10391. return letter.toUpperCase();
  10392. }
  10393. // Convert dashed to camelCase; used by the css and data modules
  10394. // Support: IE <=9 - 11, Edge 12 - 15
  10395. // Microsoft forgot to hump their vendor prefix (#9572)
  10396. function camelCase( string ) {
  10397. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10398. }
  10399. var acceptData = function( owner ) {
  10400. // Accepts only:
  10401. // - Node
  10402. // - Node.ELEMENT_NODE
  10403. // - Node.DOCUMENT_NODE
  10404. // - Object
  10405. // - Any
  10406. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10407. };
  10408. function Data() {
  10409. this.expando = jQuery.expando + Data.uid++;
  10410. }
  10411. Data.uid = 1;
  10412. Data.prototype = {
  10413. cache: function( owner ) {
  10414. // Check if the owner object already has a cache
  10415. var value = owner[ this.expando ];
  10416. // If not, create one
  10417. if ( !value ) {
  10418. value = {};
  10419. // We can accept data for non-element nodes in modern browsers,
  10420. // but we should not, see #8335.
  10421. // Always return an empty object.
  10422. if ( acceptData( owner ) ) {
  10423. // If it is a node unlikely to be stringify-ed or looped over
  10424. // use plain assignment
  10425. if ( owner.nodeType ) {
  10426. owner[ this.expando ] = value;
  10427. // Otherwise secure it in a non-enumerable property
  10428. // configurable must be true to allow the property to be
  10429. // deleted when data is removed
  10430. } else {
  10431. Object.defineProperty( owner, this.expando, {
  10432. value: value,
  10433. configurable: true
  10434. } );
  10435. }
  10436. }
  10437. }
  10438. return value;
  10439. },
  10440. set: function( owner, data, value ) {
  10441. var prop,
  10442. cache = this.cache( owner );
  10443. // Handle: [ owner, key, value ] args
  10444. // Always use camelCase key (gh-2257)
  10445. if ( typeof data === "string" ) {
  10446. cache[ camelCase( data ) ] = value;
  10447. // Handle: [ owner, { properties } ] args
  10448. } else {
  10449. // Copy the properties one-by-one to the cache object
  10450. for ( prop in data ) {
  10451. cache[ camelCase( prop ) ] = data[ prop ];
  10452. }
  10453. }
  10454. return cache;
  10455. },
  10456. get: function( owner, key ) {
  10457. return key === undefined ?
  10458. this.cache( owner ) :
  10459. // Always use camelCase key (gh-2257)
  10460. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10461. },
  10462. access: function( owner, key, value ) {
  10463. // In cases where either:
  10464. //
  10465. // 1. No key was specified
  10466. // 2. A string key was specified, but no value provided
  10467. //
  10468. // Take the "read" path and allow the get method to determine
  10469. // which value to return, respectively either:
  10470. //
  10471. // 1. The entire cache object
  10472. // 2. The data stored at the key
  10473. //
  10474. if ( key === undefined ||
  10475. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10476. return this.get( owner, key );
  10477. }
  10478. // When the key is not a string, or both a key and value
  10479. // are specified, set or extend (existing objects) with either:
  10480. //
  10481. // 1. An object of properties
  10482. // 2. A key and value
  10483. //
  10484. this.set( owner, key, value );
  10485. // Since the "set" path can have two possible entry points
  10486. // return the expected data based on which path was taken[*]
  10487. return value !== undefined ? value : key;
  10488. },
  10489. remove: function( owner, key ) {
  10490. var i,
  10491. cache = owner[ this.expando ];
  10492. if ( cache === undefined ) {
  10493. return;
  10494. }
  10495. if ( key !== undefined ) {
  10496. // Support array or space separated string of keys
  10497. if ( Array.isArray( key ) ) {
  10498. // If key is an array of keys...
  10499. // We always set camelCase keys, so remove that.
  10500. key = key.map( camelCase );
  10501. } else {
  10502. key = camelCase( key );
  10503. // If a key with the spaces exists, use it.
  10504. // Otherwise, create an array by matching non-whitespace
  10505. key = key in cache ?
  10506. [ key ] :
  10507. ( key.match( rnothtmlwhite ) || [] );
  10508. }
  10509. i = key.length;
  10510. while ( i-- ) {
  10511. delete cache[ key[ i ] ];
  10512. }
  10513. }
  10514. // Remove the expando if there's no more data
  10515. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10516. // Support: Chrome <=35 - 45
  10517. // Webkit & Blink performance suffers when deleting properties
  10518. // from DOM nodes, so set to undefined instead
  10519. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10520. if ( owner.nodeType ) {
  10521. owner[ this.expando ] = undefined;
  10522. } else {
  10523. delete owner[ this.expando ];
  10524. }
  10525. }
  10526. },
  10527. hasData: function( owner ) {
  10528. var cache = owner[ this.expando ];
  10529. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10530. }
  10531. };
  10532. var dataPriv = new Data();
  10533. var dataUser = new Data();
  10534. // Implementation Summary
  10535. //
  10536. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10537. // 2. Improve the module's maintainability by reducing the storage
  10538. // paths to a single mechanism.
  10539. // 3. Use the same single mechanism to support "private" and "user" data.
  10540. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10541. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10542. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10543. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10544. rmultiDash = /[A-Z]/g;
  10545. function getData( data ) {
  10546. if ( data === "true" ) {
  10547. return true;
  10548. }
  10549. if ( data === "false" ) {
  10550. return false;
  10551. }
  10552. if ( data === "null" ) {
  10553. return null;
  10554. }
  10555. // Only convert to a number if it doesn't change the string
  10556. if ( data === +data + "" ) {
  10557. return +data;
  10558. }
  10559. if ( rbrace.test( data ) ) {
  10560. return JSON.parse( data );
  10561. }
  10562. return data;
  10563. }
  10564. function dataAttr( elem, key, data ) {
  10565. var name;
  10566. // If nothing was found internally, try to fetch any
  10567. // data from the HTML5 data-* attribute
  10568. if ( data === undefined && elem.nodeType === 1 ) {
  10569. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10570. data = elem.getAttribute( name );
  10571. if ( typeof data === "string" ) {
  10572. try {
  10573. data = getData( data );
  10574. } catch ( e ) {}
  10575. // Make sure we set the data so it isn't changed later
  10576. dataUser.set( elem, key, data );
  10577. } else {
  10578. data = undefined;
  10579. }
  10580. }
  10581. return data;
  10582. }
  10583. jQuery.extend( {
  10584. hasData: function( elem ) {
  10585. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10586. },
  10587. data: function( elem, name, data ) {
  10588. return dataUser.access( elem, name, data );
  10589. },
  10590. removeData: function( elem, name ) {
  10591. dataUser.remove( elem, name );
  10592. },
  10593. // TODO: Now that all calls to _data and _removeData have been replaced
  10594. // with direct calls to dataPriv methods, these can be deprecated.
  10595. _data: function( elem, name, data ) {
  10596. return dataPriv.access( elem, name, data );
  10597. },
  10598. _removeData: function( elem, name ) {
  10599. dataPriv.remove( elem, name );
  10600. }
  10601. } );
  10602. jQuery.fn.extend( {
  10603. data: function( key, value ) {
  10604. var i, name, data,
  10605. elem = this[ 0 ],
  10606. attrs = elem && elem.attributes;
  10607. // Gets all values
  10608. if ( key === undefined ) {
  10609. if ( this.length ) {
  10610. data = dataUser.get( elem );
  10611. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10612. i = attrs.length;
  10613. while ( i-- ) {
  10614. // Support: IE 11 only
  10615. // The attrs elements can be null (#14894)
  10616. if ( attrs[ i ] ) {
  10617. name = attrs[ i ].name;
  10618. if ( name.indexOf( "data-" ) === 0 ) {
  10619. name = camelCase( name.slice( 5 ) );
  10620. dataAttr( elem, name, data[ name ] );
  10621. }
  10622. }
  10623. }
  10624. dataPriv.set( elem, "hasDataAttrs", true );
  10625. }
  10626. }
  10627. return data;
  10628. }
  10629. // Sets multiple values
  10630. if ( typeof key === "object" ) {
  10631. return this.each( function() {
  10632. dataUser.set( this, key );
  10633. } );
  10634. }
  10635. return access( this, function( value ) {
  10636. var data;
  10637. // The calling jQuery object (element matches) is not empty
  10638. // (and therefore has an element appears at this[ 0 ]) and the
  10639. // `value` parameter was not undefined. An empty jQuery object
  10640. // will result in `undefined` for elem = this[ 0 ] which will
  10641. // throw an exception if an attempt to read a data cache is made.
  10642. if ( elem && value === undefined ) {
  10643. // Attempt to get data from the cache
  10644. // The key will always be camelCased in Data
  10645. data = dataUser.get( elem, key );
  10646. if ( data !== undefined ) {
  10647. return data;
  10648. }
  10649. // Attempt to "discover" the data in
  10650. // HTML5 custom data-* attrs
  10651. data = dataAttr( elem, key );
  10652. if ( data !== undefined ) {
  10653. return data;
  10654. }
  10655. // We tried really hard, but the data doesn't exist.
  10656. return;
  10657. }
  10658. // Set the data...
  10659. this.each( function() {
  10660. // We always store the camelCased key
  10661. dataUser.set( this, key, value );
  10662. } );
  10663. }, null, value, arguments.length > 1, null, true );
  10664. },
  10665. removeData: function( key ) {
  10666. return this.each( function() {
  10667. dataUser.remove( this, key );
  10668. } );
  10669. }
  10670. } );
  10671. jQuery.extend( {
  10672. queue: function( elem, type, data ) {
  10673. var queue;
  10674. if ( elem ) {
  10675. type = ( type || "fx" ) + "queue";
  10676. queue = dataPriv.get( elem, type );
  10677. // Speed up dequeue by getting out quickly if this is just a lookup
  10678. if ( data ) {
  10679. if ( !queue || Array.isArray( data ) ) {
  10680. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10681. } else {
  10682. queue.push( data );
  10683. }
  10684. }
  10685. return queue || [];
  10686. }
  10687. },
  10688. dequeue: function( elem, type ) {
  10689. type = type || "fx";
  10690. var queue = jQuery.queue( elem, type ),
  10691. startLength = queue.length,
  10692. fn = queue.shift(),
  10693. hooks = jQuery._queueHooks( elem, type ),
  10694. next = function() {
  10695. jQuery.dequeue( elem, type );
  10696. };
  10697. // If the fx queue is dequeued, always remove the progress sentinel
  10698. if ( fn === "inprogress" ) {
  10699. fn = queue.shift();
  10700. startLength--;
  10701. }
  10702. if ( fn ) {
  10703. // Add a progress sentinel to prevent the fx queue from being
  10704. // automatically dequeued
  10705. if ( type === "fx" ) {
  10706. queue.unshift( "inprogress" );
  10707. }
  10708. // Clear up the last queue stop function
  10709. delete hooks.stop;
  10710. fn.call( elem, next, hooks );
  10711. }
  10712. if ( !startLength && hooks ) {
  10713. hooks.empty.fire();
  10714. }
  10715. },
  10716. // Not public - generate a queueHooks object, or return the current one
  10717. _queueHooks: function( elem, type ) {
  10718. var key = type + "queueHooks";
  10719. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10720. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10721. dataPriv.remove( elem, [ type + "queue", key ] );
  10722. } )
  10723. } );
  10724. }
  10725. } );
  10726. jQuery.fn.extend( {
  10727. queue: function( type, data ) {
  10728. var setter = 2;
  10729. if ( typeof type !== "string" ) {
  10730. data = type;
  10731. type = "fx";
  10732. setter--;
  10733. }
  10734. if ( arguments.length < setter ) {
  10735. return jQuery.queue( this[ 0 ], type );
  10736. }
  10737. return data === undefined ?
  10738. this :
  10739. this.each( function() {
  10740. var queue = jQuery.queue( this, type, data );
  10741. // Ensure a hooks for this queue
  10742. jQuery._queueHooks( this, type );
  10743. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10744. jQuery.dequeue( this, type );
  10745. }
  10746. } );
  10747. },
  10748. dequeue: function( type ) {
  10749. return this.each( function() {
  10750. jQuery.dequeue( this, type );
  10751. } );
  10752. },
  10753. clearQueue: function( type ) {
  10754. return this.queue( type || "fx", [] );
  10755. },
  10756. // Get a promise resolved when queues of a certain type
  10757. // are emptied (fx is the type by default)
  10758. promise: function( type, obj ) {
  10759. var tmp,
  10760. count = 1,
  10761. defer = jQuery.Deferred(),
  10762. elements = this,
  10763. i = this.length,
  10764. resolve = function() {
  10765. if ( !( --count ) ) {
  10766. defer.resolveWith( elements, [ elements ] );
  10767. }
  10768. };
  10769. if ( typeof type !== "string" ) {
  10770. obj = type;
  10771. type = undefined;
  10772. }
  10773. type = type || "fx";
  10774. while ( i-- ) {
  10775. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10776. if ( tmp && tmp.empty ) {
  10777. count++;
  10778. tmp.empty.add( resolve );
  10779. }
  10780. }
  10781. resolve();
  10782. return defer.promise( obj );
  10783. }
  10784. } );
  10785. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10786. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10787. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10788. var documentElement = document.documentElement;
  10789. var isAttached = function( elem ) {
  10790. return jQuery.contains( elem.ownerDocument, elem );
  10791. },
  10792. composed = { composed: true };
  10793. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10794. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10795. // Support: iOS 10.0-10.2 only
  10796. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10797. // leading to errors. We need to check for `getRootNode`.
  10798. if ( documentElement.getRootNode ) {
  10799. isAttached = function( elem ) {
  10800. return jQuery.contains( elem.ownerDocument, elem ) ||
  10801. elem.getRootNode( composed ) === elem.ownerDocument;
  10802. };
  10803. }
  10804. var isHiddenWithinTree = function( elem, el ) {
  10805. // isHiddenWithinTree might be called from jQuery#filter function;
  10806. // in that case, element will be second argument
  10807. elem = el || elem;
  10808. // Inline style trumps all
  10809. return elem.style.display === "none" ||
  10810. elem.style.display === "" &&
  10811. // Otherwise, check computed style
  10812. // Support: Firefox <=43 - 45
  10813. // Disconnected elements can have computed display: none, so first confirm that elem is
  10814. // in the document.
  10815. isAttached( elem ) &&
  10816. jQuery.css( elem, "display" ) === "none";
  10817. };
  10818. var swap = function( elem, options, callback, args ) {
  10819. var ret, name,
  10820. old = {};
  10821. // Remember the old values, and insert the new ones
  10822. for ( name in options ) {
  10823. old[ name ] = elem.style[ name ];
  10824. elem.style[ name ] = options[ name ];
  10825. }
  10826. ret = callback.apply( elem, args || [] );
  10827. // Revert the old values
  10828. for ( name in options ) {
  10829. elem.style[ name ] = old[ name ];
  10830. }
  10831. return ret;
  10832. };
  10833. function adjustCSS( elem, prop, valueParts, tween ) {
  10834. var adjusted, scale,
  10835. maxIterations = 20,
  10836. currentValue = tween ?
  10837. function() {
  10838. return tween.cur();
  10839. } :
  10840. function() {
  10841. return jQuery.css( elem, prop, "" );
  10842. },
  10843. initial = currentValue(),
  10844. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10845. // Starting value computation is required for potential unit mismatches
  10846. initialInUnit = elem.nodeType &&
  10847. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10848. rcssNum.exec( jQuery.css( elem, prop ) );
  10849. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10850. // Support: Firefox <=54
  10851. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10852. initial = initial / 2;
  10853. // Trust units reported by jQuery.css
  10854. unit = unit || initialInUnit[ 3 ];
  10855. // Iteratively approximate from a nonzero starting point
  10856. initialInUnit = +initial || 1;
  10857. while ( maxIterations-- ) {
  10858. // Evaluate and update our best guess (doubling guesses that zero out).
  10859. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10860. jQuery.style( elem, prop, initialInUnit + unit );
  10861. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10862. maxIterations = 0;
  10863. }
  10864. initialInUnit = initialInUnit / scale;
  10865. }
  10866. initialInUnit = initialInUnit * 2;
  10867. jQuery.style( elem, prop, initialInUnit + unit );
  10868. // Make sure we update the tween properties later on
  10869. valueParts = valueParts || [];
  10870. }
  10871. if ( valueParts ) {
  10872. initialInUnit = +initialInUnit || +initial || 0;
  10873. // Apply relative offset (+=/-=) if specified
  10874. adjusted = valueParts[ 1 ] ?
  10875. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10876. +valueParts[ 2 ];
  10877. if ( tween ) {
  10878. tween.unit = unit;
  10879. tween.start = initialInUnit;
  10880. tween.end = adjusted;
  10881. }
  10882. }
  10883. return adjusted;
  10884. }
  10885. var defaultDisplayMap = {};
  10886. function getDefaultDisplay( elem ) {
  10887. var temp,
  10888. doc = elem.ownerDocument,
  10889. nodeName = elem.nodeName,
  10890. display = defaultDisplayMap[ nodeName ];
  10891. if ( display ) {
  10892. return display;
  10893. }
  10894. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10895. display = jQuery.css( temp, "display" );
  10896. temp.parentNode.removeChild( temp );
  10897. if ( display === "none" ) {
  10898. display = "block";
  10899. }
  10900. defaultDisplayMap[ nodeName ] = display;
  10901. return display;
  10902. }
  10903. function showHide( elements, show ) {
  10904. var display, elem,
  10905. values = [],
  10906. index = 0,
  10907. length = elements.length;
  10908. // Determine new display value for elements that need to change
  10909. for ( ; index < length; index++ ) {
  10910. elem = elements[ index ];
  10911. if ( !elem.style ) {
  10912. continue;
  10913. }
  10914. display = elem.style.display;
  10915. if ( show ) {
  10916. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10917. // check is required in this first loop unless we have a nonempty display value (either
  10918. // inline or about-to-be-restored)
  10919. if ( display === "none" ) {
  10920. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10921. if ( !values[ index ] ) {
  10922. elem.style.display = "";
  10923. }
  10924. }
  10925. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10926. values[ index ] = getDefaultDisplay( elem );
  10927. }
  10928. } else {
  10929. if ( display !== "none" ) {
  10930. values[ index ] = "none";
  10931. // Remember what we're overwriting
  10932. dataPriv.set( elem, "display", display );
  10933. }
  10934. }
  10935. }
  10936. // Set the display of the elements in a second loop to avoid constant reflow
  10937. for ( index = 0; index < length; index++ ) {
  10938. if ( values[ index ] != null ) {
  10939. elements[ index ].style.display = values[ index ];
  10940. }
  10941. }
  10942. return elements;
  10943. }
  10944. jQuery.fn.extend( {
  10945. show: function() {
  10946. return showHide( this, true );
  10947. },
  10948. hide: function() {
  10949. return showHide( this );
  10950. },
  10951. toggle: function( state ) {
  10952. if ( typeof state === "boolean" ) {
  10953. return state ? this.show() : this.hide();
  10954. }
  10955. return this.each( function() {
  10956. if ( isHiddenWithinTree( this ) ) {
  10957. jQuery( this ).show();
  10958. } else {
  10959. jQuery( this ).hide();
  10960. }
  10961. } );
  10962. }
  10963. } );
  10964. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  10965. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  10966. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  10967. // We have to close these tags to support XHTML (#13200)
  10968. var wrapMap = {
  10969. // Support: IE <=9 only
  10970. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  10971. // XHTML parsers do not magically insert elements in the
  10972. // same way that tag soup parsers do. So we cannot shorten
  10973. // this by omitting <tbody> or other required elements.
  10974. thead: [ 1, "<table>", "</table>" ],
  10975. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  10976. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  10977. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  10978. _default: [ 0, "", "" ]
  10979. };
  10980. // Support: IE <=9 only
  10981. wrapMap.optgroup = wrapMap.option;
  10982. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  10983. wrapMap.th = wrapMap.td;
  10984. function getAll( context, tag ) {
  10985. // Support: IE <=9 - 11 only
  10986. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  10987. var ret;
  10988. if ( typeof context.getElementsByTagName !== "undefined" ) {
  10989. ret = context.getElementsByTagName( tag || "*" );
  10990. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  10991. ret = context.querySelectorAll( tag || "*" );
  10992. } else {
  10993. ret = [];
  10994. }
  10995. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  10996. return jQuery.merge( [ context ], ret );
  10997. }
  10998. return ret;
  10999. }
  11000. // Mark scripts as having already been evaluated
  11001. function setGlobalEval( elems, refElements ) {
  11002. var i = 0,
  11003. l = elems.length;
  11004. for ( ; i < l; i++ ) {
  11005. dataPriv.set(
  11006. elems[ i ],
  11007. "globalEval",
  11008. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11009. );
  11010. }
  11011. }
  11012. var rhtml = /<|&#?\w+;/;
  11013. function buildFragment( elems, context, scripts, selection, ignored ) {
  11014. var elem, tmp, tag, wrap, attached, j,
  11015. fragment = context.createDocumentFragment(),
  11016. nodes = [],
  11017. i = 0,
  11018. l = elems.length;
  11019. for ( ; i < l; i++ ) {
  11020. elem = elems[ i ];
  11021. if ( elem || elem === 0 ) {
  11022. // Add nodes directly
  11023. if ( toType( elem ) === "object" ) {
  11024. // Support: Android <=4.0 only, PhantomJS 1 only
  11025. // push.apply(_, arraylike) throws on ancient WebKit
  11026. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11027. // Convert non-html into a text node
  11028. } else if ( !rhtml.test( elem ) ) {
  11029. nodes.push( context.createTextNode( elem ) );
  11030. // Convert html into DOM nodes
  11031. } else {
  11032. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11033. // Deserialize a standard representation
  11034. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11035. wrap = wrapMap[ tag ] || wrapMap._default;
  11036. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11037. // Descend through wrappers to the right content
  11038. j = wrap[ 0 ];
  11039. while ( j-- ) {
  11040. tmp = tmp.lastChild;
  11041. }
  11042. // Support: Android <=4.0 only, PhantomJS 1 only
  11043. // push.apply(_, arraylike) throws on ancient WebKit
  11044. jQuery.merge( nodes, tmp.childNodes );
  11045. // Remember the top-level container
  11046. tmp = fragment.firstChild;
  11047. // Ensure the created nodes are orphaned (#12392)
  11048. tmp.textContent = "";
  11049. }
  11050. }
  11051. }
  11052. // Remove wrapper from fragment
  11053. fragment.textContent = "";
  11054. i = 0;
  11055. while ( ( elem = nodes[ i++ ] ) ) {
  11056. // Skip elements already in the context collection (trac-4087)
  11057. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11058. if ( ignored ) {
  11059. ignored.push( elem );
  11060. }
  11061. continue;
  11062. }
  11063. attached = isAttached( elem );
  11064. // Append to fragment
  11065. tmp = getAll( fragment.appendChild( elem ), "script" );
  11066. // Preserve script evaluation history
  11067. if ( attached ) {
  11068. setGlobalEval( tmp );
  11069. }
  11070. // Capture executables
  11071. if ( scripts ) {
  11072. j = 0;
  11073. while ( ( elem = tmp[ j++ ] ) ) {
  11074. if ( rscriptType.test( elem.type || "" ) ) {
  11075. scripts.push( elem );
  11076. }
  11077. }
  11078. }
  11079. }
  11080. return fragment;
  11081. }
  11082. ( function() {
  11083. var fragment = document.createDocumentFragment(),
  11084. div = fragment.appendChild( document.createElement( "div" ) ),
  11085. input = document.createElement( "input" );
  11086. // Support: Android 4.0 - 4.3 only
  11087. // Check state lost if the name is set (#11217)
  11088. // Support: Windows Web Apps (WWA)
  11089. // `name` and `type` must use .setAttribute for WWA (#14901)
  11090. input.setAttribute( "type", "radio" );
  11091. input.setAttribute( "checked", "checked" );
  11092. input.setAttribute( "name", "t" );
  11093. div.appendChild( input );
  11094. // Support: Android <=4.1 only
  11095. // Older WebKit doesn't clone checked state correctly in fragments
  11096. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11097. // Support: IE <=11 only
  11098. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11099. div.innerHTML = "<textarea>x</textarea>";
  11100. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11101. } )();
  11102. var
  11103. rkeyEvent = /^key/,
  11104. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11105. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11106. function returnTrue() {
  11107. return true;
  11108. }
  11109. function returnFalse() {
  11110. return false;
  11111. }
  11112. // Support: IE <=9 - 11+
  11113. // focus() and blur() are asynchronous, except when they are no-op.
  11114. // So expect focus to be synchronous when the element is already active,
  11115. // and blur to be synchronous when the element is not already active.
  11116. // (focus and blur are always synchronous in other supported browsers,
  11117. // this just defines when we can count on it).
  11118. function expectSync( elem, type ) {
  11119. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11120. }
  11121. // Support: IE <=9 only
  11122. // Accessing document.activeElement can throw unexpectedly
  11123. // https://bugs.jquery.com/ticket/13393
  11124. function safeActiveElement() {
  11125. try {
  11126. return document.activeElement;
  11127. } catch ( err ) { }
  11128. }
  11129. function on( elem, types, selector, data, fn, one ) {
  11130. var origFn, type;
  11131. // Types can be a map of types/handlers
  11132. if ( typeof types === "object" ) {
  11133. // ( types-Object, selector, data )
  11134. if ( typeof selector !== "string" ) {
  11135. // ( types-Object, data )
  11136. data = data || selector;
  11137. selector = undefined;
  11138. }
  11139. for ( type in types ) {
  11140. on( elem, type, selector, data, types[ type ], one );
  11141. }
  11142. return elem;
  11143. }
  11144. if ( data == null && fn == null ) {
  11145. // ( types, fn )
  11146. fn = selector;
  11147. data = selector = undefined;
  11148. } else if ( fn == null ) {
  11149. if ( typeof selector === "string" ) {
  11150. // ( types, selector, fn )
  11151. fn = data;
  11152. data = undefined;
  11153. } else {
  11154. // ( types, data, fn )
  11155. fn = data;
  11156. data = selector;
  11157. selector = undefined;
  11158. }
  11159. }
  11160. if ( fn === false ) {
  11161. fn = returnFalse;
  11162. } else if ( !fn ) {
  11163. return elem;
  11164. }
  11165. if ( one === 1 ) {
  11166. origFn = fn;
  11167. fn = function( event ) {
  11168. // Can use an empty set, since event contains the info
  11169. jQuery().off( event );
  11170. return origFn.apply( this, arguments );
  11171. };
  11172. // Use same guid so caller can remove using origFn
  11173. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11174. }
  11175. return elem.each( function() {
  11176. jQuery.event.add( this, types, fn, data, selector );
  11177. } );
  11178. }
  11179. /*
  11180. * Helper functions for managing events -- not part of the public interface.
  11181. * Props to Dean Edwards' addEvent library for many of the ideas.
  11182. */
  11183. jQuery.event = {
  11184. global: {},
  11185. add: function( elem, types, handler, data, selector ) {
  11186. var handleObjIn, eventHandle, tmp,
  11187. events, t, handleObj,
  11188. special, handlers, type, namespaces, origType,
  11189. elemData = dataPriv.get( elem );
  11190. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11191. if ( !elemData ) {
  11192. return;
  11193. }
  11194. // Caller can pass in an object of custom data in lieu of the handler
  11195. if ( handler.handler ) {
  11196. handleObjIn = handler;
  11197. handler = handleObjIn.handler;
  11198. selector = handleObjIn.selector;
  11199. }
  11200. // Ensure that invalid selectors throw exceptions at attach time
  11201. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11202. if ( selector ) {
  11203. jQuery.find.matchesSelector( documentElement, selector );
  11204. }
  11205. // Make sure that the handler has a unique ID, used to find/remove it later
  11206. if ( !handler.guid ) {
  11207. handler.guid = jQuery.guid++;
  11208. }
  11209. // Init the element's event structure and main handler, if this is the first
  11210. if ( !( events = elemData.events ) ) {
  11211. events = elemData.events = {};
  11212. }
  11213. if ( !( eventHandle = elemData.handle ) ) {
  11214. eventHandle = elemData.handle = function( e ) {
  11215. // Discard the second event of a jQuery.event.trigger() and
  11216. // when an event is called after a page has unloaded
  11217. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11218. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11219. };
  11220. }
  11221. // Handle multiple events separated by a space
  11222. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11223. t = types.length;
  11224. while ( t-- ) {
  11225. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11226. type = origType = tmp[ 1 ];
  11227. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11228. // There *must* be a type, no attaching namespace-only handlers
  11229. if ( !type ) {
  11230. continue;
  11231. }
  11232. // If event changes its type, use the special event handlers for the changed type
  11233. special = jQuery.event.special[ type ] || {};
  11234. // If selector defined, determine special event api type, otherwise given type
  11235. type = ( selector ? special.delegateType : special.bindType ) || type;
  11236. // Update special based on newly reset type
  11237. special = jQuery.event.special[ type ] || {};
  11238. // handleObj is passed to all event handlers
  11239. handleObj = jQuery.extend( {
  11240. type: type,
  11241. origType: origType,
  11242. data: data,
  11243. handler: handler,
  11244. guid: handler.guid,
  11245. selector: selector,
  11246. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11247. namespace: namespaces.join( "." )
  11248. }, handleObjIn );
  11249. // Init the event handler queue if we're the first
  11250. if ( !( handlers = events[ type ] ) ) {
  11251. handlers = events[ type ] = [];
  11252. handlers.delegateCount = 0;
  11253. // Only use addEventListener if the special events handler returns false
  11254. if ( !special.setup ||
  11255. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11256. if ( elem.addEventListener ) {
  11257. elem.addEventListener( type, eventHandle );
  11258. }
  11259. }
  11260. }
  11261. if ( special.add ) {
  11262. special.add.call( elem, handleObj );
  11263. if ( !handleObj.handler.guid ) {
  11264. handleObj.handler.guid = handler.guid;
  11265. }
  11266. }
  11267. // Add to the element's handler list, delegates in front
  11268. if ( selector ) {
  11269. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11270. } else {
  11271. handlers.push( handleObj );
  11272. }
  11273. // Keep track of which events have ever been used, for event optimization
  11274. jQuery.event.global[ type ] = true;
  11275. }
  11276. },
  11277. // Detach an event or set of events from an element
  11278. remove: function( elem, types, handler, selector, mappedTypes ) {
  11279. var j, origCount, tmp,
  11280. events, t, handleObj,
  11281. special, handlers, type, namespaces, origType,
  11282. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11283. if ( !elemData || !( events = elemData.events ) ) {
  11284. return;
  11285. }
  11286. // Once for each type.namespace in types; type may be omitted
  11287. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11288. t = types.length;
  11289. while ( t-- ) {
  11290. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11291. type = origType = tmp[ 1 ];
  11292. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11293. // Unbind all events (on this namespace, if provided) for the element
  11294. if ( !type ) {
  11295. for ( type in events ) {
  11296. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11297. }
  11298. continue;
  11299. }
  11300. special = jQuery.event.special[ type ] || {};
  11301. type = ( selector ? special.delegateType : special.bindType ) || type;
  11302. handlers = events[ type ] || [];
  11303. tmp = tmp[ 2 ] &&
  11304. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11305. // Remove matching events
  11306. origCount = j = handlers.length;
  11307. while ( j-- ) {
  11308. handleObj = handlers[ j ];
  11309. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11310. ( !handler || handler.guid === handleObj.guid ) &&
  11311. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11312. ( !selector || selector === handleObj.selector ||
  11313. selector === "**" && handleObj.selector ) ) {
  11314. handlers.splice( j, 1 );
  11315. if ( handleObj.selector ) {
  11316. handlers.delegateCount--;
  11317. }
  11318. if ( special.remove ) {
  11319. special.remove.call( elem, handleObj );
  11320. }
  11321. }
  11322. }
  11323. // Remove generic event handler if we removed something and no more handlers exist
  11324. // (avoids potential for endless recursion during removal of special event handlers)
  11325. if ( origCount && !handlers.length ) {
  11326. if ( !special.teardown ||
  11327. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11328. jQuery.removeEvent( elem, type, elemData.handle );
  11329. }
  11330. delete events[ type ];
  11331. }
  11332. }
  11333. // Remove data and the expando if it's no longer used
  11334. if ( jQuery.isEmptyObject( events ) ) {
  11335. dataPriv.remove( elem, "handle events" );
  11336. }
  11337. },
  11338. dispatch: function( nativeEvent ) {
  11339. // Make a writable jQuery.Event from the native event object
  11340. var event = jQuery.event.fix( nativeEvent );
  11341. var i, j, ret, matched, handleObj, handlerQueue,
  11342. args = new Array( arguments.length ),
  11343. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11344. special = jQuery.event.special[ event.type ] || {};
  11345. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11346. args[ 0 ] = event;
  11347. for ( i = 1; i < arguments.length; i++ ) {
  11348. args[ i ] = arguments[ i ];
  11349. }
  11350. event.delegateTarget = this;
  11351. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11352. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11353. return;
  11354. }
  11355. // Determine handlers
  11356. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11357. // Run delegates first; they may want to stop propagation beneath us
  11358. i = 0;
  11359. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11360. event.currentTarget = matched.elem;
  11361. j = 0;
  11362. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11363. !event.isImmediatePropagationStopped() ) {
  11364. // If the event is namespaced, then each handler is only invoked if it is
  11365. // specially universal or its namespaces are a superset of the event's.
  11366. if ( !event.rnamespace || handleObj.namespace === false ||
  11367. event.rnamespace.test( handleObj.namespace ) ) {
  11368. event.handleObj = handleObj;
  11369. event.data = handleObj.data;
  11370. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11371. handleObj.handler ).apply( matched.elem, args );
  11372. if ( ret !== undefined ) {
  11373. if ( ( event.result = ret ) === false ) {
  11374. event.preventDefault();
  11375. event.stopPropagation();
  11376. }
  11377. }
  11378. }
  11379. }
  11380. }
  11381. // Call the postDispatch hook for the mapped type
  11382. if ( special.postDispatch ) {
  11383. special.postDispatch.call( this, event );
  11384. }
  11385. return event.result;
  11386. },
  11387. handlers: function( event, handlers ) {
  11388. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11389. handlerQueue = [],
  11390. delegateCount = handlers.delegateCount,
  11391. cur = event.target;
  11392. // Find delegate handlers
  11393. if ( delegateCount &&
  11394. // Support: IE <=9
  11395. // Black-hole SVG <use> instance trees (trac-13180)
  11396. cur.nodeType &&
  11397. // Support: Firefox <=42
  11398. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11399. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11400. // Support: IE 11 only
  11401. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11402. !( event.type === "click" && event.button >= 1 ) ) {
  11403. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11404. // Don't check non-elements (#13208)
  11405. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11406. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11407. matchedHandlers = [];
  11408. matchedSelectors = {};
  11409. for ( i = 0; i < delegateCount; i++ ) {
  11410. handleObj = handlers[ i ];
  11411. // Don't conflict with Object.prototype properties (#13203)
  11412. sel = handleObj.selector + " ";
  11413. if ( matchedSelectors[ sel ] === undefined ) {
  11414. matchedSelectors[ sel ] = handleObj.needsContext ?
  11415. jQuery( sel, this ).index( cur ) > -1 :
  11416. jQuery.find( sel, this, null, [ cur ] ).length;
  11417. }
  11418. if ( matchedSelectors[ sel ] ) {
  11419. matchedHandlers.push( handleObj );
  11420. }
  11421. }
  11422. if ( matchedHandlers.length ) {
  11423. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11424. }
  11425. }
  11426. }
  11427. }
  11428. // Add the remaining (directly-bound) handlers
  11429. cur = this;
  11430. if ( delegateCount < handlers.length ) {
  11431. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11432. }
  11433. return handlerQueue;
  11434. },
  11435. addProp: function( name, hook ) {
  11436. Object.defineProperty( jQuery.Event.prototype, name, {
  11437. enumerable: true,
  11438. configurable: true,
  11439. get: isFunction( hook ) ?
  11440. function() {
  11441. if ( this.originalEvent ) {
  11442. return hook( this.originalEvent );
  11443. }
  11444. } :
  11445. function() {
  11446. if ( this.originalEvent ) {
  11447. return this.originalEvent[ name ];
  11448. }
  11449. },
  11450. set: function( value ) {
  11451. Object.defineProperty( this, name, {
  11452. enumerable: true,
  11453. configurable: true,
  11454. writable: true,
  11455. value: value
  11456. } );
  11457. }
  11458. } );
  11459. },
  11460. fix: function( originalEvent ) {
  11461. return originalEvent[ jQuery.expando ] ?
  11462. originalEvent :
  11463. new jQuery.Event( originalEvent );
  11464. },
  11465. special: {
  11466. load: {
  11467. // Prevent triggered image.load events from bubbling to window.load
  11468. noBubble: true
  11469. },
  11470. click: {
  11471. // Utilize native event to ensure correct state for checkable inputs
  11472. setup: function( data ) {
  11473. // For mutual compressibility with _default, replace `this` access with a local var.
  11474. // `|| data` is dead code meant only to preserve the variable through minification.
  11475. var el = this || data;
  11476. // Claim the first handler
  11477. if ( rcheckableType.test( el.type ) &&
  11478. el.click && nodeName( el, "input" ) ) {
  11479. // dataPriv.set( el, "click", ... )
  11480. leverageNative( el, "click", returnTrue );
  11481. }
  11482. // Return false to allow normal processing in the caller
  11483. return false;
  11484. },
  11485. trigger: function( data ) {
  11486. // For mutual compressibility with _default, replace `this` access with a local var.
  11487. // `|| data` is dead code meant only to preserve the variable through minification.
  11488. var el = this || data;
  11489. // Force setup before triggering a click
  11490. if ( rcheckableType.test( el.type ) &&
  11491. el.click && nodeName( el, "input" ) ) {
  11492. leverageNative( el, "click" );
  11493. }
  11494. // Return non-false to allow normal event-path propagation
  11495. return true;
  11496. },
  11497. // For cross-browser consistency, suppress native .click() on links
  11498. // Also prevent it if we're currently inside a leveraged native-event stack
  11499. _default: function( event ) {
  11500. var target = event.target;
  11501. return rcheckableType.test( target.type ) &&
  11502. target.click && nodeName( target, "input" ) &&
  11503. dataPriv.get( target, "click" ) ||
  11504. nodeName( target, "a" );
  11505. }
  11506. },
  11507. beforeunload: {
  11508. postDispatch: function( event ) {
  11509. // Support: Firefox 20+
  11510. // Firefox doesn't alert if the returnValue field is not set.
  11511. if ( event.result !== undefined && event.originalEvent ) {
  11512. event.originalEvent.returnValue = event.result;
  11513. }
  11514. }
  11515. }
  11516. }
  11517. };
  11518. // Ensure the presence of an event listener that handles manually-triggered
  11519. // synthetic events by interrupting progress until reinvoked in response to
  11520. // *native* events that it fires directly, ensuring that state changes have
  11521. // already occurred before other listeners are invoked.
  11522. function leverageNative( el, type, expectSync ) {
  11523. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11524. if ( !expectSync ) {
  11525. if ( dataPriv.get( el, type ) === undefined ) {
  11526. jQuery.event.add( el, type, returnTrue );
  11527. }
  11528. return;
  11529. }
  11530. // Register the controller as a special universal handler for all event namespaces
  11531. dataPriv.set( el, type, false );
  11532. jQuery.event.add( el, type, {
  11533. namespace: false,
  11534. handler: function( event ) {
  11535. var notAsync, result,
  11536. saved = dataPriv.get( this, type );
  11537. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11538. // Interrupt processing of the outer synthetic .trigger()ed event
  11539. // Saved data should be false in such cases, but might be a leftover capture object
  11540. // from an async native handler (gh-4350)
  11541. if ( !saved.length ) {
  11542. // Store arguments for use when handling the inner native event
  11543. // There will always be at least one argument (an event object), so this array
  11544. // will not be confused with a leftover capture object.
  11545. saved = slice.call( arguments );
  11546. dataPriv.set( this, type, saved );
  11547. // Trigger the native event and capture its result
  11548. // Support: IE <=9 - 11+
  11549. // focus() and blur() are asynchronous
  11550. notAsync = expectSync( this, type );
  11551. this[ type ]();
  11552. result = dataPriv.get( this, type );
  11553. if ( saved !== result || notAsync ) {
  11554. dataPriv.set( this, type, false );
  11555. } else {
  11556. result = {};
  11557. }
  11558. if ( saved !== result ) {
  11559. // Cancel the outer synthetic event
  11560. event.stopImmediatePropagation();
  11561. event.preventDefault();
  11562. return result.value;
  11563. }
  11564. // If this is an inner synthetic event for an event with a bubbling surrogate
  11565. // (focus or blur), assume that the surrogate already propagated from triggering the
  11566. // native event and prevent that from happening again here.
  11567. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11568. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11569. // less bad than duplication.
  11570. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11571. event.stopPropagation();
  11572. }
  11573. // If this is a native event triggered above, everything is now in order
  11574. // Fire an inner synthetic event with the original arguments
  11575. } else if ( saved.length ) {
  11576. // ...and capture the result
  11577. dataPriv.set( this, type, {
  11578. value: jQuery.event.trigger(
  11579. // Support: IE <=9 - 11+
  11580. // Extend with the prototype to reset the above stopImmediatePropagation()
  11581. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11582. saved.slice( 1 ),
  11583. this
  11584. )
  11585. } );
  11586. // Abort handling of the native event
  11587. event.stopImmediatePropagation();
  11588. }
  11589. }
  11590. } );
  11591. }
  11592. jQuery.removeEvent = function( elem, type, handle ) {
  11593. // This "if" is needed for plain objects
  11594. if ( elem.removeEventListener ) {
  11595. elem.removeEventListener( type, handle );
  11596. }
  11597. };
  11598. jQuery.Event = function( src, props ) {
  11599. // Allow instantiation without the 'new' keyword
  11600. if ( !( this instanceof jQuery.Event ) ) {
  11601. return new jQuery.Event( src, props );
  11602. }
  11603. // Event object
  11604. if ( src && src.type ) {
  11605. this.originalEvent = src;
  11606. this.type = src.type;
  11607. // Events bubbling up the document may have been marked as prevented
  11608. // by a handler lower down the tree; reflect the correct value.
  11609. this.isDefaultPrevented = src.defaultPrevented ||
  11610. src.defaultPrevented === undefined &&
  11611. // Support: Android <=2.3 only
  11612. src.returnValue === false ?
  11613. returnTrue :
  11614. returnFalse;
  11615. // Create target properties
  11616. // Support: Safari <=6 - 7 only
  11617. // Target should not be a text node (#504, #13143)
  11618. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11619. src.target.parentNode :
  11620. src.target;
  11621. this.currentTarget = src.currentTarget;
  11622. this.relatedTarget = src.relatedTarget;
  11623. // Event type
  11624. } else {
  11625. this.type = src;
  11626. }
  11627. // Put explicitly provided properties onto the event object
  11628. if ( props ) {
  11629. jQuery.extend( this, props );
  11630. }
  11631. // Create a timestamp if incoming event doesn't have one
  11632. this.timeStamp = src && src.timeStamp || Date.now();
  11633. // Mark it as fixed
  11634. this[ jQuery.expando ] = true;
  11635. };
  11636. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11637. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11638. jQuery.Event.prototype = {
  11639. constructor: jQuery.Event,
  11640. isDefaultPrevented: returnFalse,
  11641. isPropagationStopped: returnFalse,
  11642. isImmediatePropagationStopped: returnFalse,
  11643. isSimulated: false,
  11644. preventDefault: function() {
  11645. var e = this.originalEvent;
  11646. this.isDefaultPrevented = returnTrue;
  11647. if ( e && !this.isSimulated ) {
  11648. e.preventDefault();
  11649. }
  11650. },
  11651. stopPropagation: function() {
  11652. var e = this.originalEvent;
  11653. this.isPropagationStopped = returnTrue;
  11654. if ( e && !this.isSimulated ) {
  11655. e.stopPropagation();
  11656. }
  11657. },
  11658. stopImmediatePropagation: function() {
  11659. var e = this.originalEvent;
  11660. this.isImmediatePropagationStopped = returnTrue;
  11661. if ( e && !this.isSimulated ) {
  11662. e.stopImmediatePropagation();
  11663. }
  11664. this.stopPropagation();
  11665. }
  11666. };
  11667. // Includes all common event props including KeyEvent and MouseEvent specific props
  11668. jQuery.each( {
  11669. altKey: true,
  11670. bubbles: true,
  11671. cancelable: true,
  11672. changedTouches: true,
  11673. ctrlKey: true,
  11674. detail: true,
  11675. eventPhase: true,
  11676. metaKey: true,
  11677. pageX: true,
  11678. pageY: true,
  11679. shiftKey: true,
  11680. view: true,
  11681. "char": true,
  11682. code: true,
  11683. charCode: true,
  11684. key: true,
  11685. keyCode: true,
  11686. button: true,
  11687. buttons: true,
  11688. clientX: true,
  11689. clientY: true,
  11690. offsetX: true,
  11691. offsetY: true,
  11692. pointerId: true,
  11693. pointerType: true,
  11694. screenX: true,
  11695. screenY: true,
  11696. targetTouches: true,
  11697. toElement: true,
  11698. touches: true,
  11699. which: function( event ) {
  11700. var button = event.button;
  11701. // Add which for key events
  11702. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11703. return event.charCode != null ? event.charCode : event.keyCode;
  11704. }
  11705. // Add which for click: 1 === left; 2 === middle; 3 === right
  11706. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11707. if ( button & 1 ) {
  11708. return 1;
  11709. }
  11710. if ( button & 2 ) {
  11711. return 3;
  11712. }
  11713. if ( button & 4 ) {
  11714. return 2;
  11715. }
  11716. return 0;
  11717. }
  11718. return event.which;
  11719. }
  11720. }, jQuery.event.addProp );
  11721. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11722. jQuery.event.special[ type ] = {
  11723. // Utilize native event if possible so blur/focus sequence is correct
  11724. setup: function() {
  11725. // Claim the first handler
  11726. // dataPriv.set( this, "focus", ... )
  11727. // dataPriv.set( this, "blur", ... )
  11728. leverageNative( this, type, expectSync );
  11729. // Return false to allow normal processing in the caller
  11730. return false;
  11731. },
  11732. trigger: function() {
  11733. // Force setup before trigger
  11734. leverageNative( this, type );
  11735. // Return non-false to allow normal event-path propagation
  11736. return true;
  11737. },
  11738. delegateType: delegateType
  11739. };
  11740. } );
  11741. // Create mouseenter/leave events using mouseover/out and event-time checks
  11742. // so that event delegation works in jQuery.
  11743. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11744. //
  11745. // Support: Safari 7 only
  11746. // Safari sends mouseenter too often; see:
  11747. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11748. // for the description of the bug (it existed in older Chrome versions as well).
  11749. jQuery.each( {
  11750. mouseenter: "mouseover",
  11751. mouseleave: "mouseout",
  11752. pointerenter: "pointerover",
  11753. pointerleave: "pointerout"
  11754. }, function( orig, fix ) {
  11755. jQuery.event.special[ orig ] = {
  11756. delegateType: fix,
  11757. bindType: fix,
  11758. handle: function( event ) {
  11759. var ret,
  11760. target = this,
  11761. related = event.relatedTarget,
  11762. handleObj = event.handleObj;
  11763. // For mouseenter/leave call the handler if related is outside the target.
  11764. // NB: No relatedTarget if the mouse left/entered the browser window
  11765. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11766. event.type = handleObj.origType;
  11767. ret = handleObj.handler.apply( this, arguments );
  11768. event.type = fix;
  11769. }
  11770. return ret;
  11771. }
  11772. };
  11773. } );
  11774. jQuery.fn.extend( {
  11775. on: function( types, selector, data, fn ) {
  11776. return on( this, types, selector, data, fn );
  11777. },
  11778. one: function( types, selector, data, fn ) {
  11779. return on( this, types, selector, data, fn, 1 );
  11780. },
  11781. off: function( types, selector, fn ) {
  11782. var handleObj, type;
  11783. if ( types && types.preventDefault && types.handleObj ) {
  11784. // ( event ) dispatched jQuery.Event
  11785. handleObj = types.handleObj;
  11786. jQuery( types.delegateTarget ).off(
  11787. handleObj.namespace ?
  11788. handleObj.origType + "." + handleObj.namespace :
  11789. handleObj.origType,
  11790. handleObj.selector,
  11791. handleObj.handler
  11792. );
  11793. return this;
  11794. }
  11795. if ( typeof types === "object" ) {
  11796. // ( types-object [, selector] )
  11797. for ( type in types ) {
  11798. this.off( type, selector, types[ type ] );
  11799. }
  11800. return this;
  11801. }
  11802. if ( selector === false || typeof selector === "function" ) {
  11803. // ( types [, fn] )
  11804. fn = selector;
  11805. selector = undefined;
  11806. }
  11807. if ( fn === false ) {
  11808. fn = returnFalse;
  11809. }
  11810. return this.each( function() {
  11811. jQuery.event.remove( this, types, fn, selector );
  11812. } );
  11813. }
  11814. } );
  11815. var
  11816. /* eslint-disable max-len */
  11817. // See https://github.com/eslint/eslint/issues/3229
  11818. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11819. /* eslint-enable */
  11820. // Support: IE <=10 - 11, Edge 12 - 13 only
  11821. // In IE/Edge using regex groups here causes severe slowdowns.
  11822. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11823. rnoInnerhtml = /<script|<style|<link/i,
  11824. // checked="checked" or checked
  11825. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11826. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11827. // Prefer a tbody over its parent table for containing new rows
  11828. function manipulationTarget( elem, content ) {
  11829. if ( nodeName( elem, "table" ) &&
  11830. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11831. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11832. }
  11833. return elem;
  11834. }
  11835. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11836. function disableScript( elem ) {
  11837. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11838. return elem;
  11839. }
  11840. function restoreScript( elem ) {
  11841. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11842. elem.type = elem.type.slice( 5 );
  11843. } else {
  11844. elem.removeAttribute( "type" );
  11845. }
  11846. return elem;
  11847. }
  11848. function cloneCopyEvent( src, dest ) {
  11849. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11850. if ( dest.nodeType !== 1 ) {
  11851. return;
  11852. }
  11853. // 1. Copy private data: events, handlers, etc.
  11854. if ( dataPriv.hasData( src ) ) {
  11855. pdataOld = dataPriv.access( src );
  11856. pdataCur = dataPriv.set( dest, pdataOld );
  11857. events = pdataOld.events;
  11858. if ( events ) {
  11859. delete pdataCur.handle;
  11860. pdataCur.events = {};
  11861. for ( type in events ) {
  11862. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11863. jQuery.event.add( dest, type, events[ type ][ i ] );
  11864. }
  11865. }
  11866. }
  11867. }
  11868. // 2. Copy user data
  11869. if ( dataUser.hasData( src ) ) {
  11870. udataOld = dataUser.access( src );
  11871. udataCur = jQuery.extend( {}, udataOld );
  11872. dataUser.set( dest, udataCur );
  11873. }
  11874. }
  11875. // Fix IE bugs, see support tests
  11876. function fixInput( src, dest ) {
  11877. var nodeName = dest.nodeName.toLowerCase();
  11878. // Fails to persist the checked state of a cloned checkbox or radio button.
  11879. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11880. dest.checked = src.checked;
  11881. // Fails to return the selected option to the default selected state when cloning options
  11882. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11883. dest.defaultValue = src.defaultValue;
  11884. }
  11885. }
  11886. function domManip( collection, args, callback, ignored ) {
  11887. // Flatten any nested arrays
  11888. args = concat.apply( [], args );
  11889. var fragment, first, scripts, hasScripts, node, doc,
  11890. i = 0,
  11891. l = collection.length,
  11892. iNoClone = l - 1,
  11893. value = args[ 0 ],
  11894. valueIsFunction = isFunction( value );
  11895. // We can't cloneNode fragments that contain checked, in WebKit
  11896. if ( valueIsFunction ||
  11897. ( l > 1 && typeof value === "string" &&
  11898. !support.checkClone && rchecked.test( value ) ) ) {
  11899. return collection.each( function( index ) {
  11900. var self = collection.eq( index );
  11901. if ( valueIsFunction ) {
  11902. args[ 0 ] = value.call( this, index, self.html() );
  11903. }
  11904. domManip( self, args, callback, ignored );
  11905. } );
  11906. }
  11907. if ( l ) {
  11908. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11909. first = fragment.firstChild;
  11910. if ( fragment.childNodes.length === 1 ) {
  11911. fragment = first;
  11912. }
  11913. // Require either new content or an interest in ignored elements to invoke the callback
  11914. if ( first || ignored ) {
  11915. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11916. hasScripts = scripts.length;
  11917. // Use the original fragment for the last item
  11918. // instead of the first because it can end up
  11919. // being emptied incorrectly in certain situations (#8070).
  11920. for ( ; i < l; i++ ) {
  11921. node = fragment;
  11922. if ( i !== iNoClone ) {
  11923. node = jQuery.clone( node, true, true );
  11924. // Keep references to cloned scripts for later restoration
  11925. if ( hasScripts ) {
  11926. // Support: Android <=4.0 only, PhantomJS 1 only
  11927. // push.apply(_, arraylike) throws on ancient WebKit
  11928. jQuery.merge( scripts, getAll( node, "script" ) );
  11929. }
  11930. }
  11931. callback.call( collection[ i ], node, i );
  11932. }
  11933. if ( hasScripts ) {
  11934. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11935. // Reenable scripts
  11936. jQuery.map( scripts, restoreScript );
  11937. // Evaluate executable scripts on first document insertion
  11938. for ( i = 0; i < hasScripts; i++ ) {
  11939. node = scripts[ i ];
  11940. if ( rscriptType.test( node.type || "" ) &&
  11941. !dataPriv.access( node, "globalEval" ) &&
  11942. jQuery.contains( doc, node ) ) {
  11943. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11944. // Optional AJAX dependency, but won't run scripts if not present
  11945. if ( jQuery._evalUrl && !node.noModule ) {
  11946. jQuery._evalUrl( node.src, {
  11947. nonce: node.nonce || node.getAttribute( "nonce" )
  11948. } );
  11949. }
  11950. } else {
  11951. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11952. }
  11953. }
  11954. }
  11955. }
  11956. }
  11957. }
  11958. return collection;
  11959. }
  11960. function remove( elem, selector, keepData ) {
  11961. var node,
  11962. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  11963. i = 0;
  11964. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  11965. if ( !keepData && node.nodeType === 1 ) {
  11966. jQuery.cleanData( getAll( node ) );
  11967. }
  11968. if ( node.parentNode ) {
  11969. if ( keepData && isAttached( node ) ) {
  11970. setGlobalEval( getAll( node, "script" ) );
  11971. }
  11972. node.parentNode.removeChild( node );
  11973. }
  11974. }
  11975. return elem;
  11976. }
  11977. jQuery.extend( {
  11978. htmlPrefilter: function( html ) {
  11979. return html.replace( rxhtmlTag, "<$1></$2>" );
  11980. },
  11981. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  11982. var i, l, srcElements, destElements,
  11983. clone = elem.cloneNode( true ),
  11984. inPage = isAttached( elem );
  11985. // Fix IE cloning issues
  11986. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  11987. !jQuery.isXMLDoc( elem ) ) {
  11988. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  11989. destElements = getAll( clone );
  11990. srcElements = getAll( elem );
  11991. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  11992. fixInput( srcElements[ i ], destElements[ i ] );
  11993. }
  11994. }
  11995. // Copy the events from the original to the clone
  11996. if ( dataAndEvents ) {
  11997. if ( deepDataAndEvents ) {
  11998. srcElements = srcElements || getAll( elem );
  11999. destElements = destElements || getAll( clone );
  12000. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12001. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12002. }
  12003. } else {
  12004. cloneCopyEvent( elem, clone );
  12005. }
  12006. }
  12007. // Preserve script evaluation history
  12008. destElements = getAll( clone, "script" );
  12009. if ( destElements.length > 0 ) {
  12010. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12011. }
  12012. // Return the cloned set
  12013. return clone;
  12014. },
  12015. cleanData: function( elems ) {
  12016. var data, elem, type,
  12017. special = jQuery.event.special,
  12018. i = 0;
  12019. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12020. if ( acceptData( elem ) ) {
  12021. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12022. if ( data.events ) {
  12023. for ( type in data.events ) {
  12024. if ( special[ type ] ) {
  12025. jQuery.event.remove( elem, type );
  12026. // This is a shortcut to avoid jQuery.event.remove's overhead
  12027. } else {
  12028. jQuery.removeEvent( elem, type, data.handle );
  12029. }
  12030. }
  12031. }
  12032. // Support: Chrome <=35 - 45+
  12033. // Assign undefined instead of using delete, see Data#remove
  12034. elem[ dataPriv.expando ] = undefined;
  12035. }
  12036. if ( elem[ dataUser.expando ] ) {
  12037. // Support: Chrome <=35 - 45+
  12038. // Assign undefined instead of using delete, see Data#remove
  12039. elem[ dataUser.expando ] = undefined;
  12040. }
  12041. }
  12042. }
  12043. }
  12044. } );
  12045. jQuery.fn.extend( {
  12046. detach: function( selector ) {
  12047. return remove( this, selector, true );
  12048. },
  12049. remove: function( selector ) {
  12050. return remove( this, selector );
  12051. },
  12052. text: function( value ) {
  12053. return access( this, function( value ) {
  12054. return value === undefined ?
  12055. jQuery.text( this ) :
  12056. this.empty().each( function() {
  12057. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12058. this.textContent = value;
  12059. }
  12060. } );
  12061. }, null, value, arguments.length );
  12062. },
  12063. append: function() {
  12064. return domManip( this, arguments, function( elem ) {
  12065. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12066. var target = manipulationTarget( this, elem );
  12067. target.appendChild( elem );
  12068. }
  12069. } );
  12070. },
  12071. prepend: function() {
  12072. return domManip( this, arguments, function( elem ) {
  12073. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12074. var target = manipulationTarget( this, elem );
  12075. target.insertBefore( elem, target.firstChild );
  12076. }
  12077. } );
  12078. },
  12079. before: function() {
  12080. return domManip( this, arguments, function( elem ) {
  12081. if ( this.parentNode ) {
  12082. this.parentNode.insertBefore( elem, this );
  12083. }
  12084. } );
  12085. },
  12086. after: function() {
  12087. return domManip( this, arguments, function( elem ) {
  12088. if ( this.parentNode ) {
  12089. this.parentNode.insertBefore( elem, this.nextSibling );
  12090. }
  12091. } );
  12092. },
  12093. empty: function() {
  12094. var elem,
  12095. i = 0;
  12096. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12097. if ( elem.nodeType === 1 ) {
  12098. // Prevent memory leaks
  12099. jQuery.cleanData( getAll( elem, false ) );
  12100. // Remove any remaining nodes
  12101. elem.textContent = "";
  12102. }
  12103. }
  12104. return this;
  12105. },
  12106. clone: function( dataAndEvents, deepDataAndEvents ) {
  12107. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12108. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12109. return this.map( function() {
  12110. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12111. } );
  12112. },
  12113. html: function( value ) {
  12114. return access( this, function( value ) {
  12115. var elem = this[ 0 ] || {},
  12116. i = 0,
  12117. l = this.length;
  12118. if ( value === undefined && elem.nodeType === 1 ) {
  12119. return elem.innerHTML;
  12120. }
  12121. // See if we can take a shortcut and just use innerHTML
  12122. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12123. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12124. value = jQuery.htmlPrefilter( value );
  12125. try {
  12126. for ( ; i < l; i++ ) {
  12127. elem = this[ i ] || {};
  12128. // Remove element nodes and prevent memory leaks
  12129. if ( elem.nodeType === 1 ) {
  12130. jQuery.cleanData( getAll( elem, false ) );
  12131. elem.innerHTML = value;
  12132. }
  12133. }
  12134. elem = 0;
  12135. // If using innerHTML throws an exception, use the fallback method
  12136. } catch ( e ) {}
  12137. }
  12138. if ( elem ) {
  12139. this.empty().append( value );
  12140. }
  12141. }, null, value, arguments.length );
  12142. },
  12143. replaceWith: function() {
  12144. var ignored = [];
  12145. // Make the changes, replacing each non-ignored context element with the new content
  12146. return domManip( this, arguments, function( elem ) {
  12147. var parent = this.parentNode;
  12148. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12149. jQuery.cleanData( getAll( this ) );
  12150. if ( parent ) {
  12151. parent.replaceChild( elem, this );
  12152. }
  12153. }
  12154. // Force callback invocation
  12155. }, ignored );
  12156. }
  12157. } );
  12158. jQuery.each( {
  12159. appendTo: "append",
  12160. prependTo: "prepend",
  12161. insertBefore: "before",
  12162. insertAfter: "after",
  12163. replaceAll: "replaceWith"
  12164. }, function( name, original ) {
  12165. jQuery.fn[ name ] = function( selector ) {
  12166. var elems,
  12167. ret = [],
  12168. insert = jQuery( selector ),
  12169. last = insert.length - 1,
  12170. i = 0;
  12171. for ( ; i <= last; i++ ) {
  12172. elems = i === last ? this : this.clone( true );
  12173. jQuery( insert[ i ] )[ original ]( elems );
  12174. // Support: Android <=4.0 only, PhantomJS 1 only
  12175. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12176. push.apply( ret, elems.get() );
  12177. }
  12178. return this.pushStack( ret );
  12179. };
  12180. } );
  12181. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12182. var getStyles = function( elem ) {
  12183. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12184. // IE throws on elements created in popups
  12185. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12186. var view = elem.ownerDocument.defaultView;
  12187. if ( !view || !view.opener ) {
  12188. view = window;
  12189. }
  12190. return view.getComputedStyle( elem );
  12191. };
  12192. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12193. ( function() {
  12194. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12195. // so they're executed at the same time to save the second computation.
  12196. function computeStyleTests() {
  12197. // This is a singleton, we need to execute it only once
  12198. if ( !div ) {
  12199. return;
  12200. }
  12201. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12202. "margin-top:1px;padding:0;border:0";
  12203. div.style.cssText =
  12204. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12205. "margin:auto;border:1px;padding:1px;" +
  12206. "width:60%;top:1%";
  12207. documentElement.appendChild( container ).appendChild( div );
  12208. var divStyle = window.getComputedStyle( div );
  12209. pixelPositionVal = divStyle.top !== "1%";
  12210. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12211. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12212. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12213. // Some styles come back with percentage values, even though they shouldn't
  12214. div.style.right = "60%";
  12215. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12216. // Support: IE 9 - 11 only
  12217. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12218. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12219. // Support: IE 9 only
  12220. // Detect overflow:scroll screwiness (gh-3699)
  12221. // Support: Chrome <=64
  12222. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12223. div.style.position = "absolute";
  12224. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12225. documentElement.removeChild( container );
  12226. // Nullify the div so it wouldn't be stored in the memory and
  12227. // it will also be a sign that checks already performed
  12228. div = null;
  12229. }
  12230. function roundPixelMeasures( measure ) {
  12231. return Math.round( parseFloat( measure ) );
  12232. }
  12233. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12234. reliableMarginLeftVal,
  12235. container = document.createElement( "div" ),
  12236. div = document.createElement( "div" );
  12237. // Finish early in limited (non-browser) environments
  12238. if ( !div.style ) {
  12239. return;
  12240. }
  12241. // Support: IE <=9 - 11 only
  12242. // Style of cloned element affects source element cloned (#8908)
  12243. div.style.backgroundClip = "content-box";
  12244. div.cloneNode( true ).style.backgroundClip = "";
  12245. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12246. jQuery.extend( support, {
  12247. boxSizingReliable: function() {
  12248. computeStyleTests();
  12249. return boxSizingReliableVal;
  12250. },
  12251. pixelBoxStyles: function() {
  12252. computeStyleTests();
  12253. return pixelBoxStylesVal;
  12254. },
  12255. pixelPosition: function() {
  12256. computeStyleTests();
  12257. return pixelPositionVal;
  12258. },
  12259. reliableMarginLeft: function() {
  12260. computeStyleTests();
  12261. return reliableMarginLeftVal;
  12262. },
  12263. scrollboxSize: function() {
  12264. computeStyleTests();
  12265. return scrollboxSizeVal;
  12266. }
  12267. } );
  12268. } )();
  12269. function curCSS( elem, name, computed ) {
  12270. var width, minWidth, maxWidth, ret,
  12271. // Support: Firefox 51+
  12272. // Retrieving style before computed somehow
  12273. // fixes an issue with getting wrong values
  12274. // on detached elements
  12275. style = elem.style;
  12276. computed = computed || getStyles( elem );
  12277. // getPropertyValue is needed for:
  12278. // .css('filter') (IE 9 only, #12537)
  12279. // .css('--customProperty) (#3144)
  12280. if ( computed ) {
  12281. ret = computed.getPropertyValue( name ) || computed[ name ];
  12282. if ( ret === "" && !isAttached( elem ) ) {
  12283. ret = jQuery.style( elem, name );
  12284. }
  12285. // A tribute to the "awesome hack by Dean Edwards"
  12286. // Android Browser returns percentage for some values,
  12287. // but width seems to be reliably pixels.
  12288. // This is against the CSSOM draft spec:
  12289. // https://drafts.csswg.org/cssom/#resolved-values
  12290. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12291. // Remember the original values
  12292. width = style.width;
  12293. minWidth = style.minWidth;
  12294. maxWidth = style.maxWidth;
  12295. // Put in the new values to get a computed value out
  12296. style.minWidth = style.maxWidth = style.width = ret;
  12297. ret = computed.width;
  12298. // Revert the changed values
  12299. style.width = width;
  12300. style.minWidth = minWidth;
  12301. style.maxWidth = maxWidth;
  12302. }
  12303. }
  12304. return ret !== undefined ?
  12305. // Support: IE <=9 - 11 only
  12306. // IE returns zIndex value as an integer.
  12307. ret + "" :
  12308. ret;
  12309. }
  12310. function addGetHookIf( conditionFn, hookFn ) {
  12311. // Define the hook, we'll check on the first run if it's really needed.
  12312. return {
  12313. get: function() {
  12314. if ( conditionFn() ) {
  12315. // Hook not needed (or it's not possible to use it due
  12316. // to missing dependency), remove it.
  12317. delete this.get;
  12318. return;
  12319. }
  12320. // Hook needed; redefine it so that the support test is not executed again.
  12321. return ( this.get = hookFn ).apply( this, arguments );
  12322. }
  12323. };
  12324. }
  12325. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12326. emptyStyle = document.createElement( "div" ).style,
  12327. vendorProps = {};
  12328. // Return a vendor-prefixed property or undefined
  12329. function vendorPropName( name ) {
  12330. // Check for vendor prefixed names
  12331. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12332. i = cssPrefixes.length;
  12333. while ( i-- ) {
  12334. name = cssPrefixes[ i ] + capName;
  12335. if ( name in emptyStyle ) {
  12336. return name;
  12337. }
  12338. }
  12339. }
  12340. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12341. function finalPropName( name ) {
  12342. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12343. if ( final ) {
  12344. return final;
  12345. }
  12346. if ( name in emptyStyle ) {
  12347. return name;
  12348. }
  12349. return vendorProps[ name ] = vendorPropName( name ) || name;
  12350. }
  12351. var
  12352. // Swappable if display is none or starts with table
  12353. // except "table", "table-cell", or "table-caption"
  12354. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12355. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12356. rcustomProp = /^--/,
  12357. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12358. cssNormalTransform = {
  12359. letterSpacing: "0",
  12360. fontWeight: "400"
  12361. };
  12362. function setPositiveNumber( elem, value, subtract ) {
  12363. // Any relative (+/-) values have already been
  12364. // normalized at this point
  12365. var matches = rcssNum.exec( value );
  12366. return matches ?
  12367. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12368. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12369. value;
  12370. }
  12371. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12372. var i = dimension === "width" ? 1 : 0,
  12373. extra = 0,
  12374. delta = 0;
  12375. // Adjustment may not be necessary
  12376. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12377. return 0;
  12378. }
  12379. for ( ; i < 4; i += 2 ) {
  12380. // Both box models exclude margin
  12381. if ( box === "margin" ) {
  12382. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12383. }
  12384. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12385. if ( !isBorderBox ) {
  12386. // Add padding
  12387. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12388. // For "border" or "margin", add border
  12389. if ( box !== "padding" ) {
  12390. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12391. // But still keep track of it otherwise
  12392. } else {
  12393. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12394. }
  12395. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12396. // "padding" or "margin"
  12397. } else {
  12398. // For "content", subtract padding
  12399. if ( box === "content" ) {
  12400. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12401. }
  12402. // For "content" or "padding", subtract border
  12403. if ( box !== "margin" ) {
  12404. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12405. }
  12406. }
  12407. }
  12408. // Account for positive content-box scroll gutter when requested by providing computedVal
  12409. if ( !isBorderBox && computedVal >= 0 ) {
  12410. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12411. // Assuming integer scroll gutter, subtract the rest and round down
  12412. delta += Math.max( 0, Math.ceil(
  12413. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12414. computedVal -
  12415. delta -
  12416. extra -
  12417. 0.5
  12418. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12419. // Use an explicit zero to avoid NaN (gh-3964)
  12420. ) ) || 0;
  12421. }
  12422. return delta;
  12423. }
  12424. function getWidthOrHeight( elem, dimension, extra ) {
  12425. // Start with computed style
  12426. var styles = getStyles( elem ),
  12427. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12428. // Fake content-box until we know it's needed to know the true value.
  12429. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12430. isBorderBox = boxSizingNeeded &&
  12431. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12432. valueIsBorderBox = isBorderBox,
  12433. val = curCSS( elem, dimension, styles ),
  12434. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12435. // Support: Firefox <=54
  12436. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12437. if ( rnumnonpx.test( val ) ) {
  12438. if ( !extra ) {
  12439. return val;
  12440. }
  12441. val = "auto";
  12442. }
  12443. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12444. // This happens for inline elements with no explicit setting (gh-3571)
  12445. // Support: Android <=4.1 - 4.3 only
  12446. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12447. // Support: IE 9-11 only
  12448. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12449. // We use getClientRects() to check for hidden/disconnected.
  12450. // In those cases, the computed value can be trusted to be border-box
  12451. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12452. val === "auto" ||
  12453. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12454. elem.getClientRects().length ) {
  12455. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12456. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12457. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12458. // retrieved value as a content box dimension.
  12459. valueIsBorderBox = offsetProp in elem;
  12460. if ( valueIsBorderBox ) {
  12461. val = elem[ offsetProp ];
  12462. }
  12463. }
  12464. // Normalize "" and auto
  12465. val = parseFloat( val ) || 0;
  12466. // Adjust for the element's box model
  12467. return ( val +
  12468. boxModelAdjustment(
  12469. elem,
  12470. dimension,
  12471. extra || ( isBorderBox ? "border" : "content" ),
  12472. valueIsBorderBox,
  12473. styles,
  12474. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12475. val
  12476. )
  12477. ) + "px";
  12478. }
  12479. jQuery.extend( {
  12480. // Add in style property hooks for overriding the default
  12481. // behavior of getting and setting a style property
  12482. cssHooks: {
  12483. opacity: {
  12484. get: function( elem, computed ) {
  12485. if ( computed ) {
  12486. // We should always get a number back from opacity
  12487. var ret = curCSS( elem, "opacity" );
  12488. return ret === "" ? "1" : ret;
  12489. }
  12490. }
  12491. }
  12492. },
  12493. // Don't automatically add "px" to these possibly-unitless properties
  12494. cssNumber: {
  12495. "animationIterationCount": true,
  12496. "columnCount": true,
  12497. "fillOpacity": true,
  12498. "flexGrow": true,
  12499. "flexShrink": true,
  12500. "fontWeight": true,
  12501. "gridArea": true,
  12502. "gridColumn": true,
  12503. "gridColumnEnd": true,
  12504. "gridColumnStart": true,
  12505. "gridRow": true,
  12506. "gridRowEnd": true,
  12507. "gridRowStart": true,
  12508. "lineHeight": true,
  12509. "opacity": true,
  12510. "order": true,
  12511. "orphans": true,
  12512. "widows": true,
  12513. "zIndex": true,
  12514. "zoom": true
  12515. },
  12516. // Add in properties whose names you wish to fix before
  12517. // setting or getting the value
  12518. cssProps: {},
  12519. // Get and set the style property on a DOM Node
  12520. style: function( elem, name, value, extra ) {
  12521. // Don't set styles on text and comment nodes
  12522. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12523. return;
  12524. }
  12525. // Make sure that we're working with the right name
  12526. var ret, type, hooks,
  12527. origName = camelCase( name ),
  12528. isCustomProp = rcustomProp.test( name ),
  12529. style = elem.style;
  12530. // Make sure that we're working with the right name. We don't
  12531. // want to query the value if it is a CSS custom property
  12532. // since they are user-defined.
  12533. if ( !isCustomProp ) {
  12534. name = finalPropName( origName );
  12535. }
  12536. // Gets hook for the prefixed version, then unprefixed version
  12537. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12538. // Check if we're setting a value
  12539. if ( value !== undefined ) {
  12540. type = typeof value;
  12541. // Convert "+=" or "-=" to relative numbers (#7345)
  12542. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12543. value = adjustCSS( elem, name, ret );
  12544. // Fixes bug #9237
  12545. type = "number";
  12546. }
  12547. // Make sure that null and NaN values aren't set (#7116)
  12548. if ( value == null || value !== value ) {
  12549. return;
  12550. }
  12551. // If a number was passed in, add the unit (except for certain CSS properties)
  12552. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12553. // "px" to a few hardcoded values.
  12554. if ( type === "number" && !isCustomProp ) {
  12555. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12556. }
  12557. // background-* props affect original clone's values
  12558. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12559. style[ name ] = "inherit";
  12560. }
  12561. // If a hook was provided, use that value, otherwise just set the specified value
  12562. if ( !hooks || !( "set" in hooks ) ||
  12563. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12564. if ( isCustomProp ) {
  12565. style.setProperty( name, value );
  12566. } else {
  12567. style[ name ] = value;
  12568. }
  12569. }
  12570. } else {
  12571. // If a hook was provided get the non-computed value from there
  12572. if ( hooks && "get" in hooks &&
  12573. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12574. return ret;
  12575. }
  12576. // Otherwise just get the value from the style object
  12577. return style[ name ];
  12578. }
  12579. },
  12580. css: function( elem, name, extra, styles ) {
  12581. var val, num, hooks,
  12582. origName = camelCase( name ),
  12583. isCustomProp = rcustomProp.test( name );
  12584. // Make sure that we're working with the right name. We don't
  12585. // want to modify the value if it is a CSS custom property
  12586. // since they are user-defined.
  12587. if ( !isCustomProp ) {
  12588. name = finalPropName( origName );
  12589. }
  12590. // Try prefixed name followed by the unprefixed name
  12591. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12592. // If a hook was provided get the computed value from there
  12593. if ( hooks && "get" in hooks ) {
  12594. val = hooks.get( elem, true, extra );
  12595. }
  12596. // Otherwise, if a way to get the computed value exists, use that
  12597. if ( val === undefined ) {
  12598. val = curCSS( elem, name, styles );
  12599. }
  12600. // Convert "normal" to computed value
  12601. if ( val === "normal" && name in cssNormalTransform ) {
  12602. val = cssNormalTransform[ name ];
  12603. }
  12604. // Make numeric if forced or a qualifier was provided and val looks numeric
  12605. if ( extra === "" || extra ) {
  12606. num = parseFloat( val );
  12607. return extra === true || isFinite( num ) ? num || 0 : val;
  12608. }
  12609. return val;
  12610. }
  12611. } );
  12612. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12613. jQuery.cssHooks[ dimension ] = {
  12614. get: function( elem, computed, extra ) {
  12615. if ( computed ) {
  12616. // Certain elements can have dimension info if we invisibly show them
  12617. // but it must have a current display style that would benefit
  12618. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12619. // Support: Safari 8+
  12620. // Table columns in Safari have non-zero offsetWidth & zero
  12621. // getBoundingClientRect().width unless display is changed.
  12622. // Support: IE <=11 only
  12623. // Running getBoundingClientRect on a disconnected node
  12624. // in IE throws an error.
  12625. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12626. swap( elem, cssShow, function() {
  12627. return getWidthOrHeight( elem, dimension, extra );
  12628. } ) :
  12629. getWidthOrHeight( elem, dimension, extra );
  12630. }
  12631. },
  12632. set: function( elem, value, extra ) {
  12633. var matches,
  12634. styles = getStyles( elem ),
  12635. // Only read styles.position if the test has a chance to fail
  12636. // to avoid forcing a reflow.
  12637. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12638. styles.position === "absolute",
  12639. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12640. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12641. isBorderBox = boxSizingNeeded &&
  12642. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12643. subtract = extra ?
  12644. boxModelAdjustment(
  12645. elem,
  12646. dimension,
  12647. extra,
  12648. isBorderBox,
  12649. styles
  12650. ) :
  12651. 0;
  12652. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12653. // faking a content-box to get border and padding (gh-3699)
  12654. if ( isBorderBox && scrollboxSizeBuggy ) {
  12655. subtract -= Math.ceil(
  12656. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12657. parseFloat( styles[ dimension ] ) -
  12658. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12659. 0.5
  12660. );
  12661. }
  12662. // Convert to pixels if value adjustment is needed
  12663. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12664. ( matches[ 3 ] || "px" ) !== "px" ) {
  12665. elem.style[ dimension ] = value;
  12666. value = jQuery.css( elem, dimension );
  12667. }
  12668. return setPositiveNumber( elem, value, subtract );
  12669. }
  12670. };
  12671. } );
  12672. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12673. function( elem, computed ) {
  12674. if ( computed ) {
  12675. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12676. elem.getBoundingClientRect().left -
  12677. swap( elem, { marginLeft: 0 }, function() {
  12678. return elem.getBoundingClientRect().left;
  12679. } )
  12680. ) + "px";
  12681. }
  12682. }
  12683. );
  12684. // These hooks are used by animate to expand properties
  12685. jQuery.each( {
  12686. margin: "",
  12687. padding: "",
  12688. border: "Width"
  12689. }, function( prefix, suffix ) {
  12690. jQuery.cssHooks[ prefix + suffix ] = {
  12691. expand: function( value ) {
  12692. var i = 0,
  12693. expanded = {},
  12694. // Assumes a single number if not a string
  12695. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12696. for ( ; i < 4; i++ ) {
  12697. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12698. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12699. }
  12700. return expanded;
  12701. }
  12702. };
  12703. if ( prefix !== "margin" ) {
  12704. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12705. }
  12706. } );
  12707. jQuery.fn.extend( {
  12708. css: function( name, value ) {
  12709. return access( this, function( elem, name, value ) {
  12710. var styles, len,
  12711. map = {},
  12712. i = 0;
  12713. if ( Array.isArray( name ) ) {
  12714. styles = getStyles( elem );
  12715. len = name.length;
  12716. for ( ; i < len; i++ ) {
  12717. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12718. }
  12719. return map;
  12720. }
  12721. return value !== undefined ?
  12722. jQuery.style( elem, name, value ) :
  12723. jQuery.css( elem, name );
  12724. }, name, value, arguments.length > 1 );
  12725. }
  12726. } );
  12727. function Tween( elem, options, prop, end, easing ) {
  12728. return new Tween.prototype.init( elem, options, prop, end, easing );
  12729. }
  12730. jQuery.Tween = Tween;
  12731. Tween.prototype = {
  12732. constructor: Tween,
  12733. init: function( elem, options, prop, end, easing, unit ) {
  12734. this.elem = elem;
  12735. this.prop = prop;
  12736. this.easing = easing || jQuery.easing._default;
  12737. this.options = options;
  12738. this.start = this.now = this.cur();
  12739. this.end = end;
  12740. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12741. },
  12742. cur: function() {
  12743. var hooks = Tween.propHooks[ this.prop ];
  12744. return hooks && hooks.get ?
  12745. hooks.get( this ) :
  12746. Tween.propHooks._default.get( this );
  12747. },
  12748. run: function( percent ) {
  12749. var eased,
  12750. hooks = Tween.propHooks[ this.prop ];
  12751. if ( this.options.duration ) {
  12752. this.pos = eased = jQuery.easing[ this.easing ](
  12753. percent, this.options.duration * percent, 0, 1, this.options.duration
  12754. );
  12755. } else {
  12756. this.pos = eased = percent;
  12757. }
  12758. this.now = ( this.end - this.start ) * eased + this.start;
  12759. if ( this.options.step ) {
  12760. this.options.step.call( this.elem, this.now, this );
  12761. }
  12762. if ( hooks && hooks.set ) {
  12763. hooks.set( this );
  12764. } else {
  12765. Tween.propHooks._default.set( this );
  12766. }
  12767. return this;
  12768. }
  12769. };
  12770. Tween.prototype.init.prototype = Tween.prototype;
  12771. Tween.propHooks = {
  12772. _default: {
  12773. get: function( tween ) {
  12774. var result;
  12775. // Use a property on the element directly when it is not a DOM element,
  12776. // or when there is no matching style property that exists.
  12777. if ( tween.elem.nodeType !== 1 ||
  12778. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12779. return tween.elem[ tween.prop ];
  12780. }
  12781. // Passing an empty string as a 3rd parameter to .css will automatically
  12782. // attempt a parseFloat and fallback to a string if the parse fails.
  12783. // Simple values such as "10px" are parsed to Float;
  12784. // complex values such as "rotate(1rad)" are returned as-is.
  12785. result = jQuery.css( tween.elem, tween.prop, "" );
  12786. // Empty strings, null, undefined and "auto" are converted to 0.
  12787. return !result || result === "auto" ? 0 : result;
  12788. },
  12789. set: function( tween ) {
  12790. // Use step hook for back compat.
  12791. // Use cssHook if its there.
  12792. // Use .style if available and use plain properties where available.
  12793. if ( jQuery.fx.step[ tween.prop ] ) {
  12794. jQuery.fx.step[ tween.prop ]( tween );
  12795. } else if ( tween.elem.nodeType === 1 && (
  12796. jQuery.cssHooks[ tween.prop ] ||
  12797. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12798. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12799. } else {
  12800. tween.elem[ tween.prop ] = tween.now;
  12801. }
  12802. }
  12803. }
  12804. };
  12805. // Support: IE <=9 only
  12806. // Panic based approach to setting things on disconnected nodes
  12807. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12808. set: function( tween ) {
  12809. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12810. tween.elem[ tween.prop ] = tween.now;
  12811. }
  12812. }
  12813. };
  12814. jQuery.easing = {
  12815. linear: function( p ) {
  12816. return p;
  12817. },
  12818. swing: function( p ) {
  12819. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12820. },
  12821. _default: "swing"
  12822. };
  12823. jQuery.fx = Tween.prototype.init;
  12824. // Back compat <1.8 extension point
  12825. jQuery.fx.step = {};
  12826. var
  12827. fxNow, inProgress,
  12828. rfxtypes = /^(?:toggle|show|hide)$/,
  12829. rrun = /queueHooks$/;
  12830. function schedule() {
  12831. if ( inProgress ) {
  12832. if ( document.hidden === false && window.requestAnimationFrame ) {
  12833. window.requestAnimationFrame( schedule );
  12834. } else {
  12835. window.setTimeout( schedule, jQuery.fx.interval );
  12836. }
  12837. jQuery.fx.tick();
  12838. }
  12839. }
  12840. // Animations created synchronously will run synchronously
  12841. function createFxNow() {
  12842. window.setTimeout( function() {
  12843. fxNow = undefined;
  12844. } );
  12845. return ( fxNow = Date.now() );
  12846. }
  12847. // Generate parameters to create a standard animation
  12848. function genFx( type, includeWidth ) {
  12849. var which,
  12850. i = 0,
  12851. attrs = { height: type };
  12852. // If we include width, step value is 1 to do all cssExpand values,
  12853. // otherwise step value is 2 to skip over Left and Right
  12854. includeWidth = includeWidth ? 1 : 0;
  12855. for ( ; i < 4; i += 2 - includeWidth ) {
  12856. which = cssExpand[ i ];
  12857. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12858. }
  12859. if ( includeWidth ) {
  12860. attrs.opacity = attrs.width = type;
  12861. }
  12862. return attrs;
  12863. }
  12864. function createTween( value, prop, animation ) {
  12865. var tween,
  12866. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12867. index = 0,
  12868. length = collection.length;
  12869. for ( ; index < length; index++ ) {
  12870. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12871. // We're done with this property
  12872. return tween;
  12873. }
  12874. }
  12875. }
  12876. function defaultPrefilter( elem, props, opts ) {
  12877. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12878. isBox = "width" in props || "height" in props,
  12879. anim = this,
  12880. orig = {},
  12881. style = elem.style,
  12882. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12883. dataShow = dataPriv.get( elem, "fxshow" );
  12884. // Queue-skipping animations hijack the fx hooks
  12885. if ( !opts.queue ) {
  12886. hooks = jQuery._queueHooks( elem, "fx" );
  12887. if ( hooks.unqueued == null ) {
  12888. hooks.unqueued = 0;
  12889. oldfire = hooks.empty.fire;
  12890. hooks.empty.fire = function() {
  12891. if ( !hooks.unqueued ) {
  12892. oldfire();
  12893. }
  12894. };
  12895. }
  12896. hooks.unqueued++;
  12897. anim.always( function() {
  12898. // Ensure the complete handler is called before this completes
  12899. anim.always( function() {
  12900. hooks.unqueued--;
  12901. if ( !jQuery.queue( elem, "fx" ).length ) {
  12902. hooks.empty.fire();
  12903. }
  12904. } );
  12905. } );
  12906. }
  12907. // Detect show/hide animations
  12908. for ( prop in props ) {
  12909. value = props[ prop ];
  12910. if ( rfxtypes.test( value ) ) {
  12911. delete props[ prop ];
  12912. toggle = toggle || value === "toggle";
  12913. if ( value === ( hidden ? "hide" : "show" ) ) {
  12914. // Pretend to be hidden if this is a "show" and
  12915. // there is still data from a stopped show/hide
  12916. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12917. hidden = true;
  12918. // Ignore all other no-op show/hide data
  12919. } else {
  12920. continue;
  12921. }
  12922. }
  12923. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12924. }
  12925. }
  12926. // Bail out if this is a no-op like .hide().hide()
  12927. propTween = !jQuery.isEmptyObject( props );
  12928. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12929. return;
  12930. }
  12931. // Restrict "overflow" and "display" styles during box animations
  12932. if ( isBox && elem.nodeType === 1 ) {
  12933. // Support: IE <=9 - 11, Edge 12 - 15
  12934. // Record all 3 overflow attributes because IE does not infer the shorthand
  12935. // from identically-valued overflowX and overflowY and Edge just mirrors
  12936. // the overflowX value there.
  12937. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12938. // Identify a display type, preferring old show/hide data over the CSS cascade
  12939. restoreDisplay = dataShow && dataShow.display;
  12940. if ( restoreDisplay == null ) {
  12941. restoreDisplay = dataPriv.get( elem, "display" );
  12942. }
  12943. display = jQuery.css( elem, "display" );
  12944. if ( display === "none" ) {
  12945. if ( restoreDisplay ) {
  12946. display = restoreDisplay;
  12947. } else {
  12948. // Get nonempty value(s) by temporarily forcing visibility
  12949. showHide( [ elem ], true );
  12950. restoreDisplay = elem.style.display || restoreDisplay;
  12951. display = jQuery.css( elem, "display" );
  12952. showHide( [ elem ] );
  12953. }
  12954. }
  12955. // Animate inline elements as inline-block
  12956. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12957. if ( jQuery.css( elem, "float" ) === "none" ) {
  12958. // Restore the original display value at the end of pure show/hide animations
  12959. if ( !propTween ) {
  12960. anim.done( function() {
  12961. style.display = restoreDisplay;
  12962. } );
  12963. if ( restoreDisplay == null ) {
  12964. display = style.display;
  12965. restoreDisplay = display === "none" ? "" : display;
  12966. }
  12967. }
  12968. style.display = "inline-block";
  12969. }
  12970. }
  12971. }
  12972. if ( opts.overflow ) {
  12973. style.overflow = "hidden";
  12974. anim.always( function() {
  12975. style.overflow = opts.overflow[ 0 ];
  12976. style.overflowX = opts.overflow[ 1 ];
  12977. style.overflowY = opts.overflow[ 2 ];
  12978. } );
  12979. }
  12980. // Implement show/hide animations
  12981. propTween = false;
  12982. for ( prop in orig ) {
  12983. // General show/hide setup for this element animation
  12984. if ( !propTween ) {
  12985. if ( dataShow ) {
  12986. if ( "hidden" in dataShow ) {
  12987. hidden = dataShow.hidden;
  12988. }
  12989. } else {
  12990. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  12991. }
  12992. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  12993. if ( toggle ) {
  12994. dataShow.hidden = !hidden;
  12995. }
  12996. // Show elements before animating them
  12997. if ( hidden ) {
  12998. showHide( [ elem ], true );
  12999. }
  13000. /* eslint-disable no-loop-func */
  13001. anim.done( function() {
  13002. /* eslint-enable no-loop-func */
  13003. // The final step of a "hide" animation is actually hiding the element
  13004. if ( !hidden ) {
  13005. showHide( [ elem ] );
  13006. }
  13007. dataPriv.remove( elem, "fxshow" );
  13008. for ( prop in orig ) {
  13009. jQuery.style( elem, prop, orig[ prop ] );
  13010. }
  13011. } );
  13012. }
  13013. // Per-property setup
  13014. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13015. if ( !( prop in dataShow ) ) {
  13016. dataShow[ prop ] = propTween.start;
  13017. if ( hidden ) {
  13018. propTween.end = propTween.start;
  13019. propTween.start = 0;
  13020. }
  13021. }
  13022. }
  13023. }
  13024. function propFilter( props, specialEasing ) {
  13025. var index, name, easing, value, hooks;
  13026. // camelCase, specialEasing and expand cssHook pass
  13027. for ( index in props ) {
  13028. name = camelCase( index );
  13029. easing = specialEasing[ name ];
  13030. value = props[ index ];
  13031. if ( Array.isArray( value ) ) {
  13032. easing = value[ 1 ];
  13033. value = props[ index ] = value[ 0 ];
  13034. }
  13035. if ( index !== name ) {
  13036. props[ name ] = value;
  13037. delete props[ index ];
  13038. }
  13039. hooks = jQuery.cssHooks[ name ];
  13040. if ( hooks && "expand" in hooks ) {
  13041. value = hooks.expand( value );
  13042. delete props[ name ];
  13043. // Not quite $.extend, this won't overwrite existing keys.
  13044. // Reusing 'index' because we have the correct "name"
  13045. for ( index in value ) {
  13046. if ( !( index in props ) ) {
  13047. props[ index ] = value[ index ];
  13048. specialEasing[ index ] = easing;
  13049. }
  13050. }
  13051. } else {
  13052. specialEasing[ name ] = easing;
  13053. }
  13054. }
  13055. }
  13056. function Animation( elem, properties, options ) {
  13057. var result,
  13058. stopped,
  13059. index = 0,
  13060. length = Animation.prefilters.length,
  13061. deferred = jQuery.Deferred().always( function() {
  13062. // Don't match elem in the :animated selector
  13063. delete tick.elem;
  13064. } ),
  13065. tick = function() {
  13066. if ( stopped ) {
  13067. return false;
  13068. }
  13069. var currentTime = fxNow || createFxNow(),
  13070. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13071. // Support: Android 2.3 only
  13072. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13073. temp = remaining / animation.duration || 0,
  13074. percent = 1 - temp,
  13075. index = 0,
  13076. length = animation.tweens.length;
  13077. for ( ; index < length; index++ ) {
  13078. animation.tweens[ index ].run( percent );
  13079. }
  13080. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13081. // If there's more to do, yield
  13082. if ( percent < 1 && length ) {
  13083. return remaining;
  13084. }
  13085. // If this was an empty animation, synthesize a final progress notification
  13086. if ( !length ) {
  13087. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13088. }
  13089. // Resolve the animation and report its conclusion
  13090. deferred.resolveWith( elem, [ animation ] );
  13091. return false;
  13092. },
  13093. animation = deferred.promise( {
  13094. elem: elem,
  13095. props: jQuery.extend( {}, properties ),
  13096. opts: jQuery.extend( true, {
  13097. specialEasing: {},
  13098. easing: jQuery.easing._default
  13099. }, options ),
  13100. originalProperties: properties,
  13101. originalOptions: options,
  13102. startTime: fxNow || createFxNow(),
  13103. duration: options.duration,
  13104. tweens: [],
  13105. createTween: function( prop, end ) {
  13106. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13107. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13108. animation.tweens.push( tween );
  13109. return tween;
  13110. },
  13111. stop: function( gotoEnd ) {
  13112. var index = 0,
  13113. // If we are going to the end, we want to run all the tweens
  13114. // otherwise we skip this part
  13115. length = gotoEnd ? animation.tweens.length : 0;
  13116. if ( stopped ) {
  13117. return this;
  13118. }
  13119. stopped = true;
  13120. for ( ; index < length; index++ ) {
  13121. animation.tweens[ index ].run( 1 );
  13122. }
  13123. // Resolve when we played the last frame; otherwise, reject
  13124. if ( gotoEnd ) {
  13125. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13126. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13127. } else {
  13128. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13129. }
  13130. return this;
  13131. }
  13132. } ),
  13133. props = animation.props;
  13134. propFilter( props, animation.opts.specialEasing );
  13135. for ( ; index < length; index++ ) {
  13136. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13137. if ( result ) {
  13138. if ( isFunction( result.stop ) ) {
  13139. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13140. result.stop.bind( result );
  13141. }
  13142. return result;
  13143. }
  13144. }
  13145. jQuery.map( props, createTween, animation );
  13146. if ( isFunction( animation.opts.start ) ) {
  13147. animation.opts.start.call( elem, animation );
  13148. }
  13149. // Attach callbacks from options
  13150. animation
  13151. .progress( animation.opts.progress )
  13152. .done( animation.opts.done, animation.opts.complete )
  13153. .fail( animation.opts.fail )
  13154. .always( animation.opts.always );
  13155. jQuery.fx.timer(
  13156. jQuery.extend( tick, {
  13157. elem: elem,
  13158. anim: animation,
  13159. queue: animation.opts.queue
  13160. } )
  13161. );
  13162. return animation;
  13163. }
  13164. jQuery.Animation = jQuery.extend( Animation, {
  13165. tweeners: {
  13166. "*": [ function( prop, value ) {
  13167. var tween = this.createTween( prop, value );
  13168. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13169. return tween;
  13170. } ]
  13171. },
  13172. tweener: function( props, callback ) {
  13173. if ( isFunction( props ) ) {
  13174. callback = props;
  13175. props = [ "*" ];
  13176. } else {
  13177. props = props.match( rnothtmlwhite );
  13178. }
  13179. var prop,
  13180. index = 0,
  13181. length = props.length;
  13182. for ( ; index < length; index++ ) {
  13183. prop = props[ index ];
  13184. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13185. Animation.tweeners[ prop ].unshift( callback );
  13186. }
  13187. },
  13188. prefilters: [ defaultPrefilter ],
  13189. prefilter: function( callback, prepend ) {
  13190. if ( prepend ) {
  13191. Animation.prefilters.unshift( callback );
  13192. } else {
  13193. Animation.prefilters.push( callback );
  13194. }
  13195. }
  13196. } );
  13197. jQuery.speed = function( speed, easing, fn ) {
  13198. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13199. complete: fn || !fn && easing ||
  13200. isFunction( speed ) && speed,
  13201. duration: speed,
  13202. easing: fn && easing || easing && !isFunction( easing ) && easing
  13203. };
  13204. // Go to the end state if fx are off
  13205. if ( jQuery.fx.off ) {
  13206. opt.duration = 0;
  13207. } else {
  13208. if ( typeof opt.duration !== "number" ) {
  13209. if ( opt.duration in jQuery.fx.speeds ) {
  13210. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13211. } else {
  13212. opt.duration = jQuery.fx.speeds._default;
  13213. }
  13214. }
  13215. }
  13216. // Normalize opt.queue - true/undefined/null -> "fx"
  13217. if ( opt.queue == null || opt.queue === true ) {
  13218. opt.queue = "fx";
  13219. }
  13220. // Queueing
  13221. opt.old = opt.complete;
  13222. opt.complete = function() {
  13223. if ( isFunction( opt.old ) ) {
  13224. opt.old.call( this );
  13225. }
  13226. if ( opt.queue ) {
  13227. jQuery.dequeue( this, opt.queue );
  13228. }
  13229. };
  13230. return opt;
  13231. };
  13232. jQuery.fn.extend( {
  13233. fadeTo: function( speed, to, easing, callback ) {
  13234. // Show any hidden elements after setting opacity to 0
  13235. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13236. // Animate to the value specified
  13237. .end().animate( { opacity: to }, speed, easing, callback );
  13238. },
  13239. animate: function( prop, speed, easing, callback ) {
  13240. var empty = jQuery.isEmptyObject( prop ),
  13241. optall = jQuery.speed( speed, easing, callback ),
  13242. doAnimation = function() {
  13243. // Operate on a copy of prop so per-property easing won't be lost
  13244. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13245. // Empty animations, or finishing resolves immediately
  13246. if ( empty || dataPriv.get( this, "finish" ) ) {
  13247. anim.stop( true );
  13248. }
  13249. };
  13250. doAnimation.finish = doAnimation;
  13251. return empty || optall.queue === false ?
  13252. this.each( doAnimation ) :
  13253. this.queue( optall.queue, doAnimation );
  13254. },
  13255. stop: function( type, clearQueue, gotoEnd ) {
  13256. var stopQueue = function( hooks ) {
  13257. var stop = hooks.stop;
  13258. delete hooks.stop;
  13259. stop( gotoEnd );
  13260. };
  13261. if ( typeof type !== "string" ) {
  13262. gotoEnd = clearQueue;
  13263. clearQueue = type;
  13264. type = undefined;
  13265. }
  13266. if ( clearQueue && type !== false ) {
  13267. this.queue( type || "fx", [] );
  13268. }
  13269. return this.each( function() {
  13270. var dequeue = true,
  13271. index = type != null && type + "queueHooks",
  13272. timers = jQuery.timers,
  13273. data = dataPriv.get( this );
  13274. if ( index ) {
  13275. if ( data[ index ] && data[ index ].stop ) {
  13276. stopQueue( data[ index ] );
  13277. }
  13278. } else {
  13279. for ( index in data ) {
  13280. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13281. stopQueue( data[ index ] );
  13282. }
  13283. }
  13284. }
  13285. for ( index = timers.length; index--; ) {
  13286. if ( timers[ index ].elem === this &&
  13287. ( type == null || timers[ index ].queue === type ) ) {
  13288. timers[ index ].anim.stop( gotoEnd );
  13289. dequeue = false;
  13290. timers.splice( index, 1 );
  13291. }
  13292. }
  13293. // Start the next in the queue if the last step wasn't forced.
  13294. // Timers currently will call their complete callbacks, which
  13295. // will dequeue but only if they were gotoEnd.
  13296. if ( dequeue || !gotoEnd ) {
  13297. jQuery.dequeue( this, type );
  13298. }
  13299. } );
  13300. },
  13301. finish: function( type ) {
  13302. if ( type !== false ) {
  13303. type = type || "fx";
  13304. }
  13305. return this.each( function() {
  13306. var index,
  13307. data = dataPriv.get( this ),
  13308. queue = data[ type + "queue" ],
  13309. hooks = data[ type + "queueHooks" ],
  13310. timers = jQuery.timers,
  13311. length = queue ? queue.length : 0;
  13312. // Enable finishing flag on private data
  13313. data.finish = true;
  13314. // Empty the queue first
  13315. jQuery.queue( this, type, [] );
  13316. if ( hooks && hooks.stop ) {
  13317. hooks.stop.call( this, true );
  13318. }
  13319. // Look for any active animations, and finish them
  13320. for ( index = timers.length; index--; ) {
  13321. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13322. timers[ index ].anim.stop( true );
  13323. timers.splice( index, 1 );
  13324. }
  13325. }
  13326. // Look for any animations in the old queue and finish them
  13327. for ( index = 0; index < length; index++ ) {
  13328. if ( queue[ index ] && queue[ index ].finish ) {
  13329. queue[ index ].finish.call( this );
  13330. }
  13331. }
  13332. // Turn off finishing flag
  13333. delete data.finish;
  13334. } );
  13335. }
  13336. } );
  13337. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13338. var cssFn = jQuery.fn[ name ];
  13339. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13340. return speed == null || typeof speed === "boolean" ?
  13341. cssFn.apply( this, arguments ) :
  13342. this.animate( genFx( name, true ), speed, easing, callback );
  13343. };
  13344. } );
  13345. // Generate shortcuts for custom animations
  13346. jQuery.each( {
  13347. slideDown: genFx( "show" ),
  13348. slideUp: genFx( "hide" ),
  13349. slideToggle: genFx( "toggle" ),
  13350. fadeIn: { opacity: "show" },
  13351. fadeOut: { opacity: "hide" },
  13352. fadeToggle: { opacity: "toggle" }
  13353. }, function( name, props ) {
  13354. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13355. return this.animate( props, speed, easing, callback );
  13356. };
  13357. } );
  13358. jQuery.timers = [];
  13359. jQuery.fx.tick = function() {
  13360. var timer,
  13361. i = 0,
  13362. timers = jQuery.timers;
  13363. fxNow = Date.now();
  13364. for ( ; i < timers.length; i++ ) {
  13365. timer = timers[ i ];
  13366. // Run the timer and safely remove it when done (allowing for external removal)
  13367. if ( !timer() && timers[ i ] === timer ) {
  13368. timers.splice( i--, 1 );
  13369. }
  13370. }
  13371. if ( !timers.length ) {
  13372. jQuery.fx.stop();
  13373. }
  13374. fxNow = undefined;
  13375. };
  13376. jQuery.fx.timer = function( timer ) {
  13377. jQuery.timers.push( timer );
  13378. jQuery.fx.start();
  13379. };
  13380. jQuery.fx.interval = 13;
  13381. jQuery.fx.start = function() {
  13382. if ( inProgress ) {
  13383. return;
  13384. }
  13385. inProgress = true;
  13386. schedule();
  13387. };
  13388. jQuery.fx.stop = function() {
  13389. inProgress = null;
  13390. };
  13391. jQuery.fx.speeds = {
  13392. slow: 600,
  13393. fast: 200,
  13394. // Default speed
  13395. _default: 400
  13396. };
  13397. // Based off of the plugin by Clint Helfers, with permission.
  13398. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13399. jQuery.fn.delay = function( time, type ) {
  13400. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13401. type = type || "fx";
  13402. return this.queue( type, function( next, hooks ) {
  13403. var timeout = window.setTimeout( next, time );
  13404. hooks.stop = function() {
  13405. window.clearTimeout( timeout );
  13406. };
  13407. } );
  13408. };
  13409. ( function() {
  13410. var input = document.createElement( "input" ),
  13411. select = document.createElement( "select" ),
  13412. opt = select.appendChild( document.createElement( "option" ) );
  13413. input.type = "checkbox";
  13414. // Support: Android <=4.3 only
  13415. // Default value for a checkbox should be "on"
  13416. support.checkOn = input.value !== "";
  13417. // Support: IE <=11 only
  13418. // Must access selectedIndex to make default options select
  13419. support.optSelected = opt.selected;
  13420. // Support: IE <=11 only
  13421. // An input loses its value after becoming a radio
  13422. input = document.createElement( "input" );
  13423. input.value = "t";
  13424. input.type = "radio";
  13425. support.radioValue = input.value === "t";
  13426. } )();
  13427. var boolHook,
  13428. attrHandle = jQuery.expr.attrHandle;
  13429. jQuery.fn.extend( {
  13430. attr: function( name, value ) {
  13431. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13432. },
  13433. removeAttr: function( name ) {
  13434. return this.each( function() {
  13435. jQuery.removeAttr( this, name );
  13436. } );
  13437. }
  13438. } );
  13439. jQuery.extend( {
  13440. attr: function( elem, name, value ) {
  13441. var ret, hooks,
  13442. nType = elem.nodeType;
  13443. // Don't get/set attributes on text, comment and attribute nodes
  13444. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13445. return;
  13446. }
  13447. // Fallback to prop when attributes are not supported
  13448. if ( typeof elem.getAttribute === "undefined" ) {
  13449. return jQuery.prop( elem, name, value );
  13450. }
  13451. // Attribute hooks are determined by the lowercase version
  13452. // Grab necessary hook if one is defined
  13453. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13454. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13455. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13456. }
  13457. if ( value !== undefined ) {
  13458. if ( value === null ) {
  13459. jQuery.removeAttr( elem, name );
  13460. return;
  13461. }
  13462. if ( hooks && "set" in hooks &&
  13463. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13464. return ret;
  13465. }
  13466. elem.setAttribute( name, value + "" );
  13467. return value;
  13468. }
  13469. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13470. return ret;
  13471. }
  13472. ret = jQuery.find.attr( elem, name );
  13473. // Non-existent attributes return null, we normalize to undefined
  13474. return ret == null ? undefined : ret;
  13475. },
  13476. attrHooks: {
  13477. type: {
  13478. set: function( elem, value ) {
  13479. if ( !support.radioValue && value === "radio" &&
  13480. nodeName( elem, "input" ) ) {
  13481. var val = elem.value;
  13482. elem.setAttribute( "type", value );
  13483. if ( val ) {
  13484. elem.value = val;
  13485. }
  13486. return value;
  13487. }
  13488. }
  13489. }
  13490. },
  13491. removeAttr: function( elem, value ) {
  13492. var name,
  13493. i = 0,
  13494. // Attribute names can contain non-HTML whitespace characters
  13495. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13496. attrNames = value && value.match( rnothtmlwhite );
  13497. if ( attrNames && elem.nodeType === 1 ) {
  13498. while ( ( name = attrNames[ i++ ] ) ) {
  13499. elem.removeAttribute( name );
  13500. }
  13501. }
  13502. }
  13503. } );
  13504. // Hooks for boolean attributes
  13505. boolHook = {
  13506. set: function( elem, value, name ) {
  13507. if ( value === false ) {
  13508. // Remove boolean attributes when set to false
  13509. jQuery.removeAttr( elem, name );
  13510. } else {
  13511. elem.setAttribute( name, name );
  13512. }
  13513. return name;
  13514. }
  13515. };
  13516. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13517. var getter = attrHandle[ name ] || jQuery.find.attr;
  13518. attrHandle[ name ] = function( elem, name, isXML ) {
  13519. var ret, handle,
  13520. lowercaseName = name.toLowerCase();
  13521. if ( !isXML ) {
  13522. // Avoid an infinite loop by temporarily removing this function from the getter
  13523. handle = attrHandle[ lowercaseName ];
  13524. attrHandle[ lowercaseName ] = ret;
  13525. ret = getter( elem, name, isXML ) != null ?
  13526. lowercaseName :
  13527. null;
  13528. attrHandle[ lowercaseName ] = handle;
  13529. }
  13530. return ret;
  13531. };
  13532. } );
  13533. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13534. rclickable = /^(?:a|area)$/i;
  13535. jQuery.fn.extend( {
  13536. prop: function( name, value ) {
  13537. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13538. },
  13539. removeProp: function( name ) {
  13540. return this.each( function() {
  13541. delete this[ jQuery.propFix[ name ] || name ];
  13542. } );
  13543. }
  13544. } );
  13545. jQuery.extend( {
  13546. prop: function( elem, name, value ) {
  13547. var ret, hooks,
  13548. nType = elem.nodeType;
  13549. // Don't get/set properties on text, comment and attribute nodes
  13550. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13551. return;
  13552. }
  13553. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13554. // Fix name and attach hooks
  13555. name = jQuery.propFix[ name ] || name;
  13556. hooks = jQuery.propHooks[ name ];
  13557. }
  13558. if ( value !== undefined ) {
  13559. if ( hooks && "set" in hooks &&
  13560. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13561. return ret;
  13562. }
  13563. return ( elem[ name ] = value );
  13564. }
  13565. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13566. return ret;
  13567. }
  13568. return elem[ name ];
  13569. },
  13570. propHooks: {
  13571. tabIndex: {
  13572. get: function( elem ) {
  13573. // Support: IE <=9 - 11 only
  13574. // elem.tabIndex doesn't always return the
  13575. // correct value when it hasn't been explicitly set
  13576. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13577. // Use proper attribute retrieval(#12072)
  13578. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13579. if ( tabindex ) {
  13580. return parseInt( tabindex, 10 );
  13581. }
  13582. if (
  13583. rfocusable.test( elem.nodeName ) ||
  13584. rclickable.test( elem.nodeName ) &&
  13585. elem.href
  13586. ) {
  13587. return 0;
  13588. }
  13589. return -1;
  13590. }
  13591. }
  13592. },
  13593. propFix: {
  13594. "for": "htmlFor",
  13595. "class": "className"
  13596. }
  13597. } );
  13598. // Support: IE <=11 only
  13599. // Accessing the selectedIndex property
  13600. // forces the browser to respect setting selected
  13601. // on the option
  13602. // The getter ensures a default option is selected
  13603. // when in an optgroup
  13604. // eslint rule "no-unused-expressions" is disabled for this code
  13605. // since it considers such accessions noop
  13606. if ( !support.optSelected ) {
  13607. jQuery.propHooks.selected = {
  13608. get: function( elem ) {
  13609. /* eslint no-unused-expressions: "off" */
  13610. var parent = elem.parentNode;
  13611. if ( parent && parent.parentNode ) {
  13612. parent.parentNode.selectedIndex;
  13613. }
  13614. return null;
  13615. },
  13616. set: function( elem ) {
  13617. /* eslint no-unused-expressions: "off" */
  13618. var parent = elem.parentNode;
  13619. if ( parent ) {
  13620. parent.selectedIndex;
  13621. if ( parent.parentNode ) {
  13622. parent.parentNode.selectedIndex;
  13623. }
  13624. }
  13625. }
  13626. };
  13627. }
  13628. jQuery.each( [
  13629. "tabIndex",
  13630. "readOnly",
  13631. "maxLength",
  13632. "cellSpacing",
  13633. "cellPadding",
  13634. "rowSpan",
  13635. "colSpan",
  13636. "useMap",
  13637. "frameBorder",
  13638. "contentEditable"
  13639. ], function() {
  13640. jQuery.propFix[ this.toLowerCase() ] = this;
  13641. } );
  13642. // Strip and collapse whitespace according to HTML spec
  13643. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13644. function stripAndCollapse( value ) {
  13645. var tokens = value.match( rnothtmlwhite ) || [];
  13646. return tokens.join( " " );
  13647. }
  13648. function getClass( elem ) {
  13649. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13650. }
  13651. function classesToArray( value ) {
  13652. if ( Array.isArray( value ) ) {
  13653. return value;
  13654. }
  13655. if ( typeof value === "string" ) {
  13656. return value.match( rnothtmlwhite ) || [];
  13657. }
  13658. return [];
  13659. }
  13660. jQuery.fn.extend( {
  13661. addClass: function( value ) {
  13662. var classes, elem, cur, curValue, clazz, j, finalValue,
  13663. i = 0;
  13664. if ( isFunction( value ) ) {
  13665. return this.each( function( j ) {
  13666. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13667. } );
  13668. }
  13669. classes = classesToArray( value );
  13670. if ( classes.length ) {
  13671. while ( ( elem = this[ i++ ] ) ) {
  13672. curValue = getClass( elem );
  13673. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13674. if ( cur ) {
  13675. j = 0;
  13676. while ( ( clazz = classes[ j++ ] ) ) {
  13677. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13678. cur += clazz + " ";
  13679. }
  13680. }
  13681. // Only assign if different to avoid unneeded rendering.
  13682. finalValue = stripAndCollapse( cur );
  13683. if ( curValue !== finalValue ) {
  13684. elem.setAttribute( "class", finalValue );
  13685. }
  13686. }
  13687. }
  13688. }
  13689. return this;
  13690. },
  13691. removeClass: function( value ) {
  13692. var classes, elem, cur, curValue, clazz, j, finalValue,
  13693. i = 0;
  13694. if ( isFunction( value ) ) {
  13695. return this.each( function( j ) {
  13696. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13697. } );
  13698. }
  13699. if ( !arguments.length ) {
  13700. return this.attr( "class", "" );
  13701. }
  13702. classes = classesToArray( value );
  13703. if ( classes.length ) {
  13704. while ( ( elem = this[ i++ ] ) ) {
  13705. curValue = getClass( elem );
  13706. // This expression is here for better compressibility (see addClass)
  13707. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13708. if ( cur ) {
  13709. j = 0;
  13710. while ( ( clazz = classes[ j++ ] ) ) {
  13711. // Remove *all* instances
  13712. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13713. cur = cur.replace( " " + clazz + " ", " " );
  13714. }
  13715. }
  13716. // Only assign if different to avoid unneeded rendering.
  13717. finalValue = stripAndCollapse( cur );
  13718. if ( curValue !== finalValue ) {
  13719. elem.setAttribute( "class", finalValue );
  13720. }
  13721. }
  13722. }
  13723. }
  13724. return this;
  13725. },
  13726. toggleClass: function( value, stateVal ) {
  13727. var type = typeof value,
  13728. isValidValue = type === "string" || Array.isArray( value );
  13729. if ( typeof stateVal === "boolean" && isValidValue ) {
  13730. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13731. }
  13732. if ( isFunction( value ) ) {
  13733. return this.each( function( i ) {
  13734. jQuery( this ).toggleClass(
  13735. value.call( this, i, getClass( this ), stateVal ),
  13736. stateVal
  13737. );
  13738. } );
  13739. }
  13740. return this.each( function() {
  13741. var className, i, self, classNames;
  13742. if ( isValidValue ) {
  13743. // Toggle individual class names
  13744. i = 0;
  13745. self = jQuery( this );
  13746. classNames = classesToArray( value );
  13747. while ( ( className = classNames[ i++ ] ) ) {
  13748. // Check each className given, space separated list
  13749. if ( self.hasClass( className ) ) {
  13750. self.removeClass( className );
  13751. } else {
  13752. self.addClass( className );
  13753. }
  13754. }
  13755. // Toggle whole class name
  13756. } else if ( value === undefined || type === "boolean" ) {
  13757. className = getClass( this );
  13758. if ( className ) {
  13759. // Store className if set
  13760. dataPriv.set( this, "__className__", className );
  13761. }
  13762. // If the element has a class name or if we're passed `false`,
  13763. // then remove the whole classname (if there was one, the above saved it).
  13764. // Otherwise bring back whatever was previously saved (if anything),
  13765. // falling back to the empty string if nothing was stored.
  13766. if ( this.setAttribute ) {
  13767. this.setAttribute( "class",
  13768. className || value === false ?
  13769. "" :
  13770. dataPriv.get( this, "__className__" ) || ""
  13771. );
  13772. }
  13773. }
  13774. } );
  13775. },
  13776. hasClass: function( selector ) {
  13777. var className, elem,
  13778. i = 0;
  13779. className = " " + selector + " ";
  13780. while ( ( elem = this[ i++ ] ) ) {
  13781. if ( elem.nodeType === 1 &&
  13782. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13783. return true;
  13784. }
  13785. }
  13786. return false;
  13787. }
  13788. } );
  13789. var rreturn = /\r/g;
  13790. jQuery.fn.extend( {
  13791. val: function( value ) {
  13792. var hooks, ret, valueIsFunction,
  13793. elem = this[ 0 ];
  13794. if ( !arguments.length ) {
  13795. if ( elem ) {
  13796. hooks = jQuery.valHooks[ elem.type ] ||
  13797. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13798. if ( hooks &&
  13799. "get" in hooks &&
  13800. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13801. ) {
  13802. return ret;
  13803. }
  13804. ret = elem.value;
  13805. // Handle most common string cases
  13806. if ( typeof ret === "string" ) {
  13807. return ret.replace( rreturn, "" );
  13808. }
  13809. // Handle cases where value is null/undef or number
  13810. return ret == null ? "" : ret;
  13811. }
  13812. return;
  13813. }
  13814. valueIsFunction = isFunction( value );
  13815. return this.each( function( i ) {
  13816. var val;
  13817. if ( this.nodeType !== 1 ) {
  13818. return;
  13819. }
  13820. if ( valueIsFunction ) {
  13821. val = value.call( this, i, jQuery( this ).val() );
  13822. } else {
  13823. val = value;
  13824. }
  13825. // Treat null/undefined as ""; convert numbers to string
  13826. if ( val == null ) {
  13827. val = "";
  13828. } else if ( typeof val === "number" ) {
  13829. val += "";
  13830. } else if ( Array.isArray( val ) ) {
  13831. val = jQuery.map( val, function( value ) {
  13832. return value == null ? "" : value + "";
  13833. } );
  13834. }
  13835. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13836. // If set returns undefined, fall back to normal setting
  13837. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13838. this.value = val;
  13839. }
  13840. } );
  13841. }
  13842. } );
  13843. jQuery.extend( {
  13844. valHooks: {
  13845. option: {
  13846. get: function( elem ) {
  13847. var val = jQuery.find.attr( elem, "value" );
  13848. return val != null ?
  13849. val :
  13850. // Support: IE <=10 - 11 only
  13851. // option.text throws exceptions (#14686, #14858)
  13852. // Strip and collapse whitespace
  13853. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13854. stripAndCollapse( jQuery.text( elem ) );
  13855. }
  13856. },
  13857. select: {
  13858. get: function( elem ) {
  13859. var value, option, i,
  13860. options = elem.options,
  13861. index = elem.selectedIndex,
  13862. one = elem.type === "select-one",
  13863. values = one ? null : [],
  13864. max = one ? index + 1 : options.length;
  13865. if ( index < 0 ) {
  13866. i = max;
  13867. } else {
  13868. i = one ? index : 0;
  13869. }
  13870. // Loop through all the selected options
  13871. for ( ; i < max; i++ ) {
  13872. option = options[ i ];
  13873. // Support: IE <=9 only
  13874. // IE8-9 doesn't update selected after form reset (#2551)
  13875. if ( ( option.selected || i === index ) &&
  13876. // Don't return options that are disabled or in a disabled optgroup
  13877. !option.disabled &&
  13878. ( !option.parentNode.disabled ||
  13879. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13880. // Get the specific value for the option
  13881. value = jQuery( option ).val();
  13882. // We don't need an array for one selects
  13883. if ( one ) {
  13884. return value;
  13885. }
  13886. // Multi-Selects return an array
  13887. values.push( value );
  13888. }
  13889. }
  13890. return values;
  13891. },
  13892. set: function( elem, value ) {
  13893. var optionSet, option,
  13894. options = elem.options,
  13895. values = jQuery.makeArray( value ),
  13896. i = options.length;
  13897. while ( i-- ) {
  13898. option = options[ i ];
  13899. /* eslint-disable no-cond-assign */
  13900. if ( option.selected =
  13901. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13902. ) {
  13903. optionSet = true;
  13904. }
  13905. /* eslint-enable no-cond-assign */
  13906. }
  13907. // Force browsers to behave consistently when non-matching value is set
  13908. if ( !optionSet ) {
  13909. elem.selectedIndex = -1;
  13910. }
  13911. return values;
  13912. }
  13913. }
  13914. }
  13915. } );
  13916. // Radios and checkboxes getter/setter
  13917. jQuery.each( [ "radio", "checkbox" ], function() {
  13918. jQuery.valHooks[ this ] = {
  13919. set: function( elem, value ) {
  13920. if ( Array.isArray( value ) ) {
  13921. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13922. }
  13923. }
  13924. };
  13925. if ( !support.checkOn ) {
  13926. jQuery.valHooks[ this ].get = function( elem ) {
  13927. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13928. };
  13929. }
  13930. } );
  13931. // Return jQuery for attributes-only inclusion
  13932. support.focusin = "onfocusin" in window;
  13933. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13934. stopPropagationCallback = function( e ) {
  13935. e.stopPropagation();
  13936. };
  13937. jQuery.extend( jQuery.event, {
  13938. trigger: function( event, data, elem, onlyHandlers ) {
  13939. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13940. eventPath = [ elem || document ],
  13941. type = hasOwn.call( event, "type" ) ? event.type : event,
  13942. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13943. cur = lastElement = tmp = elem = elem || document;
  13944. // Don't do events on text and comment nodes
  13945. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13946. return;
  13947. }
  13948. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13949. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13950. return;
  13951. }
  13952. if ( type.indexOf( "." ) > -1 ) {
  13953. // Namespaced trigger; create a regexp to match event type in handle()
  13954. namespaces = type.split( "." );
  13955. type = namespaces.shift();
  13956. namespaces.sort();
  13957. }
  13958. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13959. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13960. event = event[ jQuery.expando ] ?
  13961. event :
  13962. new jQuery.Event( type, typeof event === "object" && event );
  13963. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  13964. event.isTrigger = onlyHandlers ? 2 : 3;
  13965. event.namespace = namespaces.join( "." );
  13966. event.rnamespace = event.namespace ?
  13967. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  13968. null;
  13969. // Clean up the event in case it is being reused
  13970. event.result = undefined;
  13971. if ( !event.target ) {
  13972. event.target = elem;
  13973. }
  13974. // Clone any incoming data and prepend the event, creating the handler arg list
  13975. data = data == null ?
  13976. [ event ] :
  13977. jQuery.makeArray( data, [ event ] );
  13978. // Allow special events to draw outside the lines
  13979. special = jQuery.event.special[ type ] || {};
  13980. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  13981. return;
  13982. }
  13983. // Determine event propagation path in advance, per W3C events spec (#9951)
  13984. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  13985. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  13986. bubbleType = special.delegateType || type;
  13987. if ( !rfocusMorph.test( bubbleType + type ) ) {
  13988. cur = cur.parentNode;
  13989. }
  13990. for ( ; cur; cur = cur.parentNode ) {
  13991. eventPath.push( cur );
  13992. tmp = cur;
  13993. }
  13994. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  13995. if ( tmp === ( elem.ownerDocument || document ) ) {
  13996. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  13997. }
  13998. }
  13999. // Fire handlers on the event path
  14000. i = 0;
  14001. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14002. lastElement = cur;
  14003. event.type = i > 1 ?
  14004. bubbleType :
  14005. special.bindType || type;
  14006. // jQuery handler
  14007. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14008. dataPriv.get( cur, "handle" );
  14009. if ( handle ) {
  14010. handle.apply( cur, data );
  14011. }
  14012. // Native handler
  14013. handle = ontype && cur[ ontype ];
  14014. if ( handle && handle.apply && acceptData( cur ) ) {
  14015. event.result = handle.apply( cur, data );
  14016. if ( event.result === false ) {
  14017. event.preventDefault();
  14018. }
  14019. }
  14020. }
  14021. event.type = type;
  14022. // If nobody prevented the default action, do it now
  14023. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14024. if ( ( !special._default ||
  14025. special._default.apply( eventPath.pop(), data ) === false ) &&
  14026. acceptData( elem ) ) {
  14027. // Call a native DOM method on the target with the same name as the event.
  14028. // Don't do default actions on window, that's where global variables be (#6170)
  14029. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14030. // Don't re-trigger an onFOO event when we call its FOO() method
  14031. tmp = elem[ ontype ];
  14032. if ( tmp ) {
  14033. elem[ ontype ] = null;
  14034. }
  14035. // Prevent re-triggering of the same event, since we already bubbled it above
  14036. jQuery.event.triggered = type;
  14037. if ( event.isPropagationStopped() ) {
  14038. lastElement.addEventListener( type, stopPropagationCallback );
  14039. }
  14040. elem[ type ]();
  14041. if ( event.isPropagationStopped() ) {
  14042. lastElement.removeEventListener( type, stopPropagationCallback );
  14043. }
  14044. jQuery.event.triggered = undefined;
  14045. if ( tmp ) {
  14046. elem[ ontype ] = tmp;
  14047. }
  14048. }
  14049. }
  14050. }
  14051. return event.result;
  14052. },
  14053. // Piggyback on a donor event to simulate a different one
  14054. // Used only for `focus(in | out)` events
  14055. simulate: function( type, elem, event ) {
  14056. var e = jQuery.extend(
  14057. new jQuery.Event(),
  14058. event,
  14059. {
  14060. type: type,
  14061. isSimulated: true
  14062. }
  14063. );
  14064. jQuery.event.trigger( e, null, elem );
  14065. }
  14066. } );
  14067. jQuery.fn.extend( {
  14068. trigger: function( type, data ) {
  14069. return this.each( function() {
  14070. jQuery.event.trigger( type, data, this );
  14071. } );
  14072. },
  14073. triggerHandler: function( type, data ) {
  14074. var elem = this[ 0 ];
  14075. if ( elem ) {
  14076. return jQuery.event.trigger( type, data, elem, true );
  14077. }
  14078. }
  14079. } );
  14080. // Support: Firefox <=44
  14081. // Firefox doesn't have focus(in | out) events
  14082. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14083. //
  14084. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14085. // focus(in | out) events fire after focus & blur events,
  14086. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14087. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14088. if ( !support.focusin ) {
  14089. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14090. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14091. var handler = function( event ) {
  14092. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14093. };
  14094. jQuery.event.special[ fix ] = {
  14095. setup: function() {
  14096. var doc = this.ownerDocument || this,
  14097. attaches = dataPriv.access( doc, fix );
  14098. if ( !attaches ) {
  14099. doc.addEventListener( orig, handler, true );
  14100. }
  14101. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14102. },
  14103. teardown: function() {
  14104. var doc = this.ownerDocument || this,
  14105. attaches = dataPriv.access( doc, fix ) - 1;
  14106. if ( !attaches ) {
  14107. doc.removeEventListener( orig, handler, true );
  14108. dataPriv.remove( doc, fix );
  14109. } else {
  14110. dataPriv.access( doc, fix, attaches );
  14111. }
  14112. }
  14113. };
  14114. } );
  14115. }
  14116. var location = window.location;
  14117. var nonce = Date.now();
  14118. var rquery = ( /\?/ );
  14119. // Cross-browser xml parsing
  14120. jQuery.parseXML = function( data ) {
  14121. var xml;
  14122. if ( !data || typeof data !== "string" ) {
  14123. return null;
  14124. }
  14125. // Support: IE 9 - 11 only
  14126. // IE throws on parseFromString with invalid input.
  14127. try {
  14128. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14129. } catch ( e ) {
  14130. xml = undefined;
  14131. }
  14132. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14133. jQuery.error( "Invalid XML: " + data );
  14134. }
  14135. return xml;
  14136. };
  14137. var
  14138. rbracket = /\[\]$/,
  14139. rCRLF = /\r?\n/g,
  14140. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14141. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14142. function buildParams( prefix, obj, traditional, add ) {
  14143. var name;
  14144. if ( Array.isArray( obj ) ) {
  14145. // Serialize array item.
  14146. jQuery.each( obj, function( i, v ) {
  14147. if ( traditional || rbracket.test( prefix ) ) {
  14148. // Treat each array item as a scalar.
  14149. add( prefix, v );
  14150. } else {
  14151. // Item is non-scalar (array or object), encode its numeric index.
  14152. buildParams(
  14153. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14154. v,
  14155. traditional,
  14156. add
  14157. );
  14158. }
  14159. } );
  14160. } else if ( !traditional && toType( obj ) === "object" ) {
  14161. // Serialize object item.
  14162. for ( name in obj ) {
  14163. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14164. }
  14165. } else {
  14166. // Serialize scalar item.
  14167. add( prefix, obj );
  14168. }
  14169. }
  14170. // Serialize an array of form elements or a set of
  14171. // key/values into a query string
  14172. jQuery.param = function( a, traditional ) {
  14173. var prefix,
  14174. s = [],
  14175. add = function( key, valueOrFunction ) {
  14176. // If value is a function, invoke it and use its return value
  14177. var value = isFunction( valueOrFunction ) ?
  14178. valueOrFunction() :
  14179. valueOrFunction;
  14180. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14181. encodeURIComponent( value == null ? "" : value );
  14182. };
  14183. if ( a == null ) {
  14184. return "";
  14185. }
  14186. // If an array was passed in, assume that it is an array of form elements.
  14187. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14188. // Serialize the form elements
  14189. jQuery.each( a, function() {
  14190. add( this.name, this.value );
  14191. } );
  14192. } else {
  14193. // If traditional, encode the "old" way (the way 1.3.2 or older
  14194. // did it), otherwise encode params recursively.
  14195. for ( prefix in a ) {
  14196. buildParams( prefix, a[ prefix ], traditional, add );
  14197. }
  14198. }
  14199. // Return the resulting serialization
  14200. return s.join( "&" );
  14201. };
  14202. jQuery.fn.extend( {
  14203. serialize: function() {
  14204. return jQuery.param( this.serializeArray() );
  14205. },
  14206. serializeArray: function() {
  14207. return this.map( function() {
  14208. // Can add propHook for "elements" to filter or add form elements
  14209. var elements = jQuery.prop( this, "elements" );
  14210. return elements ? jQuery.makeArray( elements ) : this;
  14211. } )
  14212. .filter( function() {
  14213. var type = this.type;
  14214. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14215. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14216. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14217. ( this.checked || !rcheckableType.test( type ) );
  14218. } )
  14219. .map( function( i, elem ) {
  14220. var val = jQuery( this ).val();
  14221. if ( val == null ) {
  14222. return null;
  14223. }
  14224. if ( Array.isArray( val ) ) {
  14225. return jQuery.map( val, function( val ) {
  14226. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14227. } );
  14228. }
  14229. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14230. } ).get();
  14231. }
  14232. } );
  14233. var
  14234. r20 = /%20/g,
  14235. rhash = /#.*$/,
  14236. rantiCache = /([?&])_=[^&]*/,
  14237. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14238. // #7653, #8125, #8152: local protocol detection
  14239. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14240. rnoContent = /^(?:GET|HEAD)$/,
  14241. rprotocol = /^\/\//,
  14242. /* Prefilters
  14243. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14244. * 2) These are called:
  14245. * - BEFORE asking for a transport
  14246. * - AFTER param serialization (s.data is a string if s.processData is true)
  14247. * 3) key is the dataType
  14248. * 4) the catchall symbol "*" can be used
  14249. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14250. */
  14251. prefilters = {},
  14252. /* Transports bindings
  14253. * 1) key is the dataType
  14254. * 2) the catchall symbol "*" can be used
  14255. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14256. */
  14257. transports = {},
  14258. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14259. allTypes = "*/".concat( "*" ),
  14260. // Anchor tag for parsing the document origin
  14261. originAnchor = document.createElement( "a" );
  14262. originAnchor.href = location.href;
  14263. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14264. function addToPrefiltersOrTransports( structure ) {
  14265. // dataTypeExpression is optional and defaults to "*"
  14266. return function( dataTypeExpression, func ) {
  14267. if ( typeof dataTypeExpression !== "string" ) {
  14268. func = dataTypeExpression;
  14269. dataTypeExpression = "*";
  14270. }
  14271. var dataType,
  14272. i = 0,
  14273. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14274. if ( isFunction( func ) ) {
  14275. // For each dataType in the dataTypeExpression
  14276. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14277. // Prepend if requested
  14278. if ( dataType[ 0 ] === "+" ) {
  14279. dataType = dataType.slice( 1 ) || "*";
  14280. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14281. // Otherwise append
  14282. } else {
  14283. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14284. }
  14285. }
  14286. }
  14287. };
  14288. }
  14289. // Base inspection function for prefilters and transports
  14290. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14291. var inspected = {},
  14292. seekingTransport = ( structure === transports );
  14293. function inspect( dataType ) {
  14294. var selected;
  14295. inspected[ dataType ] = true;
  14296. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14297. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14298. if ( typeof dataTypeOrTransport === "string" &&
  14299. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14300. options.dataTypes.unshift( dataTypeOrTransport );
  14301. inspect( dataTypeOrTransport );
  14302. return false;
  14303. } else if ( seekingTransport ) {
  14304. return !( selected = dataTypeOrTransport );
  14305. }
  14306. } );
  14307. return selected;
  14308. }
  14309. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14310. }
  14311. // A special extend for ajax options
  14312. // that takes "flat" options (not to be deep extended)
  14313. // Fixes #9887
  14314. function ajaxExtend( target, src ) {
  14315. var key, deep,
  14316. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14317. for ( key in src ) {
  14318. if ( src[ key ] !== undefined ) {
  14319. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14320. }
  14321. }
  14322. if ( deep ) {
  14323. jQuery.extend( true, target, deep );
  14324. }
  14325. return target;
  14326. }
  14327. /* Handles responses to an ajax request:
  14328. * - finds the right dataType (mediates between content-type and expected dataType)
  14329. * - returns the corresponding response
  14330. */
  14331. function ajaxHandleResponses( s, jqXHR, responses ) {
  14332. var ct, type, finalDataType, firstDataType,
  14333. contents = s.contents,
  14334. dataTypes = s.dataTypes;
  14335. // Remove auto dataType and get content-type in the process
  14336. while ( dataTypes[ 0 ] === "*" ) {
  14337. dataTypes.shift();
  14338. if ( ct === undefined ) {
  14339. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14340. }
  14341. }
  14342. // Check if we're dealing with a known content-type
  14343. if ( ct ) {
  14344. for ( type in contents ) {
  14345. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14346. dataTypes.unshift( type );
  14347. break;
  14348. }
  14349. }
  14350. }
  14351. // Check to see if we have a response for the expected dataType
  14352. if ( dataTypes[ 0 ] in responses ) {
  14353. finalDataType = dataTypes[ 0 ];
  14354. } else {
  14355. // Try convertible dataTypes
  14356. for ( type in responses ) {
  14357. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14358. finalDataType = type;
  14359. break;
  14360. }
  14361. if ( !firstDataType ) {
  14362. firstDataType = type;
  14363. }
  14364. }
  14365. // Or just use first one
  14366. finalDataType = finalDataType || firstDataType;
  14367. }
  14368. // If we found a dataType
  14369. // We add the dataType to the list if needed
  14370. // and return the corresponding response
  14371. if ( finalDataType ) {
  14372. if ( finalDataType !== dataTypes[ 0 ] ) {
  14373. dataTypes.unshift( finalDataType );
  14374. }
  14375. return responses[ finalDataType ];
  14376. }
  14377. }
  14378. /* Chain conversions given the request and the original response
  14379. * Also sets the responseXXX fields on the jqXHR instance
  14380. */
  14381. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14382. var conv2, current, conv, tmp, prev,
  14383. converters = {},
  14384. // Work with a copy of dataTypes in case we need to modify it for conversion
  14385. dataTypes = s.dataTypes.slice();
  14386. // Create converters map with lowercased keys
  14387. if ( dataTypes[ 1 ] ) {
  14388. for ( conv in s.converters ) {
  14389. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14390. }
  14391. }
  14392. current = dataTypes.shift();
  14393. // Convert to each sequential dataType
  14394. while ( current ) {
  14395. if ( s.responseFields[ current ] ) {
  14396. jqXHR[ s.responseFields[ current ] ] = response;
  14397. }
  14398. // Apply the dataFilter if provided
  14399. if ( !prev && isSuccess && s.dataFilter ) {
  14400. response = s.dataFilter( response, s.dataType );
  14401. }
  14402. prev = current;
  14403. current = dataTypes.shift();
  14404. if ( current ) {
  14405. // There's only work to do if current dataType is non-auto
  14406. if ( current === "*" ) {
  14407. current = prev;
  14408. // Convert response if prev dataType is non-auto and differs from current
  14409. } else if ( prev !== "*" && prev !== current ) {
  14410. // Seek a direct converter
  14411. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14412. // If none found, seek a pair
  14413. if ( !conv ) {
  14414. for ( conv2 in converters ) {
  14415. // If conv2 outputs current
  14416. tmp = conv2.split( " " );
  14417. if ( tmp[ 1 ] === current ) {
  14418. // If prev can be converted to accepted input
  14419. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14420. converters[ "* " + tmp[ 0 ] ];
  14421. if ( conv ) {
  14422. // Condense equivalence converters
  14423. if ( conv === true ) {
  14424. conv = converters[ conv2 ];
  14425. // Otherwise, insert the intermediate dataType
  14426. } else if ( converters[ conv2 ] !== true ) {
  14427. current = tmp[ 0 ];
  14428. dataTypes.unshift( tmp[ 1 ] );
  14429. }
  14430. break;
  14431. }
  14432. }
  14433. }
  14434. }
  14435. // Apply converter (if not an equivalence)
  14436. if ( conv !== true ) {
  14437. // Unless errors are allowed to bubble, catch and return them
  14438. if ( conv && s.throws ) {
  14439. response = conv( response );
  14440. } else {
  14441. try {
  14442. response = conv( response );
  14443. } catch ( e ) {
  14444. return {
  14445. state: "parsererror",
  14446. error: conv ? e : "No conversion from " + prev + " to " + current
  14447. };
  14448. }
  14449. }
  14450. }
  14451. }
  14452. }
  14453. }
  14454. return { state: "success", data: response };
  14455. }
  14456. jQuery.extend( {
  14457. // Counter for holding the number of active queries
  14458. active: 0,
  14459. // Last-Modified header cache for next request
  14460. lastModified: {},
  14461. etag: {},
  14462. ajaxSettings: {
  14463. url: location.href,
  14464. type: "GET",
  14465. isLocal: rlocalProtocol.test( location.protocol ),
  14466. global: true,
  14467. processData: true,
  14468. async: true,
  14469. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14470. /*
  14471. timeout: 0,
  14472. data: null,
  14473. dataType: null,
  14474. username: null,
  14475. password: null,
  14476. cache: null,
  14477. throws: false,
  14478. traditional: false,
  14479. headers: {},
  14480. */
  14481. accepts: {
  14482. "*": allTypes,
  14483. text: "text/plain",
  14484. html: "text/html",
  14485. xml: "application/xml, text/xml",
  14486. json: "application/json, text/javascript"
  14487. },
  14488. contents: {
  14489. xml: /\bxml\b/,
  14490. html: /\bhtml/,
  14491. json: /\bjson\b/
  14492. },
  14493. responseFields: {
  14494. xml: "responseXML",
  14495. text: "responseText",
  14496. json: "responseJSON"
  14497. },
  14498. // Data converters
  14499. // Keys separate source (or catchall "*") and destination types with a single space
  14500. converters: {
  14501. // Convert anything to text
  14502. "* text": String,
  14503. // Text to html (true = no transformation)
  14504. "text html": true,
  14505. // Evaluate text as a json expression
  14506. "text json": JSON.parse,
  14507. // Parse text as xml
  14508. "text xml": jQuery.parseXML
  14509. },
  14510. // For options that shouldn't be deep extended:
  14511. // you can add your own custom options here if
  14512. // and when you create one that shouldn't be
  14513. // deep extended (see ajaxExtend)
  14514. flatOptions: {
  14515. url: true,
  14516. context: true
  14517. }
  14518. },
  14519. // Creates a full fledged settings object into target
  14520. // with both ajaxSettings and settings fields.
  14521. // If target is omitted, writes into ajaxSettings.
  14522. ajaxSetup: function( target, settings ) {
  14523. return settings ?
  14524. // Building a settings object
  14525. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14526. // Extending ajaxSettings
  14527. ajaxExtend( jQuery.ajaxSettings, target );
  14528. },
  14529. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14530. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14531. // Main method
  14532. ajax: function( url, options ) {
  14533. // If url is an object, simulate pre-1.5 signature
  14534. if ( typeof url === "object" ) {
  14535. options = url;
  14536. url = undefined;
  14537. }
  14538. // Force options to be an object
  14539. options = options || {};
  14540. var transport,
  14541. // URL without anti-cache param
  14542. cacheURL,
  14543. // Response headers
  14544. responseHeadersString,
  14545. responseHeaders,
  14546. // timeout handle
  14547. timeoutTimer,
  14548. // Url cleanup var
  14549. urlAnchor,
  14550. // Request state (becomes false upon send and true upon completion)
  14551. completed,
  14552. // To know if global events are to be dispatched
  14553. fireGlobals,
  14554. // Loop variable
  14555. i,
  14556. // uncached part of the url
  14557. uncached,
  14558. // Create the final options object
  14559. s = jQuery.ajaxSetup( {}, options ),
  14560. // Callbacks context
  14561. callbackContext = s.context || s,
  14562. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14563. globalEventContext = s.context &&
  14564. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14565. jQuery( callbackContext ) :
  14566. jQuery.event,
  14567. // Deferreds
  14568. deferred = jQuery.Deferred(),
  14569. completeDeferred = jQuery.Callbacks( "once memory" ),
  14570. // Status-dependent callbacks
  14571. statusCode = s.statusCode || {},
  14572. // Headers (they are sent all at once)
  14573. requestHeaders = {},
  14574. requestHeadersNames = {},
  14575. // Default abort message
  14576. strAbort = "canceled",
  14577. // Fake xhr
  14578. jqXHR = {
  14579. readyState: 0,
  14580. // Builds headers hashtable if needed
  14581. getResponseHeader: function( key ) {
  14582. var match;
  14583. if ( completed ) {
  14584. if ( !responseHeaders ) {
  14585. responseHeaders = {};
  14586. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14587. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14588. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14589. .concat( match[ 2 ] );
  14590. }
  14591. }
  14592. match = responseHeaders[ key.toLowerCase() + " " ];
  14593. }
  14594. return match == null ? null : match.join( ", " );
  14595. },
  14596. // Raw string
  14597. getAllResponseHeaders: function() {
  14598. return completed ? responseHeadersString : null;
  14599. },
  14600. // Caches the header
  14601. setRequestHeader: function( name, value ) {
  14602. if ( completed == null ) {
  14603. name = requestHeadersNames[ name.toLowerCase() ] =
  14604. requestHeadersNames[ name.toLowerCase() ] || name;
  14605. requestHeaders[ name ] = value;
  14606. }
  14607. return this;
  14608. },
  14609. // Overrides response content-type header
  14610. overrideMimeType: function( type ) {
  14611. if ( completed == null ) {
  14612. s.mimeType = type;
  14613. }
  14614. return this;
  14615. },
  14616. // Status-dependent callbacks
  14617. statusCode: function( map ) {
  14618. var code;
  14619. if ( map ) {
  14620. if ( completed ) {
  14621. // Execute the appropriate callbacks
  14622. jqXHR.always( map[ jqXHR.status ] );
  14623. } else {
  14624. // Lazy-add the new callbacks in a way that preserves old ones
  14625. for ( code in map ) {
  14626. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14627. }
  14628. }
  14629. }
  14630. return this;
  14631. },
  14632. // Cancel the request
  14633. abort: function( statusText ) {
  14634. var finalText = statusText || strAbort;
  14635. if ( transport ) {
  14636. transport.abort( finalText );
  14637. }
  14638. done( 0, finalText );
  14639. return this;
  14640. }
  14641. };
  14642. // Attach deferreds
  14643. deferred.promise( jqXHR );
  14644. // Add protocol if not provided (prefilters might expect it)
  14645. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14646. // We also use the url parameter if available
  14647. s.url = ( ( url || s.url || location.href ) + "" )
  14648. .replace( rprotocol, location.protocol + "//" );
  14649. // Alias method option to type as per ticket #12004
  14650. s.type = options.method || options.type || s.method || s.type;
  14651. // Extract dataTypes list
  14652. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14653. // A cross-domain request is in order when the origin doesn't match the current origin.
  14654. if ( s.crossDomain == null ) {
  14655. urlAnchor = document.createElement( "a" );
  14656. // Support: IE <=8 - 11, Edge 12 - 15
  14657. // IE throws exception on accessing the href property if url is malformed,
  14658. // e.g. http://example.com:80x/
  14659. try {
  14660. urlAnchor.href = s.url;
  14661. // Support: IE <=8 - 11 only
  14662. // Anchor's host property isn't correctly set when s.url is relative
  14663. urlAnchor.href = urlAnchor.href;
  14664. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14665. urlAnchor.protocol + "//" + urlAnchor.host;
  14666. } catch ( e ) {
  14667. // If there is an error parsing the URL, assume it is crossDomain,
  14668. // it can be rejected by the transport if it is invalid
  14669. s.crossDomain = true;
  14670. }
  14671. }
  14672. // Convert data if not already a string
  14673. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14674. s.data = jQuery.param( s.data, s.traditional );
  14675. }
  14676. // Apply prefilters
  14677. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14678. // If request was aborted inside a prefilter, stop there
  14679. if ( completed ) {
  14680. return jqXHR;
  14681. }
  14682. // We can fire global events as of now if asked to
  14683. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14684. fireGlobals = jQuery.event && s.global;
  14685. // Watch for a new set of requests
  14686. if ( fireGlobals && jQuery.active++ === 0 ) {
  14687. jQuery.event.trigger( "ajaxStart" );
  14688. }
  14689. // Uppercase the type
  14690. s.type = s.type.toUpperCase();
  14691. // Determine if request has content
  14692. s.hasContent = !rnoContent.test( s.type );
  14693. // Save the URL in case we're toying with the If-Modified-Since
  14694. // and/or If-None-Match header later on
  14695. // Remove hash to simplify url manipulation
  14696. cacheURL = s.url.replace( rhash, "" );
  14697. // More options handling for requests with no content
  14698. if ( !s.hasContent ) {
  14699. // Remember the hash so we can put it back
  14700. uncached = s.url.slice( cacheURL.length );
  14701. // If data is available and should be processed, append data to url
  14702. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14703. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14704. // #9682: remove data so that it's not used in an eventual retry
  14705. delete s.data;
  14706. }
  14707. // Add or update anti-cache param if needed
  14708. if ( s.cache === false ) {
  14709. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14710. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14711. }
  14712. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14713. s.url = cacheURL + uncached;
  14714. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14715. } else if ( s.data && s.processData &&
  14716. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14717. s.data = s.data.replace( r20, "+" );
  14718. }
  14719. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14720. if ( s.ifModified ) {
  14721. if ( jQuery.lastModified[ cacheURL ] ) {
  14722. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14723. }
  14724. if ( jQuery.etag[ cacheURL ] ) {
  14725. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14726. }
  14727. }
  14728. // Set the correct header, if data is being sent
  14729. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14730. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14731. }
  14732. // Set the Accepts header for the server, depending on the dataType
  14733. jqXHR.setRequestHeader(
  14734. "Accept",
  14735. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14736. s.accepts[ s.dataTypes[ 0 ] ] +
  14737. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14738. s.accepts[ "*" ]
  14739. );
  14740. // Check for headers option
  14741. for ( i in s.headers ) {
  14742. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14743. }
  14744. // Allow custom headers/mimetypes and early abort
  14745. if ( s.beforeSend &&
  14746. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14747. // Abort if not done already and return
  14748. return jqXHR.abort();
  14749. }
  14750. // Aborting is no longer a cancellation
  14751. strAbort = "abort";
  14752. // Install callbacks on deferreds
  14753. completeDeferred.add( s.complete );
  14754. jqXHR.done( s.success );
  14755. jqXHR.fail( s.error );
  14756. // Get transport
  14757. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14758. // If no transport, we auto-abort
  14759. if ( !transport ) {
  14760. done( -1, "No Transport" );
  14761. } else {
  14762. jqXHR.readyState = 1;
  14763. // Send global event
  14764. if ( fireGlobals ) {
  14765. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14766. }
  14767. // If request was aborted inside ajaxSend, stop there
  14768. if ( completed ) {
  14769. return jqXHR;
  14770. }
  14771. // Timeout
  14772. if ( s.async && s.timeout > 0 ) {
  14773. timeoutTimer = window.setTimeout( function() {
  14774. jqXHR.abort( "timeout" );
  14775. }, s.timeout );
  14776. }
  14777. try {
  14778. completed = false;
  14779. transport.send( requestHeaders, done );
  14780. } catch ( e ) {
  14781. // Rethrow post-completion exceptions
  14782. if ( completed ) {
  14783. throw e;
  14784. }
  14785. // Propagate others as results
  14786. done( -1, e );
  14787. }
  14788. }
  14789. // Callback for when everything is done
  14790. function done( status, nativeStatusText, responses, headers ) {
  14791. var isSuccess, success, error, response, modified,
  14792. statusText = nativeStatusText;
  14793. // Ignore repeat invocations
  14794. if ( completed ) {
  14795. return;
  14796. }
  14797. completed = true;
  14798. // Clear timeout if it exists
  14799. if ( timeoutTimer ) {
  14800. window.clearTimeout( timeoutTimer );
  14801. }
  14802. // Dereference transport for early garbage collection
  14803. // (no matter how long the jqXHR object will be used)
  14804. transport = undefined;
  14805. // Cache response headers
  14806. responseHeadersString = headers || "";
  14807. // Set readyState
  14808. jqXHR.readyState = status > 0 ? 4 : 0;
  14809. // Determine if successful
  14810. isSuccess = status >= 200 && status < 300 || status === 304;
  14811. // Get response data
  14812. if ( responses ) {
  14813. response = ajaxHandleResponses( s, jqXHR, responses );
  14814. }
  14815. // Convert no matter what (that way responseXXX fields are always set)
  14816. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14817. // If successful, handle type chaining
  14818. if ( isSuccess ) {
  14819. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14820. if ( s.ifModified ) {
  14821. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14822. if ( modified ) {
  14823. jQuery.lastModified[ cacheURL ] = modified;
  14824. }
  14825. modified = jqXHR.getResponseHeader( "etag" );
  14826. if ( modified ) {
  14827. jQuery.etag[ cacheURL ] = modified;
  14828. }
  14829. }
  14830. // if no content
  14831. if ( status === 204 || s.type === "HEAD" ) {
  14832. statusText = "nocontent";
  14833. // if not modified
  14834. } else if ( status === 304 ) {
  14835. statusText = "notmodified";
  14836. // If we have data, let's convert it
  14837. } else {
  14838. statusText = response.state;
  14839. success = response.data;
  14840. error = response.error;
  14841. isSuccess = !error;
  14842. }
  14843. } else {
  14844. // Extract error from statusText and normalize for non-aborts
  14845. error = statusText;
  14846. if ( status || !statusText ) {
  14847. statusText = "error";
  14848. if ( status < 0 ) {
  14849. status = 0;
  14850. }
  14851. }
  14852. }
  14853. // Set data for the fake xhr object
  14854. jqXHR.status = status;
  14855. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14856. // Success/Error
  14857. if ( isSuccess ) {
  14858. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14859. } else {
  14860. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14861. }
  14862. // Status-dependent callbacks
  14863. jqXHR.statusCode( statusCode );
  14864. statusCode = undefined;
  14865. if ( fireGlobals ) {
  14866. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14867. [ jqXHR, s, isSuccess ? success : error ] );
  14868. }
  14869. // Complete
  14870. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14871. if ( fireGlobals ) {
  14872. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14873. // Handle the global AJAX counter
  14874. if ( !( --jQuery.active ) ) {
  14875. jQuery.event.trigger( "ajaxStop" );
  14876. }
  14877. }
  14878. }
  14879. return jqXHR;
  14880. },
  14881. getJSON: function( url, data, callback ) {
  14882. return jQuery.get( url, data, callback, "json" );
  14883. },
  14884. getScript: function( url, callback ) {
  14885. return jQuery.get( url, undefined, callback, "script" );
  14886. }
  14887. } );
  14888. jQuery.each( [ "get", "post" ], function( i, method ) {
  14889. jQuery[ method ] = function( url, data, callback, type ) {
  14890. // Shift arguments if data argument was omitted
  14891. if ( isFunction( data ) ) {
  14892. type = type || callback;
  14893. callback = data;
  14894. data = undefined;
  14895. }
  14896. // The url can be an options object (which then must have .url)
  14897. return jQuery.ajax( jQuery.extend( {
  14898. url: url,
  14899. type: method,
  14900. dataType: type,
  14901. data: data,
  14902. success: callback
  14903. }, jQuery.isPlainObject( url ) && url ) );
  14904. };
  14905. } );
  14906. jQuery._evalUrl = function( url, options ) {
  14907. return jQuery.ajax( {
  14908. url: url,
  14909. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14910. type: "GET",
  14911. dataType: "script",
  14912. cache: true,
  14913. async: false,
  14914. global: false,
  14915. // Only evaluate the response if it is successful (gh-4126)
  14916. // dataFilter is not invoked for failure responses, so using it instead
  14917. // of the default converter is kludgy but it works.
  14918. converters: {
  14919. "text script": function() {}
  14920. },
  14921. dataFilter: function( response ) {
  14922. jQuery.globalEval( response, options );
  14923. }
  14924. } );
  14925. };
  14926. jQuery.fn.extend( {
  14927. wrapAll: function( html ) {
  14928. var wrap;
  14929. if ( this[ 0 ] ) {
  14930. if ( isFunction( html ) ) {
  14931. html = html.call( this[ 0 ] );
  14932. }
  14933. // The elements to wrap the target around
  14934. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14935. if ( this[ 0 ].parentNode ) {
  14936. wrap.insertBefore( this[ 0 ] );
  14937. }
  14938. wrap.map( function() {
  14939. var elem = this;
  14940. while ( elem.firstElementChild ) {
  14941. elem = elem.firstElementChild;
  14942. }
  14943. return elem;
  14944. } ).append( this );
  14945. }
  14946. return this;
  14947. },
  14948. wrapInner: function( html ) {
  14949. if ( isFunction( html ) ) {
  14950. return this.each( function( i ) {
  14951. jQuery( this ).wrapInner( html.call( this, i ) );
  14952. } );
  14953. }
  14954. return this.each( function() {
  14955. var self = jQuery( this ),
  14956. contents = self.contents();
  14957. if ( contents.length ) {
  14958. contents.wrapAll( html );
  14959. } else {
  14960. self.append( html );
  14961. }
  14962. } );
  14963. },
  14964. wrap: function( html ) {
  14965. var htmlIsFunction = isFunction( html );
  14966. return this.each( function( i ) {
  14967. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  14968. } );
  14969. },
  14970. unwrap: function( selector ) {
  14971. this.parent( selector ).not( "body" ).each( function() {
  14972. jQuery( this ).replaceWith( this.childNodes );
  14973. } );
  14974. return this;
  14975. }
  14976. } );
  14977. jQuery.expr.pseudos.hidden = function( elem ) {
  14978. return !jQuery.expr.pseudos.visible( elem );
  14979. };
  14980. jQuery.expr.pseudos.visible = function( elem ) {
  14981. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  14982. };
  14983. jQuery.ajaxSettings.xhr = function() {
  14984. try {
  14985. return new window.XMLHttpRequest();
  14986. } catch ( e ) {}
  14987. };
  14988. var xhrSuccessStatus = {
  14989. // File protocol always yields status code 0, assume 200
  14990. 0: 200,
  14991. // Support: IE <=9 only
  14992. // #1450: sometimes IE returns 1223 when it should be 204
  14993. 1223: 204
  14994. },
  14995. xhrSupported = jQuery.ajaxSettings.xhr();
  14996. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  14997. support.ajax = xhrSupported = !!xhrSupported;
  14998. jQuery.ajaxTransport( function( options ) {
  14999. var callback, errorCallback;
  15000. // Cross domain only allowed if supported through XMLHttpRequest
  15001. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15002. return {
  15003. send: function( headers, complete ) {
  15004. var i,
  15005. xhr = options.xhr();
  15006. xhr.open(
  15007. options.type,
  15008. options.url,
  15009. options.async,
  15010. options.username,
  15011. options.password
  15012. );
  15013. // Apply custom fields if provided
  15014. if ( options.xhrFields ) {
  15015. for ( i in options.xhrFields ) {
  15016. xhr[ i ] = options.xhrFields[ i ];
  15017. }
  15018. }
  15019. // Override mime type if needed
  15020. if ( options.mimeType && xhr.overrideMimeType ) {
  15021. xhr.overrideMimeType( options.mimeType );
  15022. }
  15023. // X-Requested-With header
  15024. // For cross-domain requests, seeing as conditions for a preflight are
  15025. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15026. // (it can always be set on a per-request basis or even using ajaxSetup)
  15027. // For same-domain requests, won't change header if already provided.
  15028. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15029. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15030. }
  15031. // Set headers
  15032. for ( i in headers ) {
  15033. xhr.setRequestHeader( i, headers[ i ] );
  15034. }
  15035. // Callback
  15036. callback = function( type ) {
  15037. return function() {
  15038. if ( callback ) {
  15039. callback = errorCallback = xhr.onload =
  15040. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15041. xhr.onreadystatechange = null;
  15042. if ( type === "abort" ) {
  15043. xhr.abort();
  15044. } else if ( type === "error" ) {
  15045. // Support: IE <=9 only
  15046. // On a manual native abort, IE9 throws
  15047. // errors on any property access that is not readyState
  15048. if ( typeof xhr.status !== "number" ) {
  15049. complete( 0, "error" );
  15050. } else {
  15051. complete(
  15052. // File: protocol always yields status 0; see #8605, #14207
  15053. xhr.status,
  15054. xhr.statusText
  15055. );
  15056. }
  15057. } else {
  15058. complete(
  15059. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15060. xhr.statusText,
  15061. // Support: IE <=9 only
  15062. // IE9 has no XHR2 but throws on binary (trac-11426)
  15063. // For XHR2 non-text, let the caller handle it (gh-2498)
  15064. ( xhr.responseType || "text" ) !== "text" ||
  15065. typeof xhr.responseText !== "string" ?
  15066. { binary: xhr.response } :
  15067. { text: xhr.responseText },
  15068. xhr.getAllResponseHeaders()
  15069. );
  15070. }
  15071. }
  15072. };
  15073. };
  15074. // Listen to events
  15075. xhr.onload = callback();
  15076. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15077. // Support: IE 9 only
  15078. // Use onreadystatechange to replace onabort
  15079. // to handle uncaught aborts
  15080. if ( xhr.onabort !== undefined ) {
  15081. xhr.onabort = errorCallback;
  15082. } else {
  15083. xhr.onreadystatechange = function() {
  15084. // Check readyState before timeout as it changes
  15085. if ( xhr.readyState === 4 ) {
  15086. // Allow onerror to be called first,
  15087. // but that will not handle a native abort
  15088. // Also, save errorCallback to a variable
  15089. // as xhr.onerror cannot be accessed
  15090. window.setTimeout( function() {
  15091. if ( callback ) {
  15092. errorCallback();
  15093. }
  15094. } );
  15095. }
  15096. };
  15097. }
  15098. // Create the abort callback
  15099. callback = callback( "abort" );
  15100. try {
  15101. // Do send the request (this may raise an exception)
  15102. xhr.send( options.hasContent && options.data || null );
  15103. } catch ( e ) {
  15104. // #14683: Only rethrow if this hasn't been notified as an error yet
  15105. if ( callback ) {
  15106. throw e;
  15107. }
  15108. }
  15109. },
  15110. abort: function() {
  15111. if ( callback ) {
  15112. callback();
  15113. }
  15114. }
  15115. };
  15116. }
  15117. } );
  15118. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15119. jQuery.ajaxPrefilter( function( s ) {
  15120. if ( s.crossDomain ) {
  15121. s.contents.script = false;
  15122. }
  15123. } );
  15124. // Install script dataType
  15125. jQuery.ajaxSetup( {
  15126. accepts: {
  15127. script: "text/javascript, application/javascript, " +
  15128. "application/ecmascript, application/x-ecmascript"
  15129. },
  15130. contents: {
  15131. script: /\b(?:java|ecma)script\b/
  15132. },
  15133. converters: {
  15134. "text script": function( text ) {
  15135. jQuery.globalEval( text );
  15136. return text;
  15137. }
  15138. }
  15139. } );
  15140. // Handle cache's special case and crossDomain
  15141. jQuery.ajaxPrefilter( "script", function( s ) {
  15142. if ( s.cache === undefined ) {
  15143. s.cache = false;
  15144. }
  15145. if ( s.crossDomain ) {
  15146. s.type = "GET";
  15147. }
  15148. } );
  15149. // Bind script tag hack transport
  15150. jQuery.ajaxTransport( "script", function( s ) {
  15151. // This transport only deals with cross domain or forced-by-attrs requests
  15152. if ( s.crossDomain || s.scriptAttrs ) {
  15153. var script, callback;
  15154. return {
  15155. send: function( _, complete ) {
  15156. script = jQuery( "<script>" )
  15157. .attr( s.scriptAttrs || {} )
  15158. .prop( { charset: s.scriptCharset, src: s.url } )
  15159. .on( "load error", callback = function( evt ) {
  15160. script.remove();
  15161. callback = null;
  15162. if ( evt ) {
  15163. complete( evt.type === "error" ? 404 : 200, evt.type );
  15164. }
  15165. } );
  15166. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15167. document.head.appendChild( script[ 0 ] );
  15168. },
  15169. abort: function() {
  15170. if ( callback ) {
  15171. callback();
  15172. }
  15173. }
  15174. };
  15175. }
  15176. } );
  15177. var oldCallbacks = [],
  15178. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15179. // Default jsonp settings
  15180. jQuery.ajaxSetup( {
  15181. jsonp: "callback",
  15182. jsonpCallback: function() {
  15183. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15184. this[ callback ] = true;
  15185. return callback;
  15186. }
  15187. } );
  15188. // Detect, normalize options and install callbacks for jsonp requests
  15189. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15190. var callbackName, overwritten, responseContainer,
  15191. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15192. "url" :
  15193. typeof s.data === "string" &&
  15194. ( s.contentType || "" )
  15195. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15196. rjsonp.test( s.data ) && "data"
  15197. );
  15198. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15199. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15200. // Get callback name, remembering preexisting value associated with it
  15201. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15202. s.jsonpCallback() :
  15203. s.jsonpCallback;
  15204. // Insert callback into url or form data
  15205. if ( jsonProp ) {
  15206. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15207. } else if ( s.jsonp !== false ) {
  15208. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15209. }
  15210. // Use data converter to retrieve json after script execution
  15211. s.converters[ "script json" ] = function() {
  15212. if ( !responseContainer ) {
  15213. jQuery.error( callbackName + " was not called" );
  15214. }
  15215. return responseContainer[ 0 ];
  15216. };
  15217. // Force json dataType
  15218. s.dataTypes[ 0 ] = "json";
  15219. // Install callback
  15220. overwritten = window[ callbackName ];
  15221. window[ callbackName ] = function() {
  15222. responseContainer = arguments;
  15223. };
  15224. // Clean-up function (fires after converters)
  15225. jqXHR.always( function() {
  15226. // If previous value didn't exist - remove it
  15227. if ( overwritten === undefined ) {
  15228. jQuery( window ).removeProp( callbackName );
  15229. // Otherwise restore preexisting value
  15230. } else {
  15231. window[ callbackName ] = overwritten;
  15232. }
  15233. // Save back as free
  15234. if ( s[ callbackName ] ) {
  15235. // Make sure that re-using the options doesn't screw things around
  15236. s.jsonpCallback = originalSettings.jsonpCallback;
  15237. // Save the callback name for future use
  15238. oldCallbacks.push( callbackName );
  15239. }
  15240. // Call if it was a function and we have a response
  15241. if ( responseContainer && isFunction( overwritten ) ) {
  15242. overwritten( responseContainer[ 0 ] );
  15243. }
  15244. responseContainer = overwritten = undefined;
  15245. } );
  15246. // Delegate to script
  15247. return "script";
  15248. }
  15249. } );
  15250. // Support: Safari 8 only
  15251. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15252. // collapse sibling forms: the second one becomes a child of the first one.
  15253. // Because of that, this security measure has to be disabled in Safari 8.
  15254. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15255. support.createHTMLDocument = ( function() {
  15256. var body = document.implementation.createHTMLDocument( "" ).body;
  15257. body.innerHTML = "<form></form><form></form>";
  15258. return body.childNodes.length === 2;
  15259. } )();
  15260. // Argument "data" should be string of html
  15261. // context (optional): If specified, the fragment will be created in this context,
  15262. // defaults to document
  15263. // keepScripts (optional): If true, will include scripts passed in the html string
  15264. jQuery.parseHTML = function( data, context, keepScripts ) {
  15265. if ( typeof data !== "string" ) {
  15266. return [];
  15267. }
  15268. if ( typeof context === "boolean" ) {
  15269. keepScripts = context;
  15270. context = false;
  15271. }
  15272. var base, parsed, scripts;
  15273. if ( !context ) {
  15274. // Stop scripts or inline event handlers from being executed immediately
  15275. // by using document.implementation
  15276. if ( support.createHTMLDocument ) {
  15277. context = document.implementation.createHTMLDocument( "" );
  15278. // Set the base href for the created document
  15279. // so any parsed elements with URLs
  15280. // are based on the document's URL (gh-2965)
  15281. base = context.createElement( "base" );
  15282. base.href = document.location.href;
  15283. context.head.appendChild( base );
  15284. } else {
  15285. context = document;
  15286. }
  15287. }
  15288. parsed = rsingleTag.exec( data );
  15289. scripts = !keepScripts && [];
  15290. // Single tag
  15291. if ( parsed ) {
  15292. return [ context.createElement( parsed[ 1 ] ) ];
  15293. }
  15294. parsed = buildFragment( [ data ], context, scripts );
  15295. if ( scripts && scripts.length ) {
  15296. jQuery( scripts ).remove();
  15297. }
  15298. return jQuery.merge( [], parsed.childNodes );
  15299. };
  15300. /**
  15301. * Load a url into a page
  15302. */
  15303. jQuery.fn.load = function( url, params, callback ) {
  15304. var selector, type, response,
  15305. self = this,
  15306. off = url.indexOf( " " );
  15307. if ( off > -1 ) {
  15308. selector = stripAndCollapse( url.slice( off ) );
  15309. url = url.slice( 0, off );
  15310. }
  15311. // If it's a function
  15312. if ( isFunction( params ) ) {
  15313. // We assume that it's the callback
  15314. callback = params;
  15315. params = undefined;
  15316. // Otherwise, build a param string
  15317. } else if ( params && typeof params === "object" ) {
  15318. type = "POST";
  15319. }
  15320. // If we have elements to modify, make the request
  15321. if ( self.length > 0 ) {
  15322. jQuery.ajax( {
  15323. url: url,
  15324. // If "type" variable is undefined, then "GET" method will be used.
  15325. // Make value of this field explicit since
  15326. // user can override it through ajaxSetup method
  15327. type: type || "GET",
  15328. dataType: "html",
  15329. data: params
  15330. } ).done( function( responseText ) {
  15331. // Save response for use in complete callback
  15332. response = arguments;
  15333. self.html( selector ?
  15334. // If a selector was specified, locate the right elements in a dummy div
  15335. // Exclude scripts to avoid IE 'Permission Denied' errors
  15336. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15337. // Otherwise use the full result
  15338. responseText );
  15339. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15340. // but they are ignored because response was set above.
  15341. // If it fails, this function gets "jqXHR", "status", "error"
  15342. } ).always( callback && function( jqXHR, status ) {
  15343. self.each( function() {
  15344. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15345. } );
  15346. } );
  15347. }
  15348. return this;
  15349. };
  15350. // Attach a bunch of functions for handling common AJAX events
  15351. jQuery.each( [
  15352. "ajaxStart",
  15353. "ajaxStop",
  15354. "ajaxComplete",
  15355. "ajaxError",
  15356. "ajaxSuccess",
  15357. "ajaxSend"
  15358. ], function( i, type ) {
  15359. jQuery.fn[ type ] = function( fn ) {
  15360. return this.on( type, fn );
  15361. };
  15362. } );
  15363. jQuery.expr.pseudos.animated = function( elem ) {
  15364. return jQuery.grep( jQuery.timers, function( fn ) {
  15365. return elem === fn.elem;
  15366. } ).length;
  15367. };
  15368. jQuery.offset = {
  15369. setOffset: function( elem, options, i ) {
  15370. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15371. position = jQuery.css( elem, "position" ),
  15372. curElem = jQuery( elem ),
  15373. props = {};
  15374. // Set position first, in-case top/left are set even on static elem
  15375. if ( position === "static" ) {
  15376. elem.style.position = "relative";
  15377. }
  15378. curOffset = curElem.offset();
  15379. curCSSTop = jQuery.css( elem, "top" );
  15380. curCSSLeft = jQuery.css( elem, "left" );
  15381. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15382. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15383. // Need to be able to calculate position if either
  15384. // top or left is auto and position is either absolute or fixed
  15385. if ( calculatePosition ) {
  15386. curPosition = curElem.position();
  15387. curTop = curPosition.top;
  15388. curLeft = curPosition.left;
  15389. } else {
  15390. curTop = parseFloat( curCSSTop ) || 0;
  15391. curLeft = parseFloat( curCSSLeft ) || 0;
  15392. }
  15393. if ( isFunction( options ) ) {
  15394. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15395. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15396. }
  15397. if ( options.top != null ) {
  15398. props.top = ( options.top - curOffset.top ) + curTop;
  15399. }
  15400. if ( options.left != null ) {
  15401. props.left = ( options.left - curOffset.left ) + curLeft;
  15402. }
  15403. if ( "using" in options ) {
  15404. options.using.call( elem, props );
  15405. } else {
  15406. curElem.css( props );
  15407. }
  15408. }
  15409. };
  15410. jQuery.fn.extend( {
  15411. // offset() relates an element's border box to the document origin
  15412. offset: function( options ) {
  15413. // Preserve chaining for setter
  15414. if ( arguments.length ) {
  15415. return options === undefined ?
  15416. this :
  15417. this.each( function( i ) {
  15418. jQuery.offset.setOffset( this, options, i );
  15419. } );
  15420. }
  15421. var rect, win,
  15422. elem = this[ 0 ];
  15423. if ( !elem ) {
  15424. return;
  15425. }
  15426. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15427. // Support: IE <=11 only
  15428. // Running getBoundingClientRect on a
  15429. // disconnected node in IE throws an error
  15430. if ( !elem.getClientRects().length ) {
  15431. return { top: 0, left: 0 };
  15432. }
  15433. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15434. rect = elem.getBoundingClientRect();
  15435. win = elem.ownerDocument.defaultView;
  15436. return {
  15437. top: rect.top + win.pageYOffset,
  15438. left: rect.left + win.pageXOffset
  15439. };
  15440. },
  15441. // position() relates an element's margin box to its offset parent's padding box
  15442. // This corresponds to the behavior of CSS absolute positioning
  15443. position: function() {
  15444. if ( !this[ 0 ] ) {
  15445. return;
  15446. }
  15447. var offsetParent, offset, doc,
  15448. elem = this[ 0 ],
  15449. parentOffset = { top: 0, left: 0 };
  15450. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15451. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15452. // Assume position:fixed implies availability of getBoundingClientRect
  15453. offset = elem.getBoundingClientRect();
  15454. } else {
  15455. offset = this.offset();
  15456. // Account for the *real* offset parent, which can be the document or its root element
  15457. // when a statically positioned element is identified
  15458. doc = elem.ownerDocument;
  15459. offsetParent = elem.offsetParent || doc.documentElement;
  15460. while ( offsetParent &&
  15461. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15462. jQuery.css( offsetParent, "position" ) === "static" ) {
  15463. offsetParent = offsetParent.parentNode;
  15464. }
  15465. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15466. // Incorporate borders into its offset, since they are outside its content origin
  15467. parentOffset = jQuery( offsetParent ).offset();
  15468. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15469. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15470. }
  15471. }
  15472. // Subtract parent offsets and element margins
  15473. return {
  15474. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15475. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15476. };
  15477. },
  15478. // This method will return documentElement in the following cases:
  15479. // 1) For the element inside the iframe without offsetParent, this method will return
  15480. // documentElement of the parent window
  15481. // 2) For the hidden or detached element
  15482. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15483. //
  15484. // but those exceptions were never presented as a real life use-cases
  15485. // and might be considered as more preferable results.
  15486. //
  15487. // This logic, however, is not guaranteed and can change at any point in the future
  15488. offsetParent: function() {
  15489. return this.map( function() {
  15490. var offsetParent = this.offsetParent;
  15491. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15492. offsetParent = offsetParent.offsetParent;
  15493. }
  15494. return offsetParent || documentElement;
  15495. } );
  15496. }
  15497. } );
  15498. // Create scrollLeft and scrollTop methods
  15499. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15500. var top = "pageYOffset" === prop;
  15501. jQuery.fn[ method ] = function( val ) {
  15502. return access( this, function( elem, method, val ) {
  15503. // Coalesce documents and windows
  15504. var win;
  15505. if ( isWindow( elem ) ) {
  15506. win = elem;
  15507. } else if ( elem.nodeType === 9 ) {
  15508. win = elem.defaultView;
  15509. }
  15510. if ( val === undefined ) {
  15511. return win ? win[ prop ] : elem[ method ];
  15512. }
  15513. if ( win ) {
  15514. win.scrollTo(
  15515. !top ? val : win.pageXOffset,
  15516. top ? val : win.pageYOffset
  15517. );
  15518. } else {
  15519. elem[ method ] = val;
  15520. }
  15521. }, method, val, arguments.length );
  15522. };
  15523. } );
  15524. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15525. // Add the top/left cssHooks using jQuery.fn.position
  15526. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15527. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15528. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15529. // rather than make the css module depend on the offset module, just check for it here
  15530. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15531. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15532. function( elem, computed ) {
  15533. if ( computed ) {
  15534. computed = curCSS( elem, prop );
  15535. // If curCSS returns percentage, fallback to offset
  15536. return rnumnonpx.test( computed ) ?
  15537. jQuery( elem ).position()[ prop ] + "px" :
  15538. computed;
  15539. }
  15540. }
  15541. );
  15542. } );
  15543. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15544. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15545. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15546. function( defaultExtra, funcName ) {
  15547. // Margin is only for outerHeight, outerWidth
  15548. jQuery.fn[ funcName ] = function( margin, value ) {
  15549. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15550. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15551. return access( this, function( elem, type, value ) {
  15552. var doc;
  15553. if ( isWindow( elem ) ) {
  15554. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15555. return funcName.indexOf( "outer" ) === 0 ?
  15556. elem[ "inner" + name ] :
  15557. elem.document.documentElement[ "client" + name ];
  15558. }
  15559. // Get document width or height
  15560. if ( elem.nodeType === 9 ) {
  15561. doc = elem.documentElement;
  15562. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15563. // whichever is greatest
  15564. return Math.max(
  15565. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15566. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15567. doc[ "client" + name ]
  15568. );
  15569. }
  15570. return value === undefined ?
  15571. // Get width or height on the element, requesting but not forcing parseFloat
  15572. jQuery.css( elem, type, extra ) :
  15573. // Set width or height on the element
  15574. jQuery.style( elem, type, value, extra );
  15575. }, type, chainable ? margin : undefined, chainable );
  15576. };
  15577. } );
  15578. } );
  15579. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15580. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15581. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15582. function( i, name ) {
  15583. // Handle event binding
  15584. jQuery.fn[ name ] = function( data, fn ) {
  15585. return arguments.length > 0 ?
  15586. this.on( name, null, data, fn ) :
  15587. this.trigger( name );
  15588. };
  15589. } );
  15590. jQuery.fn.extend( {
  15591. hover: function( fnOver, fnOut ) {
  15592. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15593. }
  15594. } );
  15595. jQuery.fn.extend( {
  15596. bind: function( types, data, fn ) {
  15597. return this.on( types, null, data, fn );
  15598. },
  15599. unbind: function( types, fn ) {
  15600. return this.off( types, null, fn );
  15601. },
  15602. delegate: function( selector, types, data, fn ) {
  15603. return this.on( types, selector, data, fn );
  15604. },
  15605. undelegate: function( selector, types, fn ) {
  15606. // ( namespace ) or ( selector, types [, fn] )
  15607. return arguments.length === 1 ?
  15608. this.off( selector, "**" ) :
  15609. this.off( types, selector || "**", fn );
  15610. }
  15611. } );
  15612. // Bind a function to a context, optionally partially applying any
  15613. // arguments.
  15614. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15615. // However, it is not slated for removal any time soon
  15616. jQuery.proxy = function( fn, context ) {
  15617. var tmp, args, proxy;
  15618. if ( typeof context === "string" ) {
  15619. tmp = fn[ context ];
  15620. context = fn;
  15621. fn = tmp;
  15622. }
  15623. // Quick check to determine if target is callable, in the spec
  15624. // this throws a TypeError, but we will just return undefined.
  15625. if ( !isFunction( fn ) ) {
  15626. return undefined;
  15627. }
  15628. // Simulated bind
  15629. args = slice.call( arguments, 2 );
  15630. proxy = function() {
  15631. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15632. };
  15633. // Set the guid of unique handler to the same of original handler, so it can be removed
  15634. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15635. return proxy;
  15636. };
  15637. jQuery.holdReady = function( hold ) {
  15638. if ( hold ) {
  15639. jQuery.readyWait++;
  15640. } else {
  15641. jQuery.ready( true );
  15642. }
  15643. };
  15644. jQuery.isArray = Array.isArray;
  15645. jQuery.parseJSON = JSON.parse;
  15646. jQuery.nodeName = nodeName;
  15647. jQuery.isFunction = isFunction;
  15648. jQuery.isWindow = isWindow;
  15649. jQuery.camelCase = camelCase;
  15650. jQuery.type = toType;
  15651. jQuery.now = Date.now;
  15652. jQuery.isNumeric = function( obj ) {
  15653. // As of jQuery 3.0, isNumeric is limited to
  15654. // strings and numbers (primitives or objects)
  15655. // that can be coerced to finite numbers (gh-2662)
  15656. var type = jQuery.type( obj );
  15657. return ( type === "number" || type === "string" ) &&
  15658. // parseFloat NaNs numeric-cast false positives ("")
  15659. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15660. // subtraction forces infinities to NaN
  15661. !isNaN( obj - parseFloat( obj ) );
  15662. };
  15663. // Register as a named AMD module, since jQuery can be concatenated with other
  15664. // files that may use define, but not via a proper concatenation script that
  15665. // understands anonymous AMD modules. A named AMD is safest and most robust
  15666. // way to register. Lowercase jquery is used because AMD module names are
  15667. // derived from file names, and jQuery is normally delivered in a lowercase
  15668. // file name. Do this after creating the global so that if an AMD module wants
  15669. // to call noConflict to hide this version of jQuery, it will work.
  15670. // Note that for maximum portability, libraries that are not jQuery should
  15671. // declare themselves as anonymous modules, and avoid setting a global if an
  15672. // AMD loader is present. jQuery is a special case. For more information, see
  15673. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15674. if ( true ) {
  15675. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15676. return jQuery;
  15677. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15678. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15679. }
  15680. var
  15681. // Map over jQuery in case of overwrite
  15682. _jQuery = window.jQuery,
  15683. // Map over the $ in case of overwrite
  15684. _$ = window.$;
  15685. jQuery.noConflict = function( deep ) {
  15686. if ( window.$ === jQuery ) {
  15687. window.$ = _$;
  15688. }
  15689. if ( deep && window.jQuery === jQuery ) {
  15690. window.jQuery = _jQuery;
  15691. }
  15692. return jQuery;
  15693. };
  15694. // Expose jQuery and $ identifiers, even in AMD
  15695. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15696. // and CommonJS for browser emulators (#13566)
  15697. if ( !noGlobal ) {
  15698. window.jQuery = window.$ = jQuery;
  15699. }
  15700. return jQuery;
  15701. } );
  15702. /***/ }),
  15703. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15704. /*!************************************************!*\
  15705. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15706. \************************************************/
  15707. /*! exports provided: default */
  15708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15709. "use strict";
  15710. __webpack_require__.r(__webpack_exports__);
  15711. var classCallCheck = function (instance, Constructor) {
  15712. if (!(instance instanceof Constructor)) {
  15713. throw new TypeError("Cannot call a class as a function");
  15714. }
  15715. };
  15716. var createClass = function () {
  15717. function defineProperties(target, props) {
  15718. for (var i = 0; i < props.length; i++) {
  15719. var descriptor = props[i];
  15720. descriptor.enumerable = descriptor.enumerable || false;
  15721. descriptor.configurable = true;
  15722. if ("value" in descriptor) descriptor.writable = true;
  15723. Object.defineProperty(target, descriptor.key, descriptor);
  15724. }
  15725. }
  15726. return function (Constructor, protoProps, staticProps) {
  15727. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15728. if (staticProps) defineProperties(Constructor, staticProps);
  15729. return Constructor;
  15730. };
  15731. }();
  15732. var _extends = Object.assign || function (target) {
  15733. for (var i = 1; i < arguments.length; i++) {
  15734. var source = arguments[i];
  15735. for (var key in source) {
  15736. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15737. target[key] = source[key];
  15738. }
  15739. }
  15740. }
  15741. return target;
  15742. };
  15743. var inherits = function (subClass, superClass) {
  15744. if (typeof superClass !== "function" && superClass !== null) {
  15745. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15746. }
  15747. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15748. constructor: {
  15749. value: subClass,
  15750. enumerable: false,
  15751. writable: true,
  15752. configurable: true
  15753. }
  15754. });
  15755. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15756. };
  15757. var possibleConstructorReturn = function (self, call) {
  15758. if (!self) {
  15759. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15760. }
  15761. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15762. };
  15763. var Connector = function () {
  15764. /**
  15765. * Create a new class instance.
  15766. */
  15767. function Connector(options) {
  15768. classCallCheck(this, Connector);
  15769. /**
  15770. * Default connector options.
  15771. */
  15772. this._defaultOptions = {
  15773. auth: {
  15774. headers: {}
  15775. },
  15776. authEndpoint: '/broadcasting/auth',
  15777. broadcaster: 'pusher',
  15778. csrfToken: null,
  15779. host: null,
  15780. key: null,
  15781. namespace: 'App.Events'
  15782. };
  15783. this.setOptions(options);
  15784. this.connect();
  15785. }
  15786. /**
  15787. * Merge the custom options with the defaults.
  15788. */
  15789. createClass(Connector, [{
  15790. key: 'setOptions',
  15791. value: function setOptions(options) {
  15792. this.options = _extends(this._defaultOptions, options);
  15793. if (this.csrfToken()) {
  15794. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15795. }
  15796. return options;
  15797. }
  15798. /**
  15799. * Extract the CSRF token from the page.
  15800. */
  15801. }, {
  15802. key: 'csrfToken',
  15803. value: function csrfToken() {
  15804. var selector = void 0;
  15805. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15806. return window['Laravel'].csrfToken;
  15807. } else if (this.options.csrfToken) {
  15808. return this.options.csrfToken;
  15809. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15810. return selector.getAttribute('content');
  15811. }
  15812. return null;
  15813. }
  15814. }]);
  15815. return Connector;
  15816. }();
  15817. /**
  15818. * This class represents a basic channel.
  15819. */
  15820. var Channel = function () {
  15821. function Channel() {
  15822. classCallCheck(this, Channel);
  15823. }
  15824. createClass(Channel, [{
  15825. key: 'listenForWhisper',
  15826. /**
  15827. * Listen for a whisper event on the channel instance.
  15828. */
  15829. value: function listenForWhisper(event, callback) {
  15830. return this.listen('.client-' + event, callback);
  15831. }
  15832. /**
  15833. * Listen for an event on the channel instance.
  15834. */
  15835. }, {
  15836. key: 'notification',
  15837. value: function notification(callback) {
  15838. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15839. }
  15840. /**
  15841. * Stop listening for a whispser event on the channel instance.
  15842. */
  15843. }, {
  15844. key: 'stopListeningForWhisper',
  15845. value: function stopListeningForWhisper(event) {
  15846. return this.stopListening('.client-' + event);
  15847. }
  15848. }]);
  15849. return Channel;
  15850. }();
  15851. /**
  15852. * Event name formatter
  15853. */
  15854. var EventFormatter = function () {
  15855. /**
  15856. * Create a new class instance.
  15857. */
  15858. function EventFormatter(namespace) {
  15859. classCallCheck(this, EventFormatter);
  15860. this.setNamespace(namespace);
  15861. }
  15862. /**
  15863. * Format the given event name.
  15864. */
  15865. createClass(EventFormatter, [{
  15866. key: 'format',
  15867. value: function format(event) {
  15868. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15869. return event.substr(1);
  15870. } else if (this.namespace) {
  15871. event = this.namespace + '.' + event;
  15872. }
  15873. return event.replace(/\./g, '\\');
  15874. }
  15875. /**
  15876. * Set the event namespace.
  15877. */
  15878. }, {
  15879. key: 'setNamespace',
  15880. value: function setNamespace(value) {
  15881. this.namespace = value;
  15882. }
  15883. }]);
  15884. return EventFormatter;
  15885. }();
  15886. /**
  15887. * This class represents a Pusher channel.
  15888. */
  15889. var PusherChannel = function (_Channel) {
  15890. inherits(PusherChannel, _Channel);
  15891. /**
  15892. * Create a new class instance.
  15893. */
  15894. function PusherChannel(pusher, name, options) {
  15895. classCallCheck(this, PusherChannel);
  15896. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15897. _this.name = name;
  15898. _this.pusher = pusher;
  15899. _this.options = options;
  15900. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15901. _this.subscribe();
  15902. return _this;
  15903. }
  15904. /**
  15905. * Subscribe to a Pusher channel.
  15906. */
  15907. createClass(PusherChannel, [{
  15908. key: 'subscribe',
  15909. value: function subscribe() {
  15910. this.subscription = this.pusher.subscribe(this.name);
  15911. }
  15912. /**
  15913. * Unsubscribe from a Pusher channel.
  15914. */
  15915. }, {
  15916. key: 'unsubscribe',
  15917. value: function unsubscribe() {
  15918. this.pusher.unsubscribe(this.name);
  15919. }
  15920. /**
  15921. * Listen for an event on the channel instance.
  15922. */
  15923. }, {
  15924. key: 'listen',
  15925. value: function listen(event, callback) {
  15926. this.on(this.eventFormatter.format(event), callback);
  15927. return this;
  15928. }
  15929. /**
  15930. * Stop listening for an event on the channel instance.
  15931. */
  15932. }, {
  15933. key: 'stopListening',
  15934. value: function stopListening(event) {
  15935. this.subscription.unbind(this.eventFormatter.format(event));
  15936. return this;
  15937. }
  15938. /**
  15939. * Bind a channel to an event.
  15940. */
  15941. }, {
  15942. key: 'on',
  15943. value: function on(event, callback) {
  15944. this.subscription.bind(event, callback);
  15945. return this;
  15946. }
  15947. }]);
  15948. return PusherChannel;
  15949. }(Channel);
  15950. /**
  15951. * This class represents a Pusher private channel.
  15952. */
  15953. var PusherPrivateChannel = function (_PusherChannel) {
  15954. inherits(PusherPrivateChannel, _PusherChannel);
  15955. function PusherPrivateChannel() {
  15956. classCallCheck(this, PusherPrivateChannel);
  15957. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15958. }
  15959. createClass(PusherPrivateChannel, [{
  15960. key: 'whisper',
  15961. /**
  15962. * Trigger client event on the channel.
  15963. */
  15964. value: function whisper(eventName, data) {
  15965. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  15966. return this;
  15967. }
  15968. }]);
  15969. return PusherPrivateChannel;
  15970. }(PusherChannel);
  15971. /**
  15972. * This class represents a Pusher presence channel.
  15973. */
  15974. var PusherPresenceChannel = function (_PusherChannel) {
  15975. inherits(PusherPresenceChannel, _PusherChannel);
  15976. function PusherPresenceChannel() {
  15977. classCallCheck(this, PusherPresenceChannel);
  15978. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  15979. }
  15980. createClass(PusherPresenceChannel, [{
  15981. key: 'here',
  15982. /**
  15983. * Register a callback to be called anytime the member list changes.
  15984. */
  15985. value: function here(callback) {
  15986. this.on('pusher:subscription_succeeded', function (data) {
  15987. callback(Object.keys(data.members).map(function (k) {
  15988. return data.members[k];
  15989. }));
  15990. });
  15991. return this;
  15992. }
  15993. /**
  15994. * Listen for someone joining the channel.
  15995. */
  15996. }, {
  15997. key: 'joining',
  15998. value: function joining(callback) {
  15999. this.on('pusher:member_added', function (member) {
  16000. callback(member.info);
  16001. });
  16002. return this;
  16003. }
  16004. /**
  16005. * Listen for someone leaving the channel.
  16006. */
  16007. }, {
  16008. key: 'leaving',
  16009. value: function leaving(callback) {
  16010. this.on('pusher:member_removed', function (member) {
  16011. callback(member.info);
  16012. });
  16013. return this;
  16014. }
  16015. /**
  16016. * Trigger client event on the channel.
  16017. */
  16018. }, {
  16019. key: 'whisper',
  16020. value: function whisper(eventName, data) {
  16021. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16022. return this;
  16023. }
  16024. }]);
  16025. return PusherPresenceChannel;
  16026. }(PusherChannel);
  16027. /**
  16028. * This class represents a Socket.io channel.
  16029. */
  16030. var SocketIoChannel = function (_Channel) {
  16031. inherits(SocketIoChannel, _Channel);
  16032. /**
  16033. * Create a new class instance.
  16034. */
  16035. function SocketIoChannel(socket, name, options) {
  16036. classCallCheck(this, SocketIoChannel);
  16037. /**
  16038. * The event callbacks applied to the channel.
  16039. */
  16040. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16041. _this.events = {};
  16042. _this.name = name;
  16043. _this.socket = socket;
  16044. _this.options = options;
  16045. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16046. _this.subscribe();
  16047. _this.configureReconnector();
  16048. return _this;
  16049. }
  16050. /**
  16051. * Subscribe to a Socket.io channel.
  16052. */
  16053. createClass(SocketIoChannel, [{
  16054. key: 'subscribe',
  16055. value: function subscribe() {
  16056. this.socket.emit('subscribe', {
  16057. channel: this.name,
  16058. auth: this.options.auth || {}
  16059. });
  16060. }
  16061. /**
  16062. * Unsubscribe from channel and ubind event callbacks.
  16063. */
  16064. }, {
  16065. key: 'unsubscribe',
  16066. value: function unsubscribe() {
  16067. this.unbind();
  16068. this.socket.emit('unsubscribe', {
  16069. channel: this.name,
  16070. auth: this.options.auth || {}
  16071. });
  16072. }
  16073. /**
  16074. * Listen for an event on the channel instance.
  16075. */
  16076. }, {
  16077. key: 'listen',
  16078. value: function listen(event, callback) {
  16079. this.on(this.eventFormatter.format(event), callback);
  16080. return this;
  16081. }
  16082. /**
  16083. * Stop listening for an event on the channel instance.
  16084. */
  16085. }, {
  16086. key: 'stopListening',
  16087. value: function stopListening(event) {
  16088. var name = this.eventFormatter.format(event);
  16089. this.socket.removeListener(name);
  16090. delete this.events[name];
  16091. return this;
  16092. }
  16093. /**
  16094. * Bind the channel's socket to an event and store the callback.
  16095. */
  16096. }, {
  16097. key: 'on',
  16098. value: function on(event, callback) {
  16099. var _this2 = this;
  16100. var listener = function listener(channel, data) {
  16101. if (_this2.name == channel) {
  16102. callback(data);
  16103. }
  16104. };
  16105. this.socket.on(event, listener);
  16106. this.bind(event, listener);
  16107. }
  16108. /**
  16109. * Attach a 'reconnect' listener and bind the event.
  16110. */
  16111. }, {
  16112. key: 'configureReconnector',
  16113. value: function configureReconnector() {
  16114. var _this3 = this;
  16115. var listener = function listener() {
  16116. _this3.subscribe();
  16117. };
  16118. this.socket.on('reconnect', listener);
  16119. this.bind('reconnect', listener);
  16120. }
  16121. /**
  16122. * Bind the channel's socket to an event and store the callback.
  16123. */
  16124. }, {
  16125. key: 'bind',
  16126. value: function bind(event, callback) {
  16127. this.events[event] = this.events[event] || [];
  16128. this.events[event].push(callback);
  16129. }
  16130. /**
  16131. * Unbind the channel's socket from all stored event callbacks.
  16132. */
  16133. }, {
  16134. key: 'unbind',
  16135. value: function unbind() {
  16136. var _this4 = this;
  16137. Object.keys(this.events).forEach(function (event) {
  16138. _this4.events[event].forEach(function (callback) {
  16139. _this4.socket.removeListener(event, callback);
  16140. });
  16141. delete _this4.events[event];
  16142. });
  16143. }
  16144. }]);
  16145. return SocketIoChannel;
  16146. }(Channel);
  16147. /**
  16148. * This class represents a Socket.io presence channel.
  16149. */
  16150. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16151. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16152. function SocketIoPrivateChannel() {
  16153. classCallCheck(this, SocketIoPrivateChannel);
  16154. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16155. }
  16156. createClass(SocketIoPrivateChannel, [{
  16157. key: 'whisper',
  16158. /**
  16159. * Trigger client event on the channel.
  16160. */
  16161. value: function whisper(eventName, data) {
  16162. this.socket.emit('client event', {
  16163. channel: this.name,
  16164. event: 'client-' + eventName,
  16165. data: data
  16166. });
  16167. return this;
  16168. }
  16169. }]);
  16170. return SocketIoPrivateChannel;
  16171. }(SocketIoChannel);
  16172. /**
  16173. * This class represents a Socket.io presence channel.
  16174. */
  16175. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16176. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16177. function SocketIoPresenceChannel() {
  16178. classCallCheck(this, SocketIoPresenceChannel);
  16179. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16180. }
  16181. createClass(SocketIoPresenceChannel, [{
  16182. key: 'here',
  16183. /**
  16184. * Register a callback to be called anytime the member list changes.
  16185. */
  16186. value: function here(callback) {
  16187. this.on('presence:subscribed', function (members) {
  16188. callback(members.map(function (m) {
  16189. return m.user_info;
  16190. }));
  16191. });
  16192. return this;
  16193. }
  16194. /**
  16195. * Listen for someone joining the channel.
  16196. */
  16197. }, {
  16198. key: 'joining',
  16199. value: function joining(callback) {
  16200. this.on('presence:joining', function (member) {
  16201. return callback(member.user_info);
  16202. });
  16203. return this;
  16204. }
  16205. /**
  16206. * Listen for someone leaving the channel.
  16207. */
  16208. }, {
  16209. key: 'leaving',
  16210. value: function leaving(callback) {
  16211. this.on('presence:leaving', function (member) {
  16212. return callback(member.user_info);
  16213. });
  16214. return this;
  16215. }
  16216. }]);
  16217. return SocketIoPresenceChannel;
  16218. }(SocketIoPrivateChannel);
  16219. /**
  16220. * This class represents a null channel.
  16221. */
  16222. var NullChannel = function (_Channel) {
  16223. inherits(NullChannel, _Channel);
  16224. function NullChannel() {
  16225. classCallCheck(this, NullChannel);
  16226. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16227. }
  16228. createClass(NullChannel, [{
  16229. key: 'subscribe',
  16230. /**
  16231. * Subscribe to a channel.
  16232. */
  16233. value: function subscribe() {}
  16234. //
  16235. /**
  16236. * Unsubscribe from a channel.
  16237. */
  16238. }, {
  16239. key: 'unsubscribe',
  16240. value: function unsubscribe() {}
  16241. //
  16242. /**
  16243. * Listen for an event on the channel instance.
  16244. */
  16245. }, {
  16246. key: 'listen',
  16247. value: function listen(event, callback) {
  16248. return this;
  16249. }
  16250. /**
  16251. * Stop listening for an event on the channel instance.
  16252. */
  16253. }, {
  16254. key: 'stopListening',
  16255. value: function stopListening(event) {
  16256. return this;
  16257. }
  16258. /**
  16259. * Bind a channel to an event.
  16260. */
  16261. }, {
  16262. key: 'on',
  16263. value: function on(event, callback) {
  16264. return this;
  16265. }
  16266. }]);
  16267. return NullChannel;
  16268. }(Channel);
  16269. /**
  16270. * This class represents a null private channel.
  16271. */
  16272. var NullPrivateChannel = function (_NullChannel) {
  16273. inherits(NullPrivateChannel, _NullChannel);
  16274. function NullPrivateChannel() {
  16275. classCallCheck(this, NullPrivateChannel);
  16276. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16277. }
  16278. createClass(NullPrivateChannel, [{
  16279. key: 'whisper',
  16280. /**
  16281. * Trigger client event on the channel.
  16282. */
  16283. value: function whisper(eventName, data) {
  16284. return this;
  16285. }
  16286. }]);
  16287. return NullPrivateChannel;
  16288. }(NullChannel);
  16289. /**
  16290. * This class represents a null presence channel.
  16291. */
  16292. var NullPresenceChannel = function (_NullChannel) {
  16293. inherits(NullPresenceChannel, _NullChannel);
  16294. function NullPresenceChannel() {
  16295. classCallCheck(this, NullPresenceChannel);
  16296. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16297. }
  16298. createClass(NullPresenceChannel, [{
  16299. key: 'here',
  16300. /**
  16301. * Register a callback to be called anytime the member list changes.
  16302. */
  16303. value: function here(callback) {
  16304. return this;
  16305. }
  16306. /**
  16307. * Listen for someone joining the channel.
  16308. */
  16309. }, {
  16310. key: 'joining',
  16311. value: function joining(callback) {
  16312. return this;
  16313. }
  16314. /**
  16315. * Listen for someone leaving the channel.
  16316. */
  16317. }, {
  16318. key: 'leaving',
  16319. value: function leaving(callback) {
  16320. return this;
  16321. }
  16322. /**
  16323. * Trigger client event on the channel.
  16324. */
  16325. }, {
  16326. key: 'whisper',
  16327. value: function whisper(eventName, data) {
  16328. return this;
  16329. }
  16330. }]);
  16331. return NullPresenceChannel;
  16332. }(NullChannel);
  16333. /**
  16334. * This class creates a connector to Pusher.
  16335. */
  16336. var PusherConnector = function (_Connector) {
  16337. inherits(PusherConnector, _Connector);
  16338. function PusherConnector() {
  16339. classCallCheck(this, PusherConnector);
  16340. /**
  16341. * All of the subscribed channel names.
  16342. */
  16343. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16344. _this.channels = {};
  16345. return _this;
  16346. }
  16347. /**
  16348. * Create a fresh Pusher connection.
  16349. */
  16350. createClass(PusherConnector, [{
  16351. key: 'connect',
  16352. value: function connect() {
  16353. if (typeof this.options.client !== 'undefined') {
  16354. this.pusher = this.options.client;
  16355. } else {
  16356. this.pusher = new Pusher(this.options.key, this.options);
  16357. }
  16358. }
  16359. /**
  16360. * Listen for an event on a channel instance.
  16361. */
  16362. }, {
  16363. key: 'listen',
  16364. value: function listen(name, event, callback) {
  16365. return this.channel(name).listen(event, callback);
  16366. }
  16367. /**
  16368. * Get a channel instance by name.
  16369. */
  16370. }, {
  16371. key: 'channel',
  16372. value: function channel(name) {
  16373. if (!this.channels[name]) {
  16374. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16375. }
  16376. return this.channels[name];
  16377. }
  16378. /**
  16379. * Get a private channel instance by name.
  16380. */
  16381. }, {
  16382. key: 'privateChannel',
  16383. value: function privateChannel(name) {
  16384. if (!this.channels['private-' + name]) {
  16385. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16386. }
  16387. return this.channels['private-' + name];
  16388. }
  16389. /**
  16390. * Get a presence channel instance by name.
  16391. */
  16392. }, {
  16393. key: 'presenceChannel',
  16394. value: function presenceChannel(name) {
  16395. if (!this.channels['presence-' + name]) {
  16396. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16397. }
  16398. return this.channels['presence-' + name];
  16399. }
  16400. /**
  16401. * Leave the given channel, as well as its private and presence variants.
  16402. */
  16403. }, {
  16404. key: 'leave',
  16405. value: function leave(name) {
  16406. var _this2 = this;
  16407. var channels = [name, 'private-' + name, 'presence-' + name];
  16408. channels.forEach(function (name, index) {
  16409. _this2.leaveChannel(name);
  16410. });
  16411. }
  16412. /**
  16413. * Leave the given channel.
  16414. */
  16415. }, {
  16416. key: 'leaveChannel',
  16417. value: function leaveChannel(name) {
  16418. if (this.channels[name]) {
  16419. this.channels[name].unsubscribe();
  16420. delete this.channels[name];
  16421. }
  16422. }
  16423. /**
  16424. * Get the socket ID for the connection.
  16425. */
  16426. }, {
  16427. key: 'socketId',
  16428. value: function socketId() {
  16429. return this.pusher.connection.socket_id;
  16430. }
  16431. /**
  16432. * Disconnect Pusher connection.
  16433. */
  16434. }, {
  16435. key: 'disconnect',
  16436. value: function disconnect() {
  16437. this.pusher.disconnect();
  16438. }
  16439. }]);
  16440. return PusherConnector;
  16441. }(Connector);
  16442. /**
  16443. * This class creates a connnector to a Socket.io server.
  16444. */
  16445. var SocketIoConnector = function (_Connector) {
  16446. inherits(SocketIoConnector, _Connector);
  16447. function SocketIoConnector() {
  16448. classCallCheck(this, SocketIoConnector);
  16449. /**
  16450. * All of the subscribed channel names.
  16451. */
  16452. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16453. _this.channels = {};
  16454. return _this;
  16455. }
  16456. /**
  16457. * Create a fresh Socket.io connection.
  16458. */
  16459. createClass(SocketIoConnector, [{
  16460. key: 'connect',
  16461. value: function connect() {
  16462. var io = this.getSocketIO();
  16463. this.socket = io(this.options.host, this.options);
  16464. return this.socket;
  16465. }
  16466. /**
  16467. * Get socket.io module from global scope or options.
  16468. */
  16469. }, {
  16470. key: 'getSocketIO',
  16471. value: function getSocketIO() {
  16472. if (typeof this.options.client !== 'undefined') {
  16473. return this.options.client;
  16474. }
  16475. if (typeof io !== 'undefined') {
  16476. return io;
  16477. }
  16478. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16479. }
  16480. /**
  16481. * Listen for an event on a channel instance.
  16482. */
  16483. }, {
  16484. key: 'listen',
  16485. value: function listen(name, event, callback) {
  16486. return this.channel(name).listen(event, callback);
  16487. }
  16488. /**
  16489. * Get a channel instance by name.
  16490. */
  16491. }, {
  16492. key: 'channel',
  16493. value: function channel(name) {
  16494. if (!this.channels[name]) {
  16495. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16496. }
  16497. return this.channels[name];
  16498. }
  16499. /**
  16500. * Get a private channel instance by name.
  16501. */
  16502. }, {
  16503. key: 'privateChannel',
  16504. value: function privateChannel(name) {
  16505. if (!this.channels['private-' + name]) {
  16506. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16507. }
  16508. return this.channels['private-' + name];
  16509. }
  16510. /**
  16511. * Get a presence channel instance by name.
  16512. */
  16513. }, {
  16514. key: 'presenceChannel',
  16515. value: function presenceChannel(name) {
  16516. if (!this.channels['presence-' + name]) {
  16517. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16518. }
  16519. return this.channels['presence-' + name];
  16520. }
  16521. /**
  16522. * Leave the given channel, as well as its private and presence variants.
  16523. */
  16524. }, {
  16525. key: 'leave',
  16526. value: function leave(name) {
  16527. var _this2 = this;
  16528. var channels = [name, 'private-' + name, 'presence-' + name];
  16529. channels.forEach(function (name) {
  16530. _this2.leaveChannel(name);
  16531. });
  16532. }
  16533. /**
  16534. * Leave the given channel.
  16535. */
  16536. }, {
  16537. key: 'leaveChannel',
  16538. value: function leaveChannel(name) {
  16539. if (this.channels[name]) {
  16540. this.channels[name].unsubscribe();
  16541. delete this.channels[name];
  16542. }
  16543. }
  16544. /**
  16545. * Get the socket ID for the connection.
  16546. */
  16547. }, {
  16548. key: 'socketId',
  16549. value: function socketId() {
  16550. return this.socket.id;
  16551. }
  16552. /**
  16553. * Disconnect Socketio connection.
  16554. */
  16555. }, {
  16556. key: 'disconnect',
  16557. value: function disconnect() {
  16558. this.socket.disconnect();
  16559. }
  16560. }]);
  16561. return SocketIoConnector;
  16562. }(Connector);
  16563. /**
  16564. * This class creates a null connector.
  16565. */
  16566. var NullConnector = function (_Connector) {
  16567. inherits(NullConnector, _Connector);
  16568. function NullConnector() {
  16569. classCallCheck(this, NullConnector);
  16570. /**
  16571. * All of the subscribed channel names.
  16572. */
  16573. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16574. _this.channels = {};
  16575. return _this;
  16576. }
  16577. /**
  16578. * Create a fresh connection.
  16579. */
  16580. createClass(NullConnector, [{
  16581. key: 'connect',
  16582. value: function connect() {}
  16583. //
  16584. /**
  16585. * Listen for an event on a channel instance.
  16586. */
  16587. }, {
  16588. key: 'listen',
  16589. value: function listen(name, event, callback) {
  16590. return new NullChannel();
  16591. }
  16592. /**
  16593. * Get a channel instance by name.
  16594. */
  16595. }, {
  16596. key: 'channel',
  16597. value: function channel(name) {
  16598. return new NullChannel();
  16599. }
  16600. /**
  16601. * Get a private channel instance by name.
  16602. */
  16603. }, {
  16604. key: 'privateChannel',
  16605. value: function privateChannel(name) {
  16606. return new NullPrivateChannel();
  16607. }
  16608. /**
  16609. * Get a presence channel instance by name.
  16610. */
  16611. }, {
  16612. key: 'presenceChannel',
  16613. value: function presenceChannel(name) {
  16614. return new NullPresenceChannel();
  16615. }
  16616. /**
  16617. * Leave the given channel, as well as its private and presence variants.
  16618. */
  16619. }, {
  16620. key: 'leave',
  16621. value: function leave(name) {}
  16622. //
  16623. /**
  16624. * Leave the given channel.
  16625. */
  16626. }, {
  16627. key: 'leaveChannel',
  16628. value: function leaveChannel(name) {}
  16629. //
  16630. /**
  16631. * Get the socket ID for the connection.
  16632. */
  16633. }, {
  16634. key: 'socketId',
  16635. value: function socketId() {
  16636. return 'fake-socket-id';
  16637. }
  16638. /**
  16639. * Disconnect the connection.
  16640. */
  16641. }, {
  16642. key: 'disconnect',
  16643. value: function disconnect() {
  16644. //
  16645. }
  16646. }]);
  16647. return NullConnector;
  16648. }(Connector);
  16649. /**
  16650. * This class is the primary API for interacting with broadcasting.
  16651. */
  16652. var Echo = function () {
  16653. /**
  16654. * Create a new class instance.
  16655. */
  16656. function Echo(options) {
  16657. classCallCheck(this, Echo);
  16658. this.options = options;
  16659. this.connect();
  16660. if (!this.options.withoutInterceptors) {
  16661. this.registerInterceptors();
  16662. }
  16663. }
  16664. /**
  16665. * Get a channel instance by name.
  16666. */
  16667. createClass(Echo, [{
  16668. key: 'channel',
  16669. value: function channel(_channel) {
  16670. return this.connector.channel(_channel);
  16671. }
  16672. /**
  16673. * Create a new connection.
  16674. */
  16675. }, {
  16676. key: 'connect',
  16677. value: function connect() {
  16678. if (this.options.broadcaster == 'pusher') {
  16679. this.connector = new PusherConnector(this.options);
  16680. } else if (this.options.broadcaster == 'socket.io') {
  16681. this.connector = new SocketIoConnector(this.options);
  16682. } else if (this.options.broadcaster == 'null') {
  16683. this.connector = new NullConnector(this.options);
  16684. } else if (typeof this.options.broadcaster == 'function') {
  16685. this.connector = new this.options.broadcaster(this.options);
  16686. }
  16687. }
  16688. /**
  16689. * Disconnect from the Echo server.
  16690. */
  16691. }, {
  16692. key: 'disconnect',
  16693. value: function disconnect() {
  16694. this.connector.disconnect();
  16695. }
  16696. /**
  16697. * Get a presence channel instance by name.
  16698. */
  16699. }, {
  16700. key: 'join',
  16701. value: function join(channel) {
  16702. return this.connector.presenceChannel(channel);
  16703. }
  16704. /**
  16705. * Leave the given channel, as well as its private and presence variants.
  16706. */
  16707. }, {
  16708. key: 'leave',
  16709. value: function leave(channel) {
  16710. this.connector.leave(channel);
  16711. }
  16712. /**
  16713. * Leave the given channel.
  16714. */
  16715. }, {
  16716. key: 'leaveChannel',
  16717. value: function leaveChannel(channel) {
  16718. this.connector.leaveChannel(channel);
  16719. }
  16720. /**
  16721. * Listen for an event on a channel instance.
  16722. */
  16723. }, {
  16724. key: 'listen',
  16725. value: function listen(channel, event, callback) {
  16726. return this.connector.listen(channel, event, callback);
  16727. }
  16728. /**
  16729. * Get a private channel instance by name.
  16730. */
  16731. }, {
  16732. key: 'private',
  16733. value: function _private(channel) {
  16734. return this.connector.privateChannel(channel);
  16735. }
  16736. /**
  16737. * Get the Socket ID for the connection.
  16738. */
  16739. }, {
  16740. key: 'socketId',
  16741. value: function socketId() {
  16742. return this.connector.socketId();
  16743. }
  16744. /**
  16745. * Register 3rd party request interceptiors. These are used to automatically
  16746. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16747. */
  16748. }, {
  16749. key: 'registerInterceptors',
  16750. value: function registerInterceptors() {
  16751. if (typeof Vue === 'function' && Vue.http) {
  16752. this.registerVueRequestInterceptor();
  16753. }
  16754. if (typeof axios === 'function') {
  16755. this.registerAxiosRequestInterceptor();
  16756. }
  16757. if (typeof jQuery === 'function') {
  16758. this.registerjQueryAjaxSetup();
  16759. }
  16760. }
  16761. /**
  16762. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16763. */
  16764. }, {
  16765. key: 'registerVueRequestInterceptor',
  16766. value: function registerVueRequestInterceptor() {
  16767. var _this = this;
  16768. Vue.http.interceptors.push(function (request, next) {
  16769. if (_this.socketId()) {
  16770. request.headers.set('X-Socket-ID', _this.socketId());
  16771. }
  16772. next();
  16773. });
  16774. }
  16775. /**
  16776. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16777. */
  16778. }, {
  16779. key: 'registerAxiosRequestInterceptor',
  16780. value: function registerAxiosRequestInterceptor() {
  16781. var _this2 = this;
  16782. axios.interceptors.request.use(function (config) {
  16783. if (_this2.socketId()) {
  16784. config.headers['X-Socket-Id'] = _this2.socketId();
  16785. }
  16786. return config;
  16787. });
  16788. }
  16789. /**
  16790. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16791. */
  16792. }, {
  16793. key: 'registerjQueryAjaxSetup',
  16794. value: function registerjQueryAjaxSetup() {
  16795. var _this3 = this;
  16796. if (typeof jQuery.ajax != 'undefined') {
  16797. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16798. if (_this3.socketId()) {
  16799. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16800. }
  16801. });
  16802. }
  16803. }
  16804. }]);
  16805. return Echo;
  16806. }();
  16807. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16808. /***/ }),
  16809. /***/ "./node_modules/lodash/lodash.js":
  16810. /*!***************************************!*\
  16811. !*** ./node_modules/lodash/lodash.js ***!
  16812. \***************************************/
  16813. /*! no static exports found */
  16814. /***/ (function(module, exports, __webpack_require__) {
  16815. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16816. * @license
  16817. * Lodash <https://lodash.com/>
  16818. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16819. * Released under MIT license <https://lodash.com/license>
  16820. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16821. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16822. */
  16823. ;(function() {
  16824. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16825. var undefined;
  16826. /** Used as the semantic version number. */
  16827. var VERSION = '4.17.15';
  16828. /** Used as the size to enable large array optimizations. */
  16829. var LARGE_ARRAY_SIZE = 200;
  16830. /** Error message constants. */
  16831. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16832. FUNC_ERROR_TEXT = 'Expected a function';
  16833. /** Used to stand-in for `undefined` hash values. */
  16834. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16835. /** Used as the maximum memoize cache size. */
  16836. var MAX_MEMOIZE_SIZE = 500;
  16837. /** Used as the internal argument placeholder. */
  16838. var PLACEHOLDER = '__lodash_placeholder__';
  16839. /** Used to compose bitmasks for cloning. */
  16840. var CLONE_DEEP_FLAG = 1,
  16841. CLONE_FLAT_FLAG = 2,
  16842. CLONE_SYMBOLS_FLAG = 4;
  16843. /** Used to compose bitmasks for value comparisons. */
  16844. var COMPARE_PARTIAL_FLAG = 1,
  16845. COMPARE_UNORDERED_FLAG = 2;
  16846. /** Used to compose bitmasks for function metadata. */
  16847. var WRAP_BIND_FLAG = 1,
  16848. WRAP_BIND_KEY_FLAG = 2,
  16849. WRAP_CURRY_BOUND_FLAG = 4,
  16850. WRAP_CURRY_FLAG = 8,
  16851. WRAP_CURRY_RIGHT_FLAG = 16,
  16852. WRAP_PARTIAL_FLAG = 32,
  16853. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16854. WRAP_ARY_FLAG = 128,
  16855. WRAP_REARG_FLAG = 256,
  16856. WRAP_FLIP_FLAG = 512;
  16857. /** Used as default options for `_.truncate`. */
  16858. var DEFAULT_TRUNC_LENGTH = 30,
  16859. DEFAULT_TRUNC_OMISSION = '...';
  16860. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16861. var HOT_COUNT = 800,
  16862. HOT_SPAN = 16;
  16863. /** Used to indicate the type of lazy iteratees. */
  16864. var LAZY_FILTER_FLAG = 1,
  16865. LAZY_MAP_FLAG = 2,
  16866. LAZY_WHILE_FLAG = 3;
  16867. /** Used as references for various `Number` constants. */
  16868. var INFINITY = 1 / 0,
  16869. MAX_SAFE_INTEGER = 9007199254740991,
  16870. MAX_INTEGER = 1.7976931348623157e+308,
  16871. NAN = 0 / 0;
  16872. /** Used as references for the maximum length and index of an array. */
  16873. var MAX_ARRAY_LENGTH = 4294967295,
  16874. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16875. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16876. /** Used to associate wrap methods with their bit flags. */
  16877. var wrapFlags = [
  16878. ['ary', WRAP_ARY_FLAG],
  16879. ['bind', WRAP_BIND_FLAG],
  16880. ['bindKey', WRAP_BIND_KEY_FLAG],
  16881. ['curry', WRAP_CURRY_FLAG],
  16882. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16883. ['flip', WRAP_FLIP_FLAG],
  16884. ['partial', WRAP_PARTIAL_FLAG],
  16885. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16886. ['rearg', WRAP_REARG_FLAG]
  16887. ];
  16888. /** `Object#toString` result references. */
  16889. var argsTag = '[object Arguments]',
  16890. arrayTag = '[object Array]',
  16891. asyncTag = '[object AsyncFunction]',
  16892. boolTag = '[object Boolean]',
  16893. dateTag = '[object Date]',
  16894. domExcTag = '[object DOMException]',
  16895. errorTag = '[object Error]',
  16896. funcTag = '[object Function]',
  16897. genTag = '[object GeneratorFunction]',
  16898. mapTag = '[object Map]',
  16899. numberTag = '[object Number]',
  16900. nullTag = '[object Null]',
  16901. objectTag = '[object Object]',
  16902. promiseTag = '[object Promise]',
  16903. proxyTag = '[object Proxy]',
  16904. regexpTag = '[object RegExp]',
  16905. setTag = '[object Set]',
  16906. stringTag = '[object String]',
  16907. symbolTag = '[object Symbol]',
  16908. undefinedTag = '[object Undefined]',
  16909. weakMapTag = '[object WeakMap]',
  16910. weakSetTag = '[object WeakSet]';
  16911. var arrayBufferTag = '[object ArrayBuffer]',
  16912. dataViewTag = '[object DataView]',
  16913. float32Tag = '[object Float32Array]',
  16914. float64Tag = '[object Float64Array]',
  16915. int8Tag = '[object Int8Array]',
  16916. int16Tag = '[object Int16Array]',
  16917. int32Tag = '[object Int32Array]',
  16918. uint8Tag = '[object Uint8Array]',
  16919. uint8ClampedTag = '[object Uint8ClampedArray]',
  16920. uint16Tag = '[object Uint16Array]',
  16921. uint32Tag = '[object Uint32Array]';
  16922. /** Used to match empty string literals in compiled template source. */
  16923. var reEmptyStringLeading = /\b__p \+= '';/g,
  16924. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16925. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16926. /** Used to match HTML entities and HTML characters. */
  16927. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16928. reUnescapedHtml = /[&<>"']/g,
  16929. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16930. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16931. /** Used to match template delimiters. */
  16932. var reEscape = /<%-([\s\S]+?)%>/g,
  16933. reEvaluate = /<%([\s\S]+?)%>/g,
  16934. reInterpolate = /<%=([\s\S]+?)%>/g;
  16935. /** Used to match property names within property paths. */
  16936. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16937. reIsPlainProp = /^\w*$/,
  16938. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16939. /**
  16940. * Used to match `RegExp`
  16941. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16942. */
  16943. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16944. reHasRegExpChar = RegExp(reRegExpChar.source);
  16945. /** Used to match leading and trailing whitespace. */
  16946. var reTrim = /^\s+|\s+$/g,
  16947. reTrimStart = /^\s+/,
  16948. reTrimEnd = /\s+$/;
  16949. /** Used to match wrap detail comments. */
  16950. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16951. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16952. reSplitDetails = /,? & /;
  16953. /** Used to match words composed of alphanumeric characters. */
  16954. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16955. /** Used to match backslashes in property paths. */
  16956. var reEscapeChar = /\\(\\)?/g;
  16957. /**
  16958. * Used to match
  16959. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16960. */
  16961. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  16962. /** Used to match `RegExp` flags from their coerced string values. */
  16963. var reFlags = /\w*$/;
  16964. /** Used to detect bad signed hexadecimal string values. */
  16965. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  16966. /** Used to detect binary string values. */
  16967. var reIsBinary = /^0b[01]+$/i;
  16968. /** Used to detect host constructors (Safari). */
  16969. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  16970. /** Used to detect octal string values. */
  16971. var reIsOctal = /^0o[0-7]+$/i;
  16972. /** Used to detect unsigned integer values. */
  16973. var reIsUint = /^(?:0|[1-9]\d*)$/;
  16974. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  16975. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  16976. /** Used to ensure capturing order of template delimiters. */
  16977. var reNoMatch = /($^)/;
  16978. /** Used to match unescaped characters in compiled string literals. */
  16979. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  16980. /** Used to compose unicode character classes. */
  16981. var rsAstralRange = '\\ud800-\\udfff',
  16982. rsComboMarksRange = '\\u0300-\\u036f',
  16983. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  16984. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  16985. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  16986. rsDingbatRange = '\\u2700-\\u27bf',
  16987. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  16988. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  16989. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  16990. rsPunctuationRange = '\\u2000-\\u206f',
  16991. 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',
  16992. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  16993. rsVarRange = '\\ufe0e\\ufe0f',
  16994. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  16995. /** Used to compose unicode capture groups. */
  16996. var rsApos = "['\u2019]",
  16997. rsAstral = '[' + rsAstralRange + ']',
  16998. rsBreak = '[' + rsBreakRange + ']',
  16999. rsCombo = '[' + rsComboRange + ']',
  17000. rsDigits = '\\d+',
  17001. rsDingbat = '[' + rsDingbatRange + ']',
  17002. rsLower = '[' + rsLowerRange + ']',
  17003. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17004. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17005. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17006. rsNonAstral = '[^' + rsAstralRange + ']',
  17007. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17008. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17009. rsUpper = '[' + rsUpperRange + ']',
  17010. rsZWJ = '\\u200d';
  17011. /** Used to compose unicode regexes. */
  17012. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17013. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17014. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17015. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17016. reOptMod = rsModifier + '?',
  17017. rsOptVar = '[' + rsVarRange + ']?',
  17018. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17019. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17020. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17021. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17022. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17023. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17024. /** Used to match apostrophes. */
  17025. var reApos = RegExp(rsApos, 'g');
  17026. /**
  17027. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17028. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17029. */
  17030. var reComboMark = RegExp(rsCombo, 'g');
  17031. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17032. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17033. /** Used to match complex or compound words. */
  17034. var reUnicodeWord = RegExp([
  17035. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17036. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17037. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17038. rsUpper + '+' + rsOptContrUpper,
  17039. rsOrdUpper,
  17040. rsOrdLower,
  17041. rsDigits,
  17042. rsEmoji
  17043. ].join('|'), 'g');
  17044. /** 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/). */
  17045. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17046. /** Used to detect strings that need a more robust regexp to match words. */
  17047. 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 ]/;
  17048. /** Used to assign default `context` object properties. */
  17049. var contextProps = [
  17050. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17051. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17052. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17053. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17054. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17055. ];
  17056. /** Used to make template sourceURLs easier to identify. */
  17057. var templateCounter = -1;
  17058. /** Used to identify `toStringTag` values of typed arrays. */
  17059. var typedArrayTags = {};
  17060. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17061. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17062. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17063. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17064. typedArrayTags[uint32Tag] = true;
  17065. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17066. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17067. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17068. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17069. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17070. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17071. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17072. typedArrayTags[weakMapTag] = false;
  17073. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17074. var cloneableTags = {};
  17075. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17076. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17077. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17078. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17079. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17080. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17081. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17082. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17083. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17084. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17085. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17086. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17087. cloneableTags[weakMapTag] = false;
  17088. /** Used to map Latin Unicode letters to basic Latin letters. */
  17089. var deburredLetters = {
  17090. // Latin-1 Supplement block.
  17091. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17092. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17093. '\xc7': 'C', '\xe7': 'c',
  17094. '\xd0': 'D', '\xf0': 'd',
  17095. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17096. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17097. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17098. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17099. '\xd1': 'N', '\xf1': 'n',
  17100. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17101. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17102. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17103. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17104. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17105. '\xc6': 'Ae', '\xe6': 'ae',
  17106. '\xde': 'Th', '\xfe': 'th',
  17107. '\xdf': 'ss',
  17108. // Latin Extended-A block.
  17109. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17110. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17111. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17112. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17113. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17114. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17115. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17116. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17117. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17118. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17119. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17120. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17121. '\u0134': 'J', '\u0135': 'j',
  17122. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17123. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17124. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17125. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17126. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17127. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17128. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17129. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17130. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17131. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17132. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17133. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17134. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17135. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17136. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17137. '\u0174': 'W', '\u0175': 'w',
  17138. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17139. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17140. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17141. '\u0132': 'IJ', '\u0133': 'ij',
  17142. '\u0152': 'Oe', '\u0153': 'oe',
  17143. '\u0149': "'n", '\u017f': 's'
  17144. };
  17145. /** Used to map characters to HTML entities. */
  17146. var htmlEscapes = {
  17147. '&': '&amp;',
  17148. '<': '&lt;',
  17149. '>': '&gt;',
  17150. '"': '&quot;',
  17151. "'": '&#39;'
  17152. };
  17153. /** Used to map HTML entities to characters. */
  17154. var htmlUnescapes = {
  17155. '&amp;': '&',
  17156. '&lt;': '<',
  17157. '&gt;': '>',
  17158. '&quot;': '"',
  17159. '&#39;': "'"
  17160. };
  17161. /** Used to escape characters for inclusion in compiled string literals. */
  17162. var stringEscapes = {
  17163. '\\': '\\',
  17164. "'": "'",
  17165. '\n': 'n',
  17166. '\r': 'r',
  17167. '\u2028': 'u2028',
  17168. '\u2029': 'u2029'
  17169. };
  17170. /** Built-in method references without a dependency on `root`. */
  17171. var freeParseFloat = parseFloat,
  17172. freeParseInt = parseInt;
  17173. /** Detect free variable `global` from Node.js. */
  17174. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17175. /** Detect free variable `self`. */
  17176. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17177. /** Used as a reference to the global object. */
  17178. var root = freeGlobal || freeSelf || Function('return this')();
  17179. /** Detect free variable `exports`. */
  17180. var freeExports = true && exports && !exports.nodeType && exports;
  17181. /** Detect free variable `module`. */
  17182. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17183. /** Detect the popular CommonJS extension `module.exports`. */
  17184. var moduleExports = freeModule && freeModule.exports === freeExports;
  17185. /** Detect free variable `process` from Node.js. */
  17186. var freeProcess = moduleExports && freeGlobal.process;
  17187. /** Used to access faster Node.js helpers. */
  17188. var nodeUtil = (function() {
  17189. try {
  17190. // Use `util.types` for Node.js 10+.
  17191. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17192. if (types) {
  17193. return types;
  17194. }
  17195. // Legacy `process.binding('util')` for Node.js < 10.
  17196. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17197. } catch (e) {}
  17198. }());
  17199. /* Node.js helper references. */
  17200. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17201. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17202. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17203. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17204. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17205. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17206. /*--------------------------------------------------------------------------*/
  17207. /**
  17208. * A faster alternative to `Function#apply`, this function invokes `func`
  17209. * with the `this` binding of `thisArg` and the arguments of `args`.
  17210. *
  17211. * @private
  17212. * @param {Function} func The function to invoke.
  17213. * @param {*} thisArg The `this` binding of `func`.
  17214. * @param {Array} args The arguments to invoke `func` with.
  17215. * @returns {*} Returns the result of `func`.
  17216. */
  17217. function apply(func, thisArg, args) {
  17218. switch (args.length) {
  17219. case 0: return func.call(thisArg);
  17220. case 1: return func.call(thisArg, args[0]);
  17221. case 2: return func.call(thisArg, args[0], args[1]);
  17222. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17223. }
  17224. return func.apply(thisArg, args);
  17225. }
  17226. /**
  17227. * A specialized version of `baseAggregator` for arrays.
  17228. *
  17229. * @private
  17230. * @param {Array} [array] The array to iterate over.
  17231. * @param {Function} setter The function to set `accumulator` values.
  17232. * @param {Function} iteratee The iteratee to transform keys.
  17233. * @param {Object} accumulator The initial aggregated object.
  17234. * @returns {Function} Returns `accumulator`.
  17235. */
  17236. function arrayAggregator(array, setter, iteratee, accumulator) {
  17237. var index = -1,
  17238. length = array == null ? 0 : array.length;
  17239. while (++index < length) {
  17240. var value = array[index];
  17241. setter(accumulator, value, iteratee(value), array);
  17242. }
  17243. return accumulator;
  17244. }
  17245. /**
  17246. * A specialized version of `_.forEach` for arrays without support for
  17247. * iteratee shorthands.
  17248. *
  17249. * @private
  17250. * @param {Array} [array] The array to iterate over.
  17251. * @param {Function} iteratee The function invoked per iteration.
  17252. * @returns {Array} Returns `array`.
  17253. */
  17254. function arrayEach(array, iteratee) {
  17255. var index = -1,
  17256. length = array == null ? 0 : array.length;
  17257. while (++index < length) {
  17258. if (iteratee(array[index], index, array) === false) {
  17259. break;
  17260. }
  17261. }
  17262. return array;
  17263. }
  17264. /**
  17265. * A specialized version of `_.forEachRight` for arrays without support for
  17266. * iteratee shorthands.
  17267. *
  17268. * @private
  17269. * @param {Array} [array] The array to iterate over.
  17270. * @param {Function} iteratee The function invoked per iteration.
  17271. * @returns {Array} Returns `array`.
  17272. */
  17273. function arrayEachRight(array, iteratee) {
  17274. var length = array == null ? 0 : array.length;
  17275. while (length--) {
  17276. if (iteratee(array[length], length, array) === false) {
  17277. break;
  17278. }
  17279. }
  17280. return array;
  17281. }
  17282. /**
  17283. * A specialized version of `_.every` for arrays without support for
  17284. * iteratee shorthands.
  17285. *
  17286. * @private
  17287. * @param {Array} [array] The array to iterate over.
  17288. * @param {Function} predicate The function invoked per iteration.
  17289. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17290. * else `false`.
  17291. */
  17292. function arrayEvery(array, predicate) {
  17293. var index = -1,
  17294. length = array == null ? 0 : array.length;
  17295. while (++index < length) {
  17296. if (!predicate(array[index], index, array)) {
  17297. return false;
  17298. }
  17299. }
  17300. return true;
  17301. }
  17302. /**
  17303. * A specialized version of `_.filter` for arrays without support for
  17304. * iteratee shorthands.
  17305. *
  17306. * @private
  17307. * @param {Array} [array] The array to iterate over.
  17308. * @param {Function} predicate The function invoked per iteration.
  17309. * @returns {Array} Returns the new filtered array.
  17310. */
  17311. function arrayFilter(array, predicate) {
  17312. var index = -1,
  17313. length = array == null ? 0 : array.length,
  17314. resIndex = 0,
  17315. result = [];
  17316. while (++index < length) {
  17317. var value = array[index];
  17318. if (predicate(value, index, array)) {
  17319. result[resIndex++] = value;
  17320. }
  17321. }
  17322. return result;
  17323. }
  17324. /**
  17325. * A specialized version of `_.includes` for arrays without support for
  17326. * specifying an index to search from.
  17327. *
  17328. * @private
  17329. * @param {Array} [array] The array to inspect.
  17330. * @param {*} target The value to search for.
  17331. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17332. */
  17333. function arrayIncludes(array, value) {
  17334. var length = array == null ? 0 : array.length;
  17335. return !!length && baseIndexOf(array, value, 0) > -1;
  17336. }
  17337. /**
  17338. * This function is like `arrayIncludes` except that it accepts a comparator.
  17339. *
  17340. * @private
  17341. * @param {Array} [array] The array to inspect.
  17342. * @param {*} target The value to search for.
  17343. * @param {Function} comparator The comparator invoked per element.
  17344. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17345. */
  17346. function arrayIncludesWith(array, value, comparator) {
  17347. var index = -1,
  17348. length = array == null ? 0 : array.length;
  17349. while (++index < length) {
  17350. if (comparator(value, array[index])) {
  17351. return true;
  17352. }
  17353. }
  17354. return false;
  17355. }
  17356. /**
  17357. * A specialized version of `_.map` for arrays without support for iteratee
  17358. * shorthands.
  17359. *
  17360. * @private
  17361. * @param {Array} [array] The array to iterate over.
  17362. * @param {Function} iteratee The function invoked per iteration.
  17363. * @returns {Array} Returns the new mapped array.
  17364. */
  17365. function arrayMap(array, iteratee) {
  17366. var index = -1,
  17367. length = array == null ? 0 : array.length,
  17368. result = Array(length);
  17369. while (++index < length) {
  17370. result[index] = iteratee(array[index], index, array);
  17371. }
  17372. return result;
  17373. }
  17374. /**
  17375. * Appends the elements of `values` to `array`.
  17376. *
  17377. * @private
  17378. * @param {Array} array The array to modify.
  17379. * @param {Array} values The values to append.
  17380. * @returns {Array} Returns `array`.
  17381. */
  17382. function arrayPush(array, values) {
  17383. var index = -1,
  17384. length = values.length,
  17385. offset = array.length;
  17386. while (++index < length) {
  17387. array[offset + index] = values[index];
  17388. }
  17389. return array;
  17390. }
  17391. /**
  17392. * A specialized version of `_.reduce` for arrays without support for
  17393. * iteratee shorthands.
  17394. *
  17395. * @private
  17396. * @param {Array} [array] The array to iterate over.
  17397. * @param {Function} iteratee The function invoked per iteration.
  17398. * @param {*} [accumulator] The initial value.
  17399. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17400. * the initial value.
  17401. * @returns {*} Returns the accumulated value.
  17402. */
  17403. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17404. var index = -1,
  17405. length = array == null ? 0 : array.length;
  17406. if (initAccum && length) {
  17407. accumulator = array[++index];
  17408. }
  17409. while (++index < length) {
  17410. accumulator = iteratee(accumulator, array[index], index, array);
  17411. }
  17412. return accumulator;
  17413. }
  17414. /**
  17415. * A specialized version of `_.reduceRight` for arrays without support for
  17416. * iteratee shorthands.
  17417. *
  17418. * @private
  17419. * @param {Array} [array] The array to iterate over.
  17420. * @param {Function} iteratee The function invoked per iteration.
  17421. * @param {*} [accumulator] The initial value.
  17422. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17423. * the initial value.
  17424. * @returns {*} Returns the accumulated value.
  17425. */
  17426. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17427. var length = array == null ? 0 : array.length;
  17428. if (initAccum && length) {
  17429. accumulator = array[--length];
  17430. }
  17431. while (length--) {
  17432. accumulator = iteratee(accumulator, array[length], length, array);
  17433. }
  17434. return accumulator;
  17435. }
  17436. /**
  17437. * A specialized version of `_.some` for arrays without support for iteratee
  17438. * shorthands.
  17439. *
  17440. * @private
  17441. * @param {Array} [array] The array to iterate over.
  17442. * @param {Function} predicate The function invoked per iteration.
  17443. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17444. * else `false`.
  17445. */
  17446. function arraySome(array, predicate) {
  17447. var index = -1,
  17448. length = array == null ? 0 : array.length;
  17449. while (++index < length) {
  17450. if (predicate(array[index], index, array)) {
  17451. return true;
  17452. }
  17453. }
  17454. return false;
  17455. }
  17456. /**
  17457. * Gets the size of an ASCII `string`.
  17458. *
  17459. * @private
  17460. * @param {string} string The string inspect.
  17461. * @returns {number} Returns the string size.
  17462. */
  17463. var asciiSize = baseProperty('length');
  17464. /**
  17465. * Converts an ASCII `string` to an array.
  17466. *
  17467. * @private
  17468. * @param {string} string The string to convert.
  17469. * @returns {Array} Returns the converted array.
  17470. */
  17471. function asciiToArray(string) {
  17472. return string.split('');
  17473. }
  17474. /**
  17475. * Splits an ASCII `string` into an array of its words.
  17476. *
  17477. * @private
  17478. * @param {string} The string to inspect.
  17479. * @returns {Array} Returns the words of `string`.
  17480. */
  17481. function asciiWords(string) {
  17482. return string.match(reAsciiWord) || [];
  17483. }
  17484. /**
  17485. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17486. * without support for iteratee shorthands, which iterates over `collection`
  17487. * using `eachFunc`.
  17488. *
  17489. * @private
  17490. * @param {Array|Object} collection The collection to inspect.
  17491. * @param {Function} predicate The function invoked per iteration.
  17492. * @param {Function} eachFunc The function to iterate over `collection`.
  17493. * @returns {*} Returns the found element or its key, else `undefined`.
  17494. */
  17495. function baseFindKey(collection, predicate, eachFunc) {
  17496. var result;
  17497. eachFunc(collection, function(value, key, collection) {
  17498. if (predicate(value, key, collection)) {
  17499. result = key;
  17500. return false;
  17501. }
  17502. });
  17503. return result;
  17504. }
  17505. /**
  17506. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17507. * support for iteratee shorthands.
  17508. *
  17509. * @private
  17510. * @param {Array} array The array to inspect.
  17511. * @param {Function} predicate The function invoked per iteration.
  17512. * @param {number} fromIndex The index to search from.
  17513. * @param {boolean} [fromRight] Specify iterating from right to left.
  17514. * @returns {number} Returns the index of the matched value, else `-1`.
  17515. */
  17516. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17517. var length = array.length,
  17518. index = fromIndex + (fromRight ? 1 : -1);
  17519. while ((fromRight ? index-- : ++index < length)) {
  17520. if (predicate(array[index], index, array)) {
  17521. return index;
  17522. }
  17523. }
  17524. return -1;
  17525. }
  17526. /**
  17527. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17528. *
  17529. * @private
  17530. * @param {Array} array The array to inspect.
  17531. * @param {*} value The value to search for.
  17532. * @param {number} fromIndex The index to search from.
  17533. * @returns {number} Returns the index of the matched value, else `-1`.
  17534. */
  17535. function baseIndexOf(array, value, fromIndex) {
  17536. return value === value
  17537. ? strictIndexOf(array, value, fromIndex)
  17538. : baseFindIndex(array, baseIsNaN, fromIndex);
  17539. }
  17540. /**
  17541. * This function is like `baseIndexOf` except that it accepts a comparator.
  17542. *
  17543. * @private
  17544. * @param {Array} array The array to inspect.
  17545. * @param {*} value The value to search for.
  17546. * @param {number} fromIndex The index to search from.
  17547. * @param {Function} comparator The comparator invoked per element.
  17548. * @returns {number} Returns the index of the matched value, else `-1`.
  17549. */
  17550. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17551. var index = fromIndex - 1,
  17552. length = array.length;
  17553. while (++index < length) {
  17554. if (comparator(array[index], value)) {
  17555. return index;
  17556. }
  17557. }
  17558. return -1;
  17559. }
  17560. /**
  17561. * The base implementation of `_.isNaN` without support for number objects.
  17562. *
  17563. * @private
  17564. * @param {*} value The value to check.
  17565. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17566. */
  17567. function baseIsNaN(value) {
  17568. return value !== value;
  17569. }
  17570. /**
  17571. * The base implementation of `_.mean` and `_.meanBy` without support for
  17572. * iteratee shorthands.
  17573. *
  17574. * @private
  17575. * @param {Array} array The array to iterate over.
  17576. * @param {Function} iteratee The function invoked per iteration.
  17577. * @returns {number} Returns the mean.
  17578. */
  17579. function baseMean(array, iteratee) {
  17580. var length = array == null ? 0 : array.length;
  17581. return length ? (baseSum(array, iteratee) / length) : NAN;
  17582. }
  17583. /**
  17584. * The base implementation of `_.property` without support for deep paths.
  17585. *
  17586. * @private
  17587. * @param {string} key The key of the property to get.
  17588. * @returns {Function} Returns the new accessor function.
  17589. */
  17590. function baseProperty(key) {
  17591. return function(object) {
  17592. return object == null ? undefined : object[key];
  17593. };
  17594. }
  17595. /**
  17596. * The base implementation of `_.propertyOf` without support for deep paths.
  17597. *
  17598. * @private
  17599. * @param {Object} object The object to query.
  17600. * @returns {Function} Returns the new accessor function.
  17601. */
  17602. function basePropertyOf(object) {
  17603. return function(key) {
  17604. return object == null ? undefined : object[key];
  17605. };
  17606. }
  17607. /**
  17608. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17609. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17610. *
  17611. * @private
  17612. * @param {Array|Object} collection The collection to iterate over.
  17613. * @param {Function} iteratee The function invoked per iteration.
  17614. * @param {*} accumulator The initial value.
  17615. * @param {boolean} initAccum Specify using the first or last element of
  17616. * `collection` as the initial value.
  17617. * @param {Function} eachFunc The function to iterate over `collection`.
  17618. * @returns {*} Returns the accumulated value.
  17619. */
  17620. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17621. eachFunc(collection, function(value, index, collection) {
  17622. accumulator = initAccum
  17623. ? (initAccum = false, value)
  17624. : iteratee(accumulator, value, index, collection);
  17625. });
  17626. return accumulator;
  17627. }
  17628. /**
  17629. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17630. * sort order of `array` and replaces criteria objects with their corresponding
  17631. * values.
  17632. *
  17633. * @private
  17634. * @param {Array} array The array to sort.
  17635. * @param {Function} comparer The function to define sort order.
  17636. * @returns {Array} Returns `array`.
  17637. */
  17638. function baseSortBy(array, comparer) {
  17639. var length = array.length;
  17640. array.sort(comparer);
  17641. while (length--) {
  17642. array[length] = array[length].value;
  17643. }
  17644. return array;
  17645. }
  17646. /**
  17647. * The base implementation of `_.sum` and `_.sumBy` without support for
  17648. * iteratee shorthands.
  17649. *
  17650. * @private
  17651. * @param {Array} array The array to iterate over.
  17652. * @param {Function} iteratee The function invoked per iteration.
  17653. * @returns {number} Returns the sum.
  17654. */
  17655. function baseSum(array, iteratee) {
  17656. var result,
  17657. index = -1,
  17658. length = array.length;
  17659. while (++index < length) {
  17660. var current = iteratee(array[index]);
  17661. if (current !== undefined) {
  17662. result = result === undefined ? current : (result + current);
  17663. }
  17664. }
  17665. return result;
  17666. }
  17667. /**
  17668. * The base implementation of `_.times` without support for iteratee shorthands
  17669. * or max array length checks.
  17670. *
  17671. * @private
  17672. * @param {number} n The number of times to invoke `iteratee`.
  17673. * @param {Function} iteratee The function invoked per iteration.
  17674. * @returns {Array} Returns the array of results.
  17675. */
  17676. function baseTimes(n, iteratee) {
  17677. var index = -1,
  17678. result = Array(n);
  17679. while (++index < n) {
  17680. result[index] = iteratee(index);
  17681. }
  17682. return result;
  17683. }
  17684. /**
  17685. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17686. * of key-value pairs for `object` corresponding to the property names of `props`.
  17687. *
  17688. * @private
  17689. * @param {Object} object The object to query.
  17690. * @param {Array} props The property names to get values for.
  17691. * @returns {Object} Returns the key-value pairs.
  17692. */
  17693. function baseToPairs(object, props) {
  17694. return arrayMap(props, function(key) {
  17695. return [key, object[key]];
  17696. });
  17697. }
  17698. /**
  17699. * The base implementation of `_.unary` without support for storing metadata.
  17700. *
  17701. * @private
  17702. * @param {Function} func The function to cap arguments for.
  17703. * @returns {Function} Returns the new capped function.
  17704. */
  17705. function baseUnary(func) {
  17706. return function(value) {
  17707. return func(value);
  17708. };
  17709. }
  17710. /**
  17711. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17712. * array of `object` property values corresponding to the property names
  17713. * of `props`.
  17714. *
  17715. * @private
  17716. * @param {Object} object The object to query.
  17717. * @param {Array} props The property names to get values for.
  17718. * @returns {Object} Returns the array of property values.
  17719. */
  17720. function baseValues(object, props) {
  17721. return arrayMap(props, function(key) {
  17722. return object[key];
  17723. });
  17724. }
  17725. /**
  17726. * Checks if a `cache` value for `key` exists.
  17727. *
  17728. * @private
  17729. * @param {Object} cache The cache to query.
  17730. * @param {string} key The key of the entry to check.
  17731. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17732. */
  17733. function cacheHas(cache, key) {
  17734. return cache.has(key);
  17735. }
  17736. /**
  17737. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17738. * that is not found in the character symbols.
  17739. *
  17740. * @private
  17741. * @param {Array} strSymbols The string symbols to inspect.
  17742. * @param {Array} chrSymbols The character symbols to find.
  17743. * @returns {number} Returns the index of the first unmatched string symbol.
  17744. */
  17745. function charsStartIndex(strSymbols, chrSymbols) {
  17746. var index = -1,
  17747. length = strSymbols.length;
  17748. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17749. return index;
  17750. }
  17751. /**
  17752. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17753. * that is not found in the character symbols.
  17754. *
  17755. * @private
  17756. * @param {Array} strSymbols The string symbols to inspect.
  17757. * @param {Array} chrSymbols The character symbols to find.
  17758. * @returns {number} Returns the index of the last unmatched string symbol.
  17759. */
  17760. function charsEndIndex(strSymbols, chrSymbols) {
  17761. var index = strSymbols.length;
  17762. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17763. return index;
  17764. }
  17765. /**
  17766. * Gets the number of `placeholder` occurrences in `array`.
  17767. *
  17768. * @private
  17769. * @param {Array} array The array to inspect.
  17770. * @param {*} placeholder The placeholder to search for.
  17771. * @returns {number} Returns the placeholder count.
  17772. */
  17773. function countHolders(array, placeholder) {
  17774. var length = array.length,
  17775. result = 0;
  17776. while (length--) {
  17777. if (array[length] === placeholder) {
  17778. ++result;
  17779. }
  17780. }
  17781. return result;
  17782. }
  17783. /**
  17784. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17785. * letters to basic Latin letters.
  17786. *
  17787. * @private
  17788. * @param {string} letter The matched letter to deburr.
  17789. * @returns {string} Returns the deburred letter.
  17790. */
  17791. var deburrLetter = basePropertyOf(deburredLetters);
  17792. /**
  17793. * Used by `_.escape` to convert characters to HTML entities.
  17794. *
  17795. * @private
  17796. * @param {string} chr The matched character to escape.
  17797. * @returns {string} Returns the escaped character.
  17798. */
  17799. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17800. /**
  17801. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17802. *
  17803. * @private
  17804. * @param {string} chr The matched character to escape.
  17805. * @returns {string} Returns the escaped character.
  17806. */
  17807. function escapeStringChar(chr) {
  17808. return '\\' + stringEscapes[chr];
  17809. }
  17810. /**
  17811. * Gets the value at `key` of `object`.
  17812. *
  17813. * @private
  17814. * @param {Object} [object] The object to query.
  17815. * @param {string} key The key of the property to get.
  17816. * @returns {*} Returns the property value.
  17817. */
  17818. function getValue(object, key) {
  17819. return object == null ? undefined : object[key];
  17820. }
  17821. /**
  17822. * Checks if `string` contains Unicode symbols.
  17823. *
  17824. * @private
  17825. * @param {string} string The string to inspect.
  17826. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17827. */
  17828. function hasUnicode(string) {
  17829. return reHasUnicode.test(string);
  17830. }
  17831. /**
  17832. * Checks if `string` contains a word composed of Unicode symbols.
  17833. *
  17834. * @private
  17835. * @param {string} string The string to inspect.
  17836. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17837. */
  17838. function hasUnicodeWord(string) {
  17839. return reHasUnicodeWord.test(string);
  17840. }
  17841. /**
  17842. * Converts `iterator` to an array.
  17843. *
  17844. * @private
  17845. * @param {Object} iterator The iterator to convert.
  17846. * @returns {Array} Returns the converted array.
  17847. */
  17848. function iteratorToArray(iterator) {
  17849. var data,
  17850. result = [];
  17851. while (!(data = iterator.next()).done) {
  17852. result.push(data.value);
  17853. }
  17854. return result;
  17855. }
  17856. /**
  17857. * Converts `map` to its key-value pairs.
  17858. *
  17859. * @private
  17860. * @param {Object} map The map to convert.
  17861. * @returns {Array} Returns the key-value pairs.
  17862. */
  17863. function mapToArray(map) {
  17864. var index = -1,
  17865. result = Array(map.size);
  17866. map.forEach(function(value, key) {
  17867. result[++index] = [key, value];
  17868. });
  17869. return result;
  17870. }
  17871. /**
  17872. * Creates a unary function that invokes `func` with its argument transformed.
  17873. *
  17874. * @private
  17875. * @param {Function} func The function to wrap.
  17876. * @param {Function} transform The argument transform.
  17877. * @returns {Function} Returns the new function.
  17878. */
  17879. function overArg(func, transform) {
  17880. return function(arg) {
  17881. return func(transform(arg));
  17882. };
  17883. }
  17884. /**
  17885. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17886. * and returns an array of their indexes.
  17887. *
  17888. * @private
  17889. * @param {Array} array The array to modify.
  17890. * @param {*} placeholder The placeholder to replace.
  17891. * @returns {Array} Returns the new array of placeholder indexes.
  17892. */
  17893. function replaceHolders(array, placeholder) {
  17894. var index = -1,
  17895. length = array.length,
  17896. resIndex = 0,
  17897. result = [];
  17898. while (++index < length) {
  17899. var value = array[index];
  17900. if (value === placeholder || value === PLACEHOLDER) {
  17901. array[index] = PLACEHOLDER;
  17902. result[resIndex++] = index;
  17903. }
  17904. }
  17905. return result;
  17906. }
  17907. /**
  17908. * Converts `set` to an array of its values.
  17909. *
  17910. * @private
  17911. * @param {Object} set The set to convert.
  17912. * @returns {Array} Returns the values.
  17913. */
  17914. function setToArray(set) {
  17915. var index = -1,
  17916. result = Array(set.size);
  17917. set.forEach(function(value) {
  17918. result[++index] = value;
  17919. });
  17920. return result;
  17921. }
  17922. /**
  17923. * Converts `set` to its value-value pairs.
  17924. *
  17925. * @private
  17926. * @param {Object} set The set to convert.
  17927. * @returns {Array} Returns the value-value pairs.
  17928. */
  17929. function setToPairs(set) {
  17930. var index = -1,
  17931. result = Array(set.size);
  17932. set.forEach(function(value) {
  17933. result[++index] = [value, value];
  17934. });
  17935. return result;
  17936. }
  17937. /**
  17938. * A specialized version of `_.indexOf` which performs strict equality
  17939. * comparisons of values, i.e. `===`.
  17940. *
  17941. * @private
  17942. * @param {Array} array The array to inspect.
  17943. * @param {*} value The value to search for.
  17944. * @param {number} fromIndex The index to search from.
  17945. * @returns {number} Returns the index of the matched value, else `-1`.
  17946. */
  17947. function strictIndexOf(array, value, fromIndex) {
  17948. var index = fromIndex - 1,
  17949. length = array.length;
  17950. while (++index < length) {
  17951. if (array[index] === value) {
  17952. return index;
  17953. }
  17954. }
  17955. return -1;
  17956. }
  17957. /**
  17958. * A specialized version of `_.lastIndexOf` which performs strict equality
  17959. * comparisons of values, i.e. `===`.
  17960. *
  17961. * @private
  17962. * @param {Array} array The array to inspect.
  17963. * @param {*} value The value to search for.
  17964. * @param {number} fromIndex The index to search from.
  17965. * @returns {number} Returns the index of the matched value, else `-1`.
  17966. */
  17967. function strictLastIndexOf(array, value, fromIndex) {
  17968. var index = fromIndex + 1;
  17969. while (index--) {
  17970. if (array[index] === value) {
  17971. return index;
  17972. }
  17973. }
  17974. return index;
  17975. }
  17976. /**
  17977. * Gets the number of symbols in `string`.
  17978. *
  17979. * @private
  17980. * @param {string} string The string to inspect.
  17981. * @returns {number} Returns the string size.
  17982. */
  17983. function stringSize(string) {
  17984. return hasUnicode(string)
  17985. ? unicodeSize(string)
  17986. : asciiSize(string);
  17987. }
  17988. /**
  17989. * Converts `string` to an array.
  17990. *
  17991. * @private
  17992. * @param {string} string The string to convert.
  17993. * @returns {Array} Returns the converted array.
  17994. */
  17995. function stringToArray(string) {
  17996. return hasUnicode(string)
  17997. ? unicodeToArray(string)
  17998. : asciiToArray(string);
  17999. }
  18000. /**
  18001. * Used by `_.unescape` to convert HTML entities to characters.
  18002. *
  18003. * @private
  18004. * @param {string} chr The matched character to unescape.
  18005. * @returns {string} Returns the unescaped character.
  18006. */
  18007. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18008. /**
  18009. * Gets the size of a Unicode `string`.
  18010. *
  18011. * @private
  18012. * @param {string} string The string inspect.
  18013. * @returns {number} Returns the string size.
  18014. */
  18015. function unicodeSize(string) {
  18016. var result = reUnicode.lastIndex = 0;
  18017. while (reUnicode.test(string)) {
  18018. ++result;
  18019. }
  18020. return result;
  18021. }
  18022. /**
  18023. * Converts a Unicode `string` to an array.
  18024. *
  18025. * @private
  18026. * @param {string} string The string to convert.
  18027. * @returns {Array} Returns the converted array.
  18028. */
  18029. function unicodeToArray(string) {
  18030. return string.match(reUnicode) || [];
  18031. }
  18032. /**
  18033. * Splits a Unicode `string` into an array of its words.
  18034. *
  18035. * @private
  18036. * @param {string} The string to inspect.
  18037. * @returns {Array} Returns the words of `string`.
  18038. */
  18039. function unicodeWords(string) {
  18040. return string.match(reUnicodeWord) || [];
  18041. }
  18042. /*--------------------------------------------------------------------------*/
  18043. /**
  18044. * Create a new pristine `lodash` function using the `context` object.
  18045. *
  18046. * @static
  18047. * @memberOf _
  18048. * @since 1.1.0
  18049. * @category Util
  18050. * @param {Object} [context=root] The context object.
  18051. * @returns {Function} Returns a new `lodash` function.
  18052. * @example
  18053. *
  18054. * _.mixin({ 'foo': _.constant('foo') });
  18055. *
  18056. * var lodash = _.runInContext();
  18057. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18058. *
  18059. * _.isFunction(_.foo);
  18060. * // => true
  18061. * _.isFunction(_.bar);
  18062. * // => false
  18063. *
  18064. * lodash.isFunction(lodash.foo);
  18065. * // => false
  18066. * lodash.isFunction(lodash.bar);
  18067. * // => true
  18068. *
  18069. * // Create a suped-up `defer` in Node.js.
  18070. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18071. */
  18072. var runInContext = (function runInContext(context) {
  18073. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18074. /** Built-in constructor references. */
  18075. var Array = context.Array,
  18076. Date = context.Date,
  18077. Error = context.Error,
  18078. Function = context.Function,
  18079. Math = context.Math,
  18080. Object = context.Object,
  18081. RegExp = context.RegExp,
  18082. String = context.String,
  18083. TypeError = context.TypeError;
  18084. /** Used for built-in method references. */
  18085. var arrayProto = Array.prototype,
  18086. funcProto = Function.prototype,
  18087. objectProto = Object.prototype;
  18088. /** Used to detect overreaching core-js shims. */
  18089. var coreJsData = context['__core-js_shared__'];
  18090. /** Used to resolve the decompiled source of functions. */
  18091. var funcToString = funcProto.toString;
  18092. /** Used to check objects for own properties. */
  18093. var hasOwnProperty = objectProto.hasOwnProperty;
  18094. /** Used to generate unique IDs. */
  18095. var idCounter = 0;
  18096. /** Used to detect methods masquerading as native. */
  18097. var maskSrcKey = (function() {
  18098. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18099. return uid ? ('Symbol(src)_1.' + uid) : '';
  18100. }());
  18101. /**
  18102. * Used to resolve the
  18103. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18104. * of values.
  18105. */
  18106. var nativeObjectToString = objectProto.toString;
  18107. /** Used to infer the `Object` constructor. */
  18108. var objectCtorString = funcToString.call(Object);
  18109. /** Used to restore the original `_` reference in `_.noConflict`. */
  18110. var oldDash = root._;
  18111. /** Used to detect if a method is native. */
  18112. var reIsNative = RegExp('^' +
  18113. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18114. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18115. );
  18116. /** Built-in value references. */
  18117. var Buffer = moduleExports ? context.Buffer : undefined,
  18118. Symbol = context.Symbol,
  18119. Uint8Array = context.Uint8Array,
  18120. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18121. getPrototype = overArg(Object.getPrototypeOf, Object),
  18122. objectCreate = Object.create,
  18123. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18124. splice = arrayProto.splice,
  18125. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18126. symIterator = Symbol ? Symbol.iterator : undefined,
  18127. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18128. var defineProperty = (function() {
  18129. try {
  18130. var func = getNative(Object, 'defineProperty');
  18131. func({}, '', {});
  18132. return func;
  18133. } catch (e) {}
  18134. }());
  18135. /** Mocked built-ins. */
  18136. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18137. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18138. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18139. /* Built-in method references for those with the same name as other `lodash` methods. */
  18140. var nativeCeil = Math.ceil,
  18141. nativeFloor = Math.floor,
  18142. nativeGetSymbols = Object.getOwnPropertySymbols,
  18143. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18144. nativeIsFinite = context.isFinite,
  18145. nativeJoin = arrayProto.join,
  18146. nativeKeys = overArg(Object.keys, Object),
  18147. nativeMax = Math.max,
  18148. nativeMin = Math.min,
  18149. nativeNow = Date.now,
  18150. nativeParseInt = context.parseInt,
  18151. nativeRandom = Math.random,
  18152. nativeReverse = arrayProto.reverse;
  18153. /* Built-in method references that are verified to be native. */
  18154. var DataView = getNative(context, 'DataView'),
  18155. Map = getNative(context, 'Map'),
  18156. Promise = getNative(context, 'Promise'),
  18157. Set = getNative(context, 'Set'),
  18158. WeakMap = getNative(context, 'WeakMap'),
  18159. nativeCreate = getNative(Object, 'create');
  18160. /** Used to store function metadata. */
  18161. var metaMap = WeakMap && new WeakMap;
  18162. /** Used to lookup unminified function names. */
  18163. var realNames = {};
  18164. /** Used to detect maps, sets, and weakmaps. */
  18165. var dataViewCtorString = toSource(DataView),
  18166. mapCtorString = toSource(Map),
  18167. promiseCtorString = toSource(Promise),
  18168. setCtorString = toSource(Set),
  18169. weakMapCtorString = toSource(WeakMap);
  18170. /** Used to convert symbols to primitives and strings. */
  18171. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18172. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18173. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18174. /*------------------------------------------------------------------------*/
  18175. /**
  18176. * Creates a `lodash` object which wraps `value` to enable implicit method
  18177. * chain sequences. Methods that operate on and return arrays, collections,
  18178. * and functions can be chained together. Methods that retrieve a single value
  18179. * or may return a primitive value will automatically end the chain sequence
  18180. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18181. * with `_#value`.
  18182. *
  18183. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18184. * enabled using `_.chain`.
  18185. *
  18186. * The execution of chained methods is lazy, that is, it's deferred until
  18187. * `_#value` is implicitly or explicitly called.
  18188. *
  18189. * Lazy evaluation allows several methods to support shortcut fusion.
  18190. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18191. * the creation of intermediate arrays and can greatly reduce the number of
  18192. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18193. * fusion if the section is applied to an array and iteratees accept only
  18194. * one argument. The heuristic for whether a section qualifies for shortcut
  18195. * fusion is subject to change.
  18196. *
  18197. * Chaining is supported in custom builds as long as the `_#value` method is
  18198. * directly or indirectly included in the build.
  18199. *
  18200. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18201. *
  18202. * The wrapper `Array` methods are:
  18203. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18204. *
  18205. * The wrapper `String` methods are:
  18206. * `replace` and `split`
  18207. *
  18208. * The wrapper methods that support shortcut fusion are:
  18209. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18210. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18211. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18212. *
  18213. * The chainable wrapper methods are:
  18214. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18215. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18216. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18217. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18218. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18219. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18220. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18221. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18222. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18223. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18224. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18225. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18226. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18227. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18228. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18229. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18230. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18231. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18232. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18233. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18234. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18235. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18236. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18237. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18238. *
  18239. * The wrapper methods that are **not** chainable by default are:
  18240. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18241. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18242. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18243. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18244. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18245. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18246. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18247. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18248. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18249. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18250. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18251. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18252. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18253. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18254. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18255. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18256. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18257. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18258. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18259. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18260. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18261. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18262. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18263. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18264. * `upperFirst`, `value`, and `words`
  18265. *
  18266. * @name _
  18267. * @constructor
  18268. * @category Seq
  18269. * @param {*} value The value to wrap in a `lodash` instance.
  18270. * @returns {Object} Returns the new `lodash` wrapper instance.
  18271. * @example
  18272. *
  18273. * function square(n) {
  18274. * return n * n;
  18275. * }
  18276. *
  18277. * var wrapped = _([1, 2, 3]);
  18278. *
  18279. * // Returns an unwrapped value.
  18280. * wrapped.reduce(_.add);
  18281. * // => 6
  18282. *
  18283. * // Returns a wrapped value.
  18284. * var squares = wrapped.map(square);
  18285. *
  18286. * _.isArray(squares);
  18287. * // => false
  18288. *
  18289. * _.isArray(squares.value());
  18290. * // => true
  18291. */
  18292. function lodash(value) {
  18293. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18294. if (value instanceof LodashWrapper) {
  18295. return value;
  18296. }
  18297. if (hasOwnProperty.call(value, '__wrapped__')) {
  18298. return wrapperClone(value);
  18299. }
  18300. }
  18301. return new LodashWrapper(value);
  18302. }
  18303. /**
  18304. * The base implementation of `_.create` without support for assigning
  18305. * properties to the created object.
  18306. *
  18307. * @private
  18308. * @param {Object} proto The object to inherit from.
  18309. * @returns {Object} Returns the new object.
  18310. */
  18311. var baseCreate = (function() {
  18312. function object() {}
  18313. return function(proto) {
  18314. if (!isObject(proto)) {
  18315. return {};
  18316. }
  18317. if (objectCreate) {
  18318. return objectCreate(proto);
  18319. }
  18320. object.prototype = proto;
  18321. var result = new object;
  18322. object.prototype = undefined;
  18323. return result;
  18324. };
  18325. }());
  18326. /**
  18327. * The function whose prototype chain sequence wrappers inherit from.
  18328. *
  18329. * @private
  18330. */
  18331. function baseLodash() {
  18332. // No operation performed.
  18333. }
  18334. /**
  18335. * The base constructor for creating `lodash` wrapper objects.
  18336. *
  18337. * @private
  18338. * @param {*} value The value to wrap.
  18339. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18340. */
  18341. function LodashWrapper(value, chainAll) {
  18342. this.__wrapped__ = value;
  18343. this.__actions__ = [];
  18344. this.__chain__ = !!chainAll;
  18345. this.__index__ = 0;
  18346. this.__values__ = undefined;
  18347. }
  18348. /**
  18349. * By default, the template delimiters used by lodash are like those in
  18350. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18351. * following template settings to use alternative delimiters.
  18352. *
  18353. * @static
  18354. * @memberOf _
  18355. * @type {Object}
  18356. */
  18357. lodash.templateSettings = {
  18358. /**
  18359. * Used to detect `data` property values to be HTML-escaped.
  18360. *
  18361. * @memberOf _.templateSettings
  18362. * @type {RegExp}
  18363. */
  18364. 'escape': reEscape,
  18365. /**
  18366. * Used to detect code to be evaluated.
  18367. *
  18368. * @memberOf _.templateSettings
  18369. * @type {RegExp}
  18370. */
  18371. 'evaluate': reEvaluate,
  18372. /**
  18373. * Used to detect `data` property values to inject.
  18374. *
  18375. * @memberOf _.templateSettings
  18376. * @type {RegExp}
  18377. */
  18378. 'interpolate': reInterpolate,
  18379. /**
  18380. * Used to reference the data object in the template text.
  18381. *
  18382. * @memberOf _.templateSettings
  18383. * @type {string}
  18384. */
  18385. 'variable': '',
  18386. /**
  18387. * Used to import variables into the compiled template.
  18388. *
  18389. * @memberOf _.templateSettings
  18390. * @type {Object}
  18391. */
  18392. 'imports': {
  18393. /**
  18394. * A reference to the `lodash` function.
  18395. *
  18396. * @memberOf _.templateSettings.imports
  18397. * @type {Function}
  18398. */
  18399. '_': lodash
  18400. }
  18401. };
  18402. // Ensure wrappers are instances of `baseLodash`.
  18403. lodash.prototype = baseLodash.prototype;
  18404. lodash.prototype.constructor = lodash;
  18405. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18406. LodashWrapper.prototype.constructor = LodashWrapper;
  18407. /*------------------------------------------------------------------------*/
  18408. /**
  18409. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18410. *
  18411. * @private
  18412. * @constructor
  18413. * @param {*} value The value to wrap.
  18414. */
  18415. function LazyWrapper(value) {
  18416. this.__wrapped__ = value;
  18417. this.__actions__ = [];
  18418. this.__dir__ = 1;
  18419. this.__filtered__ = false;
  18420. this.__iteratees__ = [];
  18421. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18422. this.__views__ = [];
  18423. }
  18424. /**
  18425. * Creates a clone of the lazy wrapper object.
  18426. *
  18427. * @private
  18428. * @name clone
  18429. * @memberOf LazyWrapper
  18430. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18431. */
  18432. function lazyClone() {
  18433. var result = new LazyWrapper(this.__wrapped__);
  18434. result.__actions__ = copyArray(this.__actions__);
  18435. result.__dir__ = this.__dir__;
  18436. result.__filtered__ = this.__filtered__;
  18437. result.__iteratees__ = copyArray(this.__iteratees__);
  18438. result.__takeCount__ = this.__takeCount__;
  18439. result.__views__ = copyArray(this.__views__);
  18440. return result;
  18441. }
  18442. /**
  18443. * Reverses the direction of lazy iteration.
  18444. *
  18445. * @private
  18446. * @name reverse
  18447. * @memberOf LazyWrapper
  18448. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18449. */
  18450. function lazyReverse() {
  18451. if (this.__filtered__) {
  18452. var result = new LazyWrapper(this);
  18453. result.__dir__ = -1;
  18454. result.__filtered__ = true;
  18455. } else {
  18456. result = this.clone();
  18457. result.__dir__ *= -1;
  18458. }
  18459. return result;
  18460. }
  18461. /**
  18462. * Extracts the unwrapped value from its lazy wrapper.
  18463. *
  18464. * @private
  18465. * @name value
  18466. * @memberOf LazyWrapper
  18467. * @returns {*} Returns the unwrapped value.
  18468. */
  18469. function lazyValue() {
  18470. var array = this.__wrapped__.value(),
  18471. dir = this.__dir__,
  18472. isArr = isArray(array),
  18473. isRight = dir < 0,
  18474. arrLength = isArr ? array.length : 0,
  18475. view = getView(0, arrLength, this.__views__),
  18476. start = view.start,
  18477. end = view.end,
  18478. length = end - start,
  18479. index = isRight ? end : (start - 1),
  18480. iteratees = this.__iteratees__,
  18481. iterLength = iteratees.length,
  18482. resIndex = 0,
  18483. takeCount = nativeMin(length, this.__takeCount__);
  18484. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18485. return baseWrapperValue(array, this.__actions__);
  18486. }
  18487. var result = [];
  18488. outer:
  18489. while (length-- && resIndex < takeCount) {
  18490. index += dir;
  18491. var iterIndex = -1,
  18492. value = array[index];
  18493. while (++iterIndex < iterLength) {
  18494. var data = iteratees[iterIndex],
  18495. iteratee = data.iteratee,
  18496. type = data.type,
  18497. computed = iteratee(value);
  18498. if (type == LAZY_MAP_FLAG) {
  18499. value = computed;
  18500. } else if (!computed) {
  18501. if (type == LAZY_FILTER_FLAG) {
  18502. continue outer;
  18503. } else {
  18504. break outer;
  18505. }
  18506. }
  18507. }
  18508. result[resIndex++] = value;
  18509. }
  18510. return result;
  18511. }
  18512. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18513. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18514. LazyWrapper.prototype.constructor = LazyWrapper;
  18515. /*------------------------------------------------------------------------*/
  18516. /**
  18517. * Creates a hash object.
  18518. *
  18519. * @private
  18520. * @constructor
  18521. * @param {Array} [entries] The key-value pairs to cache.
  18522. */
  18523. function Hash(entries) {
  18524. var index = -1,
  18525. length = entries == null ? 0 : entries.length;
  18526. this.clear();
  18527. while (++index < length) {
  18528. var entry = entries[index];
  18529. this.set(entry[0], entry[1]);
  18530. }
  18531. }
  18532. /**
  18533. * Removes all key-value entries from the hash.
  18534. *
  18535. * @private
  18536. * @name clear
  18537. * @memberOf Hash
  18538. */
  18539. function hashClear() {
  18540. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18541. this.size = 0;
  18542. }
  18543. /**
  18544. * Removes `key` and its value from the hash.
  18545. *
  18546. * @private
  18547. * @name delete
  18548. * @memberOf Hash
  18549. * @param {Object} hash The hash to modify.
  18550. * @param {string} key The key of the value to remove.
  18551. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18552. */
  18553. function hashDelete(key) {
  18554. var result = this.has(key) && delete this.__data__[key];
  18555. this.size -= result ? 1 : 0;
  18556. return result;
  18557. }
  18558. /**
  18559. * Gets the hash value for `key`.
  18560. *
  18561. * @private
  18562. * @name get
  18563. * @memberOf Hash
  18564. * @param {string} key The key of the value to get.
  18565. * @returns {*} Returns the entry value.
  18566. */
  18567. function hashGet(key) {
  18568. var data = this.__data__;
  18569. if (nativeCreate) {
  18570. var result = data[key];
  18571. return result === HASH_UNDEFINED ? undefined : result;
  18572. }
  18573. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18574. }
  18575. /**
  18576. * Checks if a hash value for `key` exists.
  18577. *
  18578. * @private
  18579. * @name has
  18580. * @memberOf Hash
  18581. * @param {string} key The key of the entry to check.
  18582. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18583. */
  18584. function hashHas(key) {
  18585. var data = this.__data__;
  18586. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18587. }
  18588. /**
  18589. * Sets the hash `key` to `value`.
  18590. *
  18591. * @private
  18592. * @name set
  18593. * @memberOf Hash
  18594. * @param {string} key The key of the value to set.
  18595. * @param {*} value The value to set.
  18596. * @returns {Object} Returns the hash instance.
  18597. */
  18598. function hashSet(key, value) {
  18599. var data = this.__data__;
  18600. this.size += this.has(key) ? 0 : 1;
  18601. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18602. return this;
  18603. }
  18604. // Add methods to `Hash`.
  18605. Hash.prototype.clear = hashClear;
  18606. Hash.prototype['delete'] = hashDelete;
  18607. Hash.prototype.get = hashGet;
  18608. Hash.prototype.has = hashHas;
  18609. Hash.prototype.set = hashSet;
  18610. /*------------------------------------------------------------------------*/
  18611. /**
  18612. * Creates an list cache object.
  18613. *
  18614. * @private
  18615. * @constructor
  18616. * @param {Array} [entries] The key-value pairs to cache.
  18617. */
  18618. function ListCache(entries) {
  18619. var index = -1,
  18620. length = entries == null ? 0 : entries.length;
  18621. this.clear();
  18622. while (++index < length) {
  18623. var entry = entries[index];
  18624. this.set(entry[0], entry[1]);
  18625. }
  18626. }
  18627. /**
  18628. * Removes all key-value entries from the list cache.
  18629. *
  18630. * @private
  18631. * @name clear
  18632. * @memberOf ListCache
  18633. */
  18634. function listCacheClear() {
  18635. this.__data__ = [];
  18636. this.size = 0;
  18637. }
  18638. /**
  18639. * Removes `key` and its value from the list cache.
  18640. *
  18641. * @private
  18642. * @name delete
  18643. * @memberOf ListCache
  18644. * @param {string} key The key of the value to remove.
  18645. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18646. */
  18647. function listCacheDelete(key) {
  18648. var data = this.__data__,
  18649. index = assocIndexOf(data, key);
  18650. if (index < 0) {
  18651. return false;
  18652. }
  18653. var lastIndex = data.length - 1;
  18654. if (index == lastIndex) {
  18655. data.pop();
  18656. } else {
  18657. splice.call(data, index, 1);
  18658. }
  18659. --this.size;
  18660. return true;
  18661. }
  18662. /**
  18663. * Gets the list cache value for `key`.
  18664. *
  18665. * @private
  18666. * @name get
  18667. * @memberOf ListCache
  18668. * @param {string} key The key of the value to get.
  18669. * @returns {*} Returns the entry value.
  18670. */
  18671. function listCacheGet(key) {
  18672. var data = this.__data__,
  18673. index = assocIndexOf(data, key);
  18674. return index < 0 ? undefined : data[index][1];
  18675. }
  18676. /**
  18677. * Checks if a list cache value for `key` exists.
  18678. *
  18679. * @private
  18680. * @name has
  18681. * @memberOf ListCache
  18682. * @param {string} key The key of the entry to check.
  18683. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18684. */
  18685. function listCacheHas(key) {
  18686. return assocIndexOf(this.__data__, key) > -1;
  18687. }
  18688. /**
  18689. * Sets the list cache `key` to `value`.
  18690. *
  18691. * @private
  18692. * @name set
  18693. * @memberOf ListCache
  18694. * @param {string} key The key of the value to set.
  18695. * @param {*} value The value to set.
  18696. * @returns {Object} Returns the list cache instance.
  18697. */
  18698. function listCacheSet(key, value) {
  18699. var data = this.__data__,
  18700. index = assocIndexOf(data, key);
  18701. if (index < 0) {
  18702. ++this.size;
  18703. data.push([key, value]);
  18704. } else {
  18705. data[index][1] = value;
  18706. }
  18707. return this;
  18708. }
  18709. // Add methods to `ListCache`.
  18710. ListCache.prototype.clear = listCacheClear;
  18711. ListCache.prototype['delete'] = listCacheDelete;
  18712. ListCache.prototype.get = listCacheGet;
  18713. ListCache.prototype.has = listCacheHas;
  18714. ListCache.prototype.set = listCacheSet;
  18715. /*------------------------------------------------------------------------*/
  18716. /**
  18717. * Creates a map cache object to store key-value pairs.
  18718. *
  18719. * @private
  18720. * @constructor
  18721. * @param {Array} [entries] The key-value pairs to cache.
  18722. */
  18723. function MapCache(entries) {
  18724. var index = -1,
  18725. length = entries == null ? 0 : entries.length;
  18726. this.clear();
  18727. while (++index < length) {
  18728. var entry = entries[index];
  18729. this.set(entry[0], entry[1]);
  18730. }
  18731. }
  18732. /**
  18733. * Removes all key-value entries from the map.
  18734. *
  18735. * @private
  18736. * @name clear
  18737. * @memberOf MapCache
  18738. */
  18739. function mapCacheClear() {
  18740. this.size = 0;
  18741. this.__data__ = {
  18742. 'hash': new Hash,
  18743. 'map': new (Map || ListCache),
  18744. 'string': new Hash
  18745. };
  18746. }
  18747. /**
  18748. * Removes `key` and its value from the map.
  18749. *
  18750. * @private
  18751. * @name delete
  18752. * @memberOf MapCache
  18753. * @param {string} key The key of the value to remove.
  18754. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18755. */
  18756. function mapCacheDelete(key) {
  18757. var result = getMapData(this, key)['delete'](key);
  18758. this.size -= result ? 1 : 0;
  18759. return result;
  18760. }
  18761. /**
  18762. * Gets the map value for `key`.
  18763. *
  18764. * @private
  18765. * @name get
  18766. * @memberOf MapCache
  18767. * @param {string} key The key of the value to get.
  18768. * @returns {*} Returns the entry value.
  18769. */
  18770. function mapCacheGet(key) {
  18771. return getMapData(this, key).get(key);
  18772. }
  18773. /**
  18774. * Checks if a map value for `key` exists.
  18775. *
  18776. * @private
  18777. * @name has
  18778. * @memberOf MapCache
  18779. * @param {string} key The key of the entry to check.
  18780. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18781. */
  18782. function mapCacheHas(key) {
  18783. return getMapData(this, key).has(key);
  18784. }
  18785. /**
  18786. * Sets the map `key` to `value`.
  18787. *
  18788. * @private
  18789. * @name set
  18790. * @memberOf MapCache
  18791. * @param {string} key The key of the value to set.
  18792. * @param {*} value The value to set.
  18793. * @returns {Object} Returns the map cache instance.
  18794. */
  18795. function mapCacheSet(key, value) {
  18796. var data = getMapData(this, key),
  18797. size = data.size;
  18798. data.set(key, value);
  18799. this.size += data.size == size ? 0 : 1;
  18800. return this;
  18801. }
  18802. // Add methods to `MapCache`.
  18803. MapCache.prototype.clear = mapCacheClear;
  18804. MapCache.prototype['delete'] = mapCacheDelete;
  18805. MapCache.prototype.get = mapCacheGet;
  18806. MapCache.prototype.has = mapCacheHas;
  18807. MapCache.prototype.set = mapCacheSet;
  18808. /*------------------------------------------------------------------------*/
  18809. /**
  18810. *
  18811. * Creates an array cache object to store unique values.
  18812. *
  18813. * @private
  18814. * @constructor
  18815. * @param {Array} [values] The values to cache.
  18816. */
  18817. function SetCache(values) {
  18818. var index = -1,
  18819. length = values == null ? 0 : values.length;
  18820. this.__data__ = new MapCache;
  18821. while (++index < length) {
  18822. this.add(values[index]);
  18823. }
  18824. }
  18825. /**
  18826. * Adds `value` to the array cache.
  18827. *
  18828. * @private
  18829. * @name add
  18830. * @memberOf SetCache
  18831. * @alias push
  18832. * @param {*} value The value to cache.
  18833. * @returns {Object} Returns the cache instance.
  18834. */
  18835. function setCacheAdd(value) {
  18836. this.__data__.set(value, HASH_UNDEFINED);
  18837. return this;
  18838. }
  18839. /**
  18840. * Checks if `value` is in the array cache.
  18841. *
  18842. * @private
  18843. * @name has
  18844. * @memberOf SetCache
  18845. * @param {*} value The value to search for.
  18846. * @returns {number} Returns `true` if `value` is found, else `false`.
  18847. */
  18848. function setCacheHas(value) {
  18849. return this.__data__.has(value);
  18850. }
  18851. // Add methods to `SetCache`.
  18852. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18853. SetCache.prototype.has = setCacheHas;
  18854. /*------------------------------------------------------------------------*/
  18855. /**
  18856. * Creates a stack cache object to store key-value pairs.
  18857. *
  18858. * @private
  18859. * @constructor
  18860. * @param {Array} [entries] The key-value pairs to cache.
  18861. */
  18862. function Stack(entries) {
  18863. var data = this.__data__ = new ListCache(entries);
  18864. this.size = data.size;
  18865. }
  18866. /**
  18867. * Removes all key-value entries from the stack.
  18868. *
  18869. * @private
  18870. * @name clear
  18871. * @memberOf Stack
  18872. */
  18873. function stackClear() {
  18874. this.__data__ = new ListCache;
  18875. this.size = 0;
  18876. }
  18877. /**
  18878. * Removes `key` and its value from the stack.
  18879. *
  18880. * @private
  18881. * @name delete
  18882. * @memberOf Stack
  18883. * @param {string} key The key of the value to remove.
  18884. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18885. */
  18886. function stackDelete(key) {
  18887. var data = this.__data__,
  18888. result = data['delete'](key);
  18889. this.size = data.size;
  18890. return result;
  18891. }
  18892. /**
  18893. * Gets the stack value for `key`.
  18894. *
  18895. * @private
  18896. * @name get
  18897. * @memberOf Stack
  18898. * @param {string} key The key of the value to get.
  18899. * @returns {*} Returns the entry value.
  18900. */
  18901. function stackGet(key) {
  18902. return this.__data__.get(key);
  18903. }
  18904. /**
  18905. * Checks if a stack value for `key` exists.
  18906. *
  18907. * @private
  18908. * @name has
  18909. * @memberOf Stack
  18910. * @param {string} key The key of the entry to check.
  18911. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18912. */
  18913. function stackHas(key) {
  18914. return this.__data__.has(key);
  18915. }
  18916. /**
  18917. * Sets the stack `key` to `value`.
  18918. *
  18919. * @private
  18920. * @name set
  18921. * @memberOf Stack
  18922. * @param {string} key The key of the value to set.
  18923. * @param {*} value The value to set.
  18924. * @returns {Object} Returns the stack cache instance.
  18925. */
  18926. function stackSet(key, value) {
  18927. var data = this.__data__;
  18928. if (data instanceof ListCache) {
  18929. var pairs = data.__data__;
  18930. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18931. pairs.push([key, value]);
  18932. this.size = ++data.size;
  18933. return this;
  18934. }
  18935. data = this.__data__ = new MapCache(pairs);
  18936. }
  18937. data.set(key, value);
  18938. this.size = data.size;
  18939. return this;
  18940. }
  18941. // Add methods to `Stack`.
  18942. Stack.prototype.clear = stackClear;
  18943. Stack.prototype['delete'] = stackDelete;
  18944. Stack.prototype.get = stackGet;
  18945. Stack.prototype.has = stackHas;
  18946. Stack.prototype.set = stackSet;
  18947. /*------------------------------------------------------------------------*/
  18948. /**
  18949. * Creates an array of the enumerable property names of the array-like `value`.
  18950. *
  18951. * @private
  18952. * @param {*} value The value to query.
  18953. * @param {boolean} inherited Specify returning inherited property names.
  18954. * @returns {Array} Returns the array of property names.
  18955. */
  18956. function arrayLikeKeys(value, inherited) {
  18957. var isArr = isArray(value),
  18958. isArg = !isArr && isArguments(value),
  18959. isBuff = !isArr && !isArg && isBuffer(value),
  18960. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18961. skipIndexes = isArr || isArg || isBuff || isType,
  18962. result = skipIndexes ? baseTimes(value.length, String) : [],
  18963. length = result.length;
  18964. for (var key in value) {
  18965. if ((inherited || hasOwnProperty.call(value, key)) &&
  18966. !(skipIndexes && (
  18967. // Safari 9 has enumerable `arguments.length` in strict mode.
  18968. key == 'length' ||
  18969. // Node.js 0.10 has enumerable non-index properties on buffers.
  18970. (isBuff && (key == 'offset' || key == 'parent')) ||
  18971. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  18972. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  18973. // Skip index properties.
  18974. isIndex(key, length)
  18975. ))) {
  18976. result.push(key);
  18977. }
  18978. }
  18979. return result;
  18980. }
  18981. /**
  18982. * A specialized version of `_.sample` for arrays.
  18983. *
  18984. * @private
  18985. * @param {Array} array The array to sample.
  18986. * @returns {*} Returns the random element.
  18987. */
  18988. function arraySample(array) {
  18989. var length = array.length;
  18990. return length ? array[baseRandom(0, length - 1)] : undefined;
  18991. }
  18992. /**
  18993. * A specialized version of `_.sampleSize` for arrays.
  18994. *
  18995. * @private
  18996. * @param {Array} array The array to sample.
  18997. * @param {number} n The number of elements to sample.
  18998. * @returns {Array} Returns the random elements.
  18999. */
  19000. function arraySampleSize(array, n) {
  19001. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19002. }
  19003. /**
  19004. * A specialized version of `_.shuffle` for arrays.
  19005. *
  19006. * @private
  19007. * @param {Array} array The array to shuffle.
  19008. * @returns {Array} Returns the new shuffled array.
  19009. */
  19010. function arrayShuffle(array) {
  19011. return shuffleSelf(copyArray(array));
  19012. }
  19013. /**
  19014. * This function is like `assignValue` except that it doesn't assign
  19015. * `undefined` values.
  19016. *
  19017. * @private
  19018. * @param {Object} object The object to modify.
  19019. * @param {string} key The key of the property to assign.
  19020. * @param {*} value The value to assign.
  19021. */
  19022. function assignMergeValue(object, key, value) {
  19023. if ((value !== undefined && !eq(object[key], value)) ||
  19024. (value === undefined && !(key in object))) {
  19025. baseAssignValue(object, key, value);
  19026. }
  19027. }
  19028. /**
  19029. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19030. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19031. * for equality comparisons.
  19032. *
  19033. * @private
  19034. * @param {Object} object The object to modify.
  19035. * @param {string} key The key of the property to assign.
  19036. * @param {*} value The value to assign.
  19037. */
  19038. function assignValue(object, key, value) {
  19039. var objValue = object[key];
  19040. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19041. (value === undefined && !(key in object))) {
  19042. baseAssignValue(object, key, value);
  19043. }
  19044. }
  19045. /**
  19046. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19047. *
  19048. * @private
  19049. * @param {Array} array The array to inspect.
  19050. * @param {*} key The key to search for.
  19051. * @returns {number} Returns the index of the matched value, else `-1`.
  19052. */
  19053. function assocIndexOf(array, key) {
  19054. var length = array.length;
  19055. while (length--) {
  19056. if (eq(array[length][0], key)) {
  19057. return length;
  19058. }
  19059. }
  19060. return -1;
  19061. }
  19062. /**
  19063. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19064. * by `iteratee` and values set by `setter`.
  19065. *
  19066. * @private
  19067. * @param {Array|Object} collection The collection to iterate over.
  19068. * @param {Function} setter The function to set `accumulator` values.
  19069. * @param {Function} iteratee The iteratee to transform keys.
  19070. * @param {Object} accumulator The initial aggregated object.
  19071. * @returns {Function} Returns `accumulator`.
  19072. */
  19073. function baseAggregator(collection, setter, iteratee, accumulator) {
  19074. baseEach(collection, function(value, key, collection) {
  19075. setter(accumulator, value, iteratee(value), collection);
  19076. });
  19077. return accumulator;
  19078. }
  19079. /**
  19080. * The base implementation of `_.assign` without support for multiple sources
  19081. * or `customizer` functions.
  19082. *
  19083. * @private
  19084. * @param {Object} object The destination object.
  19085. * @param {Object} source The source object.
  19086. * @returns {Object} Returns `object`.
  19087. */
  19088. function baseAssign(object, source) {
  19089. return object && copyObject(source, keys(source), object);
  19090. }
  19091. /**
  19092. * The base implementation of `_.assignIn` without support for multiple sources
  19093. * or `customizer` functions.
  19094. *
  19095. * @private
  19096. * @param {Object} object The destination object.
  19097. * @param {Object} source The source object.
  19098. * @returns {Object} Returns `object`.
  19099. */
  19100. function baseAssignIn(object, source) {
  19101. return object && copyObject(source, keysIn(source), object);
  19102. }
  19103. /**
  19104. * The base implementation of `assignValue` and `assignMergeValue` without
  19105. * value checks.
  19106. *
  19107. * @private
  19108. * @param {Object} object The object to modify.
  19109. * @param {string} key The key of the property to assign.
  19110. * @param {*} value The value to assign.
  19111. */
  19112. function baseAssignValue(object, key, value) {
  19113. if (key == '__proto__' && defineProperty) {
  19114. defineProperty(object, key, {
  19115. 'configurable': true,
  19116. 'enumerable': true,
  19117. 'value': value,
  19118. 'writable': true
  19119. });
  19120. } else {
  19121. object[key] = value;
  19122. }
  19123. }
  19124. /**
  19125. * The base implementation of `_.at` without support for individual paths.
  19126. *
  19127. * @private
  19128. * @param {Object} object The object to iterate over.
  19129. * @param {string[]} paths The property paths to pick.
  19130. * @returns {Array} Returns the picked elements.
  19131. */
  19132. function baseAt(object, paths) {
  19133. var index = -1,
  19134. length = paths.length,
  19135. result = Array(length),
  19136. skip = object == null;
  19137. while (++index < length) {
  19138. result[index] = skip ? undefined : get(object, paths[index]);
  19139. }
  19140. return result;
  19141. }
  19142. /**
  19143. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19144. *
  19145. * @private
  19146. * @param {number} number The number to clamp.
  19147. * @param {number} [lower] The lower bound.
  19148. * @param {number} upper The upper bound.
  19149. * @returns {number} Returns the clamped number.
  19150. */
  19151. function baseClamp(number, lower, upper) {
  19152. if (number === number) {
  19153. if (upper !== undefined) {
  19154. number = number <= upper ? number : upper;
  19155. }
  19156. if (lower !== undefined) {
  19157. number = number >= lower ? number : lower;
  19158. }
  19159. }
  19160. return number;
  19161. }
  19162. /**
  19163. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19164. * traversed objects.
  19165. *
  19166. * @private
  19167. * @param {*} value The value to clone.
  19168. * @param {boolean} bitmask The bitmask flags.
  19169. * 1 - Deep clone
  19170. * 2 - Flatten inherited properties
  19171. * 4 - Clone symbols
  19172. * @param {Function} [customizer] The function to customize cloning.
  19173. * @param {string} [key] The key of `value`.
  19174. * @param {Object} [object] The parent object of `value`.
  19175. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19176. * @returns {*} Returns the cloned value.
  19177. */
  19178. function baseClone(value, bitmask, customizer, key, object, stack) {
  19179. var result,
  19180. isDeep = bitmask & CLONE_DEEP_FLAG,
  19181. isFlat = bitmask & CLONE_FLAT_FLAG,
  19182. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19183. if (customizer) {
  19184. result = object ? customizer(value, key, object, stack) : customizer(value);
  19185. }
  19186. if (result !== undefined) {
  19187. return result;
  19188. }
  19189. if (!isObject(value)) {
  19190. return value;
  19191. }
  19192. var isArr = isArray(value);
  19193. if (isArr) {
  19194. result = initCloneArray(value);
  19195. if (!isDeep) {
  19196. return copyArray(value, result);
  19197. }
  19198. } else {
  19199. var tag = getTag(value),
  19200. isFunc = tag == funcTag || tag == genTag;
  19201. if (isBuffer(value)) {
  19202. return cloneBuffer(value, isDeep);
  19203. }
  19204. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19205. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19206. if (!isDeep) {
  19207. return isFlat
  19208. ? copySymbolsIn(value, baseAssignIn(result, value))
  19209. : copySymbols(value, baseAssign(result, value));
  19210. }
  19211. } else {
  19212. if (!cloneableTags[tag]) {
  19213. return object ? value : {};
  19214. }
  19215. result = initCloneByTag(value, tag, isDeep);
  19216. }
  19217. }
  19218. // Check for circular references and return its corresponding clone.
  19219. stack || (stack = new Stack);
  19220. var stacked = stack.get(value);
  19221. if (stacked) {
  19222. return stacked;
  19223. }
  19224. stack.set(value, result);
  19225. if (isSet(value)) {
  19226. value.forEach(function(subValue) {
  19227. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19228. });
  19229. } else if (isMap(value)) {
  19230. value.forEach(function(subValue, key) {
  19231. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19232. });
  19233. }
  19234. var keysFunc = isFull
  19235. ? (isFlat ? getAllKeysIn : getAllKeys)
  19236. : (isFlat ? keysIn : keys);
  19237. var props = isArr ? undefined : keysFunc(value);
  19238. arrayEach(props || value, function(subValue, key) {
  19239. if (props) {
  19240. key = subValue;
  19241. subValue = value[key];
  19242. }
  19243. // Recursively populate clone (susceptible to call stack limits).
  19244. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19245. });
  19246. return result;
  19247. }
  19248. /**
  19249. * The base implementation of `_.conforms` which doesn't clone `source`.
  19250. *
  19251. * @private
  19252. * @param {Object} source The object of property predicates to conform to.
  19253. * @returns {Function} Returns the new spec function.
  19254. */
  19255. function baseConforms(source) {
  19256. var props = keys(source);
  19257. return function(object) {
  19258. return baseConformsTo(object, source, props);
  19259. };
  19260. }
  19261. /**
  19262. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19263. *
  19264. * @private
  19265. * @param {Object} object The object to inspect.
  19266. * @param {Object} source The object of property predicates to conform to.
  19267. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19268. */
  19269. function baseConformsTo(object, source, props) {
  19270. var length = props.length;
  19271. if (object == null) {
  19272. return !length;
  19273. }
  19274. object = Object(object);
  19275. while (length--) {
  19276. var key = props[length],
  19277. predicate = source[key],
  19278. value = object[key];
  19279. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19280. return false;
  19281. }
  19282. }
  19283. return true;
  19284. }
  19285. /**
  19286. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19287. * to provide to `func`.
  19288. *
  19289. * @private
  19290. * @param {Function} func The function to delay.
  19291. * @param {number} wait The number of milliseconds to delay invocation.
  19292. * @param {Array} args The arguments to provide to `func`.
  19293. * @returns {number|Object} Returns the timer id or timeout object.
  19294. */
  19295. function baseDelay(func, wait, args) {
  19296. if (typeof func != 'function') {
  19297. throw new TypeError(FUNC_ERROR_TEXT);
  19298. }
  19299. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19300. }
  19301. /**
  19302. * The base implementation of methods like `_.difference` without support
  19303. * for excluding multiple arrays or iteratee shorthands.
  19304. *
  19305. * @private
  19306. * @param {Array} array The array to inspect.
  19307. * @param {Array} values The values to exclude.
  19308. * @param {Function} [iteratee] The iteratee invoked per element.
  19309. * @param {Function} [comparator] The comparator invoked per element.
  19310. * @returns {Array} Returns the new array of filtered values.
  19311. */
  19312. function baseDifference(array, values, iteratee, comparator) {
  19313. var index = -1,
  19314. includes = arrayIncludes,
  19315. isCommon = true,
  19316. length = array.length,
  19317. result = [],
  19318. valuesLength = values.length;
  19319. if (!length) {
  19320. return result;
  19321. }
  19322. if (iteratee) {
  19323. values = arrayMap(values, baseUnary(iteratee));
  19324. }
  19325. if (comparator) {
  19326. includes = arrayIncludesWith;
  19327. isCommon = false;
  19328. }
  19329. else if (values.length >= LARGE_ARRAY_SIZE) {
  19330. includes = cacheHas;
  19331. isCommon = false;
  19332. values = new SetCache(values);
  19333. }
  19334. outer:
  19335. while (++index < length) {
  19336. var value = array[index],
  19337. computed = iteratee == null ? value : iteratee(value);
  19338. value = (comparator || value !== 0) ? value : 0;
  19339. if (isCommon && computed === computed) {
  19340. var valuesIndex = valuesLength;
  19341. while (valuesIndex--) {
  19342. if (values[valuesIndex] === computed) {
  19343. continue outer;
  19344. }
  19345. }
  19346. result.push(value);
  19347. }
  19348. else if (!includes(values, computed, comparator)) {
  19349. result.push(value);
  19350. }
  19351. }
  19352. return result;
  19353. }
  19354. /**
  19355. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19356. *
  19357. * @private
  19358. * @param {Array|Object} collection The collection to iterate over.
  19359. * @param {Function} iteratee The function invoked per iteration.
  19360. * @returns {Array|Object} Returns `collection`.
  19361. */
  19362. var baseEach = createBaseEach(baseForOwn);
  19363. /**
  19364. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19365. *
  19366. * @private
  19367. * @param {Array|Object} collection The collection to iterate over.
  19368. * @param {Function} iteratee The function invoked per iteration.
  19369. * @returns {Array|Object} Returns `collection`.
  19370. */
  19371. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19372. /**
  19373. * The base implementation of `_.every` without support for iteratee shorthands.
  19374. *
  19375. * @private
  19376. * @param {Array|Object} collection The collection to iterate over.
  19377. * @param {Function} predicate The function invoked per iteration.
  19378. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19379. * else `false`
  19380. */
  19381. function baseEvery(collection, predicate) {
  19382. var result = true;
  19383. baseEach(collection, function(value, index, collection) {
  19384. result = !!predicate(value, index, collection);
  19385. return result;
  19386. });
  19387. return result;
  19388. }
  19389. /**
  19390. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19391. * `comparator` to determine the extremum value.
  19392. *
  19393. * @private
  19394. * @param {Array} array The array to iterate over.
  19395. * @param {Function} iteratee The iteratee invoked per iteration.
  19396. * @param {Function} comparator The comparator used to compare values.
  19397. * @returns {*} Returns the extremum value.
  19398. */
  19399. function baseExtremum(array, iteratee, comparator) {
  19400. var index = -1,
  19401. length = array.length;
  19402. while (++index < length) {
  19403. var value = array[index],
  19404. current = iteratee(value);
  19405. if (current != null && (computed === undefined
  19406. ? (current === current && !isSymbol(current))
  19407. : comparator(current, computed)
  19408. )) {
  19409. var computed = current,
  19410. result = value;
  19411. }
  19412. }
  19413. return result;
  19414. }
  19415. /**
  19416. * The base implementation of `_.fill` without an iteratee call guard.
  19417. *
  19418. * @private
  19419. * @param {Array} array The array to fill.
  19420. * @param {*} value The value to fill `array` with.
  19421. * @param {number} [start=0] The start position.
  19422. * @param {number} [end=array.length] The end position.
  19423. * @returns {Array} Returns `array`.
  19424. */
  19425. function baseFill(array, value, start, end) {
  19426. var length = array.length;
  19427. start = toInteger(start);
  19428. if (start < 0) {
  19429. start = -start > length ? 0 : (length + start);
  19430. }
  19431. end = (end === undefined || end > length) ? length : toInteger(end);
  19432. if (end < 0) {
  19433. end += length;
  19434. }
  19435. end = start > end ? 0 : toLength(end);
  19436. while (start < end) {
  19437. array[start++] = value;
  19438. }
  19439. return array;
  19440. }
  19441. /**
  19442. * The base implementation of `_.filter` without support for iteratee shorthands.
  19443. *
  19444. * @private
  19445. * @param {Array|Object} collection The collection to iterate over.
  19446. * @param {Function} predicate The function invoked per iteration.
  19447. * @returns {Array} Returns the new filtered array.
  19448. */
  19449. function baseFilter(collection, predicate) {
  19450. var result = [];
  19451. baseEach(collection, function(value, index, collection) {
  19452. if (predicate(value, index, collection)) {
  19453. result.push(value);
  19454. }
  19455. });
  19456. return result;
  19457. }
  19458. /**
  19459. * The base implementation of `_.flatten` with support for restricting flattening.
  19460. *
  19461. * @private
  19462. * @param {Array} array The array to flatten.
  19463. * @param {number} depth The maximum recursion depth.
  19464. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19465. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19466. * @param {Array} [result=[]] The initial result value.
  19467. * @returns {Array} Returns the new flattened array.
  19468. */
  19469. function baseFlatten(array, depth, predicate, isStrict, result) {
  19470. var index = -1,
  19471. length = array.length;
  19472. predicate || (predicate = isFlattenable);
  19473. result || (result = []);
  19474. while (++index < length) {
  19475. var value = array[index];
  19476. if (depth > 0 && predicate(value)) {
  19477. if (depth > 1) {
  19478. // Recursively flatten arrays (susceptible to call stack limits).
  19479. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19480. } else {
  19481. arrayPush(result, value);
  19482. }
  19483. } else if (!isStrict) {
  19484. result[result.length] = value;
  19485. }
  19486. }
  19487. return result;
  19488. }
  19489. /**
  19490. * The base implementation of `baseForOwn` which iterates over `object`
  19491. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19492. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19493. *
  19494. * @private
  19495. * @param {Object} object The object to iterate over.
  19496. * @param {Function} iteratee The function invoked per iteration.
  19497. * @param {Function} keysFunc The function to get the keys of `object`.
  19498. * @returns {Object} Returns `object`.
  19499. */
  19500. var baseFor = createBaseFor();
  19501. /**
  19502. * This function is like `baseFor` except that it iterates over properties
  19503. * in the opposite order.
  19504. *
  19505. * @private
  19506. * @param {Object} object The object to iterate over.
  19507. * @param {Function} iteratee The function invoked per iteration.
  19508. * @param {Function} keysFunc The function to get the keys of `object`.
  19509. * @returns {Object} Returns `object`.
  19510. */
  19511. var baseForRight = createBaseFor(true);
  19512. /**
  19513. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19514. *
  19515. * @private
  19516. * @param {Object} object The object to iterate over.
  19517. * @param {Function} iteratee The function invoked per iteration.
  19518. * @returns {Object} Returns `object`.
  19519. */
  19520. function baseForOwn(object, iteratee) {
  19521. return object && baseFor(object, iteratee, keys);
  19522. }
  19523. /**
  19524. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19525. *
  19526. * @private
  19527. * @param {Object} object The object to iterate over.
  19528. * @param {Function} iteratee The function invoked per iteration.
  19529. * @returns {Object} Returns `object`.
  19530. */
  19531. function baseForOwnRight(object, iteratee) {
  19532. return object && baseForRight(object, iteratee, keys);
  19533. }
  19534. /**
  19535. * The base implementation of `_.functions` which creates an array of
  19536. * `object` function property names filtered from `props`.
  19537. *
  19538. * @private
  19539. * @param {Object} object The object to inspect.
  19540. * @param {Array} props The property names to filter.
  19541. * @returns {Array} Returns the function names.
  19542. */
  19543. function baseFunctions(object, props) {
  19544. return arrayFilter(props, function(key) {
  19545. return isFunction(object[key]);
  19546. });
  19547. }
  19548. /**
  19549. * The base implementation of `_.get` without support for default values.
  19550. *
  19551. * @private
  19552. * @param {Object} object The object to query.
  19553. * @param {Array|string} path The path of the property to get.
  19554. * @returns {*} Returns the resolved value.
  19555. */
  19556. function baseGet(object, path) {
  19557. path = castPath(path, object);
  19558. var index = 0,
  19559. length = path.length;
  19560. while (object != null && index < length) {
  19561. object = object[toKey(path[index++])];
  19562. }
  19563. return (index && index == length) ? object : undefined;
  19564. }
  19565. /**
  19566. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19567. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19568. * symbols of `object`.
  19569. *
  19570. * @private
  19571. * @param {Object} object The object to query.
  19572. * @param {Function} keysFunc The function to get the keys of `object`.
  19573. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19574. * @returns {Array} Returns the array of property names and symbols.
  19575. */
  19576. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19577. var result = keysFunc(object);
  19578. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19579. }
  19580. /**
  19581. * The base implementation of `getTag` without fallbacks for buggy environments.
  19582. *
  19583. * @private
  19584. * @param {*} value The value to query.
  19585. * @returns {string} Returns the `toStringTag`.
  19586. */
  19587. function baseGetTag(value) {
  19588. if (value == null) {
  19589. return value === undefined ? undefinedTag : nullTag;
  19590. }
  19591. return (symToStringTag && symToStringTag in Object(value))
  19592. ? getRawTag(value)
  19593. : objectToString(value);
  19594. }
  19595. /**
  19596. * The base implementation of `_.gt` which doesn't coerce arguments.
  19597. *
  19598. * @private
  19599. * @param {*} value The value to compare.
  19600. * @param {*} other The other value to compare.
  19601. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19602. * else `false`.
  19603. */
  19604. function baseGt(value, other) {
  19605. return value > other;
  19606. }
  19607. /**
  19608. * The base implementation of `_.has` without support for deep paths.
  19609. *
  19610. * @private
  19611. * @param {Object} [object] The object to query.
  19612. * @param {Array|string} key The key to check.
  19613. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19614. */
  19615. function baseHas(object, key) {
  19616. return object != null && hasOwnProperty.call(object, key);
  19617. }
  19618. /**
  19619. * The base implementation of `_.hasIn` without support for deep paths.
  19620. *
  19621. * @private
  19622. * @param {Object} [object] The object to query.
  19623. * @param {Array|string} key The key to check.
  19624. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19625. */
  19626. function baseHasIn(object, key) {
  19627. return object != null && key in Object(object);
  19628. }
  19629. /**
  19630. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19631. *
  19632. * @private
  19633. * @param {number} number The number to check.
  19634. * @param {number} start The start of the range.
  19635. * @param {number} end The end of the range.
  19636. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19637. */
  19638. function baseInRange(number, start, end) {
  19639. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19640. }
  19641. /**
  19642. * The base implementation of methods like `_.intersection`, without support
  19643. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19644. *
  19645. * @private
  19646. * @param {Array} arrays The arrays to inspect.
  19647. * @param {Function} [iteratee] The iteratee invoked per element.
  19648. * @param {Function} [comparator] The comparator invoked per element.
  19649. * @returns {Array} Returns the new array of shared values.
  19650. */
  19651. function baseIntersection(arrays, iteratee, comparator) {
  19652. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19653. length = arrays[0].length,
  19654. othLength = arrays.length,
  19655. othIndex = othLength,
  19656. caches = Array(othLength),
  19657. maxLength = Infinity,
  19658. result = [];
  19659. while (othIndex--) {
  19660. var array = arrays[othIndex];
  19661. if (othIndex && iteratee) {
  19662. array = arrayMap(array, baseUnary(iteratee));
  19663. }
  19664. maxLength = nativeMin(array.length, maxLength);
  19665. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19666. ? new SetCache(othIndex && array)
  19667. : undefined;
  19668. }
  19669. array = arrays[0];
  19670. var index = -1,
  19671. seen = caches[0];
  19672. outer:
  19673. while (++index < length && result.length < maxLength) {
  19674. var value = array[index],
  19675. computed = iteratee ? iteratee(value) : value;
  19676. value = (comparator || value !== 0) ? value : 0;
  19677. if (!(seen
  19678. ? cacheHas(seen, computed)
  19679. : includes(result, computed, comparator)
  19680. )) {
  19681. othIndex = othLength;
  19682. while (--othIndex) {
  19683. var cache = caches[othIndex];
  19684. if (!(cache
  19685. ? cacheHas(cache, computed)
  19686. : includes(arrays[othIndex], computed, comparator))
  19687. ) {
  19688. continue outer;
  19689. }
  19690. }
  19691. if (seen) {
  19692. seen.push(computed);
  19693. }
  19694. result.push(value);
  19695. }
  19696. }
  19697. return result;
  19698. }
  19699. /**
  19700. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19701. * `object` with values transformed by `iteratee` and set by `setter`.
  19702. *
  19703. * @private
  19704. * @param {Object} object The object to iterate over.
  19705. * @param {Function} setter The function to set `accumulator` values.
  19706. * @param {Function} iteratee The iteratee to transform values.
  19707. * @param {Object} accumulator The initial inverted object.
  19708. * @returns {Function} Returns `accumulator`.
  19709. */
  19710. function baseInverter(object, setter, iteratee, accumulator) {
  19711. baseForOwn(object, function(value, key, object) {
  19712. setter(accumulator, iteratee(value), key, object);
  19713. });
  19714. return accumulator;
  19715. }
  19716. /**
  19717. * The base implementation of `_.invoke` without support for individual
  19718. * method arguments.
  19719. *
  19720. * @private
  19721. * @param {Object} object The object to query.
  19722. * @param {Array|string} path The path of the method to invoke.
  19723. * @param {Array} args The arguments to invoke the method with.
  19724. * @returns {*} Returns the result of the invoked method.
  19725. */
  19726. function baseInvoke(object, path, args) {
  19727. path = castPath(path, object);
  19728. object = parent(object, path);
  19729. var func = object == null ? object : object[toKey(last(path))];
  19730. return func == null ? undefined : apply(func, object, args);
  19731. }
  19732. /**
  19733. * The base implementation of `_.isArguments`.
  19734. *
  19735. * @private
  19736. * @param {*} value The value to check.
  19737. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19738. */
  19739. function baseIsArguments(value) {
  19740. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19741. }
  19742. /**
  19743. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19744. *
  19745. * @private
  19746. * @param {*} value The value to check.
  19747. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19748. */
  19749. function baseIsArrayBuffer(value) {
  19750. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19751. }
  19752. /**
  19753. * The base implementation of `_.isDate` without Node.js optimizations.
  19754. *
  19755. * @private
  19756. * @param {*} value The value to check.
  19757. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19758. */
  19759. function baseIsDate(value) {
  19760. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19761. }
  19762. /**
  19763. * The base implementation of `_.isEqual` which supports partial comparisons
  19764. * and tracks traversed objects.
  19765. *
  19766. * @private
  19767. * @param {*} value The value to compare.
  19768. * @param {*} other The other value to compare.
  19769. * @param {boolean} bitmask The bitmask flags.
  19770. * 1 - Unordered comparison
  19771. * 2 - Partial comparison
  19772. * @param {Function} [customizer] The function to customize comparisons.
  19773. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19774. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19775. */
  19776. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19777. if (value === other) {
  19778. return true;
  19779. }
  19780. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19781. return value !== value && other !== other;
  19782. }
  19783. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19784. }
  19785. /**
  19786. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19787. * deep comparisons and tracks traversed objects enabling objects with circular
  19788. * references to be compared.
  19789. *
  19790. * @private
  19791. * @param {Object} object The object to compare.
  19792. * @param {Object} other The other object to compare.
  19793. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19794. * @param {Function} customizer The function to customize comparisons.
  19795. * @param {Function} equalFunc The function to determine equivalents of values.
  19796. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19797. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19798. */
  19799. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19800. var objIsArr = isArray(object),
  19801. othIsArr = isArray(other),
  19802. objTag = objIsArr ? arrayTag : getTag(object),
  19803. othTag = othIsArr ? arrayTag : getTag(other);
  19804. objTag = objTag == argsTag ? objectTag : objTag;
  19805. othTag = othTag == argsTag ? objectTag : othTag;
  19806. var objIsObj = objTag == objectTag,
  19807. othIsObj = othTag == objectTag,
  19808. isSameTag = objTag == othTag;
  19809. if (isSameTag && isBuffer(object)) {
  19810. if (!isBuffer(other)) {
  19811. return false;
  19812. }
  19813. objIsArr = true;
  19814. objIsObj = false;
  19815. }
  19816. if (isSameTag && !objIsObj) {
  19817. stack || (stack = new Stack);
  19818. return (objIsArr || isTypedArray(object))
  19819. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19820. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19821. }
  19822. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19823. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19824. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19825. if (objIsWrapped || othIsWrapped) {
  19826. var objUnwrapped = objIsWrapped ? object.value() : object,
  19827. othUnwrapped = othIsWrapped ? other.value() : other;
  19828. stack || (stack = new Stack);
  19829. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19830. }
  19831. }
  19832. if (!isSameTag) {
  19833. return false;
  19834. }
  19835. stack || (stack = new Stack);
  19836. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19837. }
  19838. /**
  19839. * The base implementation of `_.isMap` without Node.js optimizations.
  19840. *
  19841. * @private
  19842. * @param {*} value The value to check.
  19843. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19844. */
  19845. function baseIsMap(value) {
  19846. return isObjectLike(value) && getTag(value) == mapTag;
  19847. }
  19848. /**
  19849. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19850. *
  19851. * @private
  19852. * @param {Object} object The object to inspect.
  19853. * @param {Object} source The object of property values to match.
  19854. * @param {Array} matchData The property names, values, and compare flags to match.
  19855. * @param {Function} [customizer] The function to customize comparisons.
  19856. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19857. */
  19858. function baseIsMatch(object, source, matchData, customizer) {
  19859. var index = matchData.length,
  19860. length = index,
  19861. noCustomizer = !customizer;
  19862. if (object == null) {
  19863. return !length;
  19864. }
  19865. object = Object(object);
  19866. while (index--) {
  19867. var data = matchData[index];
  19868. if ((noCustomizer && data[2])
  19869. ? data[1] !== object[data[0]]
  19870. : !(data[0] in object)
  19871. ) {
  19872. return false;
  19873. }
  19874. }
  19875. while (++index < length) {
  19876. data = matchData[index];
  19877. var key = data[0],
  19878. objValue = object[key],
  19879. srcValue = data[1];
  19880. if (noCustomizer && data[2]) {
  19881. if (objValue === undefined && !(key in object)) {
  19882. return false;
  19883. }
  19884. } else {
  19885. var stack = new Stack;
  19886. if (customizer) {
  19887. var result = customizer(objValue, srcValue, key, object, source, stack);
  19888. }
  19889. if (!(result === undefined
  19890. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19891. : result
  19892. )) {
  19893. return false;
  19894. }
  19895. }
  19896. }
  19897. return true;
  19898. }
  19899. /**
  19900. * The base implementation of `_.isNative` without bad shim checks.
  19901. *
  19902. * @private
  19903. * @param {*} value The value to check.
  19904. * @returns {boolean} Returns `true` if `value` is a native function,
  19905. * else `false`.
  19906. */
  19907. function baseIsNative(value) {
  19908. if (!isObject(value) || isMasked(value)) {
  19909. return false;
  19910. }
  19911. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19912. return pattern.test(toSource(value));
  19913. }
  19914. /**
  19915. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19916. *
  19917. * @private
  19918. * @param {*} value The value to check.
  19919. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19920. */
  19921. function baseIsRegExp(value) {
  19922. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19923. }
  19924. /**
  19925. * The base implementation of `_.isSet` without Node.js optimizations.
  19926. *
  19927. * @private
  19928. * @param {*} value The value to check.
  19929. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19930. */
  19931. function baseIsSet(value) {
  19932. return isObjectLike(value) && getTag(value) == setTag;
  19933. }
  19934. /**
  19935. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19936. *
  19937. * @private
  19938. * @param {*} value The value to check.
  19939. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19940. */
  19941. function baseIsTypedArray(value) {
  19942. return isObjectLike(value) &&
  19943. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19944. }
  19945. /**
  19946. * The base implementation of `_.iteratee`.
  19947. *
  19948. * @private
  19949. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19950. * @returns {Function} Returns the iteratee.
  19951. */
  19952. function baseIteratee(value) {
  19953. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19954. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19955. if (typeof value == 'function') {
  19956. return value;
  19957. }
  19958. if (value == null) {
  19959. return identity;
  19960. }
  19961. if (typeof value == 'object') {
  19962. return isArray(value)
  19963. ? baseMatchesProperty(value[0], value[1])
  19964. : baseMatches(value);
  19965. }
  19966. return property(value);
  19967. }
  19968. /**
  19969. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  19970. *
  19971. * @private
  19972. * @param {Object} object The object to query.
  19973. * @returns {Array} Returns the array of property names.
  19974. */
  19975. function baseKeys(object) {
  19976. if (!isPrototype(object)) {
  19977. return nativeKeys(object);
  19978. }
  19979. var result = [];
  19980. for (var key in Object(object)) {
  19981. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  19982. result.push(key);
  19983. }
  19984. }
  19985. return result;
  19986. }
  19987. /**
  19988. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  19989. *
  19990. * @private
  19991. * @param {Object} object The object to query.
  19992. * @returns {Array} Returns the array of property names.
  19993. */
  19994. function baseKeysIn(object) {
  19995. if (!isObject(object)) {
  19996. return nativeKeysIn(object);
  19997. }
  19998. var isProto = isPrototype(object),
  19999. result = [];
  20000. for (var key in object) {
  20001. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20002. result.push(key);
  20003. }
  20004. }
  20005. return result;
  20006. }
  20007. /**
  20008. * The base implementation of `_.lt` which doesn't coerce arguments.
  20009. *
  20010. * @private
  20011. * @param {*} value The value to compare.
  20012. * @param {*} other The other value to compare.
  20013. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20014. * else `false`.
  20015. */
  20016. function baseLt(value, other) {
  20017. return value < other;
  20018. }
  20019. /**
  20020. * The base implementation of `_.map` without support for iteratee shorthands.
  20021. *
  20022. * @private
  20023. * @param {Array|Object} collection The collection to iterate over.
  20024. * @param {Function} iteratee The function invoked per iteration.
  20025. * @returns {Array} Returns the new mapped array.
  20026. */
  20027. function baseMap(collection, iteratee) {
  20028. var index = -1,
  20029. result = isArrayLike(collection) ? Array(collection.length) : [];
  20030. baseEach(collection, function(value, key, collection) {
  20031. result[++index] = iteratee(value, key, collection);
  20032. });
  20033. return result;
  20034. }
  20035. /**
  20036. * The base implementation of `_.matches` which doesn't clone `source`.
  20037. *
  20038. * @private
  20039. * @param {Object} source The object of property values to match.
  20040. * @returns {Function} Returns the new spec function.
  20041. */
  20042. function baseMatches(source) {
  20043. var matchData = getMatchData(source);
  20044. if (matchData.length == 1 && matchData[0][2]) {
  20045. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20046. }
  20047. return function(object) {
  20048. return object === source || baseIsMatch(object, source, matchData);
  20049. };
  20050. }
  20051. /**
  20052. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20053. *
  20054. * @private
  20055. * @param {string} path The path of the property to get.
  20056. * @param {*} srcValue The value to match.
  20057. * @returns {Function} Returns the new spec function.
  20058. */
  20059. function baseMatchesProperty(path, srcValue) {
  20060. if (isKey(path) && isStrictComparable(srcValue)) {
  20061. return matchesStrictComparable(toKey(path), srcValue);
  20062. }
  20063. return function(object) {
  20064. var objValue = get(object, path);
  20065. return (objValue === undefined && objValue === srcValue)
  20066. ? hasIn(object, path)
  20067. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20068. };
  20069. }
  20070. /**
  20071. * The base implementation of `_.merge` without support for multiple sources.
  20072. *
  20073. * @private
  20074. * @param {Object} object The destination object.
  20075. * @param {Object} source The source object.
  20076. * @param {number} srcIndex The index of `source`.
  20077. * @param {Function} [customizer] The function to customize merged values.
  20078. * @param {Object} [stack] Tracks traversed source values and their merged
  20079. * counterparts.
  20080. */
  20081. function baseMerge(object, source, srcIndex, customizer, stack) {
  20082. if (object === source) {
  20083. return;
  20084. }
  20085. baseFor(source, function(srcValue, key) {
  20086. stack || (stack = new Stack);
  20087. if (isObject(srcValue)) {
  20088. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20089. }
  20090. else {
  20091. var newValue = customizer
  20092. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20093. : undefined;
  20094. if (newValue === undefined) {
  20095. newValue = srcValue;
  20096. }
  20097. assignMergeValue(object, key, newValue);
  20098. }
  20099. }, keysIn);
  20100. }
  20101. /**
  20102. * A specialized version of `baseMerge` for arrays and objects which performs
  20103. * deep merges and tracks traversed objects enabling objects with circular
  20104. * references to be merged.
  20105. *
  20106. * @private
  20107. * @param {Object} object The destination object.
  20108. * @param {Object} source The source object.
  20109. * @param {string} key The key of the value to merge.
  20110. * @param {number} srcIndex The index of `source`.
  20111. * @param {Function} mergeFunc The function to merge values.
  20112. * @param {Function} [customizer] The function to customize assigned values.
  20113. * @param {Object} [stack] Tracks traversed source values and their merged
  20114. * counterparts.
  20115. */
  20116. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20117. var objValue = safeGet(object, key),
  20118. srcValue = safeGet(source, key),
  20119. stacked = stack.get(srcValue);
  20120. if (stacked) {
  20121. assignMergeValue(object, key, stacked);
  20122. return;
  20123. }
  20124. var newValue = customizer
  20125. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20126. : undefined;
  20127. var isCommon = newValue === undefined;
  20128. if (isCommon) {
  20129. var isArr = isArray(srcValue),
  20130. isBuff = !isArr && isBuffer(srcValue),
  20131. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20132. newValue = srcValue;
  20133. if (isArr || isBuff || isTyped) {
  20134. if (isArray(objValue)) {
  20135. newValue = objValue;
  20136. }
  20137. else if (isArrayLikeObject(objValue)) {
  20138. newValue = copyArray(objValue);
  20139. }
  20140. else if (isBuff) {
  20141. isCommon = false;
  20142. newValue = cloneBuffer(srcValue, true);
  20143. }
  20144. else if (isTyped) {
  20145. isCommon = false;
  20146. newValue = cloneTypedArray(srcValue, true);
  20147. }
  20148. else {
  20149. newValue = [];
  20150. }
  20151. }
  20152. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20153. newValue = objValue;
  20154. if (isArguments(objValue)) {
  20155. newValue = toPlainObject(objValue);
  20156. }
  20157. else if (!isObject(objValue) || isFunction(objValue)) {
  20158. newValue = initCloneObject(srcValue);
  20159. }
  20160. }
  20161. else {
  20162. isCommon = false;
  20163. }
  20164. }
  20165. if (isCommon) {
  20166. // Recursively merge objects and arrays (susceptible to call stack limits).
  20167. stack.set(srcValue, newValue);
  20168. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20169. stack['delete'](srcValue);
  20170. }
  20171. assignMergeValue(object, key, newValue);
  20172. }
  20173. /**
  20174. * The base implementation of `_.nth` which doesn't coerce arguments.
  20175. *
  20176. * @private
  20177. * @param {Array} array The array to query.
  20178. * @param {number} n The index of the element to return.
  20179. * @returns {*} Returns the nth element of `array`.
  20180. */
  20181. function baseNth(array, n) {
  20182. var length = array.length;
  20183. if (!length) {
  20184. return;
  20185. }
  20186. n += n < 0 ? length : 0;
  20187. return isIndex(n, length) ? array[n] : undefined;
  20188. }
  20189. /**
  20190. * The base implementation of `_.orderBy` without param guards.
  20191. *
  20192. * @private
  20193. * @param {Array|Object} collection The collection to iterate over.
  20194. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20195. * @param {string[]} orders The sort orders of `iteratees`.
  20196. * @returns {Array} Returns the new sorted array.
  20197. */
  20198. function baseOrderBy(collection, iteratees, orders) {
  20199. var index = -1;
  20200. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20201. var result = baseMap(collection, function(value, key, collection) {
  20202. var criteria = arrayMap(iteratees, function(iteratee) {
  20203. return iteratee(value);
  20204. });
  20205. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20206. });
  20207. return baseSortBy(result, function(object, other) {
  20208. return compareMultiple(object, other, orders);
  20209. });
  20210. }
  20211. /**
  20212. * The base implementation of `_.pick` without support for individual
  20213. * property identifiers.
  20214. *
  20215. * @private
  20216. * @param {Object} object The source object.
  20217. * @param {string[]} paths The property paths to pick.
  20218. * @returns {Object} Returns the new object.
  20219. */
  20220. function basePick(object, paths) {
  20221. return basePickBy(object, paths, function(value, path) {
  20222. return hasIn(object, path);
  20223. });
  20224. }
  20225. /**
  20226. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20227. *
  20228. * @private
  20229. * @param {Object} object The source object.
  20230. * @param {string[]} paths The property paths to pick.
  20231. * @param {Function} predicate The function invoked per property.
  20232. * @returns {Object} Returns the new object.
  20233. */
  20234. function basePickBy(object, paths, predicate) {
  20235. var index = -1,
  20236. length = paths.length,
  20237. result = {};
  20238. while (++index < length) {
  20239. var path = paths[index],
  20240. value = baseGet(object, path);
  20241. if (predicate(value, path)) {
  20242. baseSet(result, castPath(path, object), value);
  20243. }
  20244. }
  20245. return result;
  20246. }
  20247. /**
  20248. * A specialized version of `baseProperty` which supports deep paths.
  20249. *
  20250. * @private
  20251. * @param {Array|string} path The path of the property to get.
  20252. * @returns {Function} Returns the new accessor function.
  20253. */
  20254. function basePropertyDeep(path) {
  20255. return function(object) {
  20256. return baseGet(object, path);
  20257. };
  20258. }
  20259. /**
  20260. * The base implementation of `_.pullAllBy` without support for iteratee
  20261. * shorthands.
  20262. *
  20263. * @private
  20264. * @param {Array} array The array to modify.
  20265. * @param {Array} values The values to remove.
  20266. * @param {Function} [iteratee] The iteratee invoked per element.
  20267. * @param {Function} [comparator] The comparator invoked per element.
  20268. * @returns {Array} Returns `array`.
  20269. */
  20270. function basePullAll(array, values, iteratee, comparator) {
  20271. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20272. index = -1,
  20273. length = values.length,
  20274. seen = array;
  20275. if (array === values) {
  20276. values = copyArray(values);
  20277. }
  20278. if (iteratee) {
  20279. seen = arrayMap(array, baseUnary(iteratee));
  20280. }
  20281. while (++index < length) {
  20282. var fromIndex = 0,
  20283. value = values[index],
  20284. computed = iteratee ? iteratee(value) : value;
  20285. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20286. if (seen !== array) {
  20287. splice.call(seen, fromIndex, 1);
  20288. }
  20289. splice.call(array, fromIndex, 1);
  20290. }
  20291. }
  20292. return array;
  20293. }
  20294. /**
  20295. * The base implementation of `_.pullAt` without support for individual
  20296. * indexes or capturing the removed elements.
  20297. *
  20298. * @private
  20299. * @param {Array} array The array to modify.
  20300. * @param {number[]} indexes The indexes of elements to remove.
  20301. * @returns {Array} Returns `array`.
  20302. */
  20303. function basePullAt(array, indexes) {
  20304. var length = array ? indexes.length : 0,
  20305. lastIndex = length - 1;
  20306. while (length--) {
  20307. var index = indexes[length];
  20308. if (length == lastIndex || index !== previous) {
  20309. var previous = index;
  20310. if (isIndex(index)) {
  20311. splice.call(array, index, 1);
  20312. } else {
  20313. baseUnset(array, index);
  20314. }
  20315. }
  20316. }
  20317. return array;
  20318. }
  20319. /**
  20320. * The base implementation of `_.random` without support for returning
  20321. * floating-point numbers.
  20322. *
  20323. * @private
  20324. * @param {number} lower The lower bound.
  20325. * @param {number} upper The upper bound.
  20326. * @returns {number} Returns the random number.
  20327. */
  20328. function baseRandom(lower, upper) {
  20329. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20330. }
  20331. /**
  20332. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20333. * coerce arguments.
  20334. *
  20335. * @private
  20336. * @param {number} start The start of the range.
  20337. * @param {number} end The end of the range.
  20338. * @param {number} step The value to increment or decrement by.
  20339. * @param {boolean} [fromRight] Specify iterating from right to left.
  20340. * @returns {Array} Returns the range of numbers.
  20341. */
  20342. function baseRange(start, end, step, fromRight) {
  20343. var index = -1,
  20344. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20345. result = Array(length);
  20346. while (length--) {
  20347. result[fromRight ? length : ++index] = start;
  20348. start += step;
  20349. }
  20350. return result;
  20351. }
  20352. /**
  20353. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20354. *
  20355. * @private
  20356. * @param {string} string The string to repeat.
  20357. * @param {number} n The number of times to repeat the string.
  20358. * @returns {string} Returns the repeated string.
  20359. */
  20360. function baseRepeat(string, n) {
  20361. var result = '';
  20362. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20363. return result;
  20364. }
  20365. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20366. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20367. do {
  20368. if (n % 2) {
  20369. result += string;
  20370. }
  20371. n = nativeFloor(n / 2);
  20372. if (n) {
  20373. string += string;
  20374. }
  20375. } while (n);
  20376. return result;
  20377. }
  20378. /**
  20379. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20380. *
  20381. * @private
  20382. * @param {Function} func The function to apply a rest parameter to.
  20383. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20384. * @returns {Function} Returns the new function.
  20385. */
  20386. function baseRest(func, start) {
  20387. return setToString(overRest(func, start, identity), func + '');
  20388. }
  20389. /**
  20390. * The base implementation of `_.sample`.
  20391. *
  20392. * @private
  20393. * @param {Array|Object} collection The collection to sample.
  20394. * @returns {*} Returns the random element.
  20395. */
  20396. function baseSample(collection) {
  20397. return arraySample(values(collection));
  20398. }
  20399. /**
  20400. * The base implementation of `_.sampleSize` without param guards.
  20401. *
  20402. * @private
  20403. * @param {Array|Object} collection The collection to sample.
  20404. * @param {number} n The number of elements to sample.
  20405. * @returns {Array} Returns the random elements.
  20406. */
  20407. function baseSampleSize(collection, n) {
  20408. var array = values(collection);
  20409. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20410. }
  20411. /**
  20412. * The base implementation of `_.set`.
  20413. *
  20414. * @private
  20415. * @param {Object} object The object to modify.
  20416. * @param {Array|string} path The path of the property to set.
  20417. * @param {*} value The value to set.
  20418. * @param {Function} [customizer] The function to customize path creation.
  20419. * @returns {Object} Returns `object`.
  20420. */
  20421. function baseSet(object, path, value, customizer) {
  20422. if (!isObject(object)) {
  20423. return object;
  20424. }
  20425. path = castPath(path, object);
  20426. var index = -1,
  20427. length = path.length,
  20428. lastIndex = length - 1,
  20429. nested = object;
  20430. while (nested != null && ++index < length) {
  20431. var key = toKey(path[index]),
  20432. newValue = value;
  20433. if (index != lastIndex) {
  20434. var objValue = nested[key];
  20435. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20436. if (newValue === undefined) {
  20437. newValue = isObject(objValue)
  20438. ? objValue
  20439. : (isIndex(path[index + 1]) ? [] : {});
  20440. }
  20441. }
  20442. assignValue(nested, key, newValue);
  20443. nested = nested[key];
  20444. }
  20445. return object;
  20446. }
  20447. /**
  20448. * The base implementation of `setData` without support for hot loop shorting.
  20449. *
  20450. * @private
  20451. * @param {Function} func The function to associate metadata with.
  20452. * @param {*} data The metadata.
  20453. * @returns {Function} Returns `func`.
  20454. */
  20455. var baseSetData = !metaMap ? identity : function(func, data) {
  20456. metaMap.set(func, data);
  20457. return func;
  20458. };
  20459. /**
  20460. * The base implementation of `setToString` without support for hot loop shorting.
  20461. *
  20462. * @private
  20463. * @param {Function} func The function to modify.
  20464. * @param {Function} string The `toString` result.
  20465. * @returns {Function} Returns `func`.
  20466. */
  20467. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20468. return defineProperty(func, 'toString', {
  20469. 'configurable': true,
  20470. 'enumerable': false,
  20471. 'value': constant(string),
  20472. 'writable': true
  20473. });
  20474. };
  20475. /**
  20476. * The base implementation of `_.shuffle`.
  20477. *
  20478. * @private
  20479. * @param {Array|Object} collection The collection to shuffle.
  20480. * @returns {Array} Returns the new shuffled array.
  20481. */
  20482. function baseShuffle(collection) {
  20483. return shuffleSelf(values(collection));
  20484. }
  20485. /**
  20486. * The base implementation of `_.slice` without an iteratee call guard.
  20487. *
  20488. * @private
  20489. * @param {Array} array The array to slice.
  20490. * @param {number} [start=0] The start position.
  20491. * @param {number} [end=array.length] The end position.
  20492. * @returns {Array} Returns the slice of `array`.
  20493. */
  20494. function baseSlice(array, start, end) {
  20495. var index = -1,
  20496. length = array.length;
  20497. if (start < 0) {
  20498. start = -start > length ? 0 : (length + start);
  20499. }
  20500. end = end > length ? length : end;
  20501. if (end < 0) {
  20502. end += length;
  20503. }
  20504. length = start > end ? 0 : ((end - start) >>> 0);
  20505. start >>>= 0;
  20506. var result = Array(length);
  20507. while (++index < length) {
  20508. result[index] = array[index + start];
  20509. }
  20510. return result;
  20511. }
  20512. /**
  20513. * The base implementation of `_.some` without support for iteratee shorthands.
  20514. *
  20515. * @private
  20516. * @param {Array|Object} collection The collection to iterate over.
  20517. * @param {Function} predicate The function invoked per iteration.
  20518. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20519. * else `false`.
  20520. */
  20521. function baseSome(collection, predicate) {
  20522. var result;
  20523. baseEach(collection, function(value, index, collection) {
  20524. result = predicate(value, index, collection);
  20525. return !result;
  20526. });
  20527. return !!result;
  20528. }
  20529. /**
  20530. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20531. * performs a binary search of `array` to determine the index at which `value`
  20532. * should be inserted into `array` in order to maintain its sort order.
  20533. *
  20534. * @private
  20535. * @param {Array} array The sorted array to inspect.
  20536. * @param {*} value The value to evaluate.
  20537. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20538. * @returns {number} Returns the index at which `value` should be inserted
  20539. * into `array`.
  20540. */
  20541. function baseSortedIndex(array, value, retHighest) {
  20542. var low = 0,
  20543. high = array == null ? low : array.length;
  20544. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20545. while (low < high) {
  20546. var mid = (low + high) >>> 1,
  20547. computed = array[mid];
  20548. if (computed !== null && !isSymbol(computed) &&
  20549. (retHighest ? (computed <= value) : (computed < value))) {
  20550. low = mid + 1;
  20551. } else {
  20552. high = mid;
  20553. }
  20554. }
  20555. return high;
  20556. }
  20557. return baseSortedIndexBy(array, value, identity, retHighest);
  20558. }
  20559. /**
  20560. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20561. * which invokes `iteratee` for `value` and each element of `array` to compute
  20562. * their sort ranking. The iteratee is invoked with one argument; (value).
  20563. *
  20564. * @private
  20565. * @param {Array} array The sorted array to inspect.
  20566. * @param {*} value The value to evaluate.
  20567. * @param {Function} iteratee The iteratee invoked per element.
  20568. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20569. * @returns {number} Returns the index at which `value` should be inserted
  20570. * into `array`.
  20571. */
  20572. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20573. value = iteratee(value);
  20574. var low = 0,
  20575. high = array == null ? 0 : array.length,
  20576. valIsNaN = value !== value,
  20577. valIsNull = value === null,
  20578. valIsSymbol = isSymbol(value),
  20579. valIsUndefined = value === undefined;
  20580. while (low < high) {
  20581. var mid = nativeFloor((low + high) / 2),
  20582. computed = iteratee(array[mid]),
  20583. othIsDefined = computed !== undefined,
  20584. othIsNull = computed === null,
  20585. othIsReflexive = computed === computed,
  20586. othIsSymbol = isSymbol(computed);
  20587. if (valIsNaN) {
  20588. var setLow = retHighest || othIsReflexive;
  20589. } else if (valIsUndefined) {
  20590. setLow = othIsReflexive && (retHighest || othIsDefined);
  20591. } else if (valIsNull) {
  20592. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20593. } else if (valIsSymbol) {
  20594. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20595. } else if (othIsNull || othIsSymbol) {
  20596. setLow = false;
  20597. } else {
  20598. setLow = retHighest ? (computed <= value) : (computed < value);
  20599. }
  20600. if (setLow) {
  20601. low = mid + 1;
  20602. } else {
  20603. high = mid;
  20604. }
  20605. }
  20606. return nativeMin(high, MAX_ARRAY_INDEX);
  20607. }
  20608. /**
  20609. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20610. * support for iteratee shorthands.
  20611. *
  20612. * @private
  20613. * @param {Array} array The array to inspect.
  20614. * @param {Function} [iteratee] The iteratee invoked per element.
  20615. * @returns {Array} Returns the new duplicate free array.
  20616. */
  20617. function baseSortedUniq(array, iteratee) {
  20618. var index = -1,
  20619. length = array.length,
  20620. resIndex = 0,
  20621. result = [];
  20622. while (++index < length) {
  20623. var value = array[index],
  20624. computed = iteratee ? iteratee(value) : value;
  20625. if (!index || !eq(computed, seen)) {
  20626. var seen = computed;
  20627. result[resIndex++] = value === 0 ? 0 : value;
  20628. }
  20629. }
  20630. return result;
  20631. }
  20632. /**
  20633. * The base implementation of `_.toNumber` which doesn't ensure correct
  20634. * conversions of binary, hexadecimal, or octal string values.
  20635. *
  20636. * @private
  20637. * @param {*} value The value to process.
  20638. * @returns {number} Returns the number.
  20639. */
  20640. function baseToNumber(value) {
  20641. if (typeof value == 'number') {
  20642. return value;
  20643. }
  20644. if (isSymbol(value)) {
  20645. return NAN;
  20646. }
  20647. return +value;
  20648. }
  20649. /**
  20650. * The base implementation of `_.toString` which doesn't convert nullish
  20651. * values to empty strings.
  20652. *
  20653. * @private
  20654. * @param {*} value The value to process.
  20655. * @returns {string} Returns the string.
  20656. */
  20657. function baseToString(value) {
  20658. // Exit early for strings to avoid a performance hit in some environments.
  20659. if (typeof value == 'string') {
  20660. return value;
  20661. }
  20662. if (isArray(value)) {
  20663. // Recursively convert values (susceptible to call stack limits).
  20664. return arrayMap(value, baseToString) + '';
  20665. }
  20666. if (isSymbol(value)) {
  20667. return symbolToString ? symbolToString.call(value) : '';
  20668. }
  20669. var result = (value + '');
  20670. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20671. }
  20672. /**
  20673. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20674. *
  20675. * @private
  20676. * @param {Array} array The array to inspect.
  20677. * @param {Function} [iteratee] The iteratee invoked per element.
  20678. * @param {Function} [comparator] The comparator invoked per element.
  20679. * @returns {Array} Returns the new duplicate free array.
  20680. */
  20681. function baseUniq(array, iteratee, comparator) {
  20682. var index = -1,
  20683. includes = arrayIncludes,
  20684. length = array.length,
  20685. isCommon = true,
  20686. result = [],
  20687. seen = result;
  20688. if (comparator) {
  20689. isCommon = false;
  20690. includes = arrayIncludesWith;
  20691. }
  20692. else if (length >= LARGE_ARRAY_SIZE) {
  20693. var set = iteratee ? null : createSet(array);
  20694. if (set) {
  20695. return setToArray(set);
  20696. }
  20697. isCommon = false;
  20698. includes = cacheHas;
  20699. seen = new SetCache;
  20700. }
  20701. else {
  20702. seen = iteratee ? [] : result;
  20703. }
  20704. outer:
  20705. while (++index < length) {
  20706. var value = array[index],
  20707. computed = iteratee ? iteratee(value) : value;
  20708. value = (comparator || value !== 0) ? value : 0;
  20709. if (isCommon && computed === computed) {
  20710. var seenIndex = seen.length;
  20711. while (seenIndex--) {
  20712. if (seen[seenIndex] === computed) {
  20713. continue outer;
  20714. }
  20715. }
  20716. if (iteratee) {
  20717. seen.push(computed);
  20718. }
  20719. result.push(value);
  20720. }
  20721. else if (!includes(seen, computed, comparator)) {
  20722. if (seen !== result) {
  20723. seen.push(computed);
  20724. }
  20725. result.push(value);
  20726. }
  20727. }
  20728. return result;
  20729. }
  20730. /**
  20731. * The base implementation of `_.unset`.
  20732. *
  20733. * @private
  20734. * @param {Object} object The object to modify.
  20735. * @param {Array|string} path The property path to unset.
  20736. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20737. */
  20738. function baseUnset(object, path) {
  20739. path = castPath(path, object);
  20740. object = parent(object, path);
  20741. return object == null || delete object[toKey(last(path))];
  20742. }
  20743. /**
  20744. * The base implementation of `_.update`.
  20745. *
  20746. * @private
  20747. * @param {Object} object The object to modify.
  20748. * @param {Array|string} path The path of the property to update.
  20749. * @param {Function} updater The function to produce the updated value.
  20750. * @param {Function} [customizer] The function to customize path creation.
  20751. * @returns {Object} Returns `object`.
  20752. */
  20753. function baseUpdate(object, path, updater, customizer) {
  20754. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20755. }
  20756. /**
  20757. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20758. * without support for iteratee shorthands.
  20759. *
  20760. * @private
  20761. * @param {Array} array The array to query.
  20762. * @param {Function} predicate The function invoked per iteration.
  20763. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20764. * @param {boolean} [fromRight] Specify iterating from right to left.
  20765. * @returns {Array} Returns the slice of `array`.
  20766. */
  20767. function baseWhile(array, predicate, isDrop, fromRight) {
  20768. var length = array.length,
  20769. index = fromRight ? length : -1;
  20770. while ((fromRight ? index-- : ++index < length) &&
  20771. predicate(array[index], index, array)) {}
  20772. return isDrop
  20773. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20774. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20775. }
  20776. /**
  20777. * The base implementation of `wrapperValue` which returns the result of
  20778. * performing a sequence of actions on the unwrapped `value`, where each
  20779. * successive action is supplied the return value of the previous.
  20780. *
  20781. * @private
  20782. * @param {*} value The unwrapped value.
  20783. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20784. * @returns {*} Returns the resolved value.
  20785. */
  20786. function baseWrapperValue(value, actions) {
  20787. var result = value;
  20788. if (result instanceof LazyWrapper) {
  20789. result = result.value();
  20790. }
  20791. return arrayReduce(actions, function(result, action) {
  20792. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20793. }, result);
  20794. }
  20795. /**
  20796. * The base implementation of methods like `_.xor`, without support for
  20797. * iteratee shorthands, that accepts an array of arrays to inspect.
  20798. *
  20799. * @private
  20800. * @param {Array} arrays The arrays to inspect.
  20801. * @param {Function} [iteratee] The iteratee invoked per element.
  20802. * @param {Function} [comparator] The comparator invoked per element.
  20803. * @returns {Array} Returns the new array of values.
  20804. */
  20805. function baseXor(arrays, iteratee, comparator) {
  20806. var length = arrays.length;
  20807. if (length < 2) {
  20808. return length ? baseUniq(arrays[0]) : [];
  20809. }
  20810. var index = -1,
  20811. result = Array(length);
  20812. while (++index < length) {
  20813. var array = arrays[index],
  20814. othIndex = -1;
  20815. while (++othIndex < length) {
  20816. if (othIndex != index) {
  20817. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20818. }
  20819. }
  20820. }
  20821. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20822. }
  20823. /**
  20824. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20825. *
  20826. * @private
  20827. * @param {Array} props The property identifiers.
  20828. * @param {Array} values The property values.
  20829. * @param {Function} assignFunc The function to assign values.
  20830. * @returns {Object} Returns the new object.
  20831. */
  20832. function baseZipObject(props, values, assignFunc) {
  20833. var index = -1,
  20834. length = props.length,
  20835. valsLength = values.length,
  20836. result = {};
  20837. while (++index < length) {
  20838. var value = index < valsLength ? values[index] : undefined;
  20839. assignFunc(result, props[index], value);
  20840. }
  20841. return result;
  20842. }
  20843. /**
  20844. * Casts `value` to an empty array if it's not an array like object.
  20845. *
  20846. * @private
  20847. * @param {*} value The value to inspect.
  20848. * @returns {Array|Object} Returns the cast array-like object.
  20849. */
  20850. function castArrayLikeObject(value) {
  20851. return isArrayLikeObject(value) ? value : [];
  20852. }
  20853. /**
  20854. * Casts `value` to `identity` if it's not a function.
  20855. *
  20856. * @private
  20857. * @param {*} value The value to inspect.
  20858. * @returns {Function} Returns cast function.
  20859. */
  20860. function castFunction(value) {
  20861. return typeof value == 'function' ? value : identity;
  20862. }
  20863. /**
  20864. * Casts `value` to a path array if it's not one.
  20865. *
  20866. * @private
  20867. * @param {*} value The value to inspect.
  20868. * @param {Object} [object] The object to query keys on.
  20869. * @returns {Array} Returns the cast property path array.
  20870. */
  20871. function castPath(value, object) {
  20872. if (isArray(value)) {
  20873. return value;
  20874. }
  20875. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20876. }
  20877. /**
  20878. * A `baseRest` alias which can be replaced with `identity` by module
  20879. * replacement plugins.
  20880. *
  20881. * @private
  20882. * @type {Function}
  20883. * @param {Function} func The function to apply a rest parameter to.
  20884. * @returns {Function} Returns the new function.
  20885. */
  20886. var castRest = baseRest;
  20887. /**
  20888. * Casts `array` to a slice if it's needed.
  20889. *
  20890. * @private
  20891. * @param {Array} array The array to inspect.
  20892. * @param {number} start The start position.
  20893. * @param {number} [end=array.length] The end position.
  20894. * @returns {Array} Returns the cast slice.
  20895. */
  20896. function castSlice(array, start, end) {
  20897. var length = array.length;
  20898. end = end === undefined ? length : end;
  20899. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20900. }
  20901. /**
  20902. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20903. *
  20904. * @private
  20905. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20906. */
  20907. var clearTimeout = ctxClearTimeout || function(id) {
  20908. return root.clearTimeout(id);
  20909. };
  20910. /**
  20911. * Creates a clone of `buffer`.
  20912. *
  20913. * @private
  20914. * @param {Buffer} buffer The buffer to clone.
  20915. * @param {boolean} [isDeep] Specify a deep clone.
  20916. * @returns {Buffer} Returns the cloned buffer.
  20917. */
  20918. function cloneBuffer(buffer, isDeep) {
  20919. if (isDeep) {
  20920. return buffer.slice();
  20921. }
  20922. var length = buffer.length,
  20923. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20924. buffer.copy(result);
  20925. return result;
  20926. }
  20927. /**
  20928. * Creates a clone of `arrayBuffer`.
  20929. *
  20930. * @private
  20931. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20932. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20933. */
  20934. function cloneArrayBuffer(arrayBuffer) {
  20935. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20936. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20937. return result;
  20938. }
  20939. /**
  20940. * Creates a clone of `dataView`.
  20941. *
  20942. * @private
  20943. * @param {Object} dataView The data view to clone.
  20944. * @param {boolean} [isDeep] Specify a deep clone.
  20945. * @returns {Object} Returns the cloned data view.
  20946. */
  20947. function cloneDataView(dataView, isDeep) {
  20948. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20949. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20950. }
  20951. /**
  20952. * Creates a clone of `regexp`.
  20953. *
  20954. * @private
  20955. * @param {Object} regexp The regexp to clone.
  20956. * @returns {Object} Returns the cloned regexp.
  20957. */
  20958. function cloneRegExp(regexp) {
  20959. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20960. result.lastIndex = regexp.lastIndex;
  20961. return result;
  20962. }
  20963. /**
  20964. * Creates a clone of the `symbol` object.
  20965. *
  20966. * @private
  20967. * @param {Object} symbol The symbol object to clone.
  20968. * @returns {Object} Returns the cloned symbol object.
  20969. */
  20970. function cloneSymbol(symbol) {
  20971. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  20972. }
  20973. /**
  20974. * Creates a clone of `typedArray`.
  20975. *
  20976. * @private
  20977. * @param {Object} typedArray The typed array to clone.
  20978. * @param {boolean} [isDeep] Specify a deep clone.
  20979. * @returns {Object} Returns the cloned typed array.
  20980. */
  20981. function cloneTypedArray(typedArray, isDeep) {
  20982. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  20983. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  20984. }
  20985. /**
  20986. * Compares values to sort them in ascending order.
  20987. *
  20988. * @private
  20989. * @param {*} value The value to compare.
  20990. * @param {*} other The other value to compare.
  20991. * @returns {number} Returns the sort order indicator for `value`.
  20992. */
  20993. function compareAscending(value, other) {
  20994. if (value !== other) {
  20995. var valIsDefined = value !== undefined,
  20996. valIsNull = value === null,
  20997. valIsReflexive = value === value,
  20998. valIsSymbol = isSymbol(value);
  20999. var othIsDefined = other !== undefined,
  21000. othIsNull = other === null,
  21001. othIsReflexive = other === other,
  21002. othIsSymbol = isSymbol(other);
  21003. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21004. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21005. (valIsNull && othIsDefined && othIsReflexive) ||
  21006. (!valIsDefined && othIsReflexive) ||
  21007. !valIsReflexive) {
  21008. return 1;
  21009. }
  21010. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21011. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21012. (othIsNull && valIsDefined && valIsReflexive) ||
  21013. (!othIsDefined && valIsReflexive) ||
  21014. !othIsReflexive) {
  21015. return -1;
  21016. }
  21017. }
  21018. return 0;
  21019. }
  21020. /**
  21021. * Used by `_.orderBy` to compare multiple properties of a value to another
  21022. * and stable sort them.
  21023. *
  21024. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21025. * specify an order of "desc" for descending or "asc" for ascending sort order
  21026. * of corresponding values.
  21027. *
  21028. * @private
  21029. * @param {Object} object The object to compare.
  21030. * @param {Object} other The other object to compare.
  21031. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21032. * @returns {number} Returns the sort order indicator for `object`.
  21033. */
  21034. function compareMultiple(object, other, orders) {
  21035. var index = -1,
  21036. objCriteria = object.criteria,
  21037. othCriteria = other.criteria,
  21038. length = objCriteria.length,
  21039. ordersLength = orders.length;
  21040. while (++index < length) {
  21041. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21042. if (result) {
  21043. if (index >= ordersLength) {
  21044. return result;
  21045. }
  21046. var order = orders[index];
  21047. return result * (order == 'desc' ? -1 : 1);
  21048. }
  21049. }
  21050. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21051. // that causes it, under certain circumstances, to provide the same value for
  21052. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21053. // for more details.
  21054. //
  21055. // This also ensures a stable sort in V8 and other engines.
  21056. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21057. return object.index - other.index;
  21058. }
  21059. /**
  21060. * Creates an array that is the composition of partially applied arguments,
  21061. * placeholders, and provided arguments into a single array of arguments.
  21062. *
  21063. * @private
  21064. * @param {Array} args The provided arguments.
  21065. * @param {Array} partials The arguments to prepend to those provided.
  21066. * @param {Array} holders The `partials` placeholder indexes.
  21067. * @params {boolean} [isCurried] Specify composing for a curried function.
  21068. * @returns {Array} Returns the new array of composed arguments.
  21069. */
  21070. function composeArgs(args, partials, holders, isCurried) {
  21071. var argsIndex = -1,
  21072. argsLength = args.length,
  21073. holdersLength = holders.length,
  21074. leftIndex = -1,
  21075. leftLength = partials.length,
  21076. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21077. result = Array(leftLength + rangeLength),
  21078. isUncurried = !isCurried;
  21079. while (++leftIndex < leftLength) {
  21080. result[leftIndex] = partials[leftIndex];
  21081. }
  21082. while (++argsIndex < holdersLength) {
  21083. if (isUncurried || argsIndex < argsLength) {
  21084. result[holders[argsIndex]] = args[argsIndex];
  21085. }
  21086. }
  21087. while (rangeLength--) {
  21088. result[leftIndex++] = args[argsIndex++];
  21089. }
  21090. return result;
  21091. }
  21092. /**
  21093. * This function is like `composeArgs` except that the arguments composition
  21094. * is tailored for `_.partialRight`.
  21095. *
  21096. * @private
  21097. * @param {Array} args The provided arguments.
  21098. * @param {Array} partials The arguments to append to those provided.
  21099. * @param {Array} holders The `partials` placeholder indexes.
  21100. * @params {boolean} [isCurried] Specify composing for a curried function.
  21101. * @returns {Array} Returns the new array of composed arguments.
  21102. */
  21103. function composeArgsRight(args, partials, holders, isCurried) {
  21104. var argsIndex = -1,
  21105. argsLength = args.length,
  21106. holdersIndex = -1,
  21107. holdersLength = holders.length,
  21108. rightIndex = -1,
  21109. rightLength = partials.length,
  21110. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21111. result = Array(rangeLength + rightLength),
  21112. isUncurried = !isCurried;
  21113. while (++argsIndex < rangeLength) {
  21114. result[argsIndex] = args[argsIndex];
  21115. }
  21116. var offset = argsIndex;
  21117. while (++rightIndex < rightLength) {
  21118. result[offset + rightIndex] = partials[rightIndex];
  21119. }
  21120. while (++holdersIndex < holdersLength) {
  21121. if (isUncurried || argsIndex < argsLength) {
  21122. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21123. }
  21124. }
  21125. return result;
  21126. }
  21127. /**
  21128. * Copies the values of `source` to `array`.
  21129. *
  21130. * @private
  21131. * @param {Array} source The array to copy values from.
  21132. * @param {Array} [array=[]] The array to copy values to.
  21133. * @returns {Array} Returns `array`.
  21134. */
  21135. function copyArray(source, array) {
  21136. var index = -1,
  21137. length = source.length;
  21138. array || (array = Array(length));
  21139. while (++index < length) {
  21140. array[index] = source[index];
  21141. }
  21142. return array;
  21143. }
  21144. /**
  21145. * Copies properties of `source` to `object`.
  21146. *
  21147. * @private
  21148. * @param {Object} source The object to copy properties from.
  21149. * @param {Array} props The property identifiers to copy.
  21150. * @param {Object} [object={}] The object to copy properties to.
  21151. * @param {Function} [customizer] The function to customize copied values.
  21152. * @returns {Object} Returns `object`.
  21153. */
  21154. function copyObject(source, props, object, customizer) {
  21155. var isNew = !object;
  21156. object || (object = {});
  21157. var index = -1,
  21158. length = props.length;
  21159. while (++index < length) {
  21160. var key = props[index];
  21161. var newValue = customizer
  21162. ? customizer(object[key], source[key], key, object, source)
  21163. : undefined;
  21164. if (newValue === undefined) {
  21165. newValue = source[key];
  21166. }
  21167. if (isNew) {
  21168. baseAssignValue(object, key, newValue);
  21169. } else {
  21170. assignValue(object, key, newValue);
  21171. }
  21172. }
  21173. return object;
  21174. }
  21175. /**
  21176. * Copies own symbols of `source` to `object`.
  21177. *
  21178. * @private
  21179. * @param {Object} source The object to copy symbols from.
  21180. * @param {Object} [object={}] The object to copy symbols to.
  21181. * @returns {Object} Returns `object`.
  21182. */
  21183. function copySymbols(source, object) {
  21184. return copyObject(source, getSymbols(source), object);
  21185. }
  21186. /**
  21187. * Copies own and inherited symbols of `source` to `object`.
  21188. *
  21189. * @private
  21190. * @param {Object} source The object to copy symbols from.
  21191. * @param {Object} [object={}] The object to copy symbols to.
  21192. * @returns {Object} Returns `object`.
  21193. */
  21194. function copySymbolsIn(source, object) {
  21195. return copyObject(source, getSymbolsIn(source), object);
  21196. }
  21197. /**
  21198. * Creates a function like `_.groupBy`.
  21199. *
  21200. * @private
  21201. * @param {Function} setter The function to set accumulator values.
  21202. * @param {Function} [initializer] The accumulator object initializer.
  21203. * @returns {Function} Returns the new aggregator function.
  21204. */
  21205. function createAggregator(setter, initializer) {
  21206. return function(collection, iteratee) {
  21207. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21208. accumulator = initializer ? initializer() : {};
  21209. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21210. };
  21211. }
  21212. /**
  21213. * Creates a function like `_.assign`.
  21214. *
  21215. * @private
  21216. * @param {Function} assigner The function to assign values.
  21217. * @returns {Function} Returns the new assigner function.
  21218. */
  21219. function createAssigner(assigner) {
  21220. return baseRest(function(object, sources) {
  21221. var index = -1,
  21222. length = sources.length,
  21223. customizer = length > 1 ? sources[length - 1] : undefined,
  21224. guard = length > 2 ? sources[2] : undefined;
  21225. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21226. ? (length--, customizer)
  21227. : undefined;
  21228. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21229. customizer = length < 3 ? undefined : customizer;
  21230. length = 1;
  21231. }
  21232. object = Object(object);
  21233. while (++index < length) {
  21234. var source = sources[index];
  21235. if (source) {
  21236. assigner(object, source, index, customizer);
  21237. }
  21238. }
  21239. return object;
  21240. });
  21241. }
  21242. /**
  21243. * Creates a `baseEach` or `baseEachRight` function.
  21244. *
  21245. * @private
  21246. * @param {Function} eachFunc The function to iterate over a collection.
  21247. * @param {boolean} [fromRight] Specify iterating from right to left.
  21248. * @returns {Function} Returns the new base function.
  21249. */
  21250. function createBaseEach(eachFunc, fromRight) {
  21251. return function(collection, iteratee) {
  21252. if (collection == null) {
  21253. return collection;
  21254. }
  21255. if (!isArrayLike(collection)) {
  21256. return eachFunc(collection, iteratee);
  21257. }
  21258. var length = collection.length,
  21259. index = fromRight ? length : -1,
  21260. iterable = Object(collection);
  21261. while ((fromRight ? index-- : ++index < length)) {
  21262. if (iteratee(iterable[index], index, iterable) === false) {
  21263. break;
  21264. }
  21265. }
  21266. return collection;
  21267. };
  21268. }
  21269. /**
  21270. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21271. *
  21272. * @private
  21273. * @param {boolean} [fromRight] Specify iterating from right to left.
  21274. * @returns {Function} Returns the new base function.
  21275. */
  21276. function createBaseFor(fromRight) {
  21277. return function(object, iteratee, keysFunc) {
  21278. var index = -1,
  21279. iterable = Object(object),
  21280. props = keysFunc(object),
  21281. length = props.length;
  21282. while (length--) {
  21283. var key = props[fromRight ? length : ++index];
  21284. if (iteratee(iterable[key], key, iterable) === false) {
  21285. break;
  21286. }
  21287. }
  21288. return object;
  21289. };
  21290. }
  21291. /**
  21292. * Creates a function that wraps `func` to invoke it with the optional `this`
  21293. * binding of `thisArg`.
  21294. *
  21295. * @private
  21296. * @param {Function} func The function to wrap.
  21297. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21298. * @param {*} [thisArg] The `this` binding of `func`.
  21299. * @returns {Function} Returns the new wrapped function.
  21300. */
  21301. function createBind(func, bitmask, thisArg) {
  21302. var isBind = bitmask & WRAP_BIND_FLAG,
  21303. Ctor = createCtor(func);
  21304. function wrapper() {
  21305. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21306. return fn.apply(isBind ? thisArg : this, arguments);
  21307. }
  21308. return wrapper;
  21309. }
  21310. /**
  21311. * Creates a function like `_.lowerFirst`.
  21312. *
  21313. * @private
  21314. * @param {string} methodName The name of the `String` case method to use.
  21315. * @returns {Function} Returns the new case function.
  21316. */
  21317. function createCaseFirst(methodName) {
  21318. return function(string) {
  21319. string = toString(string);
  21320. var strSymbols = hasUnicode(string)
  21321. ? stringToArray(string)
  21322. : undefined;
  21323. var chr = strSymbols
  21324. ? strSymbols[0]
  21325. : string.charAt(0);
  21326. var trailing = strSymbols
  21327. ? castSlice(strSymbols, 1).join('')
  21328. : string.slice(1);
  21329. return chr[methodName]() + trailing;
  21330. };
  21331. }
  21332. /**
  21333. * Creates a function like `_.camelCase`.
  21334. *
  21335. * @private
  21336. * @param {Function} callback The function to combine each word.
  21337. * @returns {Function} Returns the new compounder function.
  21338. */
  21339. function createCompounder(callback) {
  21340. return function(string) {
  21341. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21342. };
  21343. }
  21344. /**
  21345. * Creates a function that produces an instance of `Ctor` regardless of
  21346. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21347. *
  21348. * @private
  21349. * @param {Function} Ctor The constructor to wrap.
  21350. * @returns {Function} Returns the new wrapped function.
  21351. */
  21352. function createCtor(Ctor) {
  21353. return function() {
  21354. // Use a `switch` statement to work with class constructors. See
  21355. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21356. // for more details.
  21357. var args = arguments;
  21358. switch (args.length) {
  21359. case 0: return new Ctor;
  21360. case 1: return new Ctor(args[0]);
  21361. case 2: return new Ctor(args[0], args[1]);
  21362. case 3: return new Ctor(args[0], args[1], args[2]);
  21363. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21364. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21365. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21366. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21367. }
  21368. var thisBinding = baseCreate(Ctor.prototype),
  21369. result = Ctor.apply(thisBinding, args);
  21370. // Mimic the constructor's `return` behavior.
  21371. // See https://es5.github.io/#x13.2.2 for more details.
  21372. return isObject(result) ? result : thisBinding;
  21373. };
  21374. }
  21375. /**
  21376. * Creates a function that wraps `func` to enable currying.
  21377. *
  21378. * @private
  21379. * @param {Function} func The function to wrap.
  21380. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21381. * @param {number} arity The arity of `func`.
  21382. * @returns {Function} Returns the new wrapped function.
  21383. */
  21384. function createCurry(func, bitmask, arity) {
  21385. var Ctor = createCtor(func);
  21386. function wrapper() {
  21387. var length = arguments.length,
  21388. args = Array(length),
  21389. index = length,
  21390. placeholder = getHolder(wrapper);
  21391. while (index--) {
  21392. args[index] = arguments[index];
  21393. }
  21394. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21395. ? []
  21396. : replaceHolders(args, placeholder);
  21397. length -= holders.length;
  21398. if (length < arity) {
  21399. return createRecurry(
  21400. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21401. args, holders, undefined, undefined, arity - length);
  21402. }
  21403. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21404. return apply(fn, this, args);
  21405. }
  21406. return wrapper;
  21407. }
  21408. /**
  21409. * Creates a `_.find` or `_.findLast` function.
  21410. *
  21411. * @private
  21412. * @param {Function} findIndexFunc The function to find the collection index.
  21413. * @returns {Function} Returns the new find function.
  21414. */
  21415. function createFind(findIndexFunc) {
  21416. return function(collection, predicate, fromIndex) {
  21417. var iterable = Object(collection);
  21418. if (!isArrayLike(collection)) {
  21419. var iteratee = getIteratee(predicate, 3);
  21420. collection = keys(collection);
  21421. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21422. }
  21423. var index = findIndexFunc(collection, predicate, fromIndex);
  21424. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21425. };
  21426. }
  21427. /**
  21428. * Creates a `_.flow` or `_.flowRight` function.
  21429. *
  21430. * @private
  21431. * @param {boolean} [fromRight] Specify iterating from right to left.
  21432. * @returns {Function} Returns the new flow function.
  21433. */
  21434. function createFlow(fromRight) {
  21435. return flatRest(function(funcs) {
  21436. var length = funcs.length,
  21437. index = length,
  21438. prereq = LodashWrapper.prototype.thru;
  21439. if (fromRight) {
  21440. funcs.reverse();
  21441. }
  21442. while (index--) {
  21443. var func = funcs[index];
  21444. if (typeof func != 'function') {
  21445. throw new TypeError(FUNC_ERROR_TEXT);
  21446. }
  21447. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21448. var wrapper = new LodashWrapper([], true);
  21449. }
  21450. }
  21451. index = wrapper ? index : length;
  21452. while (++index < length) {
  21453. func = funcs[index];
  21454. var funcName = getFuncName(func),
  21455. data = funcName == 'wrapper' ? getData(func) : undefined;
  21456. if (data && isLaziable(data[0]) &&
  21457. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21458. !data[4].length && data[9] == 1
  21459. ) {
  21460. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21461. } else {
  21462. wrapper = (func.length == 1 && isLaziable(func))
  21463. ? wrapper[funcName]()
  21464. : wrapper.thru(func);
  21465. }
  21466. }
  21467. return function() {
  21468. var args = arguments,
  21469. value = args[0];
  21470. if (wrapper && args.length == 1 && isArray(value)) {
  21471. return wrapper.plant(value).value();
  21472. }
  21473. var index = 0,
  21474. result = length ? funcs[index].apply(this, args) : value;
  21475. while (++index < length) {
  21476. result = funcs[index].call(this, result);
  21477. }
  21478. return result;
  21479. };
  21480. });
  21481. }
  21482. /**
  21483. * Creates a function that wraps `func` to invoke it with optional `this`
  21484. * binding of `thisArg`, partial application, and currying.
  21485. *
  21486. * @private
  21487. * @param {Function|string} func The function or method name to wrap.
  21488. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21489. * @param {*} [thisArg] The `this` binding of `func`.
  21490. * @param {Array} [partials] The arguments to prepend to those provided to
  21491. * the new function.
  21492. * @param {Array} [holders] The `partials` placeholder indexes.
  21493. * @param {Array} [partialsRight] The arguments to append to those provided
  21494. * to the new function.
  21495. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21496. * @param {Array} [argPos] The argument positions of the new function.
  21497. * @param {number} [ary] The arity cap of `func`.
  21498. * @param {number} [arity] The arity of `func`.
  21499. * @returns {Function} Returns the new wrapped function.
  21500. */
  21501. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21502. var isAry = bitmask & WRAP_ARY_FLAG,
  21503. isBind = bitmask & WRAP_BIND_FLAG,
  21504. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21505. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21506. isFlip = bitmask & WRAP_FLIP_FLAG,
  21507. Ctor = isBindKey ? undefined : createCtor(func);
  21508. function wrapper() {
  21509. var length = arguments.length,
  21510. args = Array(length),
  21511. index = length;
  21512. while (index--) {
  21513. args[index] = arguments[index];
  21514. }
  21515. if (isCurried) {
  21516. var placeholder = getHolder(wrapper),
  21517. holdersCount = countHolders(args, placeholder);
  21518. }
  21519. if (partials) {
  21520. args = composeArgs(args, partials, holders, isCurried);
  21521. }
  21522. if (partialsRight) {
  21523. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21524. }
  21525. length -= holdersCount;
  21526. if (isCurried && length < arity) {
  21527. var newHolders = replaceHolders(args, placeholder);
  21528. return createRecurry(
  21529. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21530. args, newHolders, argPos, ary, arity - length
  21531. );
  21532. }
  21533. var thisBinding = isBind ? thisArg : this,
  21534. fn = isBindKey ? thisBinding[func] : func;
  21535. length = args.length;
  21536. if (argPos) {
  21537. args = reorder(args, argPos);
  21538. } else if (isFlip && length > 1) {
  21539. args.reverse();
  21540. }
  21541. if (isAry && ary < length) {
  21542. args.length = ary;
  21543. }
  21544. if (this && this !== root && this instanceof wrapper) {
  21545. fn = Ctor || createCtor(fn);
  21546. }
  21547. return fn.apply(thisBinding, args);
  21548. }
  21549. return wrapper;
  21550. }
  21551. /**
  21552. * Creates a function like `_.invertBy`.
  21553. *
  21554. * @private
  21555. * @param {Function} setter The function to set accumulator values.
  21556. * @param {Function} toIteratee The function to resolve iteratees.
  21557. * @returns {Function} Returns the new inverter function.
  21558. */
  21559. function createInverter(setter, toIteratee) {
  21560. return function(object, iteratee) {
  21561. return baseInverter(object, setter, toIteratee(iteratee), {});
  21562. };
  21563. }
  21564. /**
  21565. * Creates a function that performs a mathematical operation on two values.
  21566. *
  21567. * @private
  21568. * @param {Function} operator The function to perform the operation.
  21569. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21570. * @returns {Function} Returns the new mathematical operation function.
  21571. */
  21572. function createMathOperation(operator, defaultValue) {
  21573. return function(value, other) {
  21574. var result;
  21575. if (value === undefined && other === undefined) {
  21576. return defaultValue;
  21577. }
  21578. if (value !== undefined) {
  21579. result = value;
  21580. }
  21581. if (other !== undefined) {
  21582. if (result === undefined) {
  21583. return other;
  21584. }
  21585. if (typeof value == 'string' || typeof other == 'string') {
  21586. value = baseToString(value);
  21587. other = baseToString(other);
  21588. } else {
  21589. value = baseToNumber(value);
  21590. other = baseToNumber(other);
  21591. }
  21592. result = operator(value, other);
  21593. }
  21594. return result;
  21595. };
  21596. }
  21597. /**
  21598. * Creates a function like `_.over`.
  21599. *
  21600. * @private
  21601. * @param {Function} arrayFunc The function to iterate over iteratees.
  21602. * @returns {Function} Returns the new over function.
  21603. */
  21604. function createOver(arrayFunc) {
  21605. return flatRest(function(iteratees) {
  21606. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21607. return baseRest(function(args) {
  21608. var thisArg = this;
  21609. return arrayFunc(iteratees, function(iteratee) {
  21610. return apply(iteratee, thisArg, args);
  21611. });
  21612. });
  21613. });
  21614. }
  21615. /**
  21616. * Creates the padding for `string` based on `length`. The `chars` string
  21617. * is truncated if the number of characters exceeds `length`.
  21618. *
  21619. * @private
  21620. * @param {number} length The padding length.
  21621. * @param {string} [chars=' '] The string used as padding.
  21622. * @returns {string} Returns the padding for `string`.
  21623. */
  21624. function createPadding(length, chars) {
  21625. chars = chars === undefined ? ' ' : baseToString(chars);
  21626. var charsLength = chars.length;
  21627. if (charsLength < 2) {
  21628. return charsLength ? baseRepeat(chars, length) : chars;
  21629. }
  21630. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21631. return hasUnicode(chars)
  21632. ? castSlice(stringToArray(result), 0, length).join('')
  21633. : result.slice(0, length);
  21634. }
  21635. /**
  21636. * Creates a function that wraps `func` to invoke it with the `this` binding
  21637. * of `thisArg` and `partials` prepended to the arguments it receives.
  21638. *
  21639. * @private
  21640. * @param {Function} func The function to wrap.
  21641. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21642. * @param {*} thisArg The `this` binding of `func`.
  21643. * @param {Array} partials The arguments to prepend to those provided to
  21644. * the new function.
  21645. * @returns {Function} Returns the new wrapped function.
  21646. */
  21647. function createPartial(func, bitmask, thisArg, partials) {
  21648. var isBind = bitmask & WRAP_BIND_FLAG,
  21649. Ctor = createCtor(func);
  21650. function wrapper() {
  21651. var argsIndex = -1,
  21652. argsLength = arguments.length,
  21653. leftIndex = -1,
  21654. leftLength = partials.length,
  21655. args = Array(leftLength + argsLength),
  21656. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21657. while (++leftIndex < leftLength) {
  21658. args[leftIndex] = partials[leftIndex];
  21659. }
  21660. while (argsLength--) {
  21661. args[leftIndex++] = arguments[++argsIndex];
  21662. }
  21663. return apply(fn, isBind ? thisArg : this, args);
  21664. }
  21665. return wrapper;
  21666. }
  21667. /**
  21668. * Creates a `_.range` or `_.rangeRight` function.
  21669. *
  21670. * @private
  21671. * @param {boolean} [fromRight] Specify iterating from right to left.
  21672. * @returns {Function} Returns the new range function.
  21673. */
  21674. function createRange(fromRight) {
  21675. return function(start, end, step) {
  21676. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21677. end = step = undefined;
  21678. }
  21679. // Ensure the sign of `-0` is preserved.
  21680. start = toFinite(start);
  21681. if (end === undefined) {
  21682. end = start;
  21683. start = 0;
  21684. } else {
  21685. end = toFinite(end);
  21686. }
  21687. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21688. return baseRange(start, end, step, fromRight);
  21689. };
  21690. }
  21691. /**
  21692. * Creates a function that performs a relational operation on two values.
  21693. *
  21694. * @private
  21695. * @param {Function} operator The function to perform the operation.
  21696. * @returns {Function} Returns the new relational operation function.
  21697. */
  21698. function createRelationalOperation(operator) {
  21699. return function(value, other) {
  21700. if (!(typeof value == 'string' && typeof other == 'string')) {
  21701. value = toNumber(value);
  21702. other = toNumber(other);
  21703. }
  21704. return operator(value, other);
  21705. };
  21706. }
  21707. /**
  21708. * Creates a function that wraps `func` to continue currying.
  21709. *
  21710. * @private
  21711. * @param {Function} func The function to wrap.
  21712. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21713. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21714. * @param {*} placeholder The placeholder value.
  21715. * @param {*} [thisArg] The `this` binding of `func`.
  21716. * @param {Array} [partials] The arguments to prepend to those provided to
  21717. * the new function.
  21718. * @param {Array} [holders] The `partials` placeholder indexes.
  21719. * @param {Array} [argPos] The argument positions of the new function.
  21720. * @param {number} [ary] The arity cap of `func`.
  21721. * @param {number} [arity] The arity of `func`.
  21722. * @returns {Function} Returns the new wrapped function.
  21723. */
  21724. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21725. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21726. newHolders = isCurry ? holders : undefined,
  21727. newHoldersRight = isCurry ? undefined : holders,
  21728. newPartials = isCurry ? partials : undefined,
  21729. newPartialsRight = isCurry ? undefined : partials;
  21730. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21731. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21732. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21733. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21734. }
  21735. var newData = [
  21736. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21737. newHoldersRight, argPos, ary, arity
  21738. ];
  21739. var result = wrapFunc.apply(undefined, newData);
  21740. if (isLaziable(func)) {
  21741. setData(result, newData);
  21742. }
  21743. result.placeholder = placeholder;
  21744. return setWrapToString(result, func, bitmask);
  21745. }
  21746. /**
  21747. * Creates a function like `_.round`.
  21748. *
  21749. * @private
  21750. * @param {string} methodName The name of the `Math` method to use when rounding.
  21751. * @returns {Function} Returns the new round function.
  21752. */
  21753. function createRound(methodName) {
  21754. var func = Math[methodName];
  21755. return function(number, precision) {
  21756. number = toNumber(number);
  21757. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21758. if (precision && nativeIsFinite(number)) {
  21759. // Shift with exponential notation to avoid floating-point issues.
  21760. // See [MDN](https://mdn.io/round#Examples) for more details.
  21761. var pair = (toString(number) + 'e').split('e'),
  21762. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21763. pair = (toString(value) + 'e').split('e');
  21764. return +(pair[0] + 'e' + (+pair[1] - precision));
  21765. }
  21766. return func(number);
  21767. };
  21768. }
  21769. /**
  21770. * Creates a set object of `values`.
  21771. *
  21772. * @private
  21773. * @param {Array} values The values to add to the set.
  21774. * @returns {Object} Returns the new set.
  21775. */
  21776. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21777. return new Set(values);
  21778. };
  21779. /**
  21780. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21781. *
  21782. * @private
  21783. * @param {Function} keysFunc The function to get the keys of a given object.
  21784. * @returns {Function} Returns the new pairs function.
  21785. */
  21786. function createToPairs(keysFunc) {
  21787. return function(object) {
  21788. var tag = getTag(object);
  21789. if (tag == mapTag) {
  21790. return mapToArray(object);
  21791. }
  21792. if (tag == setTag) {
  21793. return setToPairs(object);
  21794. }
  21795. return baseToPairs(object, keysFunc(object));
  21796. };
  21797. }
  21798. /**
  21799. * Creates a function that either curries or invokes `func` with optional
  21800. * `this` binding and partially applied arguments.
  21801. *
  21802. * @private
  21803. * @param {Function|string} func The function or method name to wrap.
  21804. * @param {number} bitmask The bitmask flags.
  21805. * 1 - `_.bind`
  21806. * 2 - `_.bindKey`
  21807. * 4 - `_.curry` or `_.curryRight` of a bound function
  21808. * 8 - `_.curry`
  21809. * 16 - `_.curryRight`
  21810. * 32 - `_.partial`
  21811. * 64 - `_.partialRight`
  21812. * 128 - `_.rearg`
  21813. * 256 - `_.ary`
  21814. * 512 - `_.flip`
  21815. * @param {*} [thisArg] The `this` binding of `func`.
  21816. * @param {Array} [partials] The arguments to be partially applied.
  21817. * @param {Array} [holders] The `partials` placeholder indexes.
  21818. * @param {Array} [argPos] The argument positions of the new function.
  21819. * @param {number} [ary] The arity cap of `func`.
  21820. * @param {number} [arity] The arity of `func`.
  21821. * @returns {Function} Returns the new wrapped function.
  21822. */
  21823. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21824. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21825. if (!isBindKey && typeof func != 'function') {
  21826. throw new TypeError(FUNC_ERROR_TEXT);
  21827. }
  21828. var length = partials ? partials.length : 0;
  21829. if (!length) {
  21830. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21831. partials = holders = undefined;
  21832. }
  21833. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21834. arity = arity === undefined ? arity : toInteger(arity);
  21835. length -= holders ? holders.length : 0;
  21836. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21837. var partialsRight = partials,
  21838. holdersRight = holders;
  21839. partials = holders = undefined;
  21840. }
  21841. var data = isBindKey ? undefined : getData(func);
  21842. var newData = [
  21843. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21844. argPos, ary, arity
  21845. ];
  21846. if (data) {
  21847. mergeData(newData, data);
  21848. }
  21849. func = newData[0];
  21850. bitmask = newData[1];
  21851. thisArg = newData[2];
  21852. partials = newData[3];
  21853. holders = newData[4];
  21854. arity = newData[9] = newData[9] === undefined
  21855. ? (isBindKey ? 0 : func.length)
  21856. : nativeMax(newData[9] - length, 0);
  21857. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21858. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21859. }
  21860. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21861. var result = createBind(func, bitmask, thisArg);
  21862. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21863. result = createCurry(func, bitmask, arity);
  21864. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21865. result = createPartial(func, bitmask, thisArg, partials);
  21866. } else {
  21867. result = createHybrid.apply(undefined, newData);
  21868. }
  21869. var setter = data ? baseSetData : setData;
  21870. return setWrapToString(setter(result, newData), func, bitmask);
  21871. }
  21872. /**
  21873. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21874. * of source objects to the destination object for all destination properties
  21875. * that resolve to `undefined`.
  21876. *
  21877. * @private
  21878. * @param {*} objValue The destination value.
  21879. * @param {*} srcValue The source value.
  21880. * @param {string} key The key of the property to assign.
  21881. * @param {Object} object The parent object of `objValue`.
  21882. * @returns {*} Returns the value to assign.
  21883. */
  21884. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21885. if (objValue === undefined ||
  21886. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21887. return srcValue;
  21888. }
  21889. return objValue;
  21890. }
  21891. /**
  21892. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21893. * objects into destination objects that are passed thru.
  21894. *
  21895. * @private
  21896. * @param {*} objValue The destination value.
  21897. * @param {*} srcValue The source value.
  21898. * @param {string} key The key of the property to merge.
  21899. * @param {Object} object The parent object of `objValue`.
  21900. * @param {Object} source The parent object of `srcValue`.
  21901. * @param {Object} [stack] Tracks traversed source values and their merged
  21902. * counterparts.
  21903. * @returns {*} Returns the value to assign.
  21904. */
  21905. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21906. if (isObject(objValue) && isObject(srcValue)) {
  21907. // Recursively merge objects and arrays (susceptible to call stack limits).
  21908. stack.set(srcValue, objValue);
  21909. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21910. stack['delete'](srcValue);
  21911. }
  21912. return objValue;
  21913. }
  21914. /**
  21915. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21916. * objects.
  21917. *
  21918. * @private
  21919. * @param {*} value The value to inspect.
  21920. * @param {string} key The key of the property to inspect.
  21921. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21922. */
  21923. function customOmitClone(value) {
  21924. return isPlainObject(value) ? undefined : value;
  21925. }
  21926. /**
  21927. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21928. * partial deep comparisons.
  21929. *
  21930. * @private
  21931. * @param {Array} array The array to compare.
  21932. * @param {Array} other The other array to compare.
  21933. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21934. * @param {Function} customizer The function to customize comparisons.
  21935. * @param {Function} equalFunc The function to determine equivalents of values.
  21936. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21937. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21938. */
  21939. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21940. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21941. arrLength = array.length,
  21942. othLength = other.length;
  21943. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21944. return false;
  21945. }
  21946. // Assume cyclic values are equal.
  21947. var stacked = stack.get(array);
  21948. if (stacked && stack.get(other)) {
  21949. return stacked == other;
  21950. }
  21951. var index = -1,
  21952. result = true,
  21953. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21954. stack.set(array, other);
  21955. stack.set(other, array);
  21956. // Ignore non-index properties.
  21957. while (++index < arrLength) {
  21958. var arrValue = array[index],
  21959. othValue = other[index];
  21960. if (customizer) {
  21961. var compared = isPartial
  21962. ? customizer(othValue, arrValue, index, other, array, stack)
  21963. : customizer(arrValue, othValue, index, array, other, stack);
  21964. }
  21965. if (compared !== undefined) {
  21966. if (compared) {
  21967. continue;
  21968. }
  21969. result = false;
  21970. break;
  21971. }
  21972. // Recursively compare arrays (susceptible to call stack limits).
  21973. if (seen) {
  21974. if (!arraySome(other, function(othValue, othIndex) {
  21975. if (!cacheHas(seen, othIndex) &&
  21976. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  21977. return seen.push(othIndex);
  21978. }
  21979. })) {
  21980. result = false;
  21981. break;
  21982. }
  21983. } else if (!(
  21984. arrValue === othValue ||
  21985. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  21986. )) {
  21987. result = false;
  21988. break;
  21989. }
  21990. }
  21991. stack['delete'](array);
  21992. stack['delete'](other);
  21993. return result;
  21994. }
  21995. /**
  21996. * A specialized version of `baseIsEqualDeep` for comparing objects of
  21997. * the same `toStringTag`.
  21998. *
  21999. * **Note:** This function only supports comparing values with tags of
  22000. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22001. *
  22002. * @private
  22003. * @param {Object} object The object to compare.
  22004. * @param {Object} other The other object to compare.
  22005. * @param {string} tag The `toStringTag` of the objects to compare.
  22006. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22007. * @param {Function} customizer The function to customize comparisons.
  22008. * @param {Function} equalFunc The function to determine equivalents of values.
  22009. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22010. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22011. */
  22012. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22013. switch (tag) {
  22014. case dataViewTag:
  22015. if ((object.byteLength != other.byteLength) ||
  22016. (object.byteOffset != other.byteOffset)) {
  22017. return false;
  22018. }
  22019. object = object.buffer;
  22020. other = other.buffer;
  22021. case arrayBufferTag:
  22022. if ((object.byteLength != other.byteLength) ||
  22023. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22024. return false;
  22025. }
  22026. return true;
  22027. case boolTag:
  22028. case dateTag:
  22029. case numberTag:
  22030. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22031. // Invalid dates are coerced to `NaN`.
  22032. return eq(+object, +other);
  22033. case errorTag:
  22034. return object.name == other.name && object.message == other.message;
  22035. case regexpTag:
  22036. case stringTag:
  22037. // Coerce regexes to strings and treat strings, primitives and objects,
  22038. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22039. // for more details.
  22040. return object == (other + '');
  22041. case mapTag:
  22042. var convert = mapToArray;
  22043. case setTag:
  22044. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22045. convert || (convert = setToArray);
  22046. if (object.size != other.size && !isPartial) {
  22047. return false;
  22048. }
  22049. // Assume cyclic values are equal.
  22050. var stacked = stack.get(object);
  22051. if (stacked) {
  22052. return stacked == other;
  22053. }
  22054. bitmask |= COMPARE_UNORDERED_FLAG;
  22055. // Recursively compare objects (susceptible to call stack limits).
  22056. stack.set(object, other);
  22057. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22058. stack['delete'](object);
  22059. return result;
  22060. case symbolTag:
  22061. if (symbolValueOf) {
  22062. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22063. }
  22064. }
  22065. return false;
  22066. }
  22067. /**
  22068. * A specialized version of `baseIsEqualDeep` for objects with support for
  22069. * partial deep comparisons.
  22070. *
  22071. * @private
  22072. * @param {Object} object The object to compare.
  22073. * @param {Object} other The other object to compare.
  22074. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22075. * @param {Function} customizer The function to customize comparisons.
  22076. * @param {Function} equalFunc The function to determine equivalents of values.
  22077. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22078. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22079. */
  22080. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22081. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22082. objProps = getAllKeys(object),
  22083. objLength = objProps.length,
  22084. othProps = getAllKeys(other),
  22085. othLength = othProps.length;
  22086. if (objLength != othLength && !isPartial) {
  22087. return false;
  22088. }
  22089. var index = objLength;
  22090. while (index--) {
  22091. var key = objProps[index];
  22092. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22093. return false;
  22094. }
  22095. }
  22096. // Assume cyclic values are equal.
  22097. var stacked = stack.get(object);
  22098. if (stacked && stack.get(other)) {
  22099. return stacked == other;
  22100. }
  22101. var result = true;
  22102. stack.set(object, other);
  22103. stack.set(other, object);
  22104. var skipCtor = isPartial;
  22105. while (++index < objLength) {
  22106. key = objProps[index];
  22107. var objValue = object[key],
  22108. othValue = other[key];
  22109. if (customizer) {
  22110. var compared = isPartial
  22111. ? customizer(othValue, objValue, key, other, object, stack)
  22112. : customizer(objValue, othValue, key, object, other, stack);
  22113. }
  22114. // Recursively compare objects (susceptible to call stack limits).
  22115. if (!(compared === undefined
  22116. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22117. : compared
  22118. )) {
  22119. result = false;
  22120. break;
  22121. }
  22122. skipCtor || (skipCtor = key == 'constructor');
  22123. }
  22124. if (result && !skipCtor) {
  22125. var objCtor = object.constructor,
  22126. othCtor = other.constructor;
  22127. // Non `Object` object instances with different constructors are not equal.
  22128. if (objCtor != othCtor &&
  22129. ('constructor' in object && 'constructor' in other) &&
  22130. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22131. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22132. result = false;
  22133. }
  22134. }
  22135. stack['delete'](object);
  22136. stack['delete'](other);
  22137. return result;
  22138. }
  22139. /**
  22140. * A specialized version of `baseRest` which flattens the rest array.
  22141. *
  22142. * @private
  22143. * @param {Function} func The function to apply a rest parameter to.
  22144. * @returns {Function} Returns the new function.
  22145. */
  22146. function flatRest(func) {
  22147. return setToString(overRest(func, undefined, flatten), func + '');
  22148. }
  22149. /**
  22150. * Creates an array of own enumerable property names and symbols of `object`.
  22151. *
  22152. * @private
  22153. * @param {Object} object The object to query.
  22154. * @returns {Array} Returns the array of property names and symbols.
  22155. */
  22156. function getAllKeys(object) {
  22157. return baseGetAllKeys(object, keys, getSymbols);
  22158. }
  22159. /**
  22160. * Creates an array of own and inherited enumerable property names and
  22161. * symbols of `object`.
  22162. *
  22163. * @private
  22164. * @param {Object} object The object to query.
  22165. * @returns {Array} Returns the array of property names and symbols.
  22166. */
  22167. function getAllKeysIn(object) {
  22168. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22169. }
  22170. /**
  22171. * Gets metadata for `func`.
  22172. *
  22173. * @private
  22174. * @param {Function} func The function to query.
  22175. * @returns {*} Returns the metadata for `func`.
  22176. */
  22177. var getData = !metaMap ? noop : function(func) {
  22178. return metaMap.get(func);
  22179. };
  22180. /**
  22181. * Gets the name of `func`.
  22182. *
  22183. * @private
  22184. * @param {Function} func The function to query.
  22185. * @returns {string} Returns the function name.
  22186. */
  22187. function getFuncName(func) {
  22188. var result = (func.name + ''),
  22189. array = realNames[result],
  22190. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22191. while (length--) {
  22192. var data = array[length],
  22193. otherFunc = data.func;
  22194. if (otherFunc == null || otherFunc == func) {
  22195. return data.name;
  22196. }
  22197. }
  22198. return result;
  22199. }
  22200. /**
  22201. * Gets the argument placeholder value for `func`.
  22202. *
  22203. * @private
  22204. * @param {Function} func The function to inspect.
  22205. * @returns {*} Returns the placeholder value.
  22206. */
  22207. function getHolder(func) {
  22208. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22209. return object.placeholder;
  22210. }
  22211. /**
  22212. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22213. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22214. * If arguments are provided, the chosen function is invoked with them and
  22215. * its result is returned.
  22216. *
  22217. * @private
  22218. * @param {*} [value] The value to convert to an iteratee.
  22219. * @param {number} [arity] The arity of the created iteratee.
  22220. * @returns {Function} Returns the chosen function or its result.
  22221. */
  22222. function getIteratee() {
  22223. var result = lodash.iteratee || iteratee;
  22224. result = result === iteratee ? baseIteratee : result;
  22225. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22226. }
  22227. /**
  22228. * Gets the data for `map`.
  22229. *
  22230. * @private
  22231. * @param {Object} map The map to query.
  22232. * @param {string} key The reference key.
  22233. * @returns {*} Returns the map data.
  22234. */
  22235. function getMapData(map, key) {
  22236. var data = map.__data__;
  22237. return isKeyable(key)
  22238. ? data[typeof key == 'string' ? 'string' : 'hash']
  22239. : data.map;
  22240. }
  22241. /**
  22242. * Gets the property names, values, and compare flags of `object`.
  22243. *
  22244. * @private
  22245. * @param {Object} object The object to query.
  22246. * @returns {Array} Returns the match data of `object`.
  22247. */
  22248. function getMatchData(object) {
  22249. var result = keys(object),
  22250. length = result.length;
  22251. while (length--) {
  22252. var key = result[length],
  22253. value = object[key];
  22254. result[length] = [key, value, isStrictComparable(value)];
  22255. }
  22256. return result;
  22257. }
  22258. /**
  22259. * Gets the native function at `key` of `object`.
  22260. *
  22261. * @private
  22262. * @param {Object} object The object to query.
  22263. * @param {string} key The key of the method to get.
  22264. * @returns {*} Returns the function if it's native, else `undefined`.
  22265. */
  22266. function getNative(object, key) {
  22267. var value = getValue(object, key);
  22268. return baseIsNative(value) ? value : undefined;
  22269. }
  22270. /**
  22271. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22272. *
  22273. * @private
  22274. * @param {*} value The value to query.
  22275. * @returns {string} Returns the raw `toStringTag`.
  22276. */
  22277. function getRawTag(value) {
  22278. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22279. tag = value[symToStringTag];
  22280. try {
  22281. value[symToStringTag] = undefined;
  22282. var unmasked = true;
  22283. } catch (e) {}
  22284. var result = nativeObjectToString.call(value);
  22285. if (unmasked) {
  22286. if (isOwn) {
  22287. value[symToStringTag] = tag;
  22288. } else {
  22289. delete value[symToStringTag];
  22290. }
  22291. }
  22292. return result;
  22293. }
  22294. /**
  22295. * Creates an array of the own enumerable symbols of `object`.
  22296. *
  22297. * @private
  22298. * @param {Object} object The object to query.
  22299. * @returns {Array} Returns the array of symbols.
  22300. */
  22301. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22302. if (object == null) {
  22303. return [];
  22304. }
  22305. object = Object(object);
  22306. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22307. return propertyIsEnumerable.call(object, symbol);
  22308. });
  22309. };
  22310. /**
  22311. * Creates an array of the own and inherited enumerable symbols of `object`.
  22312. *
  22313. * @private
  22314. * @param {Object} object The object to query.
  22315. * @returns {Array} Returns the array of symbols.
  22316. */
  22317. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22318. var result = [];
  22319. while (object) {
  22320. arrayPush(result, getSymbols(object));
  22321. object = getPrototype(object);
  22322. }
  22323. return result;
  22324. };
  22325. /**
  22326. * Gets the `toStringTag` of `value`.
  22327. *
  22328. * @private
  22329. * @param {*} value The value to query.
  22330. * @returns {string} Returns the `toStringTag`.
  22331. */
  22332. var getTag = baseGetTag;
  22333. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22334. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22335. (Map && getTag(new Map) != mapTag) ||
  22336. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22337. (Set && getTag(new Set) != setTag) ||
  22338. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22339. getTag = function(value) {
  22340. var result = baseGetTag(value),
  22341. Ctor = result == objectTag ? value.constructor : undefined,
  22342. ctorString = Ctor ? toSource(Ctor) : '';
  22343. if (ctorString) {
  22344. switch (ctorString) {
  22345. case dataViewCtorString: return dataViewTag;
  22346. case mapCtorString: return mapTag;
  22347. case promiseCtorString: return promiseTag;
  22348. case setCtorString: return setTag;
  22349. case weakMapCtorString: return weakMapTag;
  22350. }
  22351. }
  22352. return result;
  22353. };
  22354. }
  22355. /**
  22356. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22357. *
  22358. * @private
  22359. * @param {number} start The start of the view.
  22360. * @param {number} end The end of the view.
  22361. * @param {Array} transforms The transformations to apply to the view.
  22362. * @returns {Object} Returns an object containing the `start` and `end`
  22363. * positions of the view.
  22364. */
  22365. function getView(start, end, transforms) {
  22366. var index = -1,
  22367. length = transforms.length;
  22368. while (++index < length) {
  22369. var data = transforms[index],
  22370. size = data.size;
  22371. switch (data.type) {
  22372. case 'drop': start += size; break;
  22373. case 'dropRight': end -= size; break;
  22374. case 'take': end = nativeMin(end, start + size); break;
  22375. case 'takeRight': start = nativeMax(start, end - size); break;
  22376. }
  22377. }
  22378. return { 'start': start, 'end': end };
  22379. }
  22380. /**
  22381. * Extracts wrapper details from the `source` body comment.
  22382. *
  22383. * @private
  22384. * @param {string} source The source to inspect.
  22385. * @returns {Array} Returns the wrapper details.
  22386. */
  22387. function getWrapDetails(source) {
  22388. var match = source.match(reWrapDetails);
  22389. return match ? match[1].split(reSplitDetails) : [];
  22390. }
  22391. /**
  22392. * Checks if `path` exists on `object`.
  22393. *
  22394. * @private
  22395. * @param {Object} object The object to query.
  22396. * @param {Array|string} path The path to check.
  22397. * @param {Function} hasFunc The function to check properties.
  22398. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22399. */
  22400. function hasPath(object, path, hasFunc) {
  22401. path = castPath(path, object);
  22402. var index = -1,
  22403. length = path.length,
  22404. result = false;
  22405. while (++index < length) {
  22406. var key = toKey(path[index]);
  22407. if (!(result = object != null && hasFunc(object, key))) {
  22408. break;
  22409. }
  22410. object = object[key];
  22411. }
  22412. if (result || ++index != length) {
  22413. return result;
  22414. }
  22415. length = object == null ? 0 : object.length;
  22416. return !!length && isLength(length) && isIndex(key, length) &&
  22417. (isArray(object) || isArguments(object));
  22418. }
  22419. /**
  22420. * Initializes an array clone.
  22421. *
  22422. * @private
  22423. * @param {Array} array The array to clone.
  22424. * @returns {Array} Returns the initialized clone.
  22425. */
  22426. function initCloneArray(array) {
  22427. var length = array.length,
  22428. result = new array.constructor(length);
  22429. // Add properties assigned by `RegExp#exec`.
  22430. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22431. result.index = array.index;
  22432. result.input = array.input;
  22433. }
  22434. return result;
  22435. }
  22436. /**
  22437. * Initializes an object clone.
  22438. *
  22439. * @private
  22440. * @param {Object} object The object to clone.
  22441. * @returns {Object} Returns the initialized clone.
  22442. */
  22443. function initCloneObject(object) {
  22444. return (typeof object.constructor == 'function' && !isPrototype(object))
  22445. ? baseCreate(getPrototype(object))
  22446. : {};
  22447. }
  22448. /**
  22449. * Initializes an object clone based on its `toStringTag`.
  22450. *
  22451. * **Note:** This function only supports cloning values with tags of
  22452. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22453. *
  22454. * @private
  22455. * @param {Object} object The object to clone.
  22456. * @param {string} tag The `toStringTag` of the object to clone.
  22457. * @param {boolean} [isDeep] Specify a deep clone.
  22458. * @returns {Object} Returns the initialized clone.
  22459. */
  22460. function initCloneByTag(object, tag, isDeep) {
  22461. var Ctor = object.constructor;
  22462. switch (tag) {
  22463. case arrayBufferTag:
  22464. return cloneArrayBuffer(object);
  22465. case boolTag:
  22466. case dateTag:
  22467. return new Ctor(+object);
  22468. case dataViewTag:
  22469. return cloneDataView(object, isDeep);
  22470. case float32Tag: case float64Tag:
  22471. case int8Tag: case int16Tag: case int32Tag:
  22472. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22473. return cloneTypedArray(object, isDeep);
  22474. case mapTag:
  22475. return new Ctor;
  22476. case numberTag:
  22477. case stringTag:
  22478. return new Ctor(object);
  22479. case regexpTag:
  22480. return cloneRegExp(object);
  22481. case setTag:
  22482. return new Ctor;
  22483. case symbolTag:
  22484. return cloneSymbol(object);
  22485. }
  22486. }
  22487. /**
  22488. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22489. *
  22490. * @private
  22491. * @param {string} source The source to modify.
  22492. * @returns {Array} details The details to insert.
  22493. * @returns {string} Returns the modified source.
  22494. */
  22495. function insertWrapDetails(source, details) {
  22496. var length = details.length;
  22497. if (!length) {
  22498. return source;
  22499. }
  22500. var lastIndex = length - 1;
  22501. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22502. details = details.join(length > 2 ? ', ' : ' ');
  22503. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22504. }
  22505. /**
  22506. * Checks if `value` is a flattenable `arguments` object or array.
  22507. *
  22508. * @private
  22509. * @param {*} value The value to check.
  22510. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22511. */
  22512. function isFlattenable(value) {
  22513. return isArray(value) || isArguments(value) ||
  22514. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22515. }
  22516. /**
  22517. * Checks if `value` is a valid array-like index.
  22518. *
  22519. * @private
  22520. * @param {*} value The value to check.
  22521. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22522. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22523. */
  22524. function isIndex(value, length) {
  22525. var type = typeof value;
  22526. length = length == null ? MAX_SAFE_INTEGER : length;
  22527. return !!length &&
  22528. (type == 'number' ||
  22529. (type != 'symbol' && reIsUint.test(value))) &&
  22530. (value > -1 && value % 1 == 0 && value < length);
  22531. }
  22532. /**
  22533. * Checks if the given arguments are from an iteratee call.
  22534. *
  22535. * @private
  22536. * @param {*} value The potential iteratee value argument.
  22537. * @param {*} index The potential iteratee index or key argument.
  22538. * @param {*} object The potential iteratee object argument.
  22539. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22540. * else `false`.
  22541. */
  22542. function isIterateeCall(value, index, object) {
  22543. if (!isObject(object)) {
  22544. return false;
  22545. }
  22546. var type = typeof index;
  22547. if (type == 'number'
  22548. ? (isArrayLike(object) && isIndex(index, object.length))
  22549. : (type == 'string' && index in object)
  22550. ) {
  22551. return eq(object[index], value);
  22552. }
  22553. return false;
  22554. }
  22555. /**
  22556. * Checks if `value` is a property name and not a property path.
  22557. *
  22558. * @private
  22559. * @param {*} value The value to check.
  22560. * @param {Object} [object] The object to query keys on.
  22561. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22562. */
  22563. function isKey(value, object) {
  22564. if (isArray(value)) {
  22565. return false;
  22566. }
  22567. var type = typeof value;
  22568. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22569. value == null || isSymbol(value)) {
  22570. return true;
  22571. }
  22572. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22573. (object != null && value in Object(object));
  22574. }
  22575. /**
  22576. * Checks if `value` is suitable for use as unique object key.
  22577. *
  22578. * @private
  22579. * @param {*} value The value to check.
  22580. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22581. */
  22582. function isKeyable(value) {
  22583. var type = typeof value;
  22584. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22585. ? (value !== '__proto__')
  22586. : (value === null);
  22587. }
  22588. /**
  22589. * Checks if `func` has a lazy counterpart.
  22590. *
  22591. * @private
  22592. * @param {Function} func The function to check.
  22593. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22594. * else `false`.
  22595. */
  22596. function isLaziable(func) {
  22597. var funcName = getFuncName(func),
  22598. other = lodash[funcName];
  22599. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22600. return false;
  22601. }
  22602. if (func === other) {
  22603. return true;
  22604. }
  22605. var data = getData(other);
  22606. return !!data && func === data[0];
  22607. }
  22608. /**
  22609. * Checks if `func` has its source masked.
  22610. *
  22611. * @private
  22612. * @param {Function} func The function to check.
  22613. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22614. */
  22615. function isMasked(func) {
  22616. return !!maskSrcKey && (maskSrcKey in func);
  22617. }
  22618. /**
  22619. * Checks if `func` is capable of being masked.
  22620. *
  22621. * @private
  22622. * @param {*} value The value to check.
  22623. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22624. */
  22625. var isMaskable = coreJsData ? isFunction : stubFalse;
  22626. /**
  22627. * Checks if `value` is likely a prototype object.
  22628. *
  22629. * @private
  22630. * @param {*} value The value to check.
  22631. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22632. */
  22633. function isPrototype(value) {
  22634. var Ctor = value && value.constructor,
  22635. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22636. return value === proto;
  22637. }
  22638. /**
  22639. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22640. *
  22641. * @private
  22642. * @param {*} value The value to check.
  22643. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22644. * equality comparisons, else `false`.
  22645. */
  22646. function isStrictComparable(value) {
  22647. return value === value && !isObject(value);
  22648. }
  22649. /**
  22650. * A specialized version of `matchesProperty` for source values suitable
  22651. * for strict equality comparisons, i.e. `===`.
  22652. *
  22653. * @private
  22654. * @param {string} key The key of the property to get.
  22655. * @param {*} srcValue The value to match.
  22656. * @returns {Function} Returns the new spec function.
  22657. */
  22658. function matchesStrictComparable(key, srcValue) {
  22659. return function(object) {
  22660. if (object == null) {
  22661. return false;
  22662. }
  22663. return object[key] === srcValue &&
  22664. (srcValue !== undefined || (key in Object(object)));
  22665. };
  22666. }
  22667. /**
  22668. * A specialized version of `_.memoize` which clears the memoized function's
  22669. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22670. *
  22671. * @private
  22672. * @param {Function} func The function to have its output memoized.
  22673. * @returns {Function} Returns the new memoized function.
  22674. */
  22675. function memoizeCapped(func) {
  22676. var result = memoize(func, function(key) {
  22677. if (cache.size === MAX_MEMOIZE_SIZE) {
  22678. cache.clear();
  22679. }
  22680. return key;
  22681. });
  22682. var cache = result.cache;
  22683. return result;
  22684. }
  22685. /**
  22686. * Merges the function metadata of `source` into `data`.
  22687. *
  22688. * Merging metadata reduces the number of wrappers used to invoke a function.
  22689. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22690. * may be applied regardless of execution order. Methods like `_.ary` and
  22691. * `_.rearg` modify function arguments, making the order in which they are
  22692. * executed important, preventing the merging of metadata. However, we make
  22693. * an exception for a safe combined case where curried functions have `_.ary`
  22694. * and or `_.rearg` applied.
  22695. *
  22696. * @private
  22697. * @param {Array} data The destination metadata.
  22698. * @param {Array} source The source metadata.
  22699. * @returns {Array} Returns `data`.
  22700. */
  22701. function mergeData(data, source) {
  22702. var bitmask = data[1],
  22703. srcBitmask = source[1],
  22704. newBitmask = bitmask | srcBitmask,
  22705. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22706. var isCombo =
  22707. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22708. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22709. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22710. // Exit early if metadata can't be merged.
  22711. if (!(isCommon || isCombo)) {
  22712. return data;
  22713. }
  22714. // Use source `thisArg` if available.
  22715. if (srcBitmask & WRAP_BIND_FLAG) {
  22716. data[2] = source[2];
  22717. // Set when currying a bound function.
  22718. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22719. }
  22720. // Compose partial arguments.
  22721. var value = source[3];
  22722. if (value) {
  22723. var partials = data[3];
  22724. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22725. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22726. }
  22727. // Compose partial right arguments.
  22728. value = source[5];
  22729. if (value) {
  22730. partials = data[5];
  22731. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22732. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22733. }
  22734. // Use source `argPos` if available.
  22735. value = source[7];
  22736. if (value) {
  22737. data[7] = value;
  22738. }
  22739. // Use source `ary` if it's smaller.
  22740. if (srcBitmask & WRAP_ARY_FLAG) {
  22741. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22742. }
  22743. // Use source `arity` if one is not provided.
  22744. if (data[9] == null) {
  22745. data[9] = source[9];
  22746. }
  22747. // Use source `func` and merge bitmasks.
  22748. data[0] = source[0];
  22749. data[1] = newBitmask;
  22750. return data;
  22751. }
  22752. /**
  22753. * This function is like
  22754. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22755. * except that it includes inherited enumerable properties.
  22756. *
  22757. * @private
  22758. * @param {Object} object The object to query.
  22759. * @returns {Array} Returns the array of property names.
  22760. */
  22761. function nativeKeysIn(object) {
  22762. var result = [];
  22763. if (object != null) {
  22764. for (var key in Object(object)) {
  22765. result.push(key);
  22766. }
  22767. }
  22768. return result;
  22769. }
  22770. /**
  22771. * Converts `value` to a string using `Object.prototype.toString`.
  22772. *
  22773. * @private
  22774. * @param {*} value The value to convert.
  22775. * @returns {string} Returns the converted string.
  22776. */
  22777. function objectToString(value) {
  22778. return nativeObjectToString.call(value);
  22779. }
  22780. /**
  22781. * A specialized version of `baseRest` which transforms the rest array.
  22782. *
  22783. * @private
  22784. * @param {Function} func The function to apply a rest parameter to.
  22785. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22786. * @param {Function} transform The rest array transform.
  22787. * @returns {Function} Returns the new function.
  22788. */
  22789. function overRest(func, start, transform) {
  22790. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22791. return function() {
  22792. var args = arguments,
  22793. index = -1,
  22794. length = nativeMax(args.length - start, 0),
  22795. array = Array(length);
  22796. while (++index < length) {
  22797. array[index] = args[start + index];
  22798. }
  22799. index = -1;
  22800. var otherArgs = Array(start + 1);
  22801. while (++index < start) {
  22802. otherArgs[index] = args[index];
  22803. }
  22804. otherArgs[start] = transform(array);
  22805. return apply(func, this, otherArgs);
  22806. };
  22807. }
  22808. /**
  22809. * Gets the parent value at `path` of `object`.
  22810. *
  22811. * @private
  22812. * @param {Object} object The object to query.
  22813. * @param {Array} path The path to get the parent value of.
  22814. * @returns {*} Returns the parent value.
  22815. */
  22816. function parent(object, path) {
  22817. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22818. }
  22819. /**
  22820. * Reorder `array` according to the specified indexes where the element at
  22821. * the first index is assigned as the first element, the element at
  22822. * the second index is assigned as the second element, and so on.
  22823. *
  22824. * @private
  22825. * @param {Array} array The array to reorder.
  22826. * @param {Array} indexes The arranged array indexes.
  22827. * @returns {Array} Returns `array`.
  22828. */
  22829. function reorder(array, indexes) {
  22830. var arrLength = array.length,
  22831. length = nativeMin(indexes.length, arrLength),
  22832. oldArray = copyArray(array);
  22833. while (length--) {
  22834. var index = indexes[length];
  22835. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22836. }
  22837. return array;
  22838. }
  22839. /**
  22840. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22841. *
  22842. * @private
  22843. * @param {Object} object The object to query.
  22844. * @param {string} key The key of the property to get.
  22845. * @returns {*} Returns the property value.
  22846. */
  22847. function safeGet(object, key) {
  22848. if (key === 'constructor' && typeof object[key] === 'function') {
  22849. return;
  22850. }
  22851. if (key == '__proto__') {
  22852. return;
  22853. }
  22854. return object[key];
  22855. }
  22856. /**
  22857. * Sets metadata for `func`.
  22858. *
  22859. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22860. * period of time, it will trip its breaker and transition to an identity
  22861. * function to avoid garbage collection pauses in V8. See
  22862. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22863. * for more details.
  22864. *
  22865. * @private
  22866. * @param {Function} func The function to associate metadata with.
  22867. * @param {*} data The metadata.
  22868. * @returns {Function} Returns `func`.
  22869. */
  22870. var setData = shortOut(baseSetData);
  22871. /**
  22872. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22873. *
  22874. * @private
  22875. * @param {Function} func The function to delay.
  22876. * @param {number} wait The number of milliseconds to delay invocation.
  22877. * @returns {number|Object} Returns the timer id or timeout object.
  22878. */
  22879. var setTimeout = ctxSetTimeout || function(func, wait) {
  22880. return root.setTimeout(func, wait);
  22881. };
  22882. /**
  22883. * Sets the `toString` method of `func` to return `string`.
  22884. *
  22885. * @private
  22886. * @param {Function} func The function to modify.
  22887. * @param {Function} string The `toString` result.
  22888. * @returns {Function} Returns `func`.
  22889. */
  22890. var setToString = shortOut(baseSetToString);
  22891. /**
  22892. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22893. * with wrapper details in a comment at the top of the source body.
  22894. *
  22895. * @private
  22896. * @param {Function} wrapper The function to modify.
  22897. * @param {Function} reference The reference function.
  22898. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22899. * @returns {Function} Returns `wrapper`.
  22900. */
  22901. function setWrapToString(wrapper, reference, bitmask) {
  22902. var source = (reference + '');
  22903. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22904. }
  22905. /**
  22906. * Creates a function that'll short out and invoke `identity` instead
  22907. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22908. * milliseconds.
  22909. *
  22910. * @private
  22911. * @param {Function} func The function to restrict.
  22912. * @returns {Function} Returns the new shortable function.
  22913. */
  22914. function shortOut(func) {
  22915. var count = 0,
  22916. lastCalled = 0;
  22917. return function() {
  22918. var stamp = nativeNow(),
  22919. remaining = HOT_SPAN - (stamp - lastCalled);
  22920. lastCalled = stamp;
  22921. if (remaining > 0) {
  22922. if (++count >= HOT_COUNT) {
  22923. return arguments[0];
  22924. }
  22925. } else {
  22926. count = 0;
  22927. }
  22928. return func.apply(undefined, arguments);
  22929. };
  22930. }
  22931. /**
  22932. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22933. *
  22934. * @private
  22935. * @param {Array} array The array to shuffle.
  22936. * @param {number} [size=array.length] The size of `array`.
  22937. * @returns {Array} Returns `array`.
  22938. */
  22939. function shuffleSelf(array, size) {
  22940. var index = -1,
  22941. length = array.length,
  22942. lastIndex = length - 1;
  22943. size = size === undefined ? length : size;
  22944. while (++index < size) {
  22945. var rand = baseRandom(index, lastIndex),
  22946. value = array[rand];
  22947. array[rand] = array[index];
  22948. array[index] = value;
  22949. }
  22950. array.length = size;
  22951. return array;
  22952. }
  22953. /**
  22954. * Converts `string` to a property path array.
  22955. *
  22956. * @private
  22957. * @param {string} string The string to convert.
  22958. * @returns {Array} Returns the property path array.
  22959. */
  22960. var stringToPath = memoizeCapped(function(string) {
  22961. var result = [];
  22962. if (string.charCodeAt(0) === 46 /* . */) {
  22963. result.push('');
  22964. }
  22965. string.replace(rePropName, function(match, number, quote, subString) {
  22966. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  22967. });
  22968. return result;
  22969. });
  22970. /**
  22971. * Converts `value` to a string key if it's not a string or symbol.
  22972. *
  22973. * @private
  22974. * @param {*} value The value to inspect.
  22975. * @returns {string|symbol} Returns the key.
  22976. */
  22977. function toKey(value) {
  22978. if (typeof value == 'string' || isSymbol(value)) {
  22979. return value;
  22980. }
  22981. var result = (value + '');
  22982. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  22983. }
  22984. /**
  22985. * Converts `func` to its source code.
  22986. *
  22987. * @private
  22988. * @param {Function} func The function to convert.
  22989. * @returns {string} Returns the source code.
  22990. */
  22991. function toSource(func) {
  22992. if (func != null) {
  22993. try {
  22994. return funcToString.call(func);
  22995. } catch (e) {}
  22996. try {
  22997. return (func + '');
  22998. } catch (e) {}
  22999. }
  23000. return '';
  23001. }
  23002. /**
  23003. * Updates wrapper `details` based on `bitmask` flags.
  23004. *
  23005. * @private
  23006. * @returns {Array} details The details to modify.
  23007. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23008. * @returns {Array} Returns `details`.
  23009. */
  23010. function updateWrapDetails(details, bitmask) {
  23011. arrayEach(wrapFlags, function(pair) {
  23012. var value = '_.' + pair[0];
  23013. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23014. details.push(value);
  23015. }
  23016. });
  23017. return details.sort();
  23018. }
  23019. /**
  23020. * Creates a clone of `wrapper`.
  23021. *
  23022. * @private
  23023. * @param {Object} wrapper The wrapper to clone.
  23024. * @returns {Object} Returns the cloned wrapper.
  23025. */
  23026. function wrapperClone(wrapper) {
  23027. if (wrapper instanceof LazyWrapper) {
  23028. return wrapper.clone();
  23029. }
  23030. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23031. result.__actions__ = copyArray(wrapper.__actions__);
  23032. result.__index__ = wrapper.__index__;
  23033. result.__values__ = wrapper.__values__;
  23034. return result;
  23035. }
  23036. /*------------------------------------------------------------------------*/
  23037. /**
  23038. * Creates an array of elements split into groups the length of `size`.
  23039. * If `array` can't be split evenly, the final chunk will be the remaining
  23040. * elements.
  23041. *
  23042. * @static
  23043. * @memberOf _
  23044. * @since 3.0.0
  23045. * @category Array
  23046. * @param {Array} array The array to process.
  23047. * @param {number} [size=1] The length of each chunk
  23048. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23049. * @returns {Array} Returns the new array of chunks.
  23050. * @example
  23051. *
  23052. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23053. * // => [['a', 'b'], ['c', 'd']]
  23054. *
  23055. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23056. * // => [['a', 'b', 'c'], ['d']]
  23057. */
  23058. function chunk(array, size, guard) {
  23059. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23060. size = 1;
  23061. } else {
  23062. size = nativeMax(toInteger(size), 0);
  23063. }
  23064. var length = array == null ? 0 : array.length;
  23065. if (!length || size < 1) {
  23066. return [];
  23067. }
  23068. var index = 0,
  23069. resIndex = 0,
  23070. result = Array(nativeCeil(length / size));
  23071. while (index < length) {
  23072. result[resIndex++] = baseSlice(array, index, (index += size));
  23073. }
  23074. return result;
  23075. }
  23076. /**
  23077. * Creates an array with all falsey values removed. The values `false`, `null`,
  23078. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23079. *
  23080. * @static
  23081. * @memberOf _
  23082. * @since 0.1.0
  23083. * @category Array
  23084. * @param {Array} array The array to compact.
  23085. * @returns {Array} Returns the new array of filtered values.
  23086. * @example
  23087. *
  23088. * _.compact([0, 1, false, 2, '', 3]);
  23089. * // => [1, 2, 3]
  23090. */
  23091. function compact(array) {
  23092. var index = -1,
  23093. length = array == null ? 0 : array.length,
  23094. resIndex = 0,
  23095. result = [];
  23096. while (++index < length) {
  23097. var value = array[index];
  23098. if (value) {
  23099. result[resIndex++] = value;
  23100. }
  23101. }
  23102. return result;
  23103. }
  23104. /**
  23105. * Creates a new array concatenating `array` with any additional arrays
  23106. * and/or values.
  23107. *
  23108. * @static
  23109. * @memberOf _
  23110. * @since 4.0.0
  23111. * @category Array
  23112. * @param {Array} array The array to concatenate.
  23113. * @param {...*} [values] The values to concatenate.
  23114. * @returns {Array} Returns the new concatenated array.
  23115. * @example
  23116. *
  23117. * var array = [1];
  23118. * var other = _.concat(array, 2, [3], [[4]]);
  23119. *
  23120. * console.log(other);
  23121. * // => [1, 2, 3, [4]]
  23122. *
  23123. * console.log(array);
  23124. * // => [1]
  23125. */
  23126. function concat() {
  23127. var length = arguments.length;
  23128. if (!length) {
  23129. return [];
  23130. }
  23131. var args = Array(length - 1),
  23132. array = arguments[0],
  23133. index = length;
  23134. while (index--) {
  23135. args[index - 1] = arguments[index];
  23136. }
  23137. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23138. }
  23139. /**
  23140. * Creates an array of `array` values not included in the other given arrays
  23141. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23142. * for equality comparisons. The order and references of result values are
  23143. * determined by the first array.
  23144. *
  23145. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23146. *
  23147. * @static
  23148. * @memberOf _
  23149. * @since 0.1.0
  23150. * @category Array
  23151. * @param {Array} array The array to inspect.
  23152. * @param {...Array} [values] The values to exclude.
  23153. * @returns {Array} Returns the new array of filtered values.
  23154. * @see _.without, _.xor
  23155. * @example
  23156. *
  23157. * _.difference([2, 1], [2, 3]);
  23158. * // => [1]
  23159. */
  23160. var difference = baseRest(function(array, values) {
  23161. return isArrayLikeObject(array)
  23162. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23163. : [];
  23164. });
  23165. /**
  23166. * This method is like `_.difference` except that it accepts `iteratee` which
  23167. * is invoked for each element of `array` and `values` to generate the criterion
  23168. * by which they're compared. The order and references of result values are
  23169. * determined by the first array. The iteratee is invoked with one argument:
  23170. * (value).
  23171. *
  23172. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23173. *
  23174. * @static
  23175. * @memberOf _
  23176. * @since 4.0.0
  23177. * @category Array
  23178. * @param {Array} array The array to inspect.
  23179. * @param {...Array} [values] The values to exclude.
  23180. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23181. * @returns {Array} Returns the new array of filtered values.
  23182. * @example
  23183. *
  23184. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23185. * // => [1.2]
  23186. *
  23187. * // The `_.property` iteratee shorthand.
  23188. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23189. * // => [{ 'x': 2 }]
  23190. */
  23191. var differenceBy = baseRest(function(array, values) {
  23192. var iteratee = last(values);
  23193. if (isArrayLikeObject(iteratee)) {
  23194. iteratee = undefined;
  23195. }
  23196. return isArrayLikeObject(array)
  23197. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23198. : [];
  23199. });
  23200. /**
  23201. * This method is like `_.difference` except that it accepts `comparator`
  23202. * which is invoked to compare elements of `array` to `values`. The order and
  23203. * references of result values are determined by the first array. The comparator
  23204. * is invoked with two arguments: (arrVal, othVal).
  23205. *
  23206. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23207. *
  23208. * @static
  23209. * @memberOf _
  23210. * @since 4.0.0
  23211. * @category Array
  23212. * @param {Array} array The array to inspect.
  23213. * @param {...Array} [values] The values to exclude.
  23214. * @param {Function} [comparator] The comparator invoked per element.
  23215. * @returns {Array} Returns the new array of filtered values.
  23216. * @example
  23217. *
  23218. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23219. *
  23220. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23221. * // => [{ 'x': 2, 'y': 1 }]
  23222. */
  23223. var differenceWith = baseRest(function(array, values) {
  23224. var comparator = last(values);
  23225. if (isArrayLikeObject(comparator)) {
  23226. comparator = undefined;
  23227. }
  23228. return isArrayLikeObject(array)
  23229. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23230. : [];
  23231. });
  23232. /**
  23233. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23234. *
  23235. * @static
  23236. * @memberOf _
  23237. * @since 0.5.0
  23238. * @category Array
  23239. * @param {Array} array The array to query.
  23240. * @param {number} [n=1] The number of elements to drop.
  23241. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23242. * @returns {Array} Returns the slice of `array`.
  23243. * @example
  23244. *
  23245. * _.drop([1, 2, 3]);
  23246. * // => [2, 3]
  23247. *
  23248. * _.drop([1, 2, 3], 2);
  23249. * // => [3]
  23250. *
  23251. * _.drop([1, 2, 3], 5);
  23252. * // => []
  23253. *
  23254. * _.drop([1, 2, 3], 0);
  23255. * // => [1, 2, 3]
  23256. */
  23257. function drop(array, n, guard) {
  23258. var length = array == null ? 0 : array.length;
  23259. if (!length) {
  23260. return [];
  23261. }
  23262. n = (guard || n === undefined) ? 1 : toInteger(n);
  23263. return baseSlice(array, n < 0 ? 0 : n, length);
  23264. }
  23265. /**
  23266. * Creates a slice of `array` with `n` elements dropped from the end.
  23267. *
  23268. * @static
  23269. * @memberOf _
  23270. * @since 3.0.0
  23271. * @category Array
  23272. * @param {Array} array The array to query.
  23273. * @param {number} [n=1] The number of elements to drop.
  23274. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23275. * @returns {Array} Returns the slice of `array`.
  23276. * @example
  23277. *
  23278. * _.dropRight([1, 2, 3]);
  23279. * // => [1, 2]
  23280. *
  23281. * _.dropRight([1, 2, 3], 2);
  23282. * // => [1]
  23283. *
  23284. * _.dropRight([1, 2, 3], 5);
  23285. * // => []
  23286. *
  23287. * _.dropRight([1, 2, 3], 0);
  23288. * // => [1, 2, 3]
  23289. */
  23290. function dropRight(array, n, guard) {
  23291. var length = array == null ? 0 : array.length;
  23292. if (!length) {
  23293. return [];
  23294. }
  23295. n = (guard || n === undefined) ? 1 : toInteger(n);
  23296. n = length - n;
  23297. return baseSlice(array, 0, n < 0 ? 0 : n);
  23298. }
  23299. /**
  23300. * Creates a slice of `array` excluding elements dropped from the end.
  23301. * Elements are dropped until `predicate` returns falsey. The predicate is
  23302. * invoked with three arguments: (value, index, array).
  23303. *
  23304. * @static
  23305. * @memberOf _
  23306. * @since 3.0.0
  23307. * @category Array
  23308. * @param {Array} array The array to query.
  23309. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23310. * @returns {Array} Returns the slice of `array`.
  23311. * @example
  23312. *
  23313. * var users = [
  23314. * { 'user': 'barney', 'active': true },
  23315. * { 'user': 'fred', 'active': false },
  23316. * { 'user': 'pebbles', 'active': false }
  23317. * ];
  23318. *
  23319. * _.dropRightWhile(users, function(o) { return !o.active; });
  23320. * // => objects for ['barney']
  23321. *
  23322. * // The `_.matches` iteratee shorthand.
  23323. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23324. * // => objects for ['barney', 'fred']
  23325. *
  23326. * // The `_.matchesProperty` iteratee shorthand.
  23327. * _.dropRightWhile(users, ['active', false]);
  23328. * // => objects for ['barney']
  23329. *
  23330. * // The `_.property` iteratee shorthand.
  23331. * _.dropRightWhile(users, 'active');
  23332. * // => objects for ['barney', 'fred', 'pebbles']
  23333. */
  23334. function dropRightWhile(array, predicate) {
  23335. return (array && array.length)
  23336. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23337. : [];
  23338. }
  23339. /**
  23340. * Creates a slice of `array` excluding elements dropped from the beginning.
  23341. * Elements are dropped until `predicate` returns falsey. The predicate is
  23342. * invoked with three arguments: (value, index, array).
  23343. *
  23344. * @static
  23345. * @memberOf _
  23346. * @since 3.0.0
  23347. * @category Array
  23348. * @param {Array} array The array to query.
  23349. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23350. * @returns {Array} Returns the slice of `array`.
  23351. * @example
  23352. *
  23353. * var users = [
  23354. * { 'user': 'barney', 'active': false },
  23355. * { 'user': 'fred', 'active': false },
  23356. * { 'user': 'pebbles', 'active': true }
  23357. * ];
  23358. *
  23359. * _.dropWhile(users, function(o) { return !o.active; });
  23360. * // => objects for ['pebbles']
  23361. *
  23362. * // The `_.matches` iteratee shorthand.
  23363. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23364. * // => objects for ['fred', 'pebbles']
  23365. *
  23366. * // The `_.matchesProperty` iteratee shorthand.
  23367. * _.dropWhile(users, ['active', false]);
  23368. * // => objects for ['pebbles']
  23369. *
  23370. * // The `_.property` iteratee shorthand.
  23371. * _.dropWhile(users, 'active');
  23372. * // => objects for ['barney', 'fred', 'pebbles']
  23373. */
  23374. function dropWhile(array, predicate) {
  23375. return (array && array.length)
  23376. ? baseWhile(array, getIteratee(predicate, 3), true)
  23377. : [];
  23378. }
  23379. /**
  23380. * Fills elements of `array` with `value` from `start` up to, but not
  23381. * including, `end`.
  23382. *
  23383. * **Note:** This method mutates `array`.
  23384. *
  23385. * @static
  23386. * @memberOf _
  23387. * @since 3.2.0
  23388. * @category Array
  23389. * @param {Array} array The array to fill.
  23390. * @param {*} value The value to fill `array` with.
  23391. * @param {number} [start=0] The start position.
  23392. * @param {number} [end=array.length] The end position.
  23393. * @returns {Array} Returns `array`.
  23394. * @example
  23395. *
  23396. * var array = [1, 2, 3];
  23397. *
  23398. * _.fill(array, 'a');
  23399. * console.log(array);
  23400. * // => ['a', 'a', 'a']
  23401. *
  23402. * _.fill(Array(3), 2);
  23403. * // => [2, 2, 2]
  23404. *
  23405. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23406. * // => [4, '*', '*', 10]
  23407. */
  23408. function fill(array, value, start, end) {
  23409. var length = array == null ? 0 : array.length;
  23410. if (!length) {
  23411. return [];
  23412. }
  23413. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23414. start = 0;
  23415. end = length;
  23416. }
  23417. return baseFill(array, value, start, end);
  23418. }
  23419. /**
  23420. * This method is like `_.find` except that it returns the index of the first
  23421. * element `predicate` returns truthy for instead of the element itself.
  23422. *
  23423. * @static
  23424. * @memberOf _
  23425. * @since 1.1.0
  23426. * @category Array
  23427. * @param {Array} array The array to inspect.
  23428. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23429. * @param {number} [fromIndex=0] The index to search from.
  23430. * @returns {number} Returns the index of the found element, else `-1`.
  23431. * @example
  23432. *
  23433. * var users = [
  23434. * { 'user': 'barney', 'active': false },
  23435. * { 'user': 'fred', 'active': false },
  23436. * { 'user': 'pebbles', 'active': true }
  23437. * ];
  23438. *
  23439. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23440. * // => 0
  23441. *
  23442. * // The `_.matches` iteratee shorthand.
  23443. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23444. * // => 1
  23445. *
  23446. * // The `_.matchesProperty` iteratee shorthand.
  23447. * _.findIndex(users, ['active', false]);
  23448. * // => 0
  23449. *
  23450. * // The `_.property` iteratee shorthand.
  23451. * _.findIndex(users, 'active');
  23452. * // => 2
  23453. */
  23454. function findIndex(array, predicate, fromIndex) {
  23455. var length = array == null ? 0 : array.length;
  23456. if (!length) {
  23457. return -1;
  23458. }
  23459. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23460. if (index < 0) {
  23461. index = nativeMax(length + index, 0);
  23462. }
  23463. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23464. }
  23465. /**
  23466. * This method is like `_.findIndex` except that it iterates over elements
  23467. * of `collection` from right to left.
  23468. *
  23469. * @static
  23470. * @memberOf _
  23471. * @since 2.0.0
  23472. * @category Array
  23473. * @param {Array} array The array to inspect.
  23474. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23475. * @param {number} [fromIndex=array.length-1] The index to search from.
  23476. * @returns {number} Returns the index of the found element, else `-1`.
  23477. * @example
  23478. *
  23479. * var users = [
  23480. * { 'user': 'barney', 'active': true },
  23481. * { 'user': 'fred', 'active': false },
  23482. * { 'user': 'pebbles', 'active': false }
  23483. * ];
  23484. *
  23485. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23486. * // => 2
  23487. *
  23488. * // The `_.matches` iteratee shorthand.
  23489. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23490. * // => 0
  23491. *
  23492. * // The `_.matchesProperty` iteratee shorthand.
  23493. * _.findLastIndex(users, ['active', false]);
  23494. * // => 2
  23495. *
  23496. * // The `_.property` iteratee shorthand.
  23497. * _.findLastIndex(users, 'active');
  23498. * // => 0
  23499. */
  23500. function findLastIndex(array, predicate, fromIndex) {
  23501. var length = array == null ? 0 : array.length;
  23502. if (!length) {
  23503. return -1;
  23504. }
  23505. var index = length - 1;
  23506. if (fromIndex !== undefined) {
  23507. index = toInteger(fromIndex);
  23508. index = fromIndex < 0
  23509. ? nativeMax(length + index, 0)
  23510. : nativeMin(index, length - 1);
  23511. }
  23512. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23513. }
  23514. /**
  23515. * Flattens `array` a single level deep.
  23516. *
  23517. * @static
  23518. * @memberOf _
  23519. * @since 0.1.0
  23520. * @category Array
  23521. * @param {Array} array The array to flatten.
  23522. * @returns {Array} Returns the new flattened array.
  23523. * @example
  23524. *
  23525. * _.flatten([1, [2, [3, [4]], 5]]);
  23526. * // => [1, 2, [3, [4]], 5]
  23527. */
  23528. function flatten(array) {
  23529. var length = array == null ? 0 : array.length;
  23530. return length ? baseFlatten(array, 1) : [];
  23531. }
  23532. /**
  23533. * Recursively flattens `array`.
  23534. *
  23535. * @static
  23536. * @memberOf _
  23537. * @since 3.0.0
  23538. * @category Array
  23539. * @param {Array} array The array to flatten.
  23540. * @returns {Array} Returns the new flattened array.
  23541. * @example
  23542. *
  23543. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23544. * // => [1, 2, 3, 4, 5]
  23545. */
  23546. function flattenDeep(array) {
  23547. var length = array == null ? 0 : array.length;
  23548. return length ? baseFlatten(array, INFINITY) : [];
  23549. }
  23550. /**
  23551. * Recursively flatten `array` up to `depth` times.
  23552. *
  23553. * @static
  23554. * @memberOf _
  23555. * @since 4.4.0
  23556. * @category Array
  23557. * @param {Array} array The array to flatten.
  23558. * @param {number} [depth=1] The maximum recursion depth.
  23559. * @returns {Array} Returns the new flattened array.
  23560. * @example
  23561. *
  23562. * var array = [1, [2, [3, [4]], 5]];
  23563. *
  23564. * _.flattenDepth(array, 1);
  23565. * // => [1, 2, [3, [4]], 5]
  23566. *
  23567. * _.flattenDepth(array, 2);
  23568. * // => [1, 2, 3, [4], 5]
  23569. */
  23570. function flattenDepth(array, depth) {
  23571. var length = array == null ? 0 : array.length;
  23572. if (!length) {
  23573. return [];
  23574. }
  23575. depth = depth === undefined ? 1 : toInteger(depth);
  23576. return baseFlatten(array, depth);
  23577. }
  23578. /**
  23579. * The inverse of `_.toPairs`; this method returns an object composed
  23580. * from key-value `pairs`.
  23581. *
  23582. * @static
  23583. * @memberOf _
  23584. * @since 4.0.0
  23585. * @category Array
  23586. * @param {Array} pairs The key-value pairs.
  23587. * @returns {Object} Returns the new object.
  23588. * @example
  23589. *
  23590. * _.fromPairs([['a', 1], ['b', 2]]);
  23591. * // => { 'a': 1, 'b': 2 }
  23592. */
  23593. function fromPairs(pairs) {
  23594. var index = -1,
  23595. length = pairs == null ? 0 : pairs.length,
  23596. result = {};
  23597. while (++index < length) {
  23598. var pair = pairs[index];
  23599. result[pair[0]] = pair[1];
  23600. }
  23601. return result;
  23602. }
  23603. /**
  23604. * Gets the first element of `array`.
  23605. *
  23606. * @static
  23607. * @memberOf _
  23608. * @since 0.1.0
  23609. * @alias first
  23610. * @category Array
  23611. * @param {Array} array The array to query.
  23612. * @returns {*} Returns the first element of `array`.
  23613. * @example
  23614. *
  23615. * _.head([1, 2, 3]);
  23616. * // => 1
  23617. *
  23618. * _.head([]);
  23619. * // => undefined
  23620. */
  23621. function head(array) {
  23622. return (array && array.length) ? array[0] : undefined;
  23623. }
  23624. /**
  23625. * Gets the index at which the first occurrence of `value` is found in `array`
  23626. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23627. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23628. * offset from the end of `array`.
  23629. *
  23630. * @static
  23631. * @memberOf _
  23632. * @since 0.1.0
  23633. * @category Array
  23634. * @param {Array} array The array to inspect.
  23635. * @param {*} value The value to search for.
  23636. * @param {number} [fromIndex=0] The index to search from.
  23637. * @returns {number} Returns the index of the matched value, else `-1`.
  23638. * @example
  23639. *
  23640. * _.indexOf([1, 2, 1, 2], 2);
  23641. * // => 1
  23642. *
  23643. * // Search from the `fromIndex`.
  23644. * _.indexOf([1, 2, 1, 2], 2, 2);
  23645. * // => 3
  23646. */
  23647. function indexOf(array, value, fromIndex) {
  23648. var length = array == null ? 0 : array.length;
  23649. if (!length) {
  23650. return -1;
  23651. }
  23652. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23653. if (index < 0) {
  23654. index = nativeMax(length + index, 0);
  23655. }
  23656. return baseIndexOf(array, value, index);
  23657. }
  23658. /**
  23659. * Gets all but the last element of `array`.
  23660. *
  23661. * @static
  23662. * @memberOf _
  23663. * @since 0.1.0
  23664. * @category Array
  23665. * @param {Array} array The array to query.
  23666. * @returns {Array} Returns the slice of `array`.
  23667. * @example
  23668. *
  23669. * _.initial([1, 2, 3]);
  23670. * // => [1, 2]
  23671. */
  23672. function initial(array) {
  23673. var length = array == null ? 0 : array.length;
  23674. return length ? baseSlice(array, 0, -1) : [];
  23675. }
  23676. /**
  23677. * Creates an array of unique values that are included in all given arrays
  23678. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23679. * for equality comparisons. The order and references of result values are
  23680. * determined by the first array.
  23681. *
  23682. * @static
  23683. * @memberOf _
  23684. * @since 0.1.0
  23685. * @category Array
  23686. * @param {...Array} [arrays] The arrays to inspect.
  23687. * @returns {Array} Returns the new array of intersecting values.
  23688. * @example
  23689. *
  23690. * _.intersection([2, 1], [2, 3]);
  23691. * // => [2]
  23692. */
  23693. var intersection = baseRest(function(arrays) {
  23694. var mapped = arrayMap(arrays, castArrayLikeObject);
  23695. return (mapped.length && mapped[0] === arrays[0])
  23696. ? baseIntersection(mapped)
  23697. : [];
  23698. });
  23699. /**
  23700. * This method is like `_.intersection` except that it accepts `iteratee`
  23701. * which is invoked for each element of each `arrays` to generate the criterion
  23702. * by which they're compared. The order and references of result values are
  23703. * determined by the first array. The iteratee is invoked with one argument:
  23704. * (value).
  23705. *
  23706. * @static
  23707. * @memberOf _
  23708. * @since 4.0.0
  23709. * @category Array
  23710. * @param {...Array} [arrays] The arrays to inspect.
  23711. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23712. * @returns {Array} Returns the new array of intersecting values.
  23713. * @example
  23714. *
  23715. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23716. * // => [2.1]
  23717. *
  23718. * // The `_.property` iteratee shorthand.
  23719. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23720. * // => [{ 'x': 1 }]
  23721. */
  23722. var intersectionBy = baseRest(function(arrays) {
  23723. var iteratee = last(arrays),
  23724. mapped = arrayMap(arrays, castArrayLikeObject);
  23725. if (iteratee === last(mapped)) {
  23726. iteratee = undefined;
  23727. } else {
  23728. mapped.pop();
  23729. }
  23730. return (mapped.length && mapped[0] === arrays[0])
  23731. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23732. : [];
  23733. });
  23734. /**
  23735. * This method is like `_.intersection` except that it accepts `comparator`
  23736. * which is invoked to compare elements of `arrays`. The order and references
  23737. * of result values are determined by the first array. The comparator is
  23738. * invoked with two arguments: (arrVal, othVal).
  23739. *
  23740. * @static
  23741. * @memberOf _
  23742. * @since 4.0.0
  23743. * @category Array
  23744. * @param {...Array} [arrays] The arrays to inspect.
  23745. * @param {Function} [comparator] The comparator invoked per element.
  23746. * @returns {Array} Returns the new array of intersecting values.
  23747. * @example
  23748. *
  23749. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23750. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23751. *
  23752. * _.intersectionWith(objects, others, _.isEqual);
  23753. * // => [{ 'x': 1, 'y': 2 }]
  23754. */
  23755. var intersectionWith = baseRest(function(arrays) {
  23756. var comparator = last(arrays),
  23757. mapped = arrayMap(arrays, castArrayLikeObject);
  23758. comparator = typeof comparator == 'function' ? comparator : undefined;
  23759. if (comparator) {
  23760. mapped.pop();
  23761. }
  23762. return (mapped.length && mapped[0] === arrays[0])
  23763. ? baseIntersection(mapped, undefined, comparator)
  23764. : [];
  23765. });
  23766. /**
  23767. * Converts all elements in `array` into a string separated by `separator`.
  23768. *
  23769. * @static
  23770. * @memberOf _
  23771. * @since 4.0.0
  23772. * @category Array
  23773. * @param {Array} array The array to convert.
  23774. * @param {string} [separator=','] The element separator.
  23775. * @returns {string} Returns the joined string.
  23776. * @example
  23777. *
  23778. * _.join(['a', 'b', 'c'], '~');
  23779. * // => 'a~b~c'
  23780. */
  23781. function join(array, separator) {
  23782. return array == null ? '' : nativeJoin.call(array, separator);
  23783. }
  23784. /**
  23785. * Gets the last element of `array`.
  23786. *
  23787. * @static
  23788. * @memberOf _
  23789. * @since 0.1.0
  23790. * @category Array
  23791. * @param {Array} array The array to query.
  23792. * @returns {*} Returns the last element of `array`.
  23793. * @example
  23794. *
  23795. * _.last([1, 2, 3]);
  23796. * // => 3
  23797. */
  23798. function last(array) {
  23799. var length = array == null ? 0 : array.length;
  23800. return length ? array[length - 1] : undefined;
  23801. }
  23802. /**
  23803. * This method is like `_.indexOf` except that it iterates over elements of
  23804. * `array` from right to left.
  23805. *
  23806. * @static
  23807. * @memberOf _
  23808. * @since 0.1.0
  23809. * @category Array
  23810. * @param {Array} array The array to inspect.
  23811. * @param {*} value The value to search for.
  23812. * @param {number} [fromIndex=array.length-1] The index to search from.
  23813. * @returns {number} Returns the index of the matched value, else `-1`.
  23814. * @example
  23815. *
  23816. * _.lastIndexOf([1, 2, 1, 2], 2);
  23817. * // => 3
  23818. *
  23819. * // Search from the `fromIndex`.
  23820. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23821. * // => 1
  23822. */
  23823. function lastIndexOf(array, value, fromIndex) {
  23824. var length = array == null ? 0 : array.length;
  23825. if (!length) {
  23826. return -1;
  23827. }
  23828. var index = length;
  23829. if (fromIndex !== undefined) {
  23830. index = toInteger(fromIndex);
  23831. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23832. }
  23833. return value === value
  23834. ? strictLastIndexOf(array, value, index)
  23835. : baseFindIndex(array, baseIsNaN, index, true);
  23836. }
  23837. /**
  23838. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23839. * element from the end is returned.
  23840. *
  23841. * @static
  23842. * @memberOf _
  23843. * @since 4.11.0
  23844. * @category Array
  23845. * @param {Array} array The array to query.
  23846. * @param {number} [n=0] The index of the element to return.
  23847. * @returns {*} Returns the nth element of `array`.
  23848. * @example
  23849. *
  23850. * var array = ['a', 'b', 'c', 'd'];
  23851. *
  23852. * _.nth(array, 1);
  23853. * // => 'b'
  23854. *
  23855. * _.nth(array, -2);
  23856. * // => 'c';
  23857. */
  23858. function nth(array, n) {
  23859. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23860. }
  23861. /**
  23862. * Removes all given values from `array` using
  23863. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23864. * for equality comparisons.
  23865. *
  23866. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23867. * to remove elements from an array by predicate.
  23868. *
  23869. * @static
  23870. * @memberOf _
  23871. * @since 2.0.0
  23872. * @category Array
  23873. * @param {Array} array The array to modify.
  23874. * @param {...*} [values] The values to remove.
  23875. * @returns {Array} Returns `array`.
  23876. * @example
  23877. *
  23878. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23879. *
  23880. * _.pull(array, 'a', 'c');
  23881. * console.log(array);
  23882. * // => ['b', 'b']
  23883. */
  23884. var pull = baseRest(pullAll);
  23885. /**
  23886. * This method is like `_.pull` except that it accepts an array of values to remove.
  23887. *
  23888. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23889. *
  23890. * @static
  23891. * @memberOf _
  23892. * @since 4.0.0
  23893. * @category Array
  23894. * @param {Array} array The array to modify.
  23895. * @param {Array} values The values to remove.
  23896. * @returns {Array} Returns `array`.
  23897. * @example
  23898. *
  23899. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23900. *
  23901. * _.pullAll(array, ['a', 'c']);
  23902. * console.log(array);
  23903. * // => ['b', 'b']
  23904. */
  23905. function pullAll(array, values) {
  23906. return (array && array.length && values && values.length)
  23907. ? basePullAll(array, values)
  23908. : array;
  23909. }
  23910. /**
  23911. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23912. * invoked for each element of `array` and `values` to generate the criterion
  23913. * by which they're compared. The iteratee is invoked with one argument: (value).
  23914. *
  23915. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23916. *
  23917. * @static
  23918. * @memberOf _
  23919. * @since 4.0.0
  23920. * @category Array
  23921. * @param {Array} array The array to modify.
  23922. * @param {Array} values The values to remove.
  23923. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23924. * @returns {Array} Returns `array`.
  23925. * @example
  23926. *
  23927. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23928. *
  23929. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23930. * console.log(array);
  23931. * // => [{ 'x': 2 }]
  23932. */
  23933. function pullAllBy(array, values, iteratee) {
  23934. return (array && array.length && values && values.length)
  23935. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23936. : array;
  23937. }
  23938. /**
  23939. * This method is like `_.pullAll` except that it accepts `comparator` which
  23940. * is invoked to compare elements of `array` to `values`. The comparator is
  23941. * invoked with two arguments: (arrVal, othVal).
  23942. *
  23943. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23944. *
  23945. * @static
  23946. * @memberOf _
  23947. * @since 4.6.0
  23948. * @category Array
  23949. * @param {Array} array The array to modify.
  23950. * @param {Array} values The values to remove.
  23951. * @param {Function} [comparator] The comparator invoked per element.
  23952. * @returns {Array} Returns `array`.
  23953. * @example
  23954. *
  23955. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23956. *
  23957. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23958. * console.log(array);
  23959. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23960. */
  23961. function pullAllWith(array, values, comparator) {
  23962. return (array && array.length && values && values.length)
  23963. ? basePullAll(array, values, undefined, comparator)
  23964. : array;
  23965. }
  23966. /**
  23967. * Removes elements from `array` corresponding to `indexes` and returns an
  23968. * array of removed elements.
  23969. *
  23970. * **Note:** Unlike `_.at`, this method mutates `array`.
  23971. *
  23972. * @static
  23973. * @memberOf _
  23974. * @since 3.0.0
  23975. * @category Array
  23976. * @param {Array} array The array to modify.
  23977. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  23978. * @returns {Array} Returns the new array of removed elements.
  23979. * @example
  23980. *
  23981. * var array = ['a', 'b', 'c', 'd'];
  23982. * var pulled = _.pullAt(array, [1, 3]);
  23983. *
  23984. * console.log(array);
  23985. * // => ['a', 'c']
  23986. *
  23987. * console.log(pulled);
  23988. * // => ['b', 'd']
  23989. */
  23990. var pullAt = flatRest(function(array, indexes) {
  23991. var length = array == null ? 0 : array.length,
  23992. result = baseAt(array, indexes);
  23993. basePullAt(array, arrayMap(indexes, function(index) {
  23994. return isIndex(index, length) ? +index : index;
  23995. }).sort(compareAscending));
  23996. return result;
  23997. });
  23998. /**
  23999. * Removes all elements from `array` that `predicate` returns truthy for
  24000. * and returns an array of the removed elements. The predicate is invoked
  24001. * with three arguments: (value, index, array).
  24002. *
  24003. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24004. * to pull elements from an array by value.
  24005. *
  24006. * @static
  24007. * @memberOf _
  24008. * @since 2.0.0
  24009. * @category Array
  24010. * @param {Array} array The array to modify.
  24011. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24012. * @returns {Array} Returns the new array of removed elements.
  24013. * @example
  24014. *
  24015. * var array = [1, 2, 3, 4];
  24016. * var evens = _.remove(array, function(n) {
  24017. * return n % 2 == 0;
  24018. * });
  24019. *
  24020. * console.log(array);
  24021. * // => [1, 3]
  24022. *
  24023. * console.log(evens);
  24024. * // => [2, 4]
  24025. */
  24026. function remove(array, predicate) {
  24027. var result = [];
  24028. if (!(array && array.length)) {
  24029. return result;
  24030. }
  24031. var index = -1,
  24032. indexes = [],
  24033. length = array.length;
  24034. predicate = getIteratee(predicate, 3);
  24035. while (++index < length) {
  24036. var value = array[index];
  24037. if (predicate(value, index, array)) {
  24038. result.push(value);
  24039. indexes.push(index);
  24040. }
  24041. }
  24042. basePullAt(array, indexes);
  24043. return result;
  24044. }
  24045. /**
  24046. * Reverses `array` so that the first element becomes the last, the second
  24047. * element becomes the second to last, and so on.
  24048. *
  24049. * **Note:** This method mutates `array` and is based on
  24050. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24051. *
  24052. * @static
  24053. * @memberOf _
  24054. * @since 4.0.0
  24055. * @category Array
  24056. * @param {Array} array The array to modify.
  24057. * @returns {Array} Returns `array`.
  24058. * @example
  24059. *
  24060. * var array = [1, 2, 3];
  24061. *
  24062. * _.reverse(array);
  24063. * // => [3, 2, 1]
  24064. *
  24065. * console.log(array);
  24066. * // => [3, 2, 1]
  24067. */
  24068. function reverse(array) {
  24069. return array == null ? array : nativeReverse.call(array);
  24070. }
  24071. /**
  24072. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24073. *
  24074. * **Note:** This method is used instead of
  24075. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24076. * returned.
  24077. *
  24078. * @static
  24079. * @memberOf _
  24080. * @since 3.0.0
  24081. * @category Array
  24082. * @param {Array} array The array to slice.
  24083. * @param {number} [start=0] The start position.
  24084. * @param {number} [end=array.length] The end position.
  24085. * @returns {Array} Returns the slice of `array`.
  24086. */
  24087. function slice(array, start, end) {
  24088. var length = array == null ? 0 : array.length;
  24089. if (!length) {
  24090. return [];
  24091. }
  24092. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24093. start = 0;
  24094. end = length;
  24095. }
  24096. else {
  24097. start = start == null ? 0 : toInteger(start);
  24098. end = end === undefined ? length : toInteger(end);
  24099. }
  24100. return baseSlice(array, start, end);
  24101. }
  24102. /**
  24103. * Uses a binary search to determine the lowest index at which `value`
  24104. * should be inserted into `array` in order to maintain its sort order.
  24105. *
  24106. * @static
  24107. * @memberOf _
  24108. * @since 0.1.0
  24109. * @category Array
  24110. * @param {Array} array The sorted array to inspect.
  24111. * @param {*} value The value to evaluate.
  24112. * @returns {number} Returns the index at which `value` should be inserted
  24113. * into `array`.
  24114. * @example
  24115. *
  24116. * _.sortedIndex([30, 50], 40);
  24117. * // => 1
  24118. */
  24119. function sortedIndex(array, value) {
  24120. return baseSortedIndex(array, value);
  24121. }
  24122. /**
  24123. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24124. * which is invoked for `value` and each element of `array` to compute their
  24125. * sort ranking. The iteratee is invoked with one argument: (value).
  24126. *
  24127. * @static
  24128. * @memberOf _
  24129. * @since 4.0.0
  24130. * @category Array
  24131. * @param {Array} array The sorted array to inspect.
  24132. * @param {*} value The value to evaluate.
  24133. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24134. * @returns {number} Returns the index at which `value` should be inserted
  24135. * into `array`.
  24136. * @example
  24137. *
  24138. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24139. *
  24140. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24141. * // => 0
  24142. *
  24143. * // The `_.property` iteratee shorthand.
  24144. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24145. * // => 0
  24146. */
  24147. function sortedIndexBy(array, value, iteratee) {
  24148. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24149. }
  24150. /**
  24151. * This method is like `_.indexOf` except that it performs a binary
  24152. * search on a sorted `array`.
  24153. *
  24154. * @static
  24155. * @memberOf _
  24156. * @since 4.0.0
  24157. * @category Array
  24158. * @param {Array} array The array to inspect.
  24159. * @param {*} value The value to search for.
  24160. * @returns {number} Returns the index of the matched value, else `-1`.
  24161. * @example
  24162. *
  24163. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24164. * // => 1
  24165. */
  24166. function sortedIndexOf(array, value) {
  24167. var length = array == null ? 0 : array.length;
  24168. if (length) {
  24169. var index = baseSortedIndex(array, value);
  24170. if (index < length && eq(array[index], value)) {
  24171. return index;
  24172. }
  24173. }
  24174. return -1;
  24175. }
  24176. /**
  24177. * This method is like `_.sortedIndex` except that it returns the highest
  24178. * index at which `value` should be inserted into `array` in order to
  24179. * maintain its sort order.
  24180. *
  24181. * @static
  24182. * @memberOf _
  24183. * @since 3.0.0
  24184. * @category Array
  24185. * @param {Array} array The sorted array to inspect.
  24186. * @param {*} value The value to evaluate.
  24187. * @returns {number} Returns the index at which `value` should be inserted
  24188. * into `array`.
  24189. * @example
  24190. *
  24191. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24192. * // => 4
  24193. */
  24194. function sortedLastIndex(array, value) {
  24195. return baseSortedIndex(array, value, true);
  24196. }
  24197. /**
  24198. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24199. * which is invoked for `value` and each element of `array` to compute their
  24200. * sort ranking. The iteratee is invoked with one argument: (value).
  24201. *
  24202. * @static
  24203. * @memberOf _
  24204. * @since 4.0.0
  24205. * @category Array
  24206. * @param {Array} array The sorted array to inspect.
  24207. * @param {*} value The value to evaluate.
  24208. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24209. * @returns {number} Returns the index at which `value` should be inserted
  24210. * into `array`.
  24211. * @example
  24212. *
  24213. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24214. *
  24215. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24216. * // => 1
  24217. *
  24218. * // The `_.property` iteratee shorthand.
  24219. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24220. * // => 1
  24221. */
  24222. function sortedLastIndexBy(array, value, iteratee) {
  24223. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24224. }
  24225. /**
  24226. * This method is like `_.lastIndexOf` except that it performs a binary
  24227. * search on a sorted `array`.
  24228. *
  24229. * @static
  24230. * @memberOf _
  24231. * @since 4.0.0
  24232. * @category Array
  24233. * @param {Array} array The array to inspect.
  24234. * @param {*} value The value to search for.
  24235. * @returns {number} Returns the index of the matched value, else `-1`.
  24236. * @example
  24237. *
  24238. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24239. * // => 3
  24240. */
  24241. function sortedLastIndexOf(array, value) {
  24242. var length = array == null ? 0 : array.length;
  24243. if (length) {
  24244. var index = baseSortedIndex(array, value, true) - 1;
  24245. if (eq(array[index], value)) {
  24246. return index;
  24247. }
  24248. }
  24249. return -1;
  24250. }
  24251. /**
  24252. * This method is like `_.uniq` except that it's designed and optimized
  24253. * for sorted arrays.
  24254. *
  24255. * @static
  24256. * @memberOf _
  24257. * @since 4.0.0
  24258. * @category Array
  24259. * @param {Array} array The array to inspect.
  24260. * @returns {Array} Returns the new duplicate free array.
  24261. * @example
  24262. *
  24263. * _.sortedUniq([1, 1, 2]);
  24264. * // => [1, 2]
  24265. */
  24266. function sortedUniq(array) {
  24267. return (array && array.length)
  24268. ? baseSortedUniq(array)
  24269. : [];
  24270. }
  24271. /**
  24272. * This method is like `_.uniqBy` except that it's designed and optimized
  24273. * for sorted arrays.
  24274. *
  24275. * @static
  24276. * @memberOf _
  24277. * @since 4.0.0
  24278. * @category Array
  24279. * @param {Array} array The array to inspect.
  24280. * @param {Function} [iteratee] The iteratee invoked per element.
  24281. * @returns {Array} Returns the new duplicate free array.
  24282. * @example
  24283. *
  24284. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24285. * // => [1.1, 2.3]
  24286. */
  24287. function sortedUniqBy(array, iteratee) {
  24288. return (array && array.length)
  24289. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24290. : [];
  24291. }
  24292. /**
  24293. * Gets all but the first element of `array`.
  24294. *
  24295. * @static
  24296. * @memberOf _
  24297. * @since 4.0.0
  24298. * @category Array
  24299. * @param {Array} array The array to query.
  24300. * @returns {Array} Returns the slice of `array`.
  24301. * @example
  24302. *
  24303. * _.tail([1, 2, 3]);
  24304. * // => [2, 3]
  24305. */
  24306. function tail(array) {
  24307. var length = array == null ? 0 : array.length;
  24308. return length ? baseSlice(array, 1, length) : [];
  24309. }
  24310. /**
  24311. * Creates a slice of `array` with `n` elements taken from the beginning.
  24312. *
  24313. * @static
  24314. * @memberOf _
  24315. * @since 0.1.0
  24316. * @category Array
  24317. * @param {Array} array The array to query.
  24318. * @param {number} [n=1] The number of elements to take.
  24319. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24320. * @returns {Array} Returns the slice of `array`.
  24321. * @example
  24322. *
  24323. * _.take([1, 2, 3]);
  24324. * // => [1]
  24325. *
  24326. * _.take([1, 2, 3], 2);
  24327. * // => [1, 2]
  24328. *
  24329. * _.take([1, 2, 3], 5);
  24330. * // => [1, 2, 3]
  24331. *
  24332. * _.take([1, 2, 3], 0);
  24333. * // => []
  24334. */
  24335. function take(array, n, guard) {
  24336. if (!(array && array.length)) {
  24337. return [];
  24338. }
  24339. n = (guard || n === undefined) ? 1 : toInteger(n);
  24340. return baseSlice(array, 0, n < 0 ? 0 : n);
  24341. }
  24342. /**
  24343. * Creates a slice of `array` with `n` elements taken from the end.
  24344. *
  24345. * @static
  24346. * @memberOf _
  24347. * @since 3.0.0
  24348. * @category Array
  24349. * @param {Array} array The array to query.
  24350. * @param {number} [n=1] The number of elements to take.
  24351. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24352. * @returns {Array} Returns the slice of `array`.
  24353. * @example
  24354. *
  24355. * _.takeRight([1, 2, 3]);
  24356. * // => [3]
  24357. *
  24358. * _.takeRight([1, 2, 3], 2);
  24359. * // => [2, 3]
  24360. *
  24361. * _.takeRight([1, 2, 3], 5);
  24362. * // => [1, 2, 3]
  24363. *
  24364. * _.takeRight([1, 2, 3], 0);
  24365. * // => []
  24366. */
  24367. function takeRight(array, n, guard) {
  24368. var length = array == null ? 0 : array.length;
  24369. if (!length) {
  24370. return [];
  24371. }
  24372. n = (guard || n === undefined) ? 1 : toInteger(n);
  24373. n = length - n;
  24374. return baseSlice(array, n < 0 ? 0 : n, length);
  24375. }
  24376. /**
  24377. * Creates a slice of `array` with elements taken from the end. Elements are
  24378. * taken until `predicate` returns falsey. The predicate is invoked with
  24379. * three arguments: (value, index, array).
  24380. *
  24381. * @static
  24382. * @memberOf _
  24383. * @since 3.0.0
  24384. * @category Array
  24385. * @param {Array} array The array to query.
  24386. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24387. * @returns {Array} Returns the slice of `array`.
  24388. * @example
  24389. *
  24390. * var users = [
  24391. * { 'user': 'barney', 'active': true },
  24392. * { 'user': 'fred', 'active': false },
  24393. * { 'user': 'pebbles', 'active': false }
  24394. * ];
  24395. *
  24396. * _.takeRightWhile(users, function(o) { return !o.active; });
  24397. * // => objects for ['fred', 'pebbles']
  24398. *
  24399. * // The `_.matches` iteratee shorthand.
  24400. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24401. * // => objects for ['pebbles']
  24402. *
  24403. * // The `_.matchesProperty` iteratee shorthand.
  24404. * _.takeRightWhile(users, ['active', false]);
  24405. * // => objects for ['fred', 'pebbles']
  24406. *
  24407. * // The `_.property` iteratee shorthand.
  24408. * _.takeRightWhile(users, 'active');
  24409. * // => []
  24410. */
  24411. function takeRightWhile(array, predicate) {
  24412. return (array && array.length)
  24413. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24414. : [];
  24415. }
  24416. /**
  24417. * Creates a slice of `array` with elements taken from the beginning. Elements
  24418. * are taken until `predicate` returns falsey. The predicate is invoked with
  24419. * three arguments: (value, index, array).
  24420. *
  24421. * @static
  24422. * @memberOf _
  24423. * @since 3.0.0
  24424. * @category Array
  24425. * @param {Array} array The array to query.
  24426. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24427. * @returns {Array} Returns the slice of `array`.
  24428. * @example
  24429. *
  24430. * var users = [
  24431. * { 'user': 'barney', 'active': false },
  24432. * { 'user': 'fred', 'active': false },
  24433. * { 'user': 'pebbles', 'active': true }
  24434. * ];
  24435. *
  24436. * _.takeWhile(users, function(o) { return !o.active; });
  24437. * // => objects for ['barney', 'fred']
  24438. *
  24439. * // The `_.matches` iteratee shorthand.
  24440. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24441. * // => objects for ['barney']
  24442. *
  24443. * // The `_.matchesProperty` iteratee shorthand.
  24444. * _.takeWhile(users, ['active', false]);
  24445. * // => objects for ['barney', 'fred']
  24446. *
  24447. * // The `_.property` iteratee shorthand.
  24448. * _.takeWhile(users, 'active');
  24449. * // => []
  24450. */
  24451. function takeWhile(array, predicate) {
  24452. return (array && array.length)
  24453. ? baseWhile(array, getIteratee(predicate, 3))
  24454. : [];
  24455. }
  24456. /**
  24457. * Creates an array of unique values, in order, from all given arrays using
  24458. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24459. * for equality comparisons.
  24460. *
  24461. * @static
  24462. * @memberOf _
  24463. * @since 0.1.0
  24464. * @category Array
  24465. * @param {...Array} [arrays] The arrays to inspect.
  24466. * @returns {Array} Returns the new array of combined values.
  24467. * @example
  24468. *
  24469. * _.union([2], [1, 2]);
  24470. * // => [2, 1]
  24471. */
  24472. var union = baseRest(function(arrays) {
  24473. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24474. });
  24475. /**
  24476. * This method is like `_.union` except that it accepts `iteratee` which is
  24477. * invoked for each element of each `arrays` to generate the criterion by
  24478. * which uniqueness is computed. Result values are chosen from the first
  24479. * array in which the value occurs. The iteratee is invoked with one argument:
  24480. * (value).
  24481. *
  24482. * @static
  24483. * @memberOf _
  24484. * @since 4.0.0
  24485. * @category Array
  24486. * @param {...Array} [arrays] The arrays to inspect.
  24487. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24488. * @returns {Array} Returns the new array of combined values.
  24489. * @example
  24490. *
  24491. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24492. * // => [2.1, 1.2]
  24493. *
  24494. * // The `_.property` iteratee shorthand.
  24495. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24496. * // => [{ 'x': 1 }, { 'x': 2 }]
  24497. */
  24498. var unionBy = baseRest(function(arrays) {
  24499. var iteratee = last(arrays);
  24500. if (isArrayLikeObject(iteratee)) {
  24501. iteratee = undefined;
  24502. }
  24503. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24504. });
  24505. /**
  24506. * This method is like `_.union` except that it accepts `comparator` which
  24507. * is invoked to compare elements of `arrays`. Result values are chosen from
  24508. * the first array in which the value occurs. The comparator is invoked
  24509. * with two arguments: (arrVal, othVal).
  24510. *
  24511. * @static
  24512. * @memberOf _
  24513. * @since 4.0.0
  24514. * @category Array
  24515. * @param {...Array} [arrays] The arrays to inspect.
  24516. * @param {Function} [comparator] The comparator invoked per element.
  24517. * @returns {Array} Returns the new array of combined values.
  24518. * @example
  24519. *
  24520. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24521. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24522. *
  24523. * _.unionWith(objects, others, _.isEqual);
  24524. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24525. */
  24526. var unionWith = baseRest(function(arrays) {
  24527. var comparator = last(arrays);
  24528. comparator = typeof comparator == 'function' ? comparator : undefined;
  24529. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24530. });
  24531. /**
  24532. * Creates a duplicate-free version of an array, using
  24533. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24534. * for equality comparisons, in which only the first occurrence of each element
  24535. * is kept. The order of result values is determined by the order they occur
  24536. * in the array.
  24537. *
  24538. * @static
  24539. * @memberOf _
  24540. * @since 0.1.0
  24541. * @category Array
  24542. * @param {Array} array The array to inspect.
  24543. * @returns {Array} Returns the new duplicate free array.
  24544. * @example
  24545. *
  24546. * _.uniq([2, 1, 2]);
  24547. * // => [2, 1]
  24548. */
  24549. function uniq(array) {
  24550. return (array && array.length) ? baseUniq(array) : [];
  24551. }
  24552. /**
  24553. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24554. * invoked for each element in `array` to generate the criterion by which
  24555. * uniqueness is computed. The order of result values is determined by the
  24556. * order they occur in the array. The iteratee is invoked with one argument:
  24557. * (value).
  24558. *
  24559. * @static
  24560. * @memberOf _
  24561. * @since 4.0.0
  24562. * @category Array
  24563. * @param {Array} array The array to inspect.
  24564. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24565. * @returns {Array} Returns the new duplicate free array.
  24566. * @example
  24567. *
  24568. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24569. * // => [2.1, 1.2]
  24570. *
  24571. * // The `_.property` iteratee shorthand.
  24572. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24573. * // => [{ 'x': 1 }, { 'x': 2 }]
  24574. */
  24575. function uniqBy(array, iteratee) {
  24576. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24577. }
  24578. /**
  24579. * This method is like `_.uniq` except that it accepts `comparator` which
  24580. * is invoked to compare elements of `array`. The order of result values is
  24581. * determined by the order they occur in the array.The comparator is invoked
  24582. * with two arguments: (arrVal, othVal).
  24583. *
  24584. * @static
  24585. * @memberOf _
  24586. * @since 4.0.0
  24587. * @category Array
  24588. * @param {Array} array The array to inspect.
  24589. * @param {Function} [comparator] The comparator invoked per element.
  24590. * @returns {Array} Returns the new duplicate free array.
  24591. * @example
  24592. *
  24593. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24594. *
  24595. * _.uniqWith(objects, _.isEqual);
  24596. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24597. */
  24598. function uniqWith(array, comparator) {
  24599. comparator = typeof comparator == 'function' ? comparator : undefined;
  24600. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24601. }
  24602. /**
  24603. * This method is like `_.zip` except that it accepts an array of grouped
  24604. * elements and creates an array regrouping the elements to their pre-zip
  24605. * configuration.
  24606. *
  24607. * @static
  24608. * @memberOf _
  24609. * @since 1.2.0
  24610. * @category Array
  24611. * @param {Array} array The array of grouped elements to process.
  24612. * @returns {Array} Returns the new array of regrouped elements.
  24613. * @example
  24614. *
  24615. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24616. * // => [['a', 1, true], ['b', 2, false]]
  24617. *
  24618. * _.unzip(zipped);
  24619. * // => [['a', 'b'], [1, 2], [true, false]]
  24620. */
  24621. function unzip(array) {
  24622. if (!(array && array.length)) {
  24623. return [];
  24624. }
  24625. var length = 0;
  24626. array = arrayFilter(array, function(group) {
  24627. if (isArrayLikeObject(group)) {
  24628. length = nativeMax(group.length, length);
  24629. return true;
  24630. }
  24631. });
  24632. return baseTimes(length, function(index) {
  24633. return arrayMap(array, baseProperty(index));
  24634. });
  24635. }
  24636. /**
  24637. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24638. * how regrouped values should be combined. The iteratee is invoked with the
  24639. * elements of each group: (...group).
  24640. *
  24641. * @static
  24642. * @memberOf _
  24643. * @since 3.8.0
  24644. * @category Array
  24645. * @param {Array} array The array of grouped elements to process.
  24646. * @param {Function} [iteratee=_.identity] The function to combine
  24647. * regrouped values.
  24648. * @returns {Array} Returns the new array of regrouped elements.
  24649. * @example
  24650. *
  24651. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24652. * // => [[1, 10, 100], [2, 20, 200]]
  24653. *
  24654. * _.unzipWith(zipped, _.add);
  24655. * // => [3, 30, 300]
  24656. */
  24657. function unzipWith(array, iteratee) {
  24658. if (!(array && array.length)) {
  24659. return [];
  24660. }
  24661. var result = unzip(array);
  24662. if (iteratee == null) {
  24663. return result;
  24664. }
  24665. return arrayMap(result, function(group) {
  24666. return apply(iteratee, undefined, group);
  24667. });
  24668. }
  24669. /**
  24670. * Creates an array excluding all given values using
  24671. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24672. * for equality comparisons.
  24673. *
  24674. * **Note:** Unlike `_.pull`, this method returns a new array.
  24675. *
  24676. * @static
  24677. * @memberOf _
  24678. * @since 0.1.0
  24679. * @category Array
  24680. * @param {Array} array The array to inspect.
  24681. * @param {...*} [values] The values to exclude.
  24682. * @returns {Array} Returns the new array of filtered values.
  24683. * @see _.difference, _.xor
  24684. * @example
  24685. *
  24686. * _.without([2, 1, 2, 3], 1, 2);
  24687. * // => [3]
  24688. */
  24689. var without = baseRest(function(array, values) {
  24690. return isArrayLikeObject(array)
  24691. ? baseDifference(array, values)
  24692. : [];
  24693. });
  24694. /**
  24695. * Creates an array of unique values that is the
  24696. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24697. * of the given arrays. The order of result values is determined by the order
  24698. * they occur in the arrays.
  24699. *
  24700. * @static
  24701. * @memberOf _
  24702. * @since 2.4.0
  24703. * @category Array
  24704. * @param {...Array} [arrays] The arrays to inspect.
  24705. * @returns {Array} Returns the new array of filtered values.
  24706. * @see _.difference, _.without
  24707. * @example
  24708. *
  24709. * _.xor([2, 1], [2, 3]);
  24710. * // => [1, 3]
  24711. */
  24712. var xor = baseRest(function(arrays) {
  24713. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24714. });
  24715. /**
  24716. * This method is like `_.xor` except that it accepts `iteratee` which is
  24717. * invoked for each element of each `arrays` to generate the criterion by
  24718. * which by which they're compared. The order of result values is determined
  24719. * by the order they occur in the arrays. The iteratee is invoked with one
  24720. * argument: (value).
  24721. *
  24722. * @static
  24723. * @memberOf _
  24724. * @since 4.0.0
  24725. * @category Array
  24726. * @param {...Array} [arrays] The arrays to inspect.
  24727. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24728. * @returns {Array} Returns the new array of filtered values.
  24729. * @example
  24730. *
  24731. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24732. * // => [1.2, 3.4]
  24733. *
  24734. * // The `_.property` iteratee shorthand.
  24735. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24736. * // => [{ 'x': 2 }]
  24737. */
  24738. var xorBy = baseRest(function(arrays) {
  24739. var iteratee = last(arrays);
  24740. if (isArrayLikeObject(iteratee)) {
  24741. iteratee = undefined;
  24742. }
  24743. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24744. });
  24745. /**
  24746. * This method is like `_.xor` except that it accepts `comparator` which is
  24747. * invoked to compare elements of `arrays`. The order of result values is
  24748. * determined by the order they occur in the arrays. The comparator is invoked
  24749. * with two arguments: (arrVal, othVal).
  24750. *
  24751. * @static
  24752. * @memberOf _
  24753. * @since 4.0.0
  24754. * @category Array
  24755. * @param {...Array} [arrays] The arrays to inspect.
  24756. * @param {Function} [comparator] The comparator invoked per element.
  24757. * @returns {Array} Returns the new array of filtered values.
  24758. * @example
  24759. *
  24760. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24761. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24762. *
  24763. * _.xorWith(objects, others, _.isEqual);
  24764. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24765. */
  24766. var xorWith = baseRest(function(arrays) {
  24767. var comparator = last(arrays);
  24768. comparator = typeof comparator == 'function' ? comparator : undefined;
  24769. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24770. });
  24771. /**
  24772. * Creates an array of grouped elements, the first of which contains the
  24773. * first elements of the given arrays, the second of which contains the
  24774. * second elements of the given arrays, and so on.
  24775. *
  24776. * @static
  24777. * @memberOf _
  24778. * @since 0.1.0
  24779. * @category Array
  24780. * @param {...Array} [arrays] The arrays to process.
  24781. * @returns {Array} Returns the new array of grouped elements.
  24782. * @example
  24783. *
  24784. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24785. * // => [['a', 1, true], ['b', 2, false]]
  24786. */
  24787. var zip = baseRest(unzip);
  24788. /**
  24789. * This method is like `_.fromPairs` except that it accepts two arrays,
  24790. * one of property identifiers and one of corresponding values.
  24791. *
  24792. * @static
  24793. * @memberOf _
  24794. * @since 0.4.0
  24795. * @category Array
  24796. * @param {Array} [props=[]] The property identifiers.
  24797. * @param {Array} [values=[]] The property values.
  24798. * @returns {Object} Returns the new object.
  24799. * @example
  24800. *
  24801. * _.zipObject(['a', 'b'], [1, 2]);
  24802. * // => { 'a': 1, 'b': 2 }
  24803. */
  24804. function zipObject(props, values) {
  24805. return baseZipObject(props || [], values || [], assignValue);
  24806. }
  24807. /**
  24808. * This method is like `_.zipObject` except that it supports property paths.
  24809. *
  24810. * @static
  24811. * @memberOf _
  24812. * @since 4.1.0
  24813. * @category Array
  24814. * @param {Array} [props=[]] The property identifiers.
  24815. * @param {Array} [values=[]] The property values.
  24816. * @returns {Object} Returns the new object.
  24817. * @example
  24818. *
  24819. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24820. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24821. */
  24822. function zipObjectDeep(props, values) {
  24823. return baseZipObject(props || [], values || [], baseSet);
  24824. }
  24825. /**
  24826. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24827. * how grouped values should be combined. The iteratee is invoked with the
  24828. * elements of each group: (...group).
  24829. *
  24830. * @static
  24831. * @memberOf _
  24832. * @since 3.8.0
  24833. * @category Array
  24834. * @param {...Array} [arrays] The arrays to process.
  24835. * @param {Function} [iteratee=_.identity] The function to combine
  24836. * grouped values.
  24837. * @returns {Array} Returns the new array of grouped elements.
  24838. * @example
  24839. *
  24840. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24841. * return a + b + c;
  24842. * });
  24843. * // => [111, 222]
  24844. */
  24845. var zipWith = baseRest(function(arrays) {
  24846. var length = arrays.length,
  24847. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24848. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24849. return unzipWith(arrays, iteratee);
  24850. });
  24851. /*------------------------------------------------------------------------*/
  24852. /**
  24853. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24854. * chain sequences enabled. The result of such sequences must be unwrapped
  24855. * with `_#value`.
  24856. *
  24857. * @static
  24858. * @memberOf _
  24859. * @since 1.3.0
  24860. * @category Seq
  24861. * @param {*} value The value to wrap.
  24862. * @returns {Object} Returns the new `lodash` wrapper instance.
  24863. * @example
  24864. *
  24865. * var users = [
  24866. * { 'user': 'barney', 'age': 36 },
  24867. * { 'user': 'fred', 'age': 40 },
  24868. * { 'user': 'pebbles', 'age': 1 }
  24869. * ];
  24870. *
  24871. * var youngest = _
  24872. * .chain(users)
  24873. * .sortBy('age')
  24874. * .map(function(o) {
  24875. * return o.user + ' is ' + o.age;
  24876. * })
  24877. * .head()
  24878. * .value();
  24879. * // => 'pebbles is 1'
  24880. */
  24881. function chain(value) {
  24882. var result = lodash(value);
  24883. result.__chain__ = true;
  24884. return result;
  24885. }
  24886. /**
  24887. * This method invokes `interceptor` and returns `value`. The interceptor
  24888. * is invoked with one argument; (value). The purpose of this method is to
  24889. * "tap into" a method chain sequence in order to modify intermediate results.
  24890. *
  24891. * @static
  24892. * @memberOf _
  24893. * @since 0.1.0
  24894. * @category Seq
  24895. * @param {*} value The value to provide to `interceptor`.
  24896. * @param {Function} interceptor The function to invoke.
  24897. * @returns {*} Returns `value`.
  24898. * @example
  24899. *
  24900. * _([1, 2, 3])
  24901. * .tap(function(array) {
  24902. * // Mutate input array.
  24903. * array.pop();
  24904. * })
  24905. * .reverse()
  24906. * .value();
  24907. * // => [2, 1]
  24908. */
  24909. function tap(value, interceptor) {
  24910. interceptor(value);
  24911. return value;
  24912. }
  24913. /**
  24914. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24915. * The purpose of this method is to "pass thru" values replacing intermediate
  24916. * results in a method chain sequence.
  24917. *
  24918. * @static
  24919. * @memberOf _
  24920. * @since 3.0.0
  24921. * @category Seq
  24922. * @param {*} value The value to provide to `interceptor`.
  24923. * @param {Function} interceptor The function to invoke.
  24924. * @returns {*} Returns the result of `interceptor`.
  24925. * @example
  24926. *
  24927. * _(' abc ')
  24928. * .chain()
  24929. * .trim()
  24930. * .thru(function(value) {
  24931. * return [value];
  24932. * })
  24933. * .value();
  24934. * // => ['abc']
  24935. */
  24936. function thru(value, interceptor) {
  24937. return interceptor(value);
  24938. }
  24939. /**
  24940. * This method is the wrapper version of `_.at`.
  24941. *
  24942. * @name at
  24943. * @memberOf _
  24944. * @since 1.0.0
  24945. * @category Seq
  24946. * @param {...(string|string[])} [paths] The property paths to pick.
  24947. * @returns {Object} Returns the new `lodash` wrapper instance.
  24948. * @example
  24949. *
  24950. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24951. *
  24952. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24953. * // => [3, 4]
  24954. */
  24955. var wrapperAt = flatRest(function(paths) {
  24956. var length = paths.length,
  24957. start = length ? paths[0] : 0,
  24958. value = this.__wrapped__,
  24959. interceptor = function(object) { return baseAt(object, paths); };
  24960. if (length > 1 || this.__actions__.length ||
  24961. !(value instanceof LazyWrapper) || !isIndex(start)) {
  24962. return this.thru(interceptor);
  24963. }
  24964. value = value.slice(start, +start + (length ? 1 : 0));
  24965. value.__actions__.push({
  24966. 'func': thru,
  24967. 'args': [interceptor],
  24968. 'thisArg': undefined
  24969. });
  24970. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  24971. if (length && !array.length) {
  24972. array.push(undefined);
  24973. }
  24974. return array;
  24975. });
  24976. });
  24977. /**
  24978. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  24979. *
  24980. * @name chain
  24981. * @memberOf _
  24982. * @since 0.1.0
  24983. * @category Seq
  24984. * @returns {Object} Returns the new `lodash` wrapper instance.
  24985. * @example
  24986. *
  24987. * var users = [
  24988. * { 'user': 'barney', 'age': 36 },
  24989. * { 'user': 'fred', 'age': 40 }
  24990. * ];
  24991. *
  24992. * // A sequence without explicit chaining.
  24993. * _(users).head();
  24994. * // => { 'user': 'barney', 'age': 36 }
  24995. *
  24996. * // A sequence with explicit chaining.
  24997. * _(users)
  24998. * .chain()
  24999. * .head()
  25000. * .pick('user')
  25001. * .value();
  25002. * // => { 'user': 'barney' }
  25003. */
  25004. function wrapperChain() {
  25005. return chain(this);
  25006. }
  25007. /**
  25008. * Executes the chain sequence and returns the wrapped result.
  25009. *
  25010. * @name commit
  25011. * @memberOf _
  25012. * @since 3.2.0
  25013. * @category Seq
  25014. * @returns {Object} Returns the new `lodash` wrapper instance.
  25015. * @example
  25016. *
  25017. * var array = [1, 2];
  25018. * var wrapped = _(array).push(3);
  25019. *
  25020. * console.log(array);
  25021. * // => [1, 2]
  25022. *
  25023. * wrapped = wrapped.commit();
  25024. * console.log(array);
  25025. * // => [1, 2, 3]
  25026. *
  25027. * wrapped.last();
  25028. * // => 3
  25029. *
  25030. * console.log(array);
  25031. * // => [1, 2, 3]
  25032. */
  25033. function wrapperCommit() {
  25034. return new LodashWrapper(this.value(), this.__chain__);
  25035. }
  25036. /**
  25037. * Gets the next value on a wrapped object following the
  25038. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25039. *
  25040. * @name next
  25041. * @memberOf _
  25042. * @since 4.0.0
  25043. * @category Seq
  25044. * @returns {Object} Returns the next iterator value.
  25045. * @example
  25046. *
  25047. * var wrapped = _([1, 2]);
  25048. *
  25049. * wrapped.next();
  25050. * // => { 'done': false, 'value': 1 }
  25051. *
  25052. * wrapped.next();
  25053. * // => { 'done': false, 'value': 2 }
  25054. *
  25055. * wrapped.next();
  25056. * // => { 'done': true, 'value': undefined }
  25057. */
  25058. function wrapperNext() {
  25059. if (this.__values__ === undefined) {
  25060. this.__values__ = toArray(this.value());
  25061. }
  25062. var done = this.__index__ >= this.__values__.length,
  25063. value = done ? undefined : this.__values__[this.__index__++];
  25064. return { 'done': done, 'value': value };
  25065. }
  25066. /**
  25067. * Enables the wrapper to be iterable.
  25068. *
  25069. * @name Symbol.iterator
  25070. * @memberOf _
  25071. * @since 4.0.0
  25072. * @category Seq
  25073. * @returns {Object} Returns the wrapper object.
  25074. * @example
  25075. *
  25076. * var wrapped = _([1, 2]);
  25077. *
  25078. * wrapped[Symbol.iterator]() === wrapped;
  25079. * // => true
  25080. *
  25081. * Array.from(wrapped);
  25082. * // => [1, 2]
  25083. */
  25084. function wrapperToIterator() {
  25085. return this;
  25086. }
  25087. /**
  25088. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25089. *
  25090. * @name plant
  25091. * @memberOf _
  25092. * @since 3.2.0
  25093. * @category Seq
  25094. * @param {*} value The value to plant.
  25095. * @returns {Object} Returns the new `lodash` wrapper instance.
  25096. * @example
  25097. *
  25098. * function square(n) {
  25099. * return n * n;
  25100. * }
  25101. *
  25102. * var wrapped = _([1, 2]).map(square);
  25103. * var other = wrapped.plant([3, 4]);
  25104. *
  25105. * other.value();
  25106. * // => [9, 16]
  25107. *
  25108. * wrapped.value();
  25109. * // => [1, 4]
  25110. */
  25111. function wrapperPlant(value) {
  25112. var result,
  25113. parent = this;
  25114. while (parent instanceof baseLodash) {
  25115. var clone = wrapperClone(parent);
  25116. clone.__index__ = 0;
  25117. clone.__values__ = undefined;
  25118. if (result) {
  25119. previous.__wrapped__ = clone;
  25120. } else {
  25121. result = clone;
  25122. }
  25123. var previous = clone;
  25124. parent = parent.__wrapped__;
  25125. }
  25126. previous.__wrapped__ = value;
  25127. return result;
  25128. }
  25129. /**
  25130. * This method is the wrapper version of `_.reverse`.
  25131. *
  25132. * **Note:** This method mutates the wrapped array.
  25133. *
  25134. * @name reverse
  25135. * @memberOf _
  25136. * @since 0.1.0
  25137. * @category Seq
  25138. * @returns {Object} Returns the new `lodash` wrapper instance.
  25139. * @example
  25140. *
  25141. * var array = [1, 2, 3];
  25142. *
  25143. * _(array).reverse().value()
  25144. * // => [3, 2, 1]
  25145. *
  25146. * console.log(array);
  25147. * // => [3, 2, 1]
  25148. */
  25149. function wrapperReverse() {
  25150. var value = this.__wrapped__;
  25151. if (value instanceof LazyWrapper) {
  25152. var wrapped = value;
  25153. if (this.__actions__.length) {
  25154. wrapped = new LazyWrapper(this);
  25155. }
  25156. wrapped = wrapped.reverse();
  25157. wrapped.__actions__.push({
  25158. 'func': thru,
  25159. 'args': [reverse],
  25160. 'thisArg': undefined
  25161. });
  25162. return new LodashWrapper(wrapped, this.__chain__);
  25163. }
  25164. return this.thru(reverse);
  25165. }
  25166. /**
  25167. * Executes the chain sequence to resolve the unwrapped value.
  25168. *
  25169. * @name value
  25170. * @memberOf _
  25171. * @since 0.1.0
  25172. * @alias toJSON, valueOf
  25173. * @category Seq
  25174. * @returns {*} Returns the resolved unwrapped value.
  25175. * @example
  25176. *
  25177. * _([1, 2, 3]).value();
  25178. * // => [1, 2, 3]
  25179. */
  25180. function wrapperValue() {
  25181. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25182. }
  25183. /*------------------------------------------------------------------------*/
  25184. /**
  25185. * Creates an object composed of keys generated from the results of running
  25186. * each element of `collection` thru `iteratee`. The corresponding value of
  25187. * each key is the number of times the key was returned by `iteratee`. The
  25188. * iteratee is invoked with one argument: (value).
  25189. *
  25190. * @static
  25191. * @memberOf _
  25192. * @since 0.5.0
  25193. * @category Collection
  25194. * @param {Array|Object} collection The collection to iterate over.
  25195. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25196. * @returns {Object} Returns the composed aggregate object.
  25197. * @example
  25198. *
  25199. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25200. * // => { '4': 1, '6': 2 }
  25201. *
  25202. * // The `_.property` iteratee shorthand.
  25203. * _.countBy(['one', 'two', 'three'], 'length');
  25204. * // => { '3': 2, '5': 1 }
  25205. */
  25206. var countBy = createAggregator(function(result, value, key) {
  25207. if (hasOwnProperty.call(result, key)) {
  25208. ++result[key];
  25209. } else {
  25210. baseAssignValue(result, key, 1);
  25211. }
  25212. });
  25213. /**
  25214. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25215. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25216. * invoked with three arguments: (value, index|key, collection).
  25217. *
  25218. * **Note:** This method returns `true` for
  25219. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25220. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25221. * elements of empty collections.
  25222. *
  25223. * @static
  25224. * @memberOf _
  25225. * @since 0.1.0
  25226. * @category Collection
  25227. * @param {Array|Object} collection The collection to iterate over.
  25228. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25229. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25230. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25231. * else `false`.
  25232. * @example
  25233. *
  25234. * _.every([true, 1, null, 'yes'], Boolean);
  25235. * // => false
  25236. *
  25237. * var users = [
  25238. * { 'user': 'barney', 'age': 36, 'active': false },
  25239. * { 'user': 'fred', 'age': 40, 'active': false }
  25240. * ];
  25241. *
  25242. * // The `_.matches` iteratee shorthand.
  25243. * _.every(users, { 'user': 'barney', 'active': false });
  25244. * // => false
  25245. *
  25246. * // The `_.matchesProperty` iteratee shorthand.
  25247. * _.every(users, ['active', false]);
  25248. * // => true
  25249. *
  25250. * // The `_.property` iteratee shorthand.
  25251. * _.every(users, 'active');
  25252. * // => false
  25253. */
  25254. function every(collection, predicate, guard) {
  25255. var func = isArray(collection) ? arrayEvery : baseEvery;
  25256. if (guard && isIterateeCall(collection, predicate, guard)) {
  25257. predicate = undefined;
  25258. }
  25259. return func(collection, getIteratee(predicate, 3));
  25260. }
  25261. /**
  25262. * Iterates over elements of `collection`, returning an array of all elements
  25263. * `predicate` returns truthy for. The predicate is invoked with three
  25264. * arguments: (value, index|key, collection).
  25265. *
  25266. * **Note:** Unlike `_.remove`, this method returns a new array.
  25267. *
  25268. * @static
  25269. * @memberOf _
  25270. * @since 0.1.0
  25271. * @category Collection
  25272. * @param {Array|Object} collection The collection to iterate over.
  25273. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25274. * @returns {Array} Returns the new filtered array.
  25275. * @see _.reject
  25276. * @example
  25277. *
  25278. * var users = [
  25279. * { 'user': 'barney', 'age': 36, 'active': true },
  25280. * { 'user': 'fred', 'age': 40, 'active': false }
  25281. * ];
  25282. *
  25283. * _.filter(users, function(o) { return !o.active; });
  25284. * // => objects for ['fred']
  25285. *
  25286. * // The `_.matches` iteratee shorthand.
  25287. * _.filter(users, { 'age': 36, 'active': true });
  25288. * // => objects for ['barney']
  25289. *
  25290. * // The `_.matchesProperty` iteratee shorthand.
  25291. * _.filter(users, ['active', false]);
  25292. * // => objects for ['fred']
  25293. *
  25294. * // The `_.property` iteratee shorthand.
  25295. * _.filter(users, 'active');
  25296. * // => objects for ['barney']
  25297. */
  25298. function filter(collection, predicate) {
  25299. var func = isArray(collection) ? arrayFilter : baseFilter;
  25300. return func(collection, getIteratee(predicate, 3));
  25301. }
  25302. /**
  25303. * Iterates over elements of `collection`, returning the first element
  25304. * `predicate` returns truthy for. The predicate is invoked with three
  25305. * arguments: (value, index|key, collection).
  25306. *
  25307. * @static
  25308. * @memberOf _
  25309. * @since 0.1.0
  25310. * @category Collection
  25311. * @param {Array|Object} collection The collection to inspect.
  25312. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25313. * @param {number} [fromIndex=0] The index to search from.
  25314. * @returns {*} Returns the matched element, else `undefined`.
  25315. * @example
  25316. *
  25317. * var users = [
  25318. * { 'user': 'barney', 'age': 36, 'active': true },
  25319. * { 'user': 'fred', 'age': 40, 'active': false },
  25320. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25321. * ];
  25322. *
  25323. * _.find(users, function(o) { return o.age < 40; });
  25324. * // => object for 'barney'
  25325. *
  25326. * // The `_.matches` iteratee shorthand.
  25327. * _.find(users, { 'age': 1, 'active': true });
  25328. * // => object for 'pebbles'
  25329. *
  25330. * // The `_.matchesProperty` iteratee shorthand.
  25331. * _.find(users, ['active', false]);
  25332. * // => object for 'fred'
  25333. *
  25334. * // The `_.property` iteratee shorthand.
  25335. * _.find(users, 'active');
  25336. * // => object for 'barney'
  25337. */
  25338. var find = createFind(findIndex);
  25339. /**
  25340. * This method is like `_.find` except that it iterates over elements of
  25341. * `collection` from right to left.
  25342. *
  25343. * @static
  25344. * @memberOf _
  25345. * @since 2.0.0
  25346. * @category Collection
  25347. * @param {Array|Object} collection The collection to inspect.
  25348. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25349. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25350. * @returns {*} Returns the matched element, else `undefined`.
  25351. * @example
  25352. *
  25353. * _.findLast([1, 2, 3, 4], function(n) {
  25354. * return n % 2 == 1;
  25355. * });
  25356. * // => 3
  25357. */
  25358. var findLast = createFind(findLastIndex);
  25359. /**
  25360. * Creates a flattened array of values by running each element in `collection`
  25361. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25362. * with three arguments: (value, index|key, collection).
  25363. *
  25364. * @static
  25365. * @memberOf _
  25366. * @since 4.0.0
  25367. * @category Collection
  25368. * @param {Array|Object} collection The collection to iterate over.
  25369. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25370. * @returns {Array} Returns the new flattened array.
  25371. * @example
  25372. *
  25373. * function duplicate(n) {
  25374. * return [n, n];
  25375. * }
  25376. *
  25377. * _.flatMap([1, 2], duplicate);
  25378. * // => [1, 1, 2, 2]
  25379. */
  25380. function flatMap(collection, iteratee) {
  25381. return baseFlatten(map(collection, iteratee), 1);
  25382. }
  25383. /**
  25384. * This method is like `_.flatMap` except that it recursively flattens the
  25385. * mapped results.
  25386. *
  25387. * @static
  25388. * @memberOf _
  25389. * @since 4.7.0
  25390. * @category Collection
  25391. * @param {Array|Object} collection The collection to iterate over.
  25392. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25393. * @returns {Array} Returns the new flattened array.
  25394. * @example
  25395. *
  25396. * function duplicate(n) {
  25397. * return [[[n, n]]];
  25398. * }
  25399. *
  25400. * _.flatMapDeep([1, 2], duplicate);
  25401. * // => [1, 1, 2, 2]
  25402. */
  25403. function flatMapDeep(collection, iteratee) {
  25404. return baseFlatten(map(collection, iteratee), INFINITY);
  25405. }
  25406. /**
  25407. * This method is like `_.flatMap` except that it recursively flattens the
  25408. * mapped results up to `depth` times.
  25409. *
  25410. * @static
  25411. * @memberOf _
  25412. * @since 4.7.0
  25413. * @category Collection
  25414. * @param {Array|Object} collection The collection to iterate over.
  25415. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25416. * @param {number} [depth=1] The maximum recursion depth.
  25417. * @returns {Array} Returns the new flattened array.
  25418. * @example
  25419. *
  25420. * function duplicate(n) {
  25421. * return [[[n, n]]];
  25422. * }
  25423. *
  25424. * _.flatMapDepth([1, 2], duplicate, 2);
  25425. * // => [[1, 1], [2, 2]]
  25426. */
  25427. function flatMapDepth(collection, iteratee, depth) {
  25428. depth = depth === undefined ? 1 : toInteger(depth);
  25429. return baseFlatten(map(collection, iteratee), depth);
  25430. }
  25431. /**
  25432. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25433. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25434. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25435. *
  25436. * **Note:** As with other "Collections" methods, objects with a "length"
  25437. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25438. * or `_.forOwn` for object iteration.
  25439. *
  25440. * @static
  25441. * @memberOf _
  25442. * @since 0.1.0
  25443. * @alias each
  25444. * @category Collection
  25445. * @param {Array|Object} collection The collection to iterate over.
  25446. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25447. * @returns {Array|Object} Returns `collection`.
  25448. * @see _.forEachRight
  25449. * @example
  25450. *
  25451. * _.forEach([1, 2], function(value) {
  25452. * console.log(value);
  25453. * });
  25454. * // => Logs `1` then `2`.
  25455. *
  25456. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25457. * console.log(key);
  25458. * });
  25459. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25460. */
  25461. function forEach(collection, iteratee) {
  25462. var func = isArray(collection) ? arrayEach : baseEach;
  25463. return func(collection, getIteratee(iteratee, 3));
  25464. }
  25465. /**
  25466. * This method is like `_.forEach` except that it iterates over elements of
  25467. * `collection` from right to left.
  25468. *
  25469. * @static
  25470. * @memberOf _
  25471. * @since 2.0.0
  25472. * @alias eachRight
  25473. * @category Collection
  25474. * @param {Array|Object} collection The collection to iterate over.
  25475. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25476. * @returns {Array|Object} Returns `collection`.
  25477. * @see _.forEach
  25478. * @example
  25479. *
  25480. * _.forEachRight([1, 2], function(value) {
  25481. * console.log(value);
  25482. * });
  25483. * // => Logs `2` then `1`.
  25484. */
  25485. function forEachRight(collection, iteratee) {
  25486. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25487. return func(collection, getIteratee(iteratee, 3));
  25488. }
  25489. /**
  25490. * Creates an object composed of keys generated from the results of running
  25491. * each element of `collection` thru `iteratee`. The order of grouped values
  25492. * is determined by the order they occur in `collection`. The corresponding
  25493. * value of each key is an array of elements responsible for generating the
  25494. * key. The iteratee is invoked with one argument: (value).
  25495. *
  25496. * @static
  25497. * @memberOf _
  25498. * @since 0.1.0
  25499. * @category Collection
  25500. * @param {Array|Object} collection The collection to iterate over.
  25501. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25502. * @returns {Object} Returns the composed aggregate object.
  25503. * @example
  25504. *
  25505. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25506. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25507. *
  25508. * // The `_.property` iteratee shorthand.
  25509. * _.groupBy(['one', 'two', 'three'], 'length');
  25510. * // => { '3': ['one', 'two'], '5': ['three'] }
  25511. */
  25512. var groupBy = createAggregator(function(result, value, key) {
  25513. if (hasOwnProperty.call(result, key)) {
  25514. result[key].push(value);
  25515. } else {
  25516. baseAssignValue(result, key, [value]);
  25517. }
  25518. });
  25519. /**
  25520. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25521. * checked for a substring of `value`, otherwise
  25522. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25523. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25524. * the offset from the end of `collection`.
  25525. *
  25526. * @static
  25527. * @memberOf _
  25528. * @since 0.1.0
  25529. * @category Collection
  25530. * @param {Array|Object|string} collection The collection to inspect.
  25531. * @param {*} value The value to search for.
  25532. * @param {number} [fromIndex=0] The index to search from.
  25533. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25534. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25535. * @example
  25536. *
  25537. * _.includes([1, 2, 3], 1);
  25538. * // => true
  25539. *
  25540. * _.includes([1, 2, 3], 1, 2);
  25541. * // => false
  25542. *
  25543. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25544. * // => true
  25545. *
  25546. * _.includes('abcd', 'bc');
  25547. * // => true
  25548. */
  25549. function includes(collection, value, fromIndex, guard) {
  25550. collection = isArrayLike(collection) ? collection : values(collection);
  25551. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25552. var length = collection.length;
  25553. if (fromIndex < 0) {
  25554. fromIndex = nativeMax(length + fromIndex, 0);
  25555. }
  25556. return isString(collection)
  25557. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25558. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25559. }
  25560. /**
  25561. * Invokes the method at `path` of each element in `collection`, returning
  25562. * an array of the results of each invoked method. Any additional arguments
  25563. * are provided to each invoked method. If `path` is a function, it's invoked
  25564. * for, and `this` bound to, each element in `collection`.
  25565. *
  25566. * @static
  25567. * @memberOf _
  25568. * @since 4.0.0
  25569. * @category Collection
  25570. * @param {Array|Object} collection The collection to iterate over.
  25571. * @param {Array|Function|string} path The path of the method to invoke or
  25572. * the function invoked per iteration.
  25573. * @param {...*} [args] The arguments to invoke each method with.
  25574. * @returns {Array} Returns the array of results.
  25575. * @example
  25576. *
  25577. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25578. * // => [[1, 5, 7], [1, 2, 3]]
  25579. *
  25580. * _.invokeMap([123, 456], String.prototype.split, '');
  25581. * // => [['1', '2', '3'], ['4', '5', '6']]
  25582. */
  25583. var invokeMap = baseRest(function(collection, path, args) {
  25584. var index = -1,
  25585. isFunc = typeof path == 'function',
  25586. result = isArrayLike(collection) ? Array(collection.length) : [];
  25587. baseEach(collection, function(value) {
  25588. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25589. });
  25590. return result;
  25591. });
  25592. /**
  25593. * Creates an object composed of keys generated from the results of running
  25594. * each element of `collection` thru `iteratee`. The corresponding value of
  25595. * each key is the last element responsible for generating the key. The
  25596. * iteratee is invoked with one argument: (value).
  25597. *
  25598. * @static
  25599. * @memberOf _
  25600. * @since 4.0.0
  25601. * @category Collection
  25602. * @param {Array|Object} collection The collection to iterate over.
  25603. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25604. * @returns {Object} Returns the composed aggregate object.
  25605. * @example
  25606. *
  25607. * var array = [
  25608. * { 'dir': 'left', 'code': 97 },
  25609. * { 'dir': 'right', 'code': 100 }
  25610. * ];
  25611. *
  25612. * _.keyBy(array, function(o) {
  25613. * return String.fromCharCode(o.code);
  25614. * });
  25615. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25616. *
  25617. * _.keyBy(array, 'dir');
  25618. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25619. */
  25620. var keyBy = createAggregator(function(result, value, key) {
  25621. baseAssignValue(result, key, value);
  25622. });
  25623. /**
  25624. * Creates an array of values by running each element in `collection` thru
  25625. * `iteratee`. The iteratee is invoked with three arguments:
  25626. * (value, index|key, collection).
  25627. *
  25628. * Many lodash methods are guarded to work as iteratees for methods like
  25629. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25630. *
  25631. * The guarded methods are:
  25632. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25633. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25634. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25635. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25636. *
  25637. * @static
  25638. * @memberOf _
  25639. * @since 0.1.0
  25640. * @category Collection
  25641. * @param {Array|Object} collection The collection to iterate over.
  25642. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25643. * @returns {Array} Returns the new mapped array.
  25644. * @example
  25645. *
  25646. * function square(n) {
  25647. * return n * n;
  25648. * }
  25649. *
  25650. * _.map([4, 8], square);
  25651. * // => [16, 64]
  25652. *
  25653. * _.map({ 'a': 4, 'b': 8 }, square);
  25654. * // => [16, 64] (iteration order is not guaranteed)
  25655. *
  25656. * var users = [
  25657. * { 'user': 'barney' },
  25658. * { 'user': 'fred' }
  25659. * ];
  25660. *
  25661. * // The `_.property` iteratee shorthand.
  25662. * _.map(users, 'user');
  25663. * // => ['barney', 'fred']
  25664. */
  25665. function map(collection, iteratee) {
  25666. var func = isArray(collection) ? arrayMap : baseMap;
  25667. return func(collection, getIteratee(iteratee, 3));
  25668. }
  25669. /**
  25670. * This method is like `_.sortBy` except that it allows specifying the sort
  25671. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25672. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25673. * descending or "asc" for ascending sort order of corresponding values.
  25674. *
  25675. * @static
  25676. * @memberOf _
  25677. * @since 4.0.0
  25678. * @category Collection
  25679. * @param {Array|Object} collection The collection to iterate over.
  25680. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25681. * The iteratees to sort by.
  25682. * @param {string[]} [orders] The sort orders of `iteratees`.
  25683. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25684. * @returns {Array} Returns the new sorted array.
  25685. * @example
  25686. *
  25687. * var users = [
  25688. * { 'user': 'fred', 'age': 48 },
  25689. * { 'user': 'barney', 'age': 34 },
  25690. * { 'user': 'fred', 'age': 40 },
  25691. * { 'user': 'barney', 'age': 36 }
  25692. * ];
  25693. *
  25694. * // Sort by `user` in ascending order and by `age` in descending order.
  25695. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25696. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25697. */
  25698. function orderBy(collection, iteratees, orders, guard) {
  25699. if (collection == null) {
  25700. return [];
  25701. }
  25702. if (!isArray(iteratees)) {
  25703. iteratees = iteratees == null ? [] : [iteratees];
  25704. }
  25705. orders = guard ? undefined : orders;
  25706. if (!isArray(orders)) {
  25707. orders = orders == null ? [] : [orders];
  25708. }
  25709. return baseOrderBy(collection, iteratees, orders);
  25710. }
  25711. /**
  25712. * Creates an array of elements split into two groups, the first of which
  25713. * contains elements `predicate` returns truthy for, the second of which
  25714. * contains elements `predicate` returns falsey for. The predicate is
  25715. * invoked with one argument: (value).
  25716. *
  25717. * @static
  25718. * @memberOf _
  25719. * @since 3.0.0
  25720. * @category Collection
  25721. * @param {Array|Object} collection The collection to iterate over.
  25722. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25723. * @returns {Array} Returns the array of grouped elements.
  25724. * @example
  25725. *
  25726. * var users = [
  25727. * { 'user': 'barney', 'age': 36, 'active': false },
  25728. * { 'user': 'fred', 'age': 40, 'active': true },
  25729. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25730. * ];
  25731. *
  25732. * _.partition(users, function(o) { return o.active; });
  25733. * // => objects for [['fred'], ['barney', 'pebbles']]
  25734. *
  25735. * // The `_.matches` iteratee shorthand.
  25736. * _.partition(users, { 'age': 1, 'active': false });
  25737. * // => objects for [['pebbles'], ['barney', 'fred']]
  25738. *
  25739. * // The `_.matchesProperty` iteratee shorthand.
  25740. * _.partition(users, ['active', false]);
  25741. * // => objects for [['barney', 'pebbles'], ['fred']]
  25742. *
  25743. * // The `_.property` iteratee shorthand.
  25744. * _.partition(users, 'active');
  25745. * // => objects for [['fred'], ['barney', 'pebbles']]
  25746. */
  25747. var partition = createAggregator(function(result, value, key) {
  25748. result[key ? 0 : 1].push(value);
  25749. }, function() { return [[], []]; });
  25750. /**
  25751. * Reduces `collection` to a value which is the accumulated result of running
  25752. * each element in `collection` thru `iteratee`, where each successive
  25753. * invocation is supplied the return value of the previous. If `accumulator`
  25754. * is not given, the first element of `collection` is used as the initial
  25755. * value. The iteratee is invoked with four arguments:
  25756. * (accumulator, value, index|key, collection).
  25757. *
  25758. * Many lodash methods are guarded to work as iteratees for methods like
  25759. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25760. *
  25761. * The guarded methods are:
  25762. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25763. * and `sortBy`
  25764. *
  25765. * @static
  25766. * @memberOf _
  25767. * @since 0.1.0
  25768. * @category Collection
  25769. * @param {Array|Object} collection The collection to iterate over.
  25770. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25771. * @param {*} [accumulator] The initial value.
  25772. * @returns {*} Returns the accumulated value.
  25773. * @see _.reduceRight
  25774. * @example
  25775. *
  25776. * _.reduce([1, 2], function(sum, n) {
  25777. * return sum + n;
  25778. * }, 0);
  25779. * // => 3
  25780. *
  25781. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25782. * (result[value] || (result[value] = [])).push(key);
  25783. * return result;
  25784. * }, {});
  25785. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25786. */
  25787. function reduce(collection, iteratee, accumulator) {
  25788. var func = isArray(collection) ? arrayReduce : baseReduce,
  25789. initAccum = arguments.length < 3;
  25790. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25791. }
  25792. /**
  25793. * This method is like `_.reduce` except that it iterates over elements of
  25794. * `collection` from right to left.
  25795. *
  25796. * @static
  25797. * @memberOf _
  25798. * @since 0.1.0
  25799. * @category Collection
  25800. * @param {Array|Object} collection The collection to iterate over.
  25801. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25802. * @param {*} [accumulator] The initial value.
  25803. * @returns {*} Returns the accumulated value.
  25804. * @see _.reduce
  25805. * @example
  25806. *
  25807. * var array = [[0, 1], [2, 3], [4, 5]];
  25808. *
  25809. * _.reduceRight(array, function(flattened, other) {
  25810. * return flattened.concat(other);
  25811. * }, []);
  25812. * // => [4, 5, 2, 3, 0, 1]
  25813. */
  25814. function reduceRight(collection, iteratee, accumulator) {
  25815. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25816. initAccum = arguments.length < 3;
  25817. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25818. }
  25819. /**
  25820. * The opposite of `_.filter`; this method returns the elements of `collection`
  25821. * that `predicate` does **not** return truthy for.
  25822. *
  25823. * @static
  25824. * @memberOf _
  25825. * @since 0.1.0
  25826. * @category Collection
  25827. * @param {Array|Object} collection The collection to iterate over.
  25828. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25829. * @returns {Array} Returns the new filtered array.
  25830. * @see _.filter
  25831. * @example
  25832. *
  25833. * var users = [
  25834. * { 'user': 'barney', 'age': 36, 'active': false },
  25835. * { 'user': 'fred', 'age': 40, 'active': true }
  25836. * ];
  25837. *
  25838. * _.reject(users, function(o) { return !o.active; });
  25839. * // => objects for ['fred']
  25840. *
  25841. * // The `_.matches` iteratee shorthand.
  25842. * _.reject(users, { 'age': 40, 'active': true });
  25843. * // => objects for ['barney']
  25844. *
  25845. * // The `_.matchesProperty` iteratee shorthand.
  25846. * _.reject(users, ['active', false]);
  25847. * // => objects for ['fred']
  25848. *
  25849. * // The `_.property` iteratee shorthand.
  25850. * _.reject(users, 'active');
  25851. * // => objects for ['barney']
  25852. */
  25853. function reject(collection, predicate) {
  25854. var func = isArray(collection) ? arrayFilter : baseFilter;
  25855. return func(collection, negate(getIteratee(predicate, 3)));
  25856. }
  25857. /**
  25858. * Gets a random element from `collection`.
  25859. *
  25860. * @static
  25861. * @memberOf _
  25862. * @since 2.0.0
  25863. * @category Collection
  25864. * @param {Array|Object} collection The collection to sample.
  25865. * @returns {*} Returns the random element.
  25866. * @example
  25867. *
  25868. * _.sample([1, 2, 3, 4]);
  25869. * // => 2
  25870. */
  25871. function sample(collection) {
  25872. var func = isArray(collection) ? arraySample : baseSample;
  25873. return func(collection);
  25874. }
  25875. /**
  25876. * Gets `n` random elements at unique keys from `collection` up to the
  25877. * size of `collection`.
  25878. *
  25879. * @static
  25880. * @memberOf _
  25881. * @since 4.0.0
  25882. * @category Collection
  25883. * @param {Array|Object} collection The collection to sample.
  25884. * @param {number} [n=1] The number of elements to sample.
  25885. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25886. * @returns {Array} Returns the random elements.
  25887. * @example
  25888. *
  25889. * _.sampleSize([1, 2, 3], 2);
  25890. * // => [3, 1]
  25891. *
  25892. * _.sampleSize([1, 2, 3], 4);
  25893. * // => [2, 3, 1]
  25894. */
  25895. function sampleSize(collection, n, guard) {
  25896. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25897. n = 1;
  25898. } else {
  25899. n = toInteger(n);
  25900. }
  25901. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25902. return func(collection, n);
  25903. }
  25904. /**
  25905. * Creates an array of shuffled values, using a version of the
  25906. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25907. *
  25908. * @static
  25909. * @memberOf _
  25910. * @since 0.1.0
  25911. * @category Collection
  25912. * @param {Array|Object} collection The collection to shuffle.
  25913. * @returns {Array} Returns the new shuffled array.
  25914. * @example
  25915. *
  25916. * _.shuffle([1, 2, 3, 4]);
  25917. * // => [4, 1, 3, 2]
  25918. */
  25919. function shuffle(collection) {
  25920. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25921. return func(collection);
  25922. }
  25923. /**
  25924. * Gets the size of `collection` by returning its length for array-like
  25925. * values or the number of own enumerable string keyed properties for objects.
  25926. *
  25927. * @static
  25928. * @memberOf _
  25929. * @since 0.1.0
  25930. * @category Collection
  25931. * @param {Array|Object|string} collection The collection to inspect.
  25932. * @returns {number} Returns the collection size.
  25933. * @example
  25934. *
  25935. * _.size([1, 2, 3]);
  25936. * // => 3
  25937. *
  25938. * _.size({ 'a': 1, 'b': 2 });
  25939. * // => 2
  25940. *
  25941. * _.size('pebbles');
  25942. * // => 7
  25943. */
  25944. function size(collection) {
  25945. if (collection == null) {
  25946. return 0;
  25947. }
  25948. if (isArrayLike(collection)) {
  25949. return isString(collection) ? stringSize(collection) : collection.length;
  25950. }
  25951. var tag = getTag(collection);
  25952. if (tag == mapTag || tag == setTag) {
  25953. return collection.size;
  25954. }
  25955. return baseKeys(collection).length;
  25956. }
  25957. /**
  25958. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25959. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25960. * invoked with three arguments: (value, index|key, collection).
  25961. *
  25962. * @static
  25963. * @memberOf _
  25964. * @since 0.1.0
  25965. * @category Collection
  25966. * @param {Array|Object} collection The collection to iterate over.
  25967. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25968. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25969. * @returns {boolean} Returns `true` if any element passes the predicate check,
  25970. * else `false`.
  25971. * @example
  25972. *
  25973. * _.some([null, 0, 'yes', false], Boolean);
  25974. * // => true
  25975. *
  25976. * var users = [
  25977. * { 'user': 'barney', 'active': true },
  25978. * { 'user': 'fred', 'active': false }
  25979. * ];
  25980. *
  25981. * // The `_.matches` iteratee shorthand.
  25982. * _.some(users, { 'user': 'barney', 'active': false });
  25983. * // => false
  25984. *
  25985. * // The `_.matchesProperty` iteratee shorthand.
  25986. * _.some(users, ['active', false]);
  25987. * // => true
  25988. *
  25989. * // The `_.property` iteratee shorthand.
  25990. * _.some(users, 'active');
  25991. * // => true
  25992. */
  25993. function some(collection, predicate, guard) {
  25994. var func = isArray(collection) ? arraySome : baseSome;
  25995. if (guard && isIterateeCall(collection, predicate, guard)) {
  25996. predicate = undefined;
  25997. }
  25998. return func(collection, getIteratee(predicate, 3));
  25999. }
  26000. /**
  26001. * Creates an array of elements, sorted in ascending order by the results of
  26002. * running each element in a collection thru each iteratee. This method
  26003. * performs a stable sort, that is, it preserves the original sort order of
  26004. * equal elements. The iteratees are invoked with one argument: (value).
  26005. *
  26006. * @static
  26007. * @memberOf _
  26008. * @since 0.1.0
  26009. * @category Collection
  26010. * @param {Array|Object} collection The collection to iterate over.
  26011. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26012. * The iteratees to sort by.
  26013. * @returns {Array} Returns the new sorted array.
  26014. * @example
  26015. *
  26016. * var users = [
  26017. * { 'user': 'fred', 'age': 48 },
  26018. * { 'user': 'barney', 'age': 36 },
  26019. * { 'user': 'fred', 'age': 40 },
  26020. * { 'user': 'barney', 'age': 34 }
  26021. * ];
  26022. *
  26023. * _.sortBy(users, [function(o) { return o.user; }]);
  26024. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26025. *
  26026. * _.sortBy(users, ['user', 'age']);
  26027. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26028. */
  26029. var sortBy = baseRest(function(collection, iteratees) {
  26030. if (collection == null) {
  26031. return [];
  26032. }
  26033. var length = iteratees.length;
  26034. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26035. iteratees = [];
  26036. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26037. iteratees = [iteratees[0]];
  26038. }
  26039. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26040. });
  26041. /*------------------------------------------------------------------------*/
  26042. /**
  26043. * Gets the timestamp of the number of milliseconds that have elapsed since
  26044. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26045. *
  26046. * @static
  26047. * @memberOf _
  26048. * @since 2.4.0
  26049. * @category Date
  26050. * @returns {number} Returns the timestamp.
  26051. * @example
  26052. *
  26053. * _.defer(function(stamp) {
  26054. * console.log(_.now() - stamp);
  26055. * }, _.now());
  26056. * // => Logs the number of milliseconds it took for the deferred invocation.
  26057. */
  26058. var now = ctxNow || function() {
  26059. return root.Date.now();
  26060. };
  26061. /*------------------------------------------------------------------------*/
  26062. /**
  26063. * The opposite of `_.before`; this method creates a function that invokes
  26064. * `func` once it's called `n` or more times.
  26065. *
  26066. * @static
  26067. * @memberOf _
  26068. * @since 0.1.0
  26069. * @category Function
  26070. * @param {number} n The number of calls before `func` is invoked.
  26071. * @param {Function} func The function to restrict.
  26072. * @returns {Function} Returns the new restricted function.
  26073. * @example
  26074. *
  26075. * var saves = ['profile', 'settings'];
  26076. *
  26077. * var done = _.after(saves.length, function() {
  26078. * console.log('done saving!');
  26079. * });
  26080. *
  26081. * _.forEach(saves, function(type) {
  26082. * asyncSave({ 'type': type, 'complete': done });
  26083. * });
  26084. * // => Logs 'done saving!' after the two async saves have completed.
  26085. */
  26086. function after(n, func) {
  26087. if (typeof func != 'function') {
  26088. throw new TypeError(FUNC_ERROR_TEXT);
  26089. }
  26090. n = toInteger(n);
  26091. return function() {
  26092. if (--n < 1) {
  26093. return func.apply(this, arguments);
  26094. }
  26095. };
  26096. }
  26097. /**
  26098. * Creates a function that invokes `func`, with up to `n` arguments,
  26099. * ignoring any additional arguments.
  26100. *
  26101. * @static
  26102. * @memberOf _
  26103. * @since 3.0.0
  26104. * @category Function
  26105. * @param {Function} func The function to cap arguments for.
  26106. * @param {number} [n=func.length] The arity cap.
  26107. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26108. * @returns {Function} Returns the new capped function.
  26109. * @example
  26110. *
  26111. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26112. * // => [6, 8, 10]
  26113. */
  26114. function ary(func, n, guard) {
  26115. n = guard ? undefined : n;
  26116. n = (func && n == null) ? func.length : n;
  26117. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26118. }
  26119. /**
  26120. * Creates a function that invokes `func`, with the `this` binding and arguments
  26121. * of the created function, while it's called less than `n` times. Subsequent
  26122. * calls to the created function return the result of the last `func` invocation.
  26123. *
  26124. * @static
  26125. * @memberOf _
  26126. * @since 3.0.0
  26127. * @category Function
  26128. * @param {number} n The number of calls at which `func` is no longer invoked.
  26129. * @param {Function} func The function to restrict.
  26130. * @returns {Function} Returns the new restricted function.
  26131. * @example
  26132. *
  26133. * jQuery(element).on('click', _.before(5, addContactToList));
  26134. * // => Allows adding up to 4 contacts to the list.
  26135. */
  26136. function before(n, func) {
  26137. var result;
  26138. if (typeof func != 'function') {
  26139. throw new TypeError(FUNC_ERROR_TEXT);
  26140. }
  26141. n = toInteger(n);
  26142. return function() {
  26143. if (--n > 0) {
  26144. result = func.apply(this, arguments);
  26145. }
  26146. if (n <= 1) {
  26147. func = undefined;
  26148. }
  26149. return result;
  26150. };
  26151. }
  26152. /**
  26153. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26154. * and `partials` prepended to the arguments it receives.
  26155. *
  26156. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26157. * may be used as a placeholder for partially applied arguments.
  26158. *
  26159. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26160. * property of bound functions.
  26161. *
  26162. * @static
  26163. * @memberOf _
  26164. * @since 0.1.0
  26165. * @category Function
  26166. * @param {Function} func The function to bind.
  26167. * @param {*} thisArg The `this` binding of `func`.
  26168. * @param {...*} [partials] The arguments to be partially applied.
  26169. * @returns {Function} Returns the new bound function.
  26170. * @example
  26171. *
  26172. * function greet(greeting, punctuation) {
  26173. * return greeting + ' ' + this.user + punctuation;
  26174. * }
  26175. *
  26176. * var object = { 'user': 'fred' };
  26177. *
  26178. * var bound = _.bind(greet, object, 'hi');
  26179. * bound('!');
  26180. * // => 'hi fred!'
  26181. *
  26182. * // Bound with placeholders.
  26183. * var bound = _.bind(greet, object, _, '!');
  26184. * bound('hi');
  26185. * // => 'hi fred!'
  26186. */
  26187. var bind = baseRest(function(func, thisArg, partials) {
  26188. var bitmask = WRAP_BIND_FLAG;
  26189. if (partials.length) {
  26190. var holders = replaceHolders(partials, getHolder(bind));
  26191. bitmask |= WRAP_PARTIAL_FLAG;
  26192. }
  26193. return createWrap(func, bitmask, thisArg, partials, holders);
  26194. });
  26195. /**
  26196. * Creates a function that invokes the method at `object[key]` with `partials`
  26197. * prepended to the arguments it receives.
  26198. *
  26199. * This method differs from `_.bind` by allowing bound functions to reference
  26200. * methods that may be redefined or don't yet exist. See
  26201. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26202. * for more details.
  26203. *
  26204. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26205. * builds, may be used as a placeholder for partially applied arguments.
  26206. *
  26207. * @static
  26208. * @memberOf _
  26209. * @since 0.10.0
  26210. * @category Function
  26211. * @param {Object} object The object to invoke the method on.
  26212. * @param {string} key The key of the method.
  26213. * @param {...*} [partials] The arguments to be partially applied.
  26214. * @returns {Function} Returns the new bound function.
  26215. * @example
  26216. *
  26217. * var object = {
  26218. * 'user': 'fred',
  26219. * 'greet': function(greeting, punctuation) {
  26220. * return greeting + ' ' + this.user + punctuation;
  26221. * }
  26222. * };
  26223. *
  26224. * var bound = _.bindKey(object, 'greet', 'hi');
  26225. * bound('!');
  26226. * // => 'hi fred!'
  26227. *
  26228. * object.greet = function(greeting, punctuation) {
  26229. * return greeting + 'ya ' + this.user + punctuation;
  26230. * };
  26231. *
  26232. * bound('!');
  26233. * // => 'hiya fred!'
  26234. *
  26235. * // Bound with placeholders.
  26236. * var bound = _.bindKey(object, 'greet', _, '!');
  26237. * bound('hi');
  26238. * // => 'hiya fred!'
  26239. */
  26240. var bindKey = baseRest(function(object, key, partials) {
  26241. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26242. if (partials.length) {
  26243. var holders = replaceHolders(partials, getHolder(bindKey));
  26244. bitmask |= WRAP_PARTIAL_FLAG;
  26245. }
  26246. return createWrap(key, bitmask, object, partials, holders);
  26247. });
  26248. /**
  26249. * Creates a function that accepts arguments of `func` and either invokes
  26250. * `func` returning its result, if at least `arity` number of arguments have
  26251. * been provided, or returns a function that accepts the remaining `func`
  26252. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26253. * is not sufficient.
  26254. *
  26255. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26256. * may be used as a placeholder for provided arguments.
  26257. *
  26258. * **Note:** This method doesn't set the "length" property of curried functions.
  26259. *
  26260. * @static
  26261. * @memberOf _
  26262. * @since 2.0.0
  26263. * @category Function
  26264. * @param {Function} func The function to curry.
  26265. * @param {number} [arity=func.length] The arity of `func`.
  26266. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26267. * @returns {Function} Returns the new curried function.
  26268. * @example
  26269. *
  26270. * var abc = function(a, b, c) {
  26271. * return [a, b, c];
  26272. * };
  26273. *
  26274. * var curried = _.curry(abc);
  26275. *
  26276. * curried(1)(2)(3);
  26277. * // => [1, 2, 3]
  26278. *
  26279. * curried(1, 2)(3);
  26280. * // => [1, 2, 3]
  26281. *
  26282. * curried(1, 2, 3);
  26283. * // => [1, 2, 3]
  26284. *
  26285. * // Curried with placeholders.
  26286. * curried(1)(_, 3)(2);
  26287. * // => [1, 2, 3]
  26288. */
  26289. function curry(func, arity, guard) {
  26290. arity = guard ? undefined : arity;
  26291. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26292. result.placeholder = curry.placeholder;
  26293. return result;
  26294. }
  26295. /**
  26296. * This method is like `_.curry` except that arguments are applied to `func`
  26297. * in the manner of `_.partialRight` instead of `_.partial`.
  26298. *
  26299. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26300. * builds, may be used as a placeholder for provided arguments.
  26301. *
  26302. * **Note:** This method doesn't set the "length" property of curried functions.
  26303. *
  26304. * @static
  26305. * @memberOf _
  26306. * @since 3.0.0
  26307. * @category Function
  26308. * @param {Function} func The function to curry.
  26309. * @param {number} [arity=func.length] The arity of `func`.
  26310. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26311. * @returns {Function} Returns the new curried function.
  26312. * @example
  26313. *
  26314. * var abc = function(a, b, c) {
  26315. * return [a, b, c];
  26316. * };
  26317. *
  26318. * var curried = _.curryRight(abc);
  26319. *
  26320. * curried(3)(2)(1);
  26321. * // => [1, 2, 3]
  26322. *
  26323. * curried(2, 3)(1);
  26324. * // => [1, 2, 3]
  26325. *
  26326. * curried(1, 2, 3);
  26327. * // => [1, 2, 3]
  26328. *
  26329. * // Curried with placeholders.
  26330. * curried(3)(1, _)(2);
  26331. * // => [1, 2, 3]
  26332. */
  26333. function curryRight(func, arity, guard) {
  26334. arity = guard ? undefined : arity;
  26335. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26336. result.placeholder = curryRight.placeholder;
  26337. return result;
  26338. }
  26339. /**
  26340. * Creates a debounced function that delays invoking `func` until after `wait`
  26341. * milliseconds have elapsed since the last time the debounced function was
  26342. * invoked. The debounced function comes with a `cancel` method to cancel
  26343. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26344. * Provide `options` to indicate whether `func` should be invoked on the
  26345. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26346. * with the last arguments provided to the debounced function. Subsequent
  26347. * calls to the debounced function return the result of the last `func`
  26348. * invocation.
  26349. *
  26350. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26351. * invoked on the trailing edge of the timeout only if the debounced function
  26352. * is invoked more than once during the `wait` timeout.
  26353. *
  26354. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26355. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26356. *
  26357. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26358. * for details over the differences between `_.debounce` and `_.throttle`.
  26359. *
  26360. * @static
  26361. * @memberOf _
  26362. * @since 0.1.0
  26363. * @category Function
  26364. * @param {Function} func The function to debounce.
  26365. * @param {number} [wait=0] The number of milliseconds to delay.
  26366. * @param {Object} [options={}] The options object.
  26367. * @param {boolean} [options.leading=false]
  26368. * Specify invoking on the leading edge of the timeout.
  26369. * @param {number} [options.maxWait]
  26370. * The maximum time `func` is allowed to be delayed before it's invoked.
  26371. * @param {boolean} [options.trailing=true]
  26372. * Specify invoking on the trailing edge of the timeout.
  26373. * @returns {Function} Returns the new debounced function.
  26374. * @example
  26375. *
  26376. * // Avoid costly calculations while the window size is in flux.
  26377. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26378. *
  26379. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26380. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26381. * 'leading': true,
  26382. * 'trailing': false
  26383. * }));
  26384. *
  26385. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26386. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26387. * var source = new EventSource('/stream');
  26388. * jQuery(source).on('message', debounced);
  26389. *
  26390. * // Cancel the trailing debounced invocation.
  26391. * jQuery(window).on('popstate', debounced.cancel);
  26392. */
  26393. function debounce(func, wait, options) {
  26394. var lastArgs,
  26395. lastThis,
  26396. maxWait,
  26397. result,
  26398. timerId,
  26399. lastCallTime,
  26400. lastInvokeTime = 0,
  26401. leading = false,
  26402. maxing = false,
  26403. trailing = true;
  26404. if (typeof func != 'function') {
  26405. throw new TypeError(FUNC_ERROR_TEXT);
  26406. }
  26407. wait = toNumber(wait) || 0;
  26408. if (isObject(options)) {
  26409. leading = !!options.leading;
  26410. maxing = 'maxWait' in options;
  26411. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26412. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26413. }
  26414. function invokeFunc(time) {
  26415. var args = lastArgs,
  26416. thisArg = lastThis;
  26417. lastArgs = lastThis = undefined;
  26418. lastInvokeTime = time;
  26419. result = func.apply(thisArg, args);
  26420. return result;
  26421. }
  26422. function leadingEdge(time) {
  26423. // Reset any `maxWait` timer.
  26424. lastInvokeTime = time;
  26425. // Start the timer for the trailing edge.
  26426. timerId = setTimeout(timerExpired, wait);
  26427. // Invoke the leading edge.
  26428. return leading ? invokeFunc(time) : result;
  26429. }
  26430. function remainingWait(time) {
  26431. var timeSinceLastCall = time - lastCallTime,
  26432. timeSinceLastInvoke = time - lastInvokeTime,
  26433. timeWaiting = wait - timeSinceLastCall;
  26434. return maxing
  26435. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26436. : timeWaiting;
  26437. }
  26438. function shouldInvoke(time) {
  26439. var timeSinceLastCall = time - lastCallTime,
  26440. timeSinceLastInvoke = time - lastInvokeTime;
  26441. // Either this is the first call, activity has stopped and we're at the
  26442. // trailing edge, the system time has gone backwards and we're treating
  26443. // it as the trailing edge, or we've hit the `maxWait` limit.
  26444. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26445. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26446. }
  26447. function timerExpired() {
  26448. var time = now();
  26449. if (shouldInvoke(time)) {
  26450. return trailingEdge(time);
  26451. }
  26452. // Restart the timer.
  26453. timerId = setTimeout(timerExpired, remainingWait(time));
  26454. }
  26455. function trailingEdge(time) {
  26456. timerId = undefined;
  26457. // Only invoke if we have `lastArgs` which means `func` has been
  26458. // debounced at least once.
  26459. if (trailing && lastArgs) {
  26460. return invokeFunc(time);
  26461. }
  26462. lastArgs = lastThis = undefined;
  26463. return result;
  26464. }
  26465. function cancel() {
  26466. if (timerId !== undefined) {
  26467. clearTimeout(timerId);
  26468. }
  26469. lastInvokeTime = 0;
  26470. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26471. }
  26472. function flush() {
  26473. return timerId === undefined ? result : trailingEdge(now());
  26474. }
  26475. function debounced() {
  26476. var time = now(),
  26477. isInvoking = shouldInvoke(time);
  26478. lastArgs = arguments;
  26479. lastThis = this;
  26480. lastCallTime = time;
  26481. if (isInvoking) {
  26482. if (timerId === undefined) {
  26483. return leadingEdge(lastCallTime);
  26484. }
  26485. if (maxing) {
  26486. // Handle invocations in a tight loop.
  26487. clearTimeout(timerId);
  26488. timerId = setTimeout(timerExpired, wait);
  26489. return invokeFunc(lastCallTime);
  26490. }
  26491. }
  26492. if (timerId === undefined) {
  26493. timerId = setTimeout(timerExpired, wait);
  26494. }
  26495. return result;
  26496. }
  26497. debounced.cancel = cancel;
  26498. debounced.flush = flush;
  26499. return debounced;
  26500. }
  26501. /**
  26502. * Defers invoking the `func` until the current call stack has cleared. Any
  26503. * additional arguments are provided to `func` when it's invoked.
  26504. *
  26505. * @static
  26506. * @memberOf _
  26507. * @since 0.1.0
  26508. * @category Function
  26509. * @param {Function} func The function to defer.
  26510. * @param {...*} [args] The arguments to invoke `func` with.
  26511. * @returns {number} Returns the timer id.
  26512. * @example
  26513. *
  26514. * _.defer(function(text) {
  26515. * console.log(text);
  26516. * }, 'deferred');
  26517. * // => Logs 'deferred' after one millisecond.
  26518. */
  26519. var defer = baseRest(function(func, args) {
  26520. return baseDelay(func, 1, args);
  26521. });
  26522. /**
  26523. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26524. * provided to `func` when it's invoked.
  26525. *
  26526. * @static
  26527. * @memberOf _
  26528. * @since 0.1.0
  26529. * @category Function
  26530. * @param {Function} func The function to delay.
  26531. * @param {number} wait The number of milliseconds to delay invocation.
  26532. * @param {...*} [args] The arguments to invoke `func` with.
  26533. * @returns {number} Returns the timer id.
  26534. * @example
  26535. *
  26536. * _.delay(function(text) {
  26537. * console.log(text);
  26538. * }, 1000, 'later');
  26539. * // => Logs 'later' after one second.
  26540. */
  26541. var delay = baseRest(function(func, wait, args) {
  26542. return baseDelay(func, toNumber(wait) || 0, args);
  26543. });
  26544. /**
  26545. * Creates a function that invokes `func` with arguments reversed.
  26546. *
  26547. * @static
  26548. * @memberOf _
  26549. * @since 4.0.0
  26550. * @category Function
  26551. * @param {Function} func The function to flip arguments for.
  26552. * @returns {Function} Returns the new flipped function.
  26553. * @example
  26554. *
  26555. * var flipped = _.flip(function() {
  26556. * return _.toArray(arguments);
  26557. * });
  26558. *
  26559. * flipped('a', 'b', 'c', 'd');
  26560. * // => ['d', 'c', 'b', 'a']
  26561. */
  26562. function flip(func) {
  26563. return createWrap(func, WRAP_FLIP_FLAG);
  26564. }
  26565. /**
  26566. * Creates a function that memoizes the result of `func`. If `resolver` is
  26567. * provided, it determines the cache key for storing the result based on the
  26568. * arguments provided to the memoized function. By default, the first argument
  26569. * provided to the memoized function is used as the map cache key. The `func`
  26570. * is invoked with the `this` binding of the memoized function.
  26571. *
  26572. * **Note:** The cache is exposed as the `cache` property on the memoized
  26573. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26574. * constructor with one whose instances implement the
  26575. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26576. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26577. *
  26578. * @static
  26579. * @memberOf _
  26580. * @since 0.1.0
  26581. * @category Function
  26582. * @param {Function} func The function to have its output memoized.
  26583. * @param {Function} [resolver] The function to resolve the cache key.
  26584. * @returns {Function} Returns the new memoized function.
  26585. * @example
  26586. *
  26587. * var object = { 'a': 1, 'b': 2 };
  26588. * var other = { 'c': 3, 'd': 4 };
  26589. *
  26590. * var values = _.memoize(_.values);
  26591. * values(object);
  26592. * // => [1, 2]
  26593. *
  26594. * values(other);
  26595. * // => [3, 4]
  26596. *
  26597. * object.a = 2;
  26598. * values(object);
  26599. * // => [1, 2]
  26600. *
  26601. * // Modify the result cache.
  26602. * values.cache.set(object, ['a', 'b']);
  26603. * values(object);
  26604. * // => ['a', 'b']
  26605. *
  26606. * // Replace `_.memoize.Cache`.
  26607. * _.memoize.Cache = WeakMap;
  26608. */
  26609. function memoize(func, resolver) {
  26610. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26611. throw new TypeError(FUNC_ERROR_TEXT);
  26612. }
  26613. var memoized = function() {
  26614. var args = arguments,
  26615. key = resolver ? resolver.apply(this, args) : args[0],
  26616. cache = memoized.cache;
  26617. if (cache.has(key)) {
  26618. return cache.get(key);
  26619. }
  26620. var result = func.apply(this, args);
  26621. memoized.cache = cache.set(key, result) || cache;
  26622. return result;
  26623. };
  26624. memoized.cache = new (memoize.Cache || MapCache);
  26625. return memoized;
  26626. }
  26627. // Expose `MapCache`.
  26628. memoize.Cache = MapCache;
  26629. /**
  26630. * Creates a function that negates the result of the predicate `func`. The
  26631. * `func` predicate is invoked with the `this` binding and arguments of the
  26632. * created function.
  26633. *
  26634. * @static
  26635. * @memberOf _
  26636. * @since 3.0.0
  26637. * @category Function
  26638. * @param {Function} predicate The predicate to negate.
  26639. * @returns {Function} Returns the new negated function.
  26640. * @example
  26641. *
  26642. * function isEven(n) {
  26643. * return n % 2 == 0;
  26644. * }
  26645. *
  26646. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26647. * // => [1, 3, 5]
  26648. */
  26649. function negate(predicate) {
  26650. if (typeof predicate != 'function') {
  26651. throw new TypeError(FUNC_ERROR_TEXT);
  26652. }
  26653. return function() {
  26654. var args = arguments;
  26655. switch (args.length) {
  26656. case 0: return !predicate.call(this);
  26657. case 1: return !predicate.call(this, args[0]);
  26658. case 2: return !predicate.call(this, args[0], args[1]);
  26659. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26660. }
  26661. return !predicate.apply(this, args);
  26662. };
  26663. }
  26664. /**
  26665. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26666. * to the function return the value of the first invocation. The `func` is
  26667. * invoked with the `this` binding and arguments of the created function.
  26668. *
  26669. * @static
  26670. * @memberOf _
  26671. * @since 0.1.0
  26672. * @category Function
  26673. * @param {Function} func The function to restrict.
  26674. * @returns {Function} Returns the new restricted function.
  26675. * @example
  26676. *
  26677. * var initialize = _.once(createApplication);
  26678. * initialize();
  26679. * initialize();
  26680. * // => `createApplication` is invoked once
  26681. */
  26682. function once(func) {
  26683. return before(2, func);
  26684. }
  26685. /**
  26686. * Creates a function that invokes `func` with its arguments transformed.
  26687. *
  26688. * @static
  26689. * @since 4.0.0
  26690. * @memberOf _
  26691. * @category Function
  26692. * @param {Function} func The function to wrap.
  26693. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26694. * The argument transforms.
  26695. * @returns {Function} Returns the new function.
  26696. * @example
  26697. *
  26698. * function doubled(n) {
  26699. * return n * 2;
  26700. * }
  26701. *
  26702. * function square(n) {
  26703. * return n * n;
  26704. * }
  26705. *
  26706. * var func = _.overArgs(function(x, y) {
  26707. * return [x, y];
  26708. * }, [square, doubled]);
  26709. *
  26710. * func(9, 3);
  26711. * // => [81, 6]
  26712. *
  26713. * func(10, 5);
  26714. * // => [100, 10]
  26715. */
  26716. var overArgs = castRest(function(func, transforms) {
  26717. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26718. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26719. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26720. var funcsLength = transforms.length;
  26721. return baseRest(function(args) {
  26722. var index = -1,
  26723. length = nativeMin(args.length, funcsLength);
  26724. while (++index < length) {
  26725. args[index] = transforms[index].call(this, args[index]);
  26726. }
  26727. return apply(func, this, args);
  26728. });
  26729. });
  26730. /**
  26731. * Creates a function that invokes `func` with `partials` prepended to the
  26732. * arguments it receives. This method is like `_.bind` except it does **not**
  26733. * alter the `this` binding.
  26734. *
  26735. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26736. * builds, may be used as a placeholder for partially applied arguments.
  26737. *
  26738. * **Note:** This method doesn't set the "length" property of partially
  26739. * applied functions.
  26740. *
  26741. * @static
  26742. * @memberOf _
  26743. * @since 0.2.0
  26744. * @category Function
  26745. * @param {Function} func The function to partially apply arguments to.
  26746. * @param {...*} [partials] The arguments to be partially applied.
  26747. * @returns {Function} Returns the new partially applied function.
  26748. * @example
  26749. *
  26750. * function greet(greeting, name) {
  26751. * return greeting + ' ' + name;
  26752. * }
  26753. *
  26754. * var sayHelloTo = _.partial(greet, 'hello');
  26755. * sayHelloTo('fred');
  26756. * // => 'hello fred'
  26757. *
  26758. * // Partially applied with placeholders.
  26759. * var greetFred = _.partial(greet, _, 'fred');
  26760. * greetFred('hi');
  26761. * // => 'hi fred'
  26762. */
  26763. var partial = baseRest(function(func, partials) {
  26764. var holders = replaceHolders(partials, getHolder(partial));
  26765. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26766. });
  26767. /**
  26768. * This method is like `_.partial` except that partially applied arguments
  26769. * are appended to the arguments it receives.
  26770. *
  26771. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26772. * builds, may be used as a placeholder for partially applied arguments.
  26773. *
  26774. * **Note:** This method doesn't set the "length" property of partially
  26775. * applied functions.
  26776. *
  26777. * @static
  26778. * @memberOf _
  26779. * @since 1.0.0
  26780. * @category Function
  26781. * @param {Function} func The function to partially apply arguments to.
  26782. * @param {...*} [partials] The arguments to be partially applied.
  26783. * @returns {Function} Returns the new partially applied function.
  26784. * @example
  26785. *
  26786. * function greet(greeting, name) {
  26787. * return greeting + ' ' + name;
  26788. * }
  26789. *
  26790. * var greetFred = _.partialRight(greet, 'fred');
  26791. * greetFred('hi');
  26792. * // => 'hi fred'
  26793. *
  26794. * // Partially applied with placeholders.
  26795. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26796. * sayHelloTo('fred');
  26797. * // => 'hello fred'
  26798. */
  26799. var partialRight = baseRest(function(func, partials) {
  26800. var holders = replaceHolders(partials, getHolder(partialRight));
  26801. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26802. });
  26803. /**
  26804. * Creates a function that invokes `func` with arguments arranged according
  26805. * to the specified `indexes` where the argument value at the first index is
  26806. * provided as the first argument, the argument value at the second index is
  26807. * provided as the second argument, and so on.
  26808. *
  26809. * @static
  26810. * @memberOf _
  26811. * @since 3.0.0
  26812. * @category Function
  26813. * @param {Function} func The function to rearrange arguments for.
  26814. * @param {...(number|number[])} indexes The arranged argument indexes.
  26815. * @returns {Function} Returns the new function.
  26816. * @example
  26817. *
  26818. * var rearged = _.rearg(function(a, b, c) {
  26819. * return [a, b, c];
  26820. * }, [2, 0, 1]);
  26821. *
  26822. * rearged('b', 'c', 'a')
  26823. * // => ['a', 'b', 'c']
  26824. */
  26825. var rearg = flatRest(function(func, indexes) {
  26826. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26827. });
  26828. /**
  26829. * Creates a function that invokes `func` with the `this` binding of the
  26830. * created function and arguments from `start` and beyond provided as
  26831. * an array.
  26832. *
  26833. * **Note:** This method is based on the
  26834. * [rest parameter](https://mdn.io/rest_parameters).
  26835. *
  26836. * @static
  26837. * @memberOf _
  26838. * @since 4.0.0
  26839. * @category Function
  26840. * @param {Function} func The function to apply a rest parameter to.
  26841. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26842. * @returns {Function} Returns the new function.
  26843. * @example
  26844. *
  26845. * var say = _.rest(function(what, names) {
  26846. * return what + ' ' + _.initial(names).join(', ') +
  26847. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26848. * });
  26849. *
  26850. * say('hello', 'fred', 'barney', 'pebbles');
  26851. * // => 'hello fred, barney, & pebbles'
  26852. */
  26853. function rest(func, start) {
  26854. if (typeof func != 'function') {
  26855. throw new TypeError(FUNC_ERROR_TEXT);
  26856. }
  26857. start = start === undefined ? start : toInteger(start);
  26858. return baseRest(func, start);
  26859. }
  26860. /**
  26861. * Creates a function that invokes `func` with the `this` binding of the
  26862. * create function and an array of arguments much like
  26863. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26864. *
  26865. * **Note:** This method is based on the
  26866. * [spread operator](https://mdn.io/spread_operator).
  26867. *
  26868. * @static
  26869. * @memberOf _
  26870. * @since 3.2.0
  26871. * @category Function
  26872. * @param {Function} func The function to spread arguments over.
  26873. * @param {number} [start=0] The start position of the spread.
  26874. * @returns {Function} Returns the new function.
  26875. * @example
  26876. *
  26877. * var say = _.spread(function(who, what) {
  26878. * return who + ' says ' + what;
  26879. * });
  26880. *
  26881. * say(['fred', 'hello']);
  26882. * // => 'fred says hello'
  26883. *
  26884. * var numbers = Promise.all([
  26885. * Promise.resolve(40),
  26886. * Promise.resolve(36)
  26887. * ]);
  26888. *
  26889. * numbers.then(_.spread(function(x, y) {
  26890. * return x + y;
  26891. * }));
  26892. * // => a Promise of 76
  26893. */
  26894. function spread(func, start) {
  26895. if (typeof func != 'function') {
  26896. throw new TypeError(FUNC_ERROR_TEXT);
  26897. }
  26898. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26899. return baseRest(function(args) {
  26900. var array = args[start],
  26901. otherArgs = castSlice(args, 0, start);
  26902. if (array) {
  26903. arrayPush(otherArgs, array);
  26904. }
  26905. return apply(func, this, otherArgs);
  26906. });
  26907. }
  26908. /**
  26909. * Creates a throttled function that only invokes `func` at most once per
  26910. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26911. * method to cancel delayed `func` invocations and a `flush` method to
  26912. * immediately invoke them. Provide `options` to indicate whether `func`
  26913. * should be invoked on the leading and/or trailing edge of the `wait`
  26914. * timeout. The `func` is invoked with the last arguments provided to the
  26915. * throttled function. Subsequent calls to the throttled function return the
  26916. * result of the last `func` invocation.
  26917. *
  26918. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26919. * invoked on the trailing edge of the timeout only if the throttled function
  26920. * is invoked more than once during the `wait` timeout.
  26921. *
  26922. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26923. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26924. *
  26925. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26926. * for details over the differences between `_.throttle` and `_.debounce`.
  26927. *
  26928. * @static
  26929. * @memberOf _
  26930. * @since 0.1.0
  26931. * @category Function
  26932. * @param {Function} func The function to throttle.
  26933. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26934. * @param {Object} [options={}] The options object.
  26935. * @param {boolean} [options.leading=true]
  26936. * Specify invoking on the leading edge of the timeout.
  26937. * @param {boolean} [options.trailing=true]
  26938. * Specify invoking on the trailing edge of the timeout.
  26939. * @returns {Function} Returns the new throttled function.
  26940. * @example
  26941. *
  26942. * // Avoid excessively updating the position while scrolling.
  26943. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26944. *
  26945. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26946. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26947. * jQuery(element).on('click', throttled);
  26948. *
  26949. * // Cancel the trailing throttled invocation.
  26950. * jQuery(window).on('popstate', throttled.cancel);
  26951. */
  26952. function throttle(func, wait, options) {
  26953. var leading = true,
  26954. trailing = true;
  26955. if (typeof func != 'function') {
  26956. throw new TypeError(FUNC_ERROR_TEXT);
  26957. }
  26958. if (isObject(options)) {
  26959. leading = 'leading' in options ? !!options.leading : leading;
  26960. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26961. }
  26962. return debounce(func, wait, {
  26963. 'leading': leading,
  26964. 'maxWait': wait,
  26965. 'trailing': trailing
  26966. });
  26967. }
  26968. /**
  26969. * Creates a function that accepts up to one argument, ignoring any
  26970. * additional arguments.
  26971. *
  26972. * @static
  26973. * @memberOf _
  26974. * @since 4.0.0
  26975. * @category Function
  26976. * @param {Function} func The function to cap arguments for.
  26977. * @returns {Function} Returns the new capped function.
  26978. * @example
  26979. *
  26980. * _.map(['6', '8', '10'], _.unary(parseInt));
  26981. * // => [6, 8, 10]
  26982. */
  26983. function unary(func) {
  26984. return ary(func, 1);
  26985. }
  26986. /**
  26987. * Creates a function that provides `value` to `wrapper` as its first
  26988. * argument. Any additional arguments provided to the function are appended
  26989. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  26990. * binding of the created function.
  26991. *
  26992. * @static
  26993. * @memberOf _
  26994. * @since 0.1.0
  26995. * @category Function
  26996. * @param {*} value The value to wrap.
  26997. * @param {Function} [wrapper=identity] The wrapper function.
  26998. * @returns {Function} Returns the new function.
  26999. * @example
  27000. *
  27001. * var p = _.wrap(_.escape, function(func, text) {
  27002. * return '<p>' + func(text) + '</p>';
  27003. * });
  27004. *
  27005. * p('fred, barney, & pebbles');
  27006. * // => '<p>fred, barney, &amp; pebbles</p>'
  27007. */
  27008. function wrap(value, wrapper) {
  27009. return partial(castFunction(wrapper), value);
  27010. }
  27011. /*------------------------------------------------------------------------*/
  27012. /**
  27013. * Casts `value` as an array if it's not one.
  27014. *
  27015. * @static
  27016. * @memberOf _
  27017. * @since 4.4.0
  27018. * @category Lang
  27019. * @param {*} value The value to inspect.
  27020. * @returns {Array} Returns the cast array.
  27021. * @example
  27022. *
  27023. * _.castArray(1);
  27024. * // => [1]
  27025. *
  27026. * _.castArray({ 'a': 1 });
  27027. * // => [{ 'a': 1 }]
  27028. *
  27029. * _.castArray('abc');
  27030. * // => ['abc']
  27031. *
  27032. * _.castArray(null);
  27033. * // => [null]
  27034. *
  27035. * _.castArray(undefined);
  27036. * // => [undefined]
  27037. *
  27038. * _.castArray();
  27039. * // => []
  27040. *
  27041. * var array = [1, 2, 3];
  27042. * console.log(_.castArray(array) === array);
  27043. * // => true
  27044. */
  27045. function castArray() {
  27046. if (!arguments.length) {
  27047. return [];
  27048. }
  27049. var value = arguments[0];
  27050. return isArray(value) ? value : [value];
  27051. }
  27052. /**
  27053. * Creates a shallow clone of `value`.
  27054. *
  27055. * **Note:** This method is loosely based on the
  27056. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27057. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27058. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27059. * arrays. The own enumerable properties of `arguments` objects are cloned
  27060. * as plain objects. An empty object is returned for uncloneable values such
  27061. * as error objects, functions, DOM nodes, and WeakMaps.
  27062. *
  27063. * @static
  27064. * @memberOf _
  27065. * @since 0.1.0
  27066. * @category Lang
  27067. * @param {*} value The value to clone.
  27068. * @returns {*} Returns the cloned value.
  27069. * @see _.cloneDeep
  27070. * @example
  27071. *
  27072. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27073. *
  27074. * var shallow = _.clone(objects);
  27075. * console.log(shallow[0] === objects[0]);
  27076. * // => true
  27077. */
  27078. function clone(value) {
  27079. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27080. }
  27081. /**
  27082. * This method is like `_.clone` except that it accepts `customizer` which
  27083. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27084. * cloning is handled by the method instead. The `customizer` is invoked with
  27085. * up to four arguments; (value [, index|key, object, stack]).
  27086. *
  27087. * @static
  27088. * @memberOf _
  27089. * @since 4.0.0
  27090. * @category Lang
  27091. * @param {*} value The value to clone.
  27092. * @param {Function} [customizer] The function to customize cloning.
  27093. * @returns {*} Returns the cloned value.
  27094. * @see _.cloneDeepWith
  27095. * @example
  27096. *
  27097. * function customizer(value) {
  27098. * if (_.isElement(value)) {
  27099. * return value.cloneNode(false);
  27100. * }
  27101. * }
  27102. *
  27103. * var el = _.cloneWith(document.body, customizer);
  27104. *
  27105. * console.log(el === document.body);
  27106. * // => false
  27107. * console.log(el.nodeName);
  27108. * // => 'BODY'
  27109. * console.log(el.childNodes.length);
  27110. * // => 0
  27111. */
  27112. function cloneWith(value, customizer) {
  27113. customizer = typeof customizer == 'function' ? customizer : undefined;
  27114. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27115. }
  27116. /**
  27117. * This method is like `_.clone` except that it recursively clones `value`.
  27118. *
  27119. * @static
  27120. * @memberOf _
  27121. * @since 1.0.0
  27122. * @category Lang
  27123. * @param {*} value The value to recursively clone.
  27124. * @returns {*} Returns the deep cloned value.
  27125. * @see _.clone
  27126. * @example
  27127. *
  27128. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27129. *
  27130. * var deep = _.cloneDeep(objects);
  27131. * console.log(deep[0] === objects[0]);
  27132. * // => false
  27133. */
  27134. function cloneDeep(value) {
  27135. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27136. }
  27137. /**
  27138. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27139. *
  27140. * @static
  27141. * @memberOf _
  27142. * @since 4.0.0
  27143. * @category Lang
  27144. * @param {*} value The value to recursively clone.
  27145. * @param {Function} [customizer] The function to customize cloning.
  27146. * @returns {*} Returns the deep cloned value.
  27147. * @see _.cloneWith
  27148. * @example
  27149. *
  27150. * function customizer(value) {
  27151. * if (_.isElement(value)) {
  27152. * return value.cloneNode(true);
  27153. * }
  27154. * }
  27155. *
  27156. * var el = _.cloneDeepWith(document.body, customizer);
  27157. *
  27158. * console.log(el === document.body);
  27159. * // => false
  27160. * console.log(el.nodeName);
  27161. * // => 'BODY'
  27162. * console.log(el.childNodes.length);
  27163. * // => 20
  27164. */
  27165. function cloneDeepWith(value, customizer) {
  27166. customizer = typeof customizer == 'function' ? customizer : undefined;
  27167. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27168. }
  27169. /**
  27170. * Checks if `object` conforms to `source` by invoking the predicate
  27171. * properties of `source` with the corresponding property values of `object`.
  27172. *
  27173. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27174. * partially applied.
  27175. *
  27176. * @static
  27177. * @memberOf _
  27178. * @since 4.14.0
  27179. * @category Lang
  27180. * @param {Object} object The object to inspect.
  27181. * @param {Object} source The object of property predicates to conform to.
  27182. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27183. * @example
  27184. *
  27185. * var object = { 'a': 1, 'b': 2 };
  27186. *
  27187. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27188. * // => true
  27189. *
  27190. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27191. * // => false
  27192. */
  27193. function conformsTo(object, source) {
  27194. return source == null || baseConformsTo(object, source, keys(source));
  27195. }
  27196. /**
  27197. * Performs a
  27198. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27199. * comparison between two values to determine if they are equivalent.
  27200. *
  27201. * @static
  27202. * @memberOf _
  27203. * @since 4.0.0
  27204. * @category Lang
  27205. * @param {*} value The value to compare.
  27206. * @param {*} other The other value to compare.
  27207. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27208. * @example
  27209. *
  27210. * var object = { 'a': 1 };
  27211. * var other = { 'a': 1 };
  27212. *
  27213. * _.eq(object, object);
  27214. * // => true
  27215. *
  27216. * _.eq(object, other);
  27217. * // => false
  27218. *
  27219. * _.eq('a', 'a');
  27220. * // => true
  27221. *
  27222. * _.eq('a', Object('a'));
  27223. * // => false
  27224. *
  27225. * _.eq(NaN, NaN);
  27226. * // => true
  27227. */
  27228. function eq(value, other) {
  27229. return value === other || (value !== value && other !== other);
  27230. }
  27231. /**
  27232. * Checks if `value` is greater than `other`.
  27233. *
  27234. * @static
  27235. * @memberOf _
  27236. * @since 3.9.0
  27237. * @category Lang
  27238. * @param {*} value The value to compare.
  27239. * @param {*} other The other value to compare.
  27240. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27241. * else `false`.
  27242. * @see _.lt
  27243. * @example
  27244. *
  27245. * _.gt(3, 1);
  27246. * // => true
  27247. *
  27248. * _.gt(3, 3);
  27249. * // => false
  27250. *
  27251. * _.gt(1, 3);
  27252. * // => false
  27253. */
  27254. var gt = createRelationalOperation(baseGt);
  27255. /**
  27256. * Checks if `value` is greater than or equal to `other`.
  27257. *
  27258. * @static
  27259. * @memberOf _
  27260. * @since 3.9.0
  27261. * @category Lang
  27262. * @param {*} value The value to compare.
  27263. * @param {*} other The other value to compare.
  27264. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27265. * `other`, else `false`.
  27266. * @see _.lte
  27267. * @example
  27268. *
  27269. * _.gte(3, 1);
  27270. * // => true
  27271. *
  27272. * _.gte(3, 3);
  27273. * // => true
  27274. *
  27275. * _.gte(1, 3);
  27276. * // => false
  27277. */
  27278. var gte = createRelationalOperation(function(value, other) {
  27279. return value >= other;
  27280. });
  27281. /**
  27282. * Checks if `value` is likely an `arguments` object.
  27283. *
  27284. * @static
  27285. * @memberOf _
  27286. * @since 0.1.0
  27287. * @category Lang
  27288. * @param {*} value The value to check.
  27289. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27290. * else `false`.
  27291. * @example
  27292. *
  27293. * _.isArguments(function() { return arguments; }());
  27294. * // => true
  27295. *
  27296. * _.isArguments([1, 2, 3]);
  27297. * // => false
  27298. */
  27299. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27300. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27301. !propertyIsEnumerable.call(value, 'callee');
  27302. };
  27303. /**
  27304. * Checks if `value` is classified as an `Array` object.
  27305. *
  27306. * @static
  27307. * @memberOf _
  27308. * @since 0.1.0
  27309. * @category Lang
  27310. * @param {*} value The value to check.
  27311. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27312. * @example
  27313. *
  27314. * _.isArray([1, 2, 3]);
  27315. * // => true
  27316. *
  27317. * _.isArray(document.body.children);
  27318. * // => false
  27319. *
  27320. * _.isArray('abc');
  27321. * // => false
  27322. *
  27323. * _.isArray(_.noop);
  27324. * // => false
  27325. */
  27326. var isArray = Array.isArray;
  27327. /**
  27328. * Checks if `value` is classified as an `ArrayBuffer` object.
  27329. *
  27330. * @static
  27331. * @memberOf _
  27332. * @since 4.3.0
  27333. * @category Lang
  27334. * @param {*} value The value to check.
  27335. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27336. * @example
  27337. *
  27338. * _.isArrayBuffer(new ArrayBuffer(2));
  27339. * // => true
  27340. *
  27341. * _.isArrayBuffer(new Array(2));
  27342. * // => false
  27343. */
  27344. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27345. /**
  27346. * Checks if `value` is array-like. A value is considered array-like if it's
  27347. * not a function and has a `value.length` that's an integer greater than or
  27348. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27349. *
  27350. * @static
  27351. * @memberOf _
  27352. * @since 4.0.0
  27353. * @category Lang
  27354. * @param {*} value The value to check.
  27355. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27356. * @example
  27357. *
  27358. * _.isArrayLike([1, 2, 3]);
  27359. * // => true
  27360. *
  27361. * _.isArrayLike(document.body.children);
  27362. * // => true
  27363. *
  27364. * _.isArrayLike('abc');
  27365. * // => true
  27366. *
  27367. * _.isArrayLike(_.noop);
  27368. * // => false
  27369. */
  27370. function isArrayLike(value) {
  27371. return value != null && isLength(value.length) && !isFunction(value);
  27372. }
  27373. /**
  27374. * This method is like `_.isArrayLike` except that it also checks if `value`
  27375. * is an object.
  27376. *
  27377. * @static
  27378. * @memberOf _
  27379. * @since 4.0.0
  27380. * @category Lang
  27381. * @param {*} value The value to check.
  27382. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27383. * else `false`.
  27384. * @example
  27385. *
  27386. * _.isArrayLikeObject([1, 2, 3]);
  27387. * // => true
  27388. *
  27389. * _.isArrayLikeObject(document.body.children);
  27390. * // => true
  27391. *
  27392. * _.isArrayLikeObject('abc');
  27393. * // => false
  27394. *
  27395. * _.isArrayLikeObject(_.noop);
  27396. * // => false
  27397. */
  27398. function isArrayLikeObject(value) {
  27399. return isObjectLike(value) && isArrayLike(value);
  27400. }
  27401. /**
  27402. * Checks if `value` is classified as a boolean primitive or object.
  27403. *
  27404. * @static
  27405. * @memberOf _
  27406. * @since 0.1.0
  27407. * @category Lang
  27408. * @param {*} value The value to check.
  27409. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27410. * @example
  27411. *
  27412. * _.isBoolean(false);
  27413. * // => true
  27414. *
  27415. * _.isBoolean(null);
  27416. * // => false
  27417. */
  27418. function isBoolean(value) {
  27419. return value === true || value === false ||
  27420. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27421. }
  27422. /**
  27423. * Checks if `value` is a buffer.
  27424. *
  27425. * @static
  27426. * @memberOf _
  27427. * @since 4.3.0
  27428. * @category Lang
  27429. * @param {*} value The value to check.
  27430. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27431. * @example
  27432. *
  27433. * _.isBuffer(new Buffer(2));
  27434. * // => true
  27435. *
  27436. * _.isBuffer(new Uint8Array(2));
  27437. * // => false
  27438. */
  27439. var isBuffer = nativeIsBuffer || stubFalse;
  27440. /**
  27441. * Checks if `value` is classified as a `Date` object.
  27442. *
  27443. * @static
  27444. * @memberOf _
  27445. * @since 0.1.0
  27446. * @category Lang
  27447. * @param {*} value The value to check.
  27448. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27449. * @example
  27450. *
  27451. * _.isDate(new Date);
  27452. * // => true
  27453. *
  27454. * _.isDate('Mon April 23 2012');
  27455. * // => false
  27456. */
  27457. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27458. /**
  27459. * Checks if `value` is likely a DOM element.
  27460. *
  27461. * @static
  27462. * @memberOf _
  27463. * @since 0.1.0
  27464. * @category Lang
  27465. * @param {*} value The value to check.
  27466. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27467. * @example
  27468. *
  27469. * _.isElement(document.body);
  27470. * // => true
  27471. *
  27472. * _.isElement('<body>');
  27473. * // => false
  27474. */
  27475. function isElement(value) {
  27476. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27477. }
  27478. /**
  27479. * Checks if `value` is an empty object, collection, map, or set.
  27480. *
  27481. * Objects are considered empty if they have no own enumerable string keyed
  27482. * properties.
  27483. *
  27484. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27485. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27486. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27487. *
  27488. * @static
  27489. * @memberOf _
  27490. * @since 0.1.0
  27491. * @category Lang
  27492. * @param {*} value The value to check.
  27493. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27494. * @example
  27495. *
  27496. * _.isEmpty(null);
  27497. * // => true
  27498. *
  27499. * _.isEmpty(true);
  27500. * // => true
  27501. *
  27502. * _.isEmpty(1);
  27503. * // => true
  27504. *
  27505. * _.isEmpty([1, 2, 3]);
  27506. * // => false
  27507. *
  27508. * _.isEmpty({ 'a': 1 });
  27509. * // => false
  27510. */
  27511. function isEmpty(value) {
  27512. if (value == null) {
  27513. return true;
  27514. }
  27515. if (isArrayLike(value) &&
  27516. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27517. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27518. return !value.length;
  27519. }
  27520. var tag = getTag(value);
  27521. if (tag == mapTag || tag == setTag) {
  27522. return !value.size;
  27523. }
  27524. if (isPrototype(value)) {
  27525. return !baseKeys(value).length;
  27526. }
  27527. for (var key in value) {
  27528. if (hasOwnProperty.call(value, key)) {
  27529. return false;
  27530. }
  27531. }
  27532. return true;
  27533. }
  27534. /**
  27535. * Performs a deep comparison between two values to determine if they are
  27536. * equivalent.
  27537. *
  27538. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27539. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27540. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27541. * by their own, not inherited, enumerable properties. Functions and DOM
  27542. * nodes are compared by strict equality, i.e. `===`.
  27543. *
  27544. * @static
  27545. * @memberOf _
  27546. * @since 0.1.0
  27547. * @category Lang
  27548. * @param {*} value The value to compare.
  27549. * @param {*} other The other value to compare.
  27550. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27551. * @example
  27552. *
  27553. * var object = { 'a': 1 };
  27554. * var other = { 'a': 1 };
  27555. *
  27556. * _.isEqual(object, other);
  27557. * // => true
  27558. *
  27559. * object === other;
  27560. * // => false
  27561. */
  27562. function isEqual(value, other) {
  27563. return baseIsEqual(value, other);
  27564. }
  27565. /**
  27566. * This method is like `_.isEqual` except that it accepts `customizer` which
  27567. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27568. * are handled by the method instead. The `customizer` is invoked with up to
  27569. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27570. *
  27571. * @static
  27572. * @memberOf _
  27573. * @since 4.0.0
  27574. * @category Lang
  27575. * @param {*} value The value to compare.
  27576. * @param {*} other The other value to compare.
  27577. * @param {Function} [customizer] The function to customize comparisons.
  27578. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27579. * @example
  27580. *
  27581. * function isGreeting(value) {
  27582. * return /^h(?:i|ello)$/.test(value);
  27583. * }
  27584. *
  27585. * function customizer(objValue, othValue) {
  27586. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27587. * return true;
  27588. * }
  27589. * }
  27590. *
  27591. * var array = ['hello', 'goodbye'];
  27592. * var other = ['hi', 'goodbye'];
  27593. *
  27594. * _.isEqualWith(array, other, customizer);
  27595. * // => true
  27596. */
  27597. function isEqualWith(value, other, customizer) {
  27598. customizer = typeof customizer == 'function' ? customizer : undefined;
  27599. var result = customizer ? customizer(value, other) : undefined;
  27600. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27601. }
  27602. /**
  27603. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27604. * `SyntaxError`, `TypeError`, or `URIError` object.
  27605. *
  27606. * @static
  27607. * @memberOf _
  27608. * @since 3.0.0
  27609. * @category Lang
  27610. * @param {*} value The value to check.
  27611. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27612. * @example
  27613. *
  27614. * _.isError(new Error);
  27615. * // => true
  27616. *
  27617. * _.isError(Error);
  27618. * // => false
  27619. */
  27620. function isError(value) {
  27621. if (!isObjectLike(value)) {
  27622. return false;
  27623. }
  27624. var tag = baseGetTag(value);
  27625. return tag == errorTag || tag == domExcTag ||
  27626. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27627. }
  27628. /**
  27629. * Checks if `value` is a finite primitive number.
  27630. *
  27631. * **Note:** This method is based on
  27632. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27633. *
  27634. * @static
  27635. * @memberOf _
  27636. * @since 0.1.0
  27637. * @category Lang
  27638. * @param {*} value The value to check.
  27639. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27640. * @example
  27641. *
  27642. * _.isFinite(3);
  27643. * // => true
  27644. *
  27645. * _.isFinite(Number.MIN_VALUE);
  27646. * // => true
  27647. *
  27648. * _.isFinite(Infinity);
  27649. * // => false
  27650. *
  27651. * _.isFinite('3');
  27652. * // => false
  27653. */
  27654. function isFinite(value) {
  27655. return typeof value == 'number' && nativeIsFinite(value);
  27656. }
  27657. /**
  27658. * Checks if `value` is classified as a `Function` object.
  27659. *
  27660. * @static
  27661. * @memberOf _
  27662. * @since 0.1.0
  27663. * @category Lang
  27664. * @param {*} value The value to check.
  27665. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27666. * @example
  27667. *
  27668. * _.isFunction(_);
  27669. * // => true
  27670. *
  27671. * _.isFunction(/abc/);
  27672. * // => false
  27673. */
  27674. function isFunction(value) {
  27675. if (!isObject(value)) {
  27676. return false;
  27677. }
  27678. // The use of `Object#toString` avoids issues with the `typeof` operator
  27679. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27680. var tag = baseGetTag(value);
  27681. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27682. }
  27683. /**
  27684. * Checks if `value` is an integer.
  27685. *
  27686. * **Note:** This method is based on
  27687. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27688. *
  27689. * @static
  27690. * @memberOf _
  27691. * @since 4.0.0
  27692. * @category Lang
  27693. * @param {*} value The value to check.
  27694. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27695. * @example
  27696. *
  27697. * _.isInteger(3);
  27698. * // => true
  27699. *
  27700. * _.isInteger(Number.MIN_VALUE);
  27701. * // => false
  27702. *
  27703. * _.isInteger(Infinity);
  27704. * // => false
  27705. *
  27706. * _.isInteger('3');
  27707. * // => false
  27708. */
  27709. function isInteger(value) {
  27710. return typeof value == 'number' && value == toInteger(value);
  27711. }
  27712. /**
  27713. * Checks if `value` is a valid array-like length.
  27714. *
  27715. * **Note:** This method is loosely based on
  27716. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27717. *
  27718. * @static
  27719. * @memberOf _
  27720. * @since 4.0.0
  27721. * @category Lang
  27722. * @param {*} value The value to check.
  27723. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27724. * @example
  27725. *
  27726. * _.isLength(3);
  27727. * // => true
  27728. *
  27729. * _.isLength(Number.MIN_VALUE);
  27730. * // => false
  27731. *
  27732. * _.isLength(Infinity);
  27733. * // => false
  27734. *
  27735. * _.isLength('3');
  27736. * // => false
  27737. */
  27738. function isLength(value) {
  27739. return typeof value == 'number' &&
  27740. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27741. }
  27742. /**
  27743. * Checks if `value` is the
  27744. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27745. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27746. *
  27747. * @static
  27748. * @memberOf _
  27749. * @since 0.1.0
  27750. * @category Lang
  27751. * @param {*} value The value to check.
  27752. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27753. * @example
  27754. *
  27755. * _.isObject({});
  27756. * // => true
  27757. *
  27758. * _.isObject([1, 2, 3]);
  27759. * // => true
  27760. *
  27761. * _.isObject(_.noop);
  27762. * // => true
  27763. *
  27764. * _.isObject(null);
  27765. * // => false
  27766. */
  27767. function isObject(value) {
  27768. var type = typeof value;
  27769. return value != null && (type == 'object' || type == 'function');
  27770. }
  27771. /**
  27772. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27773. * and has a `typeof` result of "object".
  27774. *
  27775. * @static
  27776. * @memberOf _
  27777. * @since 4.0.0
  27778. * @category Lang
  27779. * @param {*} value The value to check.
  27780. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27781. * @example
  27782. *
  27783. * _.isObjectLike({});
  27784. * // => true
  27785. *
  27786. * _.isObjectLike([1, 2, 3]);
  27787. * // => true
  27788. *
  27789. * _.isObjectLike(_.noop);
  27790. * // => false
  27791. *
  27792. * _.isObjectLike(null);
  27793. * // => false
  27794. */
  27795. function isObjectLike(value) {
  27796. return value != null && typeof value == 'object';
  27797. }
  27798. /**
  27799. * Checks if `value` is classified as a `Map` object.
  27800. *
  27801. * @static
  27802. * @memberOf _
  27803. * @since 4.3.0
  27804. * @category Lang
  27805. * @param {*} value The value to check.
  27806. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27807. * @example
  27808. *
  27809. * _.isMap(new Map);
  27810. * // => true
  27811. *
  27812. * _.isMap(new WeakMap);
  27813. * // => false
  27814. */
  27815. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27816. /**
  27817. * Performs a partial deep comparison between `object` and `source` to
  27818. * determine if `object` contains equivalent property values.
  27819. *
  27820. * **Note:** This method is equivalent to `_.matches` when `source` is
  27821. * partially applied.
  27822. *
  27823. * Partial comparisons will match empty array and empty object `source`
  27824. * values against any array or object value, respectively. See `_.isEqual`
  27825. * for a list of supported value comparisons.
  27826. *
  27827. * @static
  27828. * @memberOf _
  27829. * @since 3.0.0
  27830. * @category Lang
  27831. * @param {Object} object The object to inspect.
  27832. * @param {Object} source The object of property values to match.
  27833. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27834. * @example
  27835. *
  27836. * var object = { 'a': 1, 'b': 2 };
  27837. *
  27838. * _.isMatch(object, { 'b': 2 });
  27839. * // => true
  27840. *
  27841. * _.isMatch(object, { 'b': 1 });
  27842. * // => false
  27843. */
  27844. function isMatch(object, source) {
  27845. return object === source || baseIsMatch(object, source, getMatchData(source));
  27846. }
  27847. /**
  27848. * This method is like `_.isMatch` except that it accepts `customizer` which
  27849. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27850. * are handled by the method instead. The `customizer` is invoked with five
  27851. * arguments: (objValue, srcValue, index|key, object, source).
  27852. *
  27853. * @static
  27854. * @memberOf _
  27855. * @since 4.0.0
  27856. * @category Lang
  27857. * @param {Object} object The object to inspect.
  27858. * @param {Object} source The object of property values to match.
  27859. * @param {Function} [customizer] The function to customize comparisons.
  27860. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27861. * @example
  27862. *
  27863. * function isGreeting(value) {
  27864. * return /^h(?:i|ello)$/.test(value);
  27865. * }
  27866. *
  27867. * function customizer(objValue, srcValue) {
  27868. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27869. * return true;
  27870. * }
  27871. * }
  27872. *
  27873. * var object = { 'greeting': 'hello' };
  27874. * var source = { 'greeting': 'hi' };
  27875. *
  27876. * _.isMatchWith(object, source, customizer);
  27877. * // => true
  27878. */
  27879. function isMatchWith(object, source, customizer) {
  27880. customizer = typeof customizer == 'function' ? customizer : undefined;
  27881. return baseIsMatch(object, source, getMatchData(source), customizer);
  27882. }
  27883. /**
  27884. * Checks if `value` is `NaN`.
  27885. *
  27886. * **Note:** This method is based on
  27887. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27888. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27889. * `undefined` and other non-number values.
  27890. *
  27891. * @static
  27892. * @memberOf _
  27893. * @since 0.1.0
  27894. * @category Lang
  27895. * @param {*} value The value to check.
  27896. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27897. * @example
  27898. *
  27899. * _.isNaN(NaN);
  27900. * // => true
  27901. *
  27902. * _.isNaN(new Number(NaN));
  27903. * // => true
  27904. *
  27905. * isNaN(undefined);
  27906. * // => true
  27907. *
  27908. * _.isNaN(undefined);
  27909. * // => false
  27910. */
  27911. function isNaN(value) {
  27912. // An `NaN` primitive is the only value that is not equal to itself.
  27913. // Perform the `toStringTag` check first to avoid errors with some
  27914. // ActiveX objects in IE.
  27915. return isNumber(value) && value != +value;
  27916. }
  27917. /**
  27918. * Checks if `value` is a pristine native function.
  27919. *
  27920. * **Note:** This method can't reliably detect native functions in the presence
  27921. * of the core-js package because core-js circumvents this kind of detection.
  27922. * Despite multiple requests, the core-js maintainer has made it clear: any
  27923. * attempt to fix the detection will be obstructed. As a result, we're left
  27924. * with little choice but to throw an error. Unfortunately, this also affects
  27925. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27926. * which rely on core-js.
  27927. *
  27928. * @static
  27929. * @memberOf _
  27930. * @since 3.0.0
  27931. * @category Lang
  27932. * @param {*} value The value to check.
  27933. * @returns {boolean} Returns `true` if `value` is a native function,
  27934. * else `false`.
  27935. * @example
  27936. *
  27937. * _.isNative(Array.prototype.push);
  27938. * // => true
  27939. *
  27940. * _.isNative(_);
  27941. * // => false
  27942. */
  27943. function isNative(value) {
  27944. if (isMaskable(value)) {
  27945. throw new Error(CORE_ERROR_TEXT);
  27946. }
  27947. return baseIsNative(value);
  27948. }
  27949. /**
  27950. * Checks if `value` is `null`.
  27951. *
  27952. * @static
  27953. * @memberOf _
  27954. * @since 0.1.0
  27955. * @category Lang
  27956. * @param {*} value The value to check.
  27957. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27958. * @example
  27959. *
  27960. * _.isNull(null);
  27961. * // => true
  27962. *
  27963. * _.isNull(void 0);
  27964. * // => false
  27965. */
  27966. function isNull(value) {
  27967. return value === null;
  27968. }
  27969. /**
  27970. * Checks if `value` is `null` or `undefined`.
  27971. *
  27972. * @static
  27973. * @memberOf _
  27974. * @since 4.0.0
  27975. * @category Lang
  27976. * @param {*} value The value to check.
  27977. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  27978. * @example
  27979. *
  27980. * _.isNil(null);
  27981. * // => true
  27982. *
  27983. * _.isNil(void 0);
  27984. * // => true
  27985. *
  27986. * _.isNil(NaN);
  27987. * // => false
  27988. */
  27989. function isNil(value) {
  27990. return value == null;
  27991. }
  27992. /**
  27993. * Checks if `value` is classified as a `Number` primitive or object.
  27994. *
  27995. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  27996. * classified as numbers, use the `_.isFinite` method.
  27997. *
  27998. * @static
  27999. * @memberOf _
  28000. * @since 0.1.0
  28001. * @category Lang
  28002. * @param {*} value The value to check.
  28003. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28004. * @example
  28005. *
  28006. * _.isNumber(3);
  28007. * // => true
  28008. *
  28009. * _.isNumber(Number.MIN_VALUE);
  28010. * // => true
  28011. *
  28012. * _.isNumber(Infinity);
  28013. * // => true
  28014. *
  28015. * _.isNumber('3');
  28016. * // => false
  28017. */
  28018. function isNumber(value) {
  28019. return typeof value == 'number' ||
  28020. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28021. }
  28022. /**
  28023. * Checks if `value` is a plain object, that is, an object created by the
  28024. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28025. *
  28026. * @static
  28027. * @memberOf _
  28028. * @since 0.8.0
  28029. * @category Lang
  28030. * @param {*} value The value to check.
  28031. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28032. * @example
  28033. *
  28034. * function Foo() {
  28035. * this.a = 1;
  28036. * }
  28037. *
  28038. * _.isPlainObject(new Foo);
  28039. * // => false
  28040. *
  28041. * _.isPlainObject([1, 2, 3]);
  28042. * // => false
  28043. *
  28044. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28045. * // => true
  28046. *
  28047. * _.isPlainObject(Object.create(null));
  28048. * // => true
  28049. */
  28050. function isPlainObject(value) {
  28051. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28052. return false;
  28053. }
  28054. var proto = getPrototype(value);
  28055. if (proto === null) {
  28056. return true;
  28057. }
  28058. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28059. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28060. funcToString.call(Ctor) == objectCtorString;
  28061. }
  28062. /**
  28063. * Checks if `value` is classified as a `RegExp` object.
  28064. *
  28065. * @static
  28066. * @memberOf _
  28067. * @since 0.1.0
  28068. * @category Lang
  28069. * @param {*} value The value to check.
  28070. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28071. * @example
  28072. *
  28073. * _.isRegExp(/abc/);
  28074. * // => true
  28075. *
  28076. * _.isRegExp('/abc/');
  28077. * // => false
  28078. */
  28079. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28080. /**
  28081. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28082. * double precision number which isn't the result of a rounded unsafe integer.
  28083. *
  28084. * **Note:** This method is based on
  28085. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28086. *
  28087. * @static
  28088. * @memberOf _
  28089. * @since 4.0.0
  28090. * @category Lang
  28091. * @param {*} value The value to check.
  28092. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28093. * @example
  28094. *
  28095. * _.isSafeInteger(3);
  28096. * // => true
  28097. *
  28098. * _.isSafeInteger(Number.MIN_VALUE);
  28099. * // => false
  28100. *
  28101. * _.isSafeInteger(Infinity);
  28102. * // => false
  28103. *
  28104. * _.isSafeInteger('3');
  28105. * // => false
  28106. */
  28107. function isSafeInteger(value) {
  28108. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28109. }
  28110. /**
  28111. * Checks if `value` is classified as a `Set` object.
  28112. *
  28113. * @static
  28114. * @memberOf _
  28115. * @since 4.3.0
  28116. * @category Lang
  28117. * @param {*} value The value to check.
  28118. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28119. * @example
  28120. *
  28121. * _.isSet(new Set);
  28122. * // => true
  28123. *
  28124. * _.isSet(new WeakSet);
  28125. * // => false
  28126. */
  28127. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28128. /**
  28129. * Checks if `value` is classified as a `String` primitive or object.
  28130. *
  28131. * @static
  28132. * @since 0.1.0
  28133. * @memberOf _
  28134. * @category Lang
  28135. * @param {*} value The value to check.
  28136. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28137. * @example
  28138. *
  28139. * _.isString('abc');
  28140. * // => true
  28141. *
  28142. * _.isString(1);
  28143. * // => false
  28144. */
  28145. function isString(value) {
  28146. return typeof value == 'string' ||
  28147. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28148. }
  28149. /**
  28150. * Checks if `value` is classified as a `Symbol` primitive or object.
  28151. *
  28152. * @static
  28153. * @memberOf _
  28154. * @since 4.0.0
  28155. * @category Lang
  28156. * @param {*} value The value to check.
  28157. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28158. * @example
  28159. *
  28160. * _.isSymbol(Symbol.iterator);
  28161. * // => true
  28162. *
  28163. * _.isSymbol('abc');
  28164. * // => false
  28165. */
  28166. function isSymbol(value) {
  28167. return typeof value == 'symbol' ||
  28168. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28169. }
  28170. /**
  28171. * Checks if `value` is classified as a typed array.
  28172. *
  28173. * @static
  28174. * @memberOf _
  28175. * @since 3.0.0
  28176. * @category Lang
  28177. * @param {*} value The value to check.
  28178. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28179. * @example
  28180. *
  28181. * _.isTypedArray(new Uint8Array);
  28182. * // => true
  28183. *
  28184. * _.isTypedArray([]);
  28185. * // => false
  28186. */
  28187. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28188. /**
  28189. * Checks if `value` is `undefined`.
  28190. *
  28191. * @static
  28192. * @since 0.1.0
  28193. * @memberOf _
  28194. * @category Lang
  28195. * @param {*} value The value to check.
  28196. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28197. * @example
  28198. *
  28199. * _.isUndefined(void 0);
  28200. * // => true
  28201. *
  28202. * _.isUndefined(null);
  28203. * // => false
  28204. */
  28205. function isUndefined(value) {
  28206. return value === undefined;
  28207. }
  28208. /**
  28209. * Checks if `value` is classified as a `WeakMap` object.
  28210. *
  28211. * @static
  28212. * @memberOf _
  28213. * @since 4.3.0
  28214. * @category Lang
  28215. * @param {*} value The value to check.
  28216. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28217. * @example
  28218. *
  28219. * _.isWeakMap(new WeakMap);
  28220. * // => true
  28221. *
  28222. * _.isWeakMap(new Map);
  28223. * // => false
  28224. */
  28225. function isWeakMap(value) {
  28226. return isObjectLike(value) && getTag(value) == weakMapTag;
  28227. }
  28228. /**
  28229. * Checks if `value` is classified as a `WeakSet` object.
  28230. *
  28231. * @static
  28232. * @memberOf _
  28233. * @since 4.3.0
  28234. * @category Lang
  28235. * @param {*} value The value to check.
  28236. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28237. * @example
  28238. *
  28239. * _.isWeakSet(new WeakSet);
  28240. * // => true
  28241. *
  28242. * _.isWeakSet(new Set);
  28243. * // => false
  28244. */
  28245. function isWeakSet(value) {
  28246. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28247. }
  28248. /**
  28249. * Checks if `value` is less than `other`.
  28250. *
  28251. * @static
  28252. * @memberOf _
  28253. * @since 3.9.0
  28254. * @category Lang
  28255. * @param {*} value The value to compare.
  28256. * @param {*} other The other value to compare.
  28257. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28258. * else `false`.
  28259. * @see _.gt
  28260. * @example
  28261. *
  28262. * _.lt(1, 3);
  28263. * // => true
  28264. *
  28265. * _.lt(3, 3);
  28266. * // => false
  28267. *
  28268. * _.lt(3, 1);
  28269. * // => false
  28270. */
  28271. var lt = createRelationalOperation(baseLt);
  28272. /**
  28273. * Checks if `value` is less than or equal to `other`.
  28274. *
  28275. * @static
  28276. * @memberOf _
  28277. * @since 3.9.0
  28278. * @category Lang
  28279. * @param {*} value The value to compare.
  28280. * @param {*} other The other value to compare.
  28281. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28282. * `other`, else `false`.
  28283. * @see _.gte
  28284. * @example
  28285. *
  28286. * _.lte(1, 3);
  28287. * // => true
  28288. *
  28289. * _.lte(3, 3);
  28290. * // => true
  28291. *
  28292. * _.lte(3, 1);
  28293. * // => false
  28294. */
  28295. var lte = createRelationalOperation(function(value, other) {
  28296. return value <= other;
  28297. });
  28298. /**
  28299. * Converts `value` to an array.
  28300. *
  28301. * @static
  28302. * @since 0.1.0
  28303. * @memberOf _
  28304. * @category Lang
  28305. * @param {*} value The value to convert.
  28306. * @returns {Array} Returns the converted array.
  28307. * @example
  28308. *
  28309. * _.toArray({ 'a': 1, 'b': 2 });
  28310. * // => [1, 2]
  28311. *
  28312. * _.toArray('abc');
  28313. * // => ['a', 'b', 'c']
  28314. *
  28315. * _.toArray(1);
  28316. * // => []
  28317. *
  28318. * _.toArray(null);
  28319. * // => []
  28320. */
  28321. function toArray(value) {
  28322. if (!value) {
  28323. return [];
  28324. }
  28325. if (isArrayLike(value)) {
  28326. return isString(value) ? stringToArray(value) : copyArray(value);
  28327. }
  28328. if (symIterator && value[symIterator]) {
  28329. return iteratorToArray(value[symIterator]());
  28330. }
  28331. var tag = getTag(value),
  28332. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28333. return func(value);
  28334. }
  28335. /**
  28336. * Converts `value` to a finite number.
  28337. *
  28338. * @static
  28339. * @memberOf _
  28340. * @since 4.12.0
  28341. * @category Lang
  28342. * @param {*} value The value to convert.
  28343. * @returns {number} Returns the converted number.
  28344. * @example
  28345. *
  28346. * _.toFinite(3.2);
  28347. * // => 3.2
  28348. *
  28349. * _.toFinite(Number.MIN_VALUE);
  28350. * // => 5e-324
  28351. *
  28352. * _.toFinite(Infinity);
  28353. * // => 1.7976931348623157e+308
  28354. *
  28355. * _.toFinite('3.2');
  28356. * // => 3.2
  28357. */
  28358. function toFinite(value) {
  28359. if (!value) {
  28360. return value === 0 ? value : 0;
  28361. }
  28362. value = toNumber(value);
  28363. if (value === INFINITY || value === -INFINITY) {
  28364. var sign = (value < 0 ? -1 : 1);
  28365. return sign * MAX_INTEGER;
  28366. }
  28367. return value === value ? value : 0;
  28368. }
  28369. /**
  28370. * Converts `value` to an integer.
  28371. *
  28372. * **Note:** This method is loosely based on
  28373. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28374. *
  28375. * @static
  28376. * @memberOf _
  28377. * @since 4.0.0
  28378. * @category Lang
  28379. * @param {*} value The value to convert.
  28380. * @returns {number} Returns the converted integer.
  28381. * @example
  28382. *
  28383. * _.toInteger(3.2);
  28384. * // => 3
  28385. *
  28386. * _.toInteger(Number.MIN_VALUE);
  28387. * // => 0
  28388. *
  28389. * _.toInteger(Infinity);
  28390. * // => 1.7976931348623157e+308
  28391. *
  28392. * _.toInteger('3.2');
  28393. * // => 3
  28394. */
  28395. function toInteger(value) {
  28396. var result = toFinite(value),
  28397. remainder = result % 1;
  28398. return result === result ? (remainder ? result - remainder : result) : 0;
  28399. }
  28400. /**
  28401. * Converts `value` to an integer suitable for use as the length of an
  28402. * array-like object.
  28403. *
  28404. * **Note:** This method is based on
  28405. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28406. *
  28407. * @static
  28408. * @memberOf _
  28409. * @since 4.0.0
  28410. * @category Lang
  28411. * @param {*} value The value to convert.
  28412. * @returns {number} Returns the converted integer.
  28413. * @example
  28414. *
  28415. * _.toLength(3.2);
  28416. * // => 3
  28417. *
  28418. * _.toLength(Number.MIN_VALUE);
  28419. * // => 0
  28420. *
  28421. * _.toLength(Infinity);
  28422. * // => 4294967295
  28423. *
  28424. * _.toLength('3.2');
  28425. * // => 3
  28426. */
  28427. function toLength(value) {
  28428. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28429. }
  28430. /**
  28431. * Converts `value` to a number.
  28432. *
  28433. * @static
  28434. * @memberOf _
  28435. * @since 4.0.0
  28436. * @category Lang
  28437. * @param {*} value The value to process.
  28438. * @returns {number} Returns the number.
  28439. * @example
  28440. *
  28441. * _.toNumber(3.2);
  28442. * // => 3.2
  28443. *
  28444. * _.toNumber(Number.MIN_VALUE);
  28445. * // => 5e-324
  28446. *
  28447. * _.toNumber(Infinity);
  28448. * // => Infinity
  28449. *
  28450. * _.toNumber('3.2');
  28451. * // => 3.2
  28452. */
  28453. function toNumber(value) {
  28454. if (typeof value == 'number') {
  28455. return value;
  28456. }
  28457. if (isSymbol(value)) {
  28458. return NAN;
  28459. }
  28460. if (isObject(value)) {
  28461. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28462. value = isObject(other) ? (other + '') : other;
  28463. }
  28464. if (typeof value != 'string') {
  28465. return value === 0 ? value : +value;
  28466. }
  28467. value = value.replace(reTrim, '');
  28468. var isBinary = reIsBinary.test(value);
  28469. return (isBinary || reIsOctal.test(value))
  28470. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28471. : (reIsBadHex.test(value) ? NAN : +value);
  28472. }
  28473. /**
  28474. * Converts `value` to a plain object flattening inherited enumerable string
  28475. * keyed properties of `value` to own properties of the plain object.
  28476. *
  28477. * @static
  28478. * @memberOf _
  28479. * @since 3.0.0
  28480. * @category Lang
  28481. * @param {*} value The value to convert.
  28482. * @returns {Object} Returns the converted plain object.
  28483. * @example
  28484. *
  28485. * function Foo() {
  28486. * this.b = 2;
  28487. * }
  28488. *
  28489. * Foo.prototype.c = 3;
  28490. *
  28491. * _.assign({ 'a': 1 }, new Foo);
  28492. * // => { 'a': 1, 'b': 2 }
  28493. *
  28494. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28495. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28496. */
  28497. function toPlainObject(value) {
  28498. return copyObject(value, keysIn(value));
  28499. }
  28500. /**
  28501. * Converts `value` to a safe integer. A safe integer can be compared and
  28502. * represented correctly.
  28503. *
  28504. * @static
  28505. * @memberOf _
  28506. * @since 4.0.0
  28507. * @category Lang
  28508. * @param {*} value The value to convert.
  28509. * @returns {number} Returns the converted integer.
  28510. * @example
  28511. *
  28512. * _.toSafeInteger(3.2);
  28513. * // => 3
  28514. *
  28515. * _.toSafeInteger(Number.MIN_VALUE);
  28516. * // => 0
  28517. *
  28518. * _.toSafeInteger(Infinity);
  28519. * // => 9007199254740991
  28520. *
  28521. * _.toSafeInteger('3.2');
  28522. * // => 3
  28523. */
  28524. function toSafeInteger(value) {
  28525. return value
  28526. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28527. : (value === 0 ? value : 0);
  28528. }
  28529. /**
  28530. * Converts `value` to a string. An empty string is returned for `null`
  28531. * and `undefined` values. The sign of `-0` is preserved.
  28532. *
  28533. * @static
  28534. * @memberOf _
  28535. * @since 4.0.0
  28536. * @category Lang
  28537. * @param {*} value The value to convert.
  28538. * @returns {string} Returns the converted string.
  28539. * @example
  28540. *
  28541. * _.toString(null);
  28542. * // => ''
  28543. *
  28544. * _.toString(-0);
  28545. * // => '-0'
  28546. *
  28547. * _.toString([1, 2, 3]);
  28548. * // => '1,2,3'
  28549. */
  28550. function toString(value) {
  28551. return value == null ? '' : baseToString(value);
  28552. }
  28553. /*------------------------------------------------------------------------*/
  28554. /**
  28555. * Assigns own enumerable string keyed properties of source objects to the
  28556. * destination object. Source objects are applied from left to right.
  28557. * Subsequent sources overwrite property assignments of previous sources.
  28558. *
  28559. * **Note:** This method mutates `object` and is loosely based on
  28560. * [`Object.assign`](https://mdn.io/Object/assign).
  28561. *
  28562. * @static
  28563. * @memberOf _
  28564. * @since 0.10.0
  28565. * @category Object
  28566. * @param {Object} object The destination object.
  28567. * @param {...Object} [sources] The source objects.
  28568. * @returns {Object} Returns `object`.
  28569. * @see _.assignIn
  28570. * @example
  28571. *
  28572. * function Foo() {
  28573. * this.a = 1;
  28574. * }
  28575. *
  28576. * function Bar() {
  28577. * this.c = 3;
  28578. * }
  28579. *
  28580. * Foo.prototype.b = 2;
  28581. * Bar.prototype.d = 4;
  28582. *
  28583. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28584. * // => { 'a': 1, 'c': 3 }
  28585. */
  28586. var assign = createAssigner(function(object, source) {
  28587. if (isPrototype(source) || isArrayLike(source)) {
  28588. copyObject(source, keys(source), object);
  28589. return;
  28590. }
  28591. for (var key in source) {
  28592. if (hasOwnProperty.call(source, key)) {
  28593. assignValue(object, key, source[key]);
  28594. }
  28595. }
  28596. });
  28597. /**
  28598. * This method is like `_.assign` except that it iterates over own and
  28599. * inherited source properties.
  28600. *
  28601. * **Note:** This method mutates `object`.
  28602. *
  28603. * @static
  28604. * @memberOf _
  28605. * @since 4.0.0
  28606. * @alias extend
  28607. * @category Object
  28608. * @param {Object} object The destination object.
  28609. * @param {...Object} [sources] The source objects.
  28610. * @returns {Object} Returns `object`.
  28611. * @see _.assign
  28612. * @example
  28613. *
  28614. * function Foo() {
  28615. * this.a = 1;
  28616. * }
  28617. *
  28618. * function Bar() {
  28619. * this.c = 3;
  28620. * }
  28621. *
  28622. * Foo.prototype.b = 2;
  28623. * Bar.prototype.d = 4;
  28624. *
  28625. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28626. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28627. */
  28628. var assignIn = createAssigner(function(object, source) {
  28629. copyObject(source, keysIn(source), object);
  28630. });
  28631. /**
  28632. * This method is like `_.assignIn` except that it accepts `customizer`
  28633. * which is invoked to produce the assigned values. If `customizer` returns
  28634. * `undefined`, assignment is handled by the method instead. The `customizer`
  28635. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28636. *
  28637. * **Note:** This method mutates `object`.
  28638. *
  28639. * @static
  28640. * @memberOf _
  28641. * @since 4.0.0
  28642. * @alias extendWith
  28643. * @category Object
  28644. * @param {Object} object The destination object.
  28645. * @param {...Object} sources The source objects.
  28646. * @param {Function} [customizer] The function to customize assigned values.
  28647. * @returns {Object} Returns `object`.
  28648. * @see _.assignWith
  28649. * @example
  28650. *
  28651. * function customizer(objValue, srcValue) {
  28652. * return _.isUndefined(objValue) ? srcValue : objValue;
  28653. * }
  28654. *
  28655. * var defaults = _.partialRight(_.assignInWith, customizer);
  28656. *
  28657. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28658. * // => { 'a': 1, 'b': 2 }
  28659. */
  28660. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28661. copyObject(source, keysIn(source), object, customizer);
  28662. });
  28663. /**
  28664. * This method is like `_.assign` except that it accepts `customizer`
  28665. * which is invoked to produce the assigned values. If `customizer` returns
  28666. * `undefined`, assignment is handled by the method instead. The `customizer`
  28667. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28668. *
  28669. * **Note:** This method mutates `object`.
  28670. *
  28671. * @static
  28672. * @memberOf _
  28673. * @since 4.0.0
  28674. * @category Object
  28675. * @param {Object} object The destination object.
  28676. * @param {...Object} sources The source objects.
  28677. * @param {Function} [customizer] The function to customize assigned values.
  28678. * @returns {Object} Returns `object`.
  28679. * @see _.assignInWith
  28680. * @example
  28681. *
  28682. * function customizer(objValue, srcValue) {
  28683. * return _.isUndefined(objValue) ? srcValue : objValue;
  28684. * }
  28685. *
  28686. * var defaults = _.partialRight(_.assignWith, customizer);
  28687. *
  28688. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28689. * // => { 'a': 1, 'b': 2 }
  28690. */
  28691. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28692. copyObject(source, keys(source), object, customizer);
  28693. });
  28694. /**
  28695. * Creates an array of values corresponding to `paths` of `object`.
  28696. *
  28697. * @static
  28698. * @memberOf _
  28699. * @since 1.0.0
  28700. * @category Object
  28701. * @param {Object} object The object to iterate over.
  28702. * @param {...(string|string[])} [paths] The property paths to pick.
  28703. * @returns {Array} Returns the picked values.
  28704. * @example
  28705. *
  28706. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28707. *
  28708. * _.at(object, ['a[0].b.c', 'a[1]']);
  28709. * // => [3, 4]
  28710. */
  28711. var at = flatRest(baseAt);
  28712. /**
  28713. * Creates an object that inherits from the `prototype` object. If a
  28714. * `properties` object is given, its own enumerable string keyed properties
  28715. * are assigned to the created object.
  28716. *
  28717. * @static
  28718. * @memberOf _
  28719. * @since 2.3.0
  28720. * @category Object
  28721. * @param {Object} prototype The object to inherit from.
  28722. * @param {Object} [properties] The properties to assign to the object.
  28723. * @returns {Object} Returns the new object.
  28724. * @example
  28725. *
  28726. * function Shape() {
  28727. * this.x = 0;
  28728. * this.y = 0;
  28729. * }
  28730. *
  28731. * function Circle() {
  28732. * Shape.call(this);
  28733. * }
  28734. *
  28735. * Circle.prototype = _.create(Shape.prototype, {
  28736. * 'constructor': Circle
  28737. * });
  28738. *
  28739. * var circle = new Circle;
  28740. * circle instanceof Circle;
  28741. * // => true
  28742. *
  28743. * circle instanceof Shape;
  28744. * // => true
  28745. */
  28746. function create(prototype, properties) {
  28747. var result = baseCreate(prototype);
  28748. return properties == null ? result : baseAssign(result, properties);
  28749. }
  28750. /**
  28751. * Assigns own and inherited enumerable string keyed properties of source
  28752. * objects to the destination object for all destination properties that
  28753. * resolve to `undefined`. Source objects are applied from left to right.
  28754. * Once a property is set, additional values of the same property are ignored.
  28755. *
  28756. * **Note:** This method mutates `object`.
  28757. *
  28758. * @static
  28759. * @since 0.1.0
  28760. * @memberOf _
  28761. * @category Object
  28762. * @param {Object} object The destination object.
  28763. * @param {...Object} [sources] The source objects.
  28764. * @returns {Object} Returns `object`.
  28765. * @see _.defaultsDeep
  28766. * @example
  28767. *
  28768. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28769. * // => { 'a': 1, 'b': 2 }
  28770. */
  28771. var defaults = baseRest(function(object, sources) {
  28772. object = Object(object);
  28773. var index = -1;
  28774. var length = sources.length;
  28775. var guard = length > 2 ? sources[2] : undefined;
  28776. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28777. length = 1;
  28778. }
  28779. while (++index < length) {
  28780. var source = sources[index];
  28781. var props = keysIn(source);
  28782. var propsIndex = -1;
  28783. var propsLength = props.length;
  28784. while (++propsIndex < propsLength) {
  28785. var key = props[propsIndex];
  28786. var value = object[key];
  28787. if (value === undefined ||
  28788. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28789. object[key] = source[key];
  28790. }
  28791. }
  28792. }
  28793. return object;
  28794. });
  28795. /**
  28796. * This method is like `_.defaults` except that it recursively assigns
  28797. * default properties.
  28798. *
  28799. * **Note:** This method mutates `object`.
  28800. *
  28801. * @static
  28802. * @memberOf _
  28803. * @since 3.10.0
  28804. * @category Object
  28805. * @param {Object} object The destination object.
  28806. * @param {...Object} [sources] The source objects.
  28807. * @returns {Object} Returns `object`.
  28808. * @see _.defaults
  28809. * @example
  28810. *
  28811. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28812. * // => { 'a': { 'b': 2, 'c': 3 } }
  28813. */
  28814. var defaultsDeep = baseRest(function(args) {
  28815. args.push(undefined, customDefaultsMerge);
  28816. return apply(mergeWith, undefined, args);
  28817. });
  28818. /**
  28819. * This method is like `_.find` except that it returns the key of the first
  28820. * element `predicate` returns truthy for instead of the element itself.
  28821. *
  28822. * @static
  28823. * @memberOf _
  28824. * @since 1.1.0
  28825. * @category Object
  28826. * @param {Object} object The object to inspect.
  28827. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28828. * @returns {string|undefined} Returns the key of the matched element,
  28829. * else `undefined`.
  28830. * @example
  28831. *
  28832. * var users = {
  28833. * 'barney': { 'age': 36, 'active': true },
  28834. * 'fred': { 'age': 40, 'active': false },
  28835. * 'pebbles': { 'age': 1, 'active': true }
  28836. * };
  28837. *
  28838. * _.findKey(users, function(o) { return o.age < 40; });
  28839. * // => 'barney' (iteration order is not guaranteed)
  28840. *
  28841. * // The `_.matches` iteratee shorthand.
  28842. * _.findKey(users, { 'age': 1, 'active': true });
  28843. * // => 'pebbles'
  28844. *
  28845. * // The `_.matchesProperty` iteratee shorthand.
  28846. * _.findKey(users, ['active', false]);
  28847. * // => 'fred'
  28848. *
  28849. * // The `_.property` iteratee shorthand.
  28850. * _.findKey(users, 'active');
  28851. * // => 'barney'
  28852. */
  28853. function findKey(object, predicate) {
  28854. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28855. }
  28856. /**
  28857. * This method is like `_.findKey` except that it iterates over elements of
  28858. * a collection in the opposite order.
  28859. *
  28860. * @static
  28861. * @memberOf _
  28862. * @since 2.0.0
  28863. * @category Object
  28864. * @param {Object} object The object to inspect.
  28865. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28866. * @returns {string|undefined} Returns the key of the matched element,
  28867. * else `undefined`.
  28868. * @example
  28869. *
  28870. * var users = {
  28871. * 'barney': { 'age': 36, 'active': true },
  28872. * 'fred': { 'age': 40, 'active': false },
  28873. * 'pebbles': { 'age': 1, 'active': true }
  28874. * };
  28875. *
  28876. * _.findLastKey(users, function(o) { return o.age < 40; });
  28877. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28878. *
  28879. * // The `_.matches` iteratee shorthand.
  28880. * _.findLastKey(users, { 'age': 36, 'active': true });
  28881. * // => 'barney'
  28882. *
  28883. * // The `_.matchesProperty` iteratee shorthand.
  28884. * _.findLastKey(users, ['active', false]);
  28885. * // => 'fred'
  28886. *
  28887. * // The `_.property` iteratee shorthand.
  28888. * _.findLastKey(users, 'active');
  28889. * // => 'pebbles'
  28890. */
  28891. function findLastKey(object, predicate) {
  28892. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28893. }
  28894. /**
  28895. * Iterates over own and inherited enumerable string keyed properties of an
  28896. * object and invokes `iteratee` for each property. The iteratee is invoked
  28897. * with three arguments: (value, key, object). Iteratee functions may exit
  28898. * iteration early by explicitly returning `false`.
  28899. *
  28900. * @static
  28901. * @memberOf _
  28902. * @since 0.3.0
  28903. * @category Object
  28904. * @param {Object} object The object to iterate over.
  28905. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28906. * @returns {Object} Returns `object`.
  28907. * @see _.forInRight
  28908. * @example
  28909. *
  28910. * function Foo() {
  28911. * this.a = 1;
  28912. * this.b = 2;
  28913. * }
  28914. *
  28915. * Foo.prototype.c = 3;
  28916. *
  28917. * _.forIn(new Foo, function(value, key) {
  28918. * console.log(key);
  28919. * });
  28920. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28921. */
  28922. function forIn(object, iteratee) {
  28923. return object == null
  28924. ? object
  28925. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28926. }
  28927. /**
  28928. * This method is like `_.forIn` except that it iterates over properties of
  28929. * `object` in the opposite order.
  28930. *
  28931. * @static
  28932. * @memberOf _
  28933. * @since 2.0.0
  28934. * @category Object
  28935. * @param {Object} object The object to iterate over.
  28936. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28937. * @returns {Object} Returns `object`.
  28938. * @see _.forIn
  28939. * @example
  28940. *
  28941. * function Foo() {
  28942. * this.a = 1;
  28943. * this.b = 2;
  28944. * }
  28945. *
  28946. * Foo.prototype.c = 3;
  28947. *
  28948. * _.forInRight(new Foo, function(value, key) {
  28949. * console.log(key);
  28950. * });
  28951. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28952. */
  28953. function forInRight(object, iteratee) {
  28954. return object == null
  28955. ? object
  28956. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28957. }
  28958. /**
  28959. * Iterates over own enumerable string keyed properties of an object and
  28960. * invokes `iteratee` for each property. The iteratee is invoked with three
  28961. * arguments: (value, key, object). Iteratee functions may exit iteration
  28962. * early by explicitly returning `false`.
  28963. *
  28964. * @static
  28965. * @memberOf _
  28966. * @since 0.3.0
  28967. * @category Object
  28968. * @param {Object} object The object to iterate over.
  28969. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28970. * @returns {Object} Returns `object`.
  28971. * @see _.forOwnRight
  28972. * @example
  28973. *
  28974. * function Foo() {
  28975. * this.a = 1;
  28976. * this.b = 2;
  28977. * }
  28978. *
  28979. * Foo.prototype.c = 3;
  28980. *
  28981. * _.forOwn(new Foo, function(value, key) {
  28982. * console.log(key);
  28983. * });
  28984. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  28985. */
  28986. function forOwn(object, iteratee) {
  28987. return object && baseForOwn(object, getIteratee(iteratee, 3));
  28988. }
  28989. /**
  28990. * This method is like `_.forOwn` except that it iterates over properties of
  28991. * `object` in the opposite order.
  28992. *
  28993. * @static
  28994. * @memberOf _
  28995. * @since 2.0.0
  28996. * @category Object
  28997. * @param {Object} object The object to iterate over.
  28998. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28999. * @returns {Object} Returns `object`.
  29000. * @see _.forOwn
  29001. * @example
  29002. *
  29003. * function Foo() {
  29004. * this.a = 1;
  29005. * this.b = 2;
  29006. * }
  29007. *
  29008. * Foo.prototype.c = 3;
  29009. *
  29010. * _.forOwnRight(new Foo, function(value, key) {
  29011. * console.log(key);
  29012. * });
  29013. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29014. */
  29015. function forOwnRight(object, iteratee) {
  29016. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29017. }
  29018. /**
  29019. * Creates an array of function property names from own enumerable properties
  29020. * of `object`.
  29021. *
  29022. * @static
  29023. * @since 0.1.0
  29024. * @memberOf _
  29025. * @category Object
  29026. * @param {Object} object The object to inspect.
  29027. * @returns {Array} Returns the function names.
  29028. * @see _.functionsIn
  29029. * @example
  29030. *
  29031. * function Foo() {
  29032. * this.a = _.constant('a');
  29033. * this.b = _.constant('b');
  29034. * }
  29035. *
  29036. * Foo.prototype.c = _.constant('c');
  29037. *
  29038. * _.functions(new Foo);
  29039. * // => ['a', 'b']
  29040. */
  29041. function functions(object) {
  29042. return object == null ? [] : baseFunctions(object, keys(object));
  29043. }
  29044. /**
  29045. * Creates an array of function property names from own and inherited
  29046. * enumerable properties of `object`.
  29047. *
  29048. * @static
  29049. * @memberOf _
  29050. * @since 4.0.0
  29051. * @category Object
  29052. * @param {Object} object The object to inspect.
  29053. * @returns {Array} Returns the function names.
  29054. * @see _.functions
  29055. * @example
  29056. *
  29057. * function Foo() {
  29058. * this.a = _.constant('a');
  29059. * this.b = _.constant('b');
  29060. * }
  29061. *
  29062. * Foo.prototype.c = _.constant('c');
  29063. *
  29064. * _.functionsIn(new Foo);
  29065. * // => ['a', 'b', 'c']
  29066. */
  29067. function functionsIn(object) {
  29068. return object == null ? [] : baseFunctions(object, keysIn(object));
  29069. }
  29070. /**
  29071. * Gets the value at `path` of `object`. If the resolved value is
  29072. * `undefined`, the `defaultValue` is returned in its place.
  29073. *
  29074. * @static
  29075. * @memberOf _
  29076. * @since 3.7.0
  29077. * @category Object
  29078. * @param {Object} object The object to query.
  29079. * @param {Array|string} path The path of the property to get.
  29080. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29081. * @returns {*} Returns the resolved value.
  29082. * @example
  29083. *
  29084. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29085. *
  29086. * _.get(object, 'a[0].b.c');
  29087. * // => 3
  29088. *
  29089. * _.get(object, ['a', '0', 'b', 'c']);
  29090. * // => 3
  29091. *
  29092. * _.get(object, 'a.b.c', 'default');
  29093. * // => 'default'
  29094. */
  29095. function get(object, path, defaultValue) {
  29096. var result = object == null ? undefined : baseGet(object, path);
  29097. return result === undefined ? defaultValue : result;
  29098. }
  29099. /**
  29100. * Checks if `path` is a direct property of `object`.
  29101. *
  29102. * @static
  29103. * @since 0.1.0
  29104. * @memberOf _
  29105. * @category Object
  29106. * @param {Object} object The object to query.
  29107. * @param {Array|string} path The path to check.
  29108. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29109. * @example
  29110. *
  29111. * var object = { 'a': { 'b': 2 } };
  29112. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29113. *
  29114. * _.has(object, 'a');
  29115. * // => true
  29116. *
  29117. * _.has(object, 'a.b');
  29118. * // => true
  29119. *
  29120. * _.has(object, ['a', 'b']);
  29121. * // => true
  29122. *
  29123. * _.has(other, 'a');
  29124. * // => false
  29125. */
  29126. function has(object, path) {
  29127. return object != null && hasPath(object, path, baseHas);
  29128. }
  29129. /**
  29130. * Checks if `path` is a direct or inherited property of `object`.
  29131. *
  29132. * @static
  29133. * @memberOf _
  29134. * @since 4.0.0
  29135. * @category Object
  29136. * @param {Object} object The object to query.
  29137. * @param {Array|string} path The path to check.
  29138. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29139. * @example
  29140. *
  29141. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29142. *
  29143. * _.hasIn(object, 'a');
  29144. * // => true
  29145. *
  29146. * _.hasIn(object, 'a.b');
  29147. * // => true
  29148. *
  29149. * _.hasIn(object, ['a', 'b']);
  29150. * // => true
  29151. *
  29152. * _.hasIn(object, 'b');
  29153. * // => false
  29154. */
  29155. function hasIn(object, path) {
  29156. return object != null && hasPath(object, path, baseHasIn);
  29157. }
  29158. /**
  29159. * Creates an object composed of the inverted keys and values of `object`.
  29160. * If `object` contains duplicate values, subsequent values overwrite
  29161. * property assignments of previous values.
  29162. *
  29163. * @static
  29164. * @memberOf _
  29165. * @since 0.7.0
  29166. * @category Object
  29167. * @param {Object} object The object to invert.
  29168. * @returns {Object} Returns the new inverted object.
  29169. * @example
  29170. *
  29171. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29172. *
  29173. * _.invert(object);
  29174. * // => { '1': 'c', '2': 'b' }
  29175. */
  29176. var invert = createInverter(function(result, value, key) {
  29177. if (value != null &&
  29178. typeof value.toString != 'function') {
  29179. value = nativeObjectToString.call(value);
  29180. }
  29181. result[value] = key;
  29182. }, constant(identity));
  29183. /**
  29184. * This method is like `_.invert` except that the inverted object is generated
  29185. * from the results of running each element of `object` thru `iteratee`. The
  29186. * corresponding inverted value of each inverted key is an array of keys
  29187. * responsible for generating the inverted value. The iteratee is invoked
  29188. * with one argument: (value).
  29189. *
  29190. * @static
  29191. * @memberOf _
  29192. * @since 4.1.0
  29193. * @category Object
  29194. * @param {Object} object The object to invert.
  29195. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29196. * @returns {Object} Returns the new inverted object.
  29197. * @example
  29198. *
  29199. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29200. *
  29201. * _.invertBy(object);
  29202. * // => { '1': ['a', 'c'], '2': ['b'] }
  29203. *
  29204. * _.invertBy(object, function(value) {
  29205. * return 'group' + value;
  29206. * });
  29207. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29208. */
  29209. var invertBy = createInverter(function(result, value, key) {
  29210. if (value != null &&
  29211. typeof value.toString != 'function') {
  29212. value = nativeObjectToString.call(value);
  29213. }
  29214. if (hasOwnProperty.call(result, value)) {
  29215. result[value].push(key);
  29216. } else {
  29217. result[value] = [key];
  29218. }
  29219. }, getIteratee);
  29220. /**
  29221. * Invokes the method at `path` of `object`.
  29222. *
  29223. * @static
  29224. * @memberOf _
  29225. * @since 4.0.0
  29226. * @category Object
  29227. * @param {Object} object The object to query.
  29228. * @param {Array|string} path The path of the method to invoke.
  29229. * @param {...*} [args] The arguments to invoke the method with.
  29230. * @returns {*} Returns the result of the invoked method.
  29231. * @example
  29232. *
  29233. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29234. *
  29235. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29236. * // => [2, 3]
  29237. */
  29238. var invoke = baseRest(baseInvoke);
  29239. /**
  29240. * Creates an array of the own enumerable property names of `object`.
  29241. *
  29242. * **Note:** Non-object values are coerced to objects. See the
  29243. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29244. * for more details.
  29245. *
  29246. * @static
  29247. * @since 0.1.0
  29248. * @memberOf _
  29249. * @category Object
  29250. * @param {Object} object The object to query.
  29251. * @returns {Array} Returns the array of property names.
  29252. * @example
  29253. *
  29254. * function Foo() {
  29255. * this.a = 1;
  29256. * this.b = 2;
  29257. * }
  29258. *
  29259. * Foo.prototype.c = 3;
  29260. *
  29261. * _.keys(new Foo);
  29262. * // => ['a', 'b'] (iteration order is not guaranteed)
  29263. *
  29264. * _.keys('hi');
  29265. * // => ['0', '1']
  29266. */
  29267. function keys(object) {
  29268. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29269. }
  29270. /**
  29271. * Creates an array of the own and inherited enumerable property names of `object`.
  29272. *
  29273. * **Note:** Non-object values are coerced to objects.
  29274. *
  29275. * @static
  29276. * @memberOf _
  29277. * @since 3.0.0
  29278. * @category Object
  29279. * @param {Object} object The object to query.
  29280. * @returns {Array} Returns the array of property names.
  29281. * @example
  29282. *
  29283. * function Foo() {
  29284. * this.a = 1;
  29285. * this.b = 2;
  29286. * }
  29287. *
  29288. * Foo.prototype.c = 3;
  29289. *
  29290. * _.keysIn(new Foo);
  29291. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29292. */
  29293. function keysIn(object) {
  29294. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29295. }
  29296. /**
  29297. * The opposite of `_.mapValues`; this method creates an object with the
  29298. * same values as `object` and keys generated by running each own enumerable
  29299. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29300. * with three arguments: (value, key, object).
  29301. *
  29302. * @static
  29303. * @memberOf _
  29304. * @since 3.8.0
  29305. * @category Object
  29306. * @param {Object} object The object to iterate over.
  29307. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29308. * @returns {Object} Returns the new mapped object.
  29309. * @see _.mapValues
  29310. * @example
  29311. *
  29312. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29313. * return key + value;
  29314. * });
  29315. * // => { 'a1': 1, 'b2': 2 }
  29316. */
  29317. function mapKeys(object, iteratee) {
  29318. var result = {};
  29319. iteratee = getIteratee(iteratee, 3);
  29320. baseForOwn(object, function(value, key, object) {
  29321. baseAssignValue(result, iteratee(value, key, object), value);
  29322. });
  29323. return result;
  29324. }
  29325. /**
  29326. * Creates an object with the same keys as `object` and values generated
  29327. * by running each own enumerable string keyed property of `object` thru
  29328. * `iteratee`. The iteratee is invoked with three arguments:
  29329. * (value, key, object).
  29330. *
  29331. * @static
  29332. * @memberOf _
  29333. * @since 2.4.0
  29334. * @category Object
  29335. * @param {Object} object The object to iterate over.
  29336. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29337. * @returns {Object} Returns the new mapped object.
  29338. * @see _.mapKeys
  29339. * @example
  29340. *
  29341. * var users = {
  29342. * 'fred': { 'user': 'fred', 'age': 40 },
  29343. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29344. * };
  29345. *
  29346. * _.mapValues(users, function(o) { return o.age; });
  29347. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29348. *
  29349. * // The `_.property` iteratee shorthand.
  29350. * _.mapValues(users, 'age');
  29351. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29352. */
  29353. function mapValues(object, iteratee) {
  29354. var result = {};
  29355. iteratee = getIteratee(iteratee, 3);
  29356. baseForOwn(object, function(value, key, object) {
  29357. baseAssignValue(result, key, iteratee(value, key, object));
  29358. });
  29359. return result;
  29360. }
  29361. /**
  29362. * This method is like `_.assign` except that it recursively merges own and
  29363. * inherited enumerable string keyed properties of source objects into the
  29364. * destination object. Source properties that resolve to `undefined` are
  29365. * skipped if a destination value exists. Array and plain object properties
  29366. * are merged recursively. Other objects and value types are overridden by
  29367. * assignment. Source objects are applied from left to right. Subsequent
  29368. * sources overwrite property assignments of previous sources.
  29369. *
  29370. * **Note:** This method mutates `object`.
  29371. *
  29372. * @static
  29373. * @memberOf _
  29374. * @since 0.5.0
  29375. * @category Object
  29376. * @param {Object} object The destination object.
  29377. * @param {...Object} [sources] The source objects.
  29378. * @returns {Object} Returns `object`.
  29379. * @example
  29380. *
  29381. * var object = {
  29382. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29383. * };
  29384. *
  29385. * var other = {
  29386. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29387. * };
  29388. *
  29389. * _.merge(object, other);
  29390. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29391. */
  29392. var merge = createAssigner(function(object, source, srcIndex) {
  29393. baseMerge(object, source, srcIndex);
  29394. });
  29395. /**
  29396. * This method is like `_.merge` except that it accepts `customizer` which
  29397. * is invoked to produce the merged values of the destination and source
  29398. * properties. If `customizer` returns `undefined`, merging is handled by the
  29399. * method instead. The `customizer` is invoked with six arguments:
  29400. * (objValue, srcValue, key, object, source, stack).
  29401. *
  29402. * **Note:** This method mutates `object`.
  29403. *
  29404. * @static
  29405. * @memberOf _
  29406. * @since 4.0.0
  29407. * @category Object
  29408. * @param {Object} object The destination object.
  29409. * @param {...Object} sources The source objects.
  29410. * @param {Function} customizer The function to customize assigned values.
  29411. * @returns {Object} Returns `object`.
  29412. * @example
  29413. *
  29414. * function customizer(objValue, srcValue) {
  29415. * if (_.isArray(objValue)) {
  29416. * return objValue.concat(srcValue);
  29417. * }
  29418. * }
  29419. *
  29420. * var object = { 'a': [1], 'b': [2] };
  29421. * var other = { 'a': [3], 'b': [4] };
  29422. *
  29423. * _.mergeWith(object, other, customizer);
  29424. * // => { 'a': [1, 3], 'b': [2, 4] }
  29425. */
  29426. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29427. baseMerge(object, source, srcIndex, customizer);
  29428. });
  29429. /**
  29430. * The opposite of `_.pick`; this method creates an object composed of the
  29431. * own and inherited enumerable property paths of `object` that are not omitted.
  29432. *
  29433. * **Note:** This method is considerably slower than `_.pick`.
  29434. *
  29435. * @static
  29436. * @since 0.1.0
  29437. * @memberOf _
  29438. * @category Object
  29439. * @param {Object} object The source object.
  29440. * @param {...(string|string[])} [paths] The property paths to omit.
  29441. * @returns {Object} Returns the new object.
  29442. * @example
  29443. *
  29444. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29445. *
  29446. * _.omit(object, ['a', 'c']);
  29447. * // => { 'b': '2' }
  29448. */
  29449. var omit = flatRest(function(object, paths) {
  29450. var result = {};
  29451. if (object == null) {
  29452. return result;
  29453. }
  29454. var isDeep = false;
  29455. paths = arrayMap(paths, function(path) {
  29456. path = castPath(path, object);
  29457. isDeep || (isDeep = path.length > 1);
  29458. return path;
  29459. });
  29460. copyObject(object, getAllKeysIn(object), result);
  29461. if (isDeep) {
  29462. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29463. }
  29464. var length = paths.length;
  29465. while (length--) {
  29466. baseUnset(result, paths[length]);
  29467. }
  29468. return result;
  29469. });
  29470. /**
  29471. * The opposite of `_.pickBy`; this method creates an object composed of
  29472. * the own and inherited enumerable string keyed properties of `object` that
  29473. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29474. * arguments: (value, key).
  29475. *
  29476. * @static
  29477. * @memberOf _
  29478. * @since 4.0.0
  29479. * @category Object
  29480. * @param {Object} object The source object.
  29481. * @param {Function} [predicate=_.identity] The function invoked per property.
  29482. * @returns {Object} Returns the new object.
  29483. * @example
  29484. *
  29485. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29486. *
  29487. * _.omitBy(object, _.isNumber);
  29488. * // => { 'b': '2' }
  29489. */
  29490. function omitBy(object, predicate) {
  29491. return pickBy(object, negate(getIteratee(predicate)));
  29492. }
  29493. /**
  29494. * Creates an object composed of the picked `object` properties.
  29495. *
  29496. * @static
  29497. * @since 0.1.0
  29498. * @memberOf _
  29499. * @category Object
  29500. * @param {Object} object The source object.
  29501. * @param {...(string|string[])} [paths] The property paths to pick.
  29502. * @returns {Object} Returns the new object.
  29503. * @example
  29504. *
  29505. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29506. *
  29507. * _.pick(object, ['a', 'c']);
  29508. * // => { 'a': 1, 'c': 3 }
  29509. */
  29510. var pick = flatRest(function(object, paths) {
  29511. return object == null ? {} : basePick(object, paths);
  29512. });
  29513. /**
  29514. * Creates an object composed of the `object` properties `predicate` returns
  29515. * truthy for. The predicate is invoked with two arguments: (value, key).
  29516. *
  29517. * @static
  29518. * @memberOf _
  29519. * @since 4.0.0
  29520. * @category Object
  29521. * @param {Object} object The source object.
  29522. * @param {Function} [predicate=_.identity] The function invoked per property.
  29523. * @returns {Object} Returns the new object.
  29524. * @example
  29525. *
  29526. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29527. *
  29528. * _.pickBy(object, _.isNumber);
  29529. * // => { 'a': 1, 'c': 3 }
  29530. */
  29531. function pickBy(object, predicate) {
  29532. if (object == null) {
  29533. return {};
  29534. }
  29535. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29536. return [prop];
  29537. });
  29538. predicate = getIteratee(predicate);
  29539. return basePickBy(object, props, function(value, path) {
  29540. return predicate(value, path[0]);
  29541. });
  29542. }
  29543. /**
  29544. * This method is like `_.get` except that if the resolved value is a
  29545. * function it's invoked with the `this` binding of its parent object and
  29546. * its result is returned.
  29547. *
  29548. * @static
  29549. * @since 0.1.0
  29550. * @memberOf _
  29551. * @category Object
  29552. * @param {Object} object The object to query.
  29553. * @param {Array|string} path The path of the property to resolve.
  29554. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29555. * @returns {*} Returns the resolved value.
  29556. * @example
  29557. *
  29558. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29559. *
  29560. * _.result(object, 'a[0].b.c1');
  29561. * // => 3
  29562. *
  29563. * _.result(object, 'a[0].b.c2');
  29564. * // => 4
  29565. *
  29566. * _.result(object, 'a[0].b.c3', 'default');
  29567. * // => 'default'
  29568. *
  29569. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29570. * // => 'default'
  29571. */
  29572. function result(object, path, defaultValue) {
  29573. path = castPath(path, object);
  29574. var index = -1,
  29575. length = path.length;
  29576. // Ensure the loop is entered when path is empty.
  29577. if (!length) {
  29578. length = 1;
  29579. object = undefined;
  29580. }
  29581. while (++index < length) {
  29582. var value = object == null ? undefined : object[toKey(path[index])];
  29583. if (value === undefined) {
  29584. index = length;
  29585. value = defaultValue;
  29586. }
  29587. object = isFunction(value) ? value.call(object) : value;
  29588. }
  29589. return object;
  29590. }
  29591. /**
  29592. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29593. * it's created. Arrays are created for missing index properties while objects
  29594. * are created for all other missing properties. Use `_.setWith` to customize
  29595. * `path` creation.
  29596. *
  29597. * **Note:** This method mutates `object`.
  29598. *
  29599. * @static
  29600. * @memberOf _
  29601. * @since 3.7.0
  29602. * @category Object
  29603. * @param {Object} object The object to modify.
  29604. * @param {Array|string} path The path of the property to set.
  29605. * @param {*} value The value to set.
  29606. * @returns {Object} Returns `object`.
  29607. * @example
  29608. *
  29609. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29610. *
  29611. * _.set(object, 'a[0].b.c', 4);
  29612. * console.log(object.a[0].b.c);
  29613. * // => 4
  29614. *
  29615. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29616. * console.log(object.x[0].y.z);
  29617. * // => 5
  29618. */
  29619. function set(object, path, value) {
  29620. return object == null ? object : baseSet(object, path, value);
  29621. }
  29622. /**
  29623. * This method is like `_.set` except that it accepts `customizer` which is
  29624. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29625. * path creation is handled by the method instead. The `customizer` is invoked
  29626. * with three arguments: (nsValue, key, nsObject).
  29627. *
  29628. * **Note:** This method mutates `object`.
  29629. *
  29630. * @static
  29631. * @memberOf _
  29632. * @since 4.0.0
  29633. * @category Object
  29634. * @param {Object} object The object to modify.
  29635. * @param {Array|string} path The path of the property to set.
  29636. * @param {*} value The value to set.
  29637. * @param {Function} [customizer] The function to customize assigned values.
  29638. * @returns {Object} Returns `object`.
  29639. * @example
  29640. *
  29641. * var object = {};
  29642. *
  29643. * _.setWith(object, '[0][1]', 'a', Object);
  29644. * // => { '0': { '1': 'a' } }
  29645. */
  29646. function setWith(object, path, value, customizer) {
  29647. customizer = typeof customizer == 'function' ? customizer : undefined;
  29648. return object == null ? object : baseSet(object, path, value, customizer);
  29649. }
  29650. /**
  29651. * Creates an array of own enumerable string keyed-value pairs for `object`
  29652. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29653. * entries are returned.
  29654. *
  29655. * @static
  29656. * @memberOf _
  29657. * @since 4.0.0
  29658. * @alias entries
  29659. * @category Object
  29660. * @param {Object} object The object to query.
  29661. * @returns {Array} Returns the key-value pairs.
  29662. * @example
  29663. *
  29664. * function Foo() {
  29665. * this.a = 1;
  29666. * this.b = 2;
  29667. * }
  29668. *
  29669. * Foo.prototype.c = 3;
  29670. *
  29671. * _.toPairs(new Foo);
  29672. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29673. */
  29674. var toPairs = createToPairs(keys);
  29675. /**
  29676. * Creates an array of own and inherited enumerable string keyed-value pairs
  29677. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29678. * or set, its entries are returned.
  29679. *
  29680. * @static
  29681. * @memberOf _
  29682. * @since 4.0.0
  29683. * @alias entriesIn
  29684. * @category Object
  29685. * @param {Object} object The object to query.
  29686. * @returns {Array} Returns the key-value pairs.
  29687. * @example
  29688. *
  29689. * function Foo() {
  29690. * this.a = 1;
  29691. * this.b = 2;
  29692. * }
  29693. *
  29694. * Foo.prototype.c = 3;
  29695. *
  29696. * _.toPairsIn(new Foo);
  29697. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29698. */
  29699. var toPairsIn = createToPairs(keysIn);
  29700. /**
  29701. * An alternative to `_.reduce`; this method transforms `object` to a new
  29702. * `accumulator` object which is the result of running each of its own
  29703. * enumerable string keyed properties thru `iteratee`, with each invocation
  29704. * potentially mutating the `accumulator` object. If `accumulator` is not
  29705. * provided, a new object with the same `[[Prototype]]` will be used. The
  29706. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29707. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29708. *
  29709. * @static
  29710. * @memberOf _
  29711. * @since 1.3.0
  29712. * @category Object
  29713. * @param {Object} object The object to iterate over.
  29714. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29715. * @param {*} [accumulator] The custom accumulator value.
  29716. * @returns {*} Returns the accumulated value.
  29717. * @example
  29718. *
  29719. * _.transform([2, 3, 4], function(result, n) {
  29720. * result.push(n *= n);
  29721. * return n % 2 == 0;
  29722. * }, []);
  29723. * // => [4, 9]
  29724. *
  29725. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29726. * (result[value] || (result[value] = [])).push(key);
  29727. * }, {});
  29728. * // => { '1': ['a', 'c'], '2': ['b'] }
  29729. */
  29730. function transform(object, iteratee, accumulator) {
  29731. var isArr = isArray(object),
  29732. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29733. iteratee = getIteratee(iteratee, 4);
  29734. if (accumulator == null) {
  29735. var Ctor = object && object.constructor;
  29736. if (isArrLike) {
  29737. accumulator = isArr ? new Ctor : [];
  29738. }
  29739. else if (isObject(object)) {
  29740. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29741. }
  29742. else {
  29743. accumulator = {};
  29744. }
  29745. }
  29746. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29747. return iteratee(accumulator, value, index, object);
  29748. });
  29749. return accumulator;
  29750. }
  29751. /**
  29752. * Removes the property at `path` of `object`.
  29753. *
  29754. * **Note:** This method mutates `object`.
  29755. *
  29756. * @static
  29757. * @memberOf _
  29758. * @since 4.0.0
  29759. * @category Object
  29760. * @param {Object} object The object to modify.
  29761. * @param {Array|string} path The path of the property to unset.
  29762. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29763. * @example
  29764. *
  29765. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29766. * _.unset(object, 'a[0].b.c');
  29767. * // => true
  29768. *
  29769. * console.log(object);
  29770. * // => { 'a': [{ 'b': {} }] };
  29771. *
  29772. * _.unset(object, ['a', '0', 'b', 'c']);
  29773. * // => true
  29774. *
  29775. * console.log(object);
  29776. * // => { 'a': [{ 'b': {} }] };
  29777. */
  29778. function unset(object, path) {
  29779. return object == null ? true : baseUnset(object, path);
  29780. }
  29781. /**
  29782. * This method is like `_.set` except that accepts `updater` to produce the
  29783. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29784. * is invoked with one argument: (value).
  29785. *
  29786. * **Note:** This method mutates `object`.
  29787. *
  29788. * @static
  29789. * @memberOf _
  29790. * @since 4.6.0
  29791. * @category Object
  29792. * @param {Object} object The object to modify.
  29793. * @param {Array|string} path The path of the property to set.
  29794. * @param {Function} updater The function to produce the updated value.
  29795. * @returns {Object} Returns `object`.
  29796. * @example
  29797. *
  29798. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29799. *
  29800. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29801. * console.log(object.a[0].b.c);
  29802. * // => 9
  29803. *
  29804. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29805. * console.log(object.x[0].y.z);
  29806. * // => 0
  29807. */
  29808. function update(object, path, updater) {
  29809. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29810. }
  29811. /**
  29812. * This method is like `_.update` except that it accepts `customizer` which is
  29813. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29814. * path creation is handled by the method instead. The `customizer` is invoked
  29815. * with three arguments: (nsValue, key, nsObject).
  29816. *
  29817. * **Note:** This method mutates `object`.
  29818. *
  29819. * @static
  29820. * @memberOf _
  29821. * @since 4.6.0
  29822. * @category Object
  29823. * @param {Object} object The object to modify.
  29824. * @param {Array|string} path The path of the property to set.
  29825. * @param {Function} updater The function to produce the updated value.
  29826. * @param {Function} [customizer] The function to customize assigned values.
  29827. * @returns {Object} Returns `object`.
  29828. * @example
  29829. *
  29830. * var object = {};
  29831. *
  29832. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29833. * // => { '0': { '1': 'a' } }
  29834. */
  29835. function updateWith(object, path, updater, customizer) {
  29836. customizer = typeof customizer == 'function' ? customizer : undefined;
  29837. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29838. }
  29839. /**
  29840. * Creates an array of the own enumerable string keyed property values of `object`.
  29841. *
  29842. * **Note:** Non-object values are coerced to objects.
  29843. *
  29844. * @static
  29845. * @since 0.1.0
  29846. * @memberOf _
  29847. * @category Object
  29848. * @param {Object} object The object to query.
  29849. * @returns {Array} Returns the array of property values.
  29850. * @example
  29851. *
  29852. * function Foo() {
  29853. * this.a = 1;
  29854. * this.b = 2;
  29855. * }
  29856. *
  29857. * Foo.prototype.c = 3;
  29858. *
  29859. * _.values(new Foo);
  29860. * // => [1, 2] (iteration order is not guaranteed)
  29861. *
  29862. * _.values('hi');
  29863. * // => ['h', 'i']
  29864. */
  29865. function values(object) {
  29866. return object == null ? [] : baseValues(object, keys(object));
  29867. }
  29868. /**
  29869. * Creates an array of the own and inherited enumerable string keyed property
  29870. * values of `object`.
  29871. *
  29872. * **Note:** Non-object values are coerced to objects.
  29873. *
  29874. * @static
  29875. * @memberOf _
  29876. * @since 3.0.0
  29877. * @category Object
  29878. * @param {Object} object The object to query.
  29879. * @returns {Array} Returns the array of property values.
  29880. * @example
  29881. *
  29882. * function Foo() {
  29883. * this.a = 1;
  29884. * this.b = 2;
  29885. * }
  29886. *
  29887. * Foo.prototype.c = 3;
  29888. *
  29889. * _.valuesIn(new Foo);
  29890. * // => [1, 2, 3] (iteration order is not guaranteed)
  29891. */
  29892. function valuesIn(object) {
  29893. return object == null ? [] : baseValues(object, keysIn(object));
  29894. }
  29895. /*------------------------------------------------------------------------*/
  29896. /**
  29897. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29898. *
  29899. * @static
  29900. * @memberOf _
  29901. * @since 4.0.0
  29902. * @category Number
  29903. * @param {number} number The number to clamp.
  29904. * @param {number} [lower] The lower bound.
  29905. * @param {number} upper The upper bound.
  29906. * @returns {number} Returns the clamped number.
  29907. * @example
  29908. *
  29909. * _.clamp(-10, -5, 5);
  29910. * // => -5
  29911. *
  29912. * _.clamp(10, -5, 5);
  29913. * // => 5
  29914. */
  29915. function clamp(number, lower, upper) {
  29916. if (upper === undefined) {
  29917. upper = lower;
  29918. lower = undefined;
  29919. }
  29920. if (upper !== undefined) {
  29921. upper = toNumber(upper);
  29922. upper = upper === upper ? upper : 0;
  29923. }
  29924. if (lower !== undefined) {
  29925. lower = toNumber(lower);
  29926. lower = lower === lower ? lower : 0;
  29927. }
  29928. return baseClamp(toNumber(number), lower, upper);
  29929. }
  29930. /**
  29931. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29932. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29933. * If `start` is greater than `end` the params are swapped to support
  29934. * negative ranges.
  29935. *
  29936. * @static
  29937. * @memberOf _
  29938. * @since 3.3.0
  29939. * @category Number
  29940. * @param {number} number The number to check.
  29941. * @param {number} [start=0] The start of the range.
  29942. * @param {number} end The end of the range.
  29943. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29944. * @see _.range, _.rangeRight
  29945. * @example
  29946. *
  29947. * _.inRange(3, 2, 4);
  29948. * // => true
  29949. *
  29950. * _.inRange(4, 8);
  29951. * // => true
  29952. *
  29953. * _.inRange(4, 2);
  29954. * // => false
  29955. *
  29956. * _.inRange(2, 2);
  29957. * // => false
  29958. *
  29959. * _.inRange(1.2, 2);
  29960. * // => true
  29961. *
  29962. * _.inRange(5.2, 4);
  29963. * // => false
  29964. *
  29965. * _.inRange(-3, -2, -6);
  29966. * // => true
  29967. */
  29968. function inRange(number, start, end) {
  29969. start = toFinite(start);
  29970. if (end === undefined) {
  29971. end = start;
  29972. start = 0;
  29973. } else {
  29974. end = toFinite(end);
  29975. }
  29976. number = toNumber(number);
  29977. return baseInRange(number, start, end);
  29978. }
  29979. /**
  29980. * Produces a random number between the inclusive `lower` and `upper` bounds.
  29981. * If only one argument is provided a number between `0` and the given number
  29982. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  29983. * floats, a floating-point number is returned instead of an integer.
  29984. *
  29985. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  29986. * floating-point values which can produce unexpected results.
  29987. *
  29988. * @static
  29989. * @memberOf _
  29990. * @since 0.7.0
  29991. * @category Number
  29992. * @param {number} [lower=0] The lower bound.
  29993. * @param {number} [upper=1] The upper bound.
  29994. * @param {boolean} [floating] Specify returning a floating-point number.
  29995. * @returns {number} Returns the random number.
  29996. * @example
  29997. *
  29998. * _.random(0, 5);
  29999. * // => an integer between 0 and 5
  30000. *
  30001. * _.random(5);
  30002. * // => also an integer between 0 and 5
  30003. *
  30004. * _.random(5, true);
  30005. * // => a floating-point number between 0 and 5
  30006. *
  30007. * _.random(1.2, 5.2);
  30008. * // => a floating-point number between 1.2 and 5.2
  30009. */
  30010. function random(lower, upper, floating) {
  30011. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30012. upper = floating = undefined;
  30013. }
  30014. if (floating === undefined) {
  30015. if (typeof upper == 'boolean') {
  30016. floating = upper;
  30017. upper = undefined;
  30018. }
  30019. else if (typeof lower == 'boolean') {
  30020. floating = lower;
  30021. lower = undefined;
  30022. }
  30023. }
  30024. if (lower === undefined && upper === undefined) {
  30025. lower = 0;
  30026. upper = 1;
  30027. }
  30028. else {
  30029. lower = toFinite(lower);
  30030. if (upper === undefined) {
  30031. upper = lower;
  30032. lower = 0;
  30033. } else {
  30034. upper = toFinite(upper);
  30035. }
  30036. }
  30037. if (lower > upper) {
  30038. var temp = lower;
  30039. lower = upper;
  30040. upper = temp;
  30041. }
  30042. if (floating || lower % 1 || upper % 1) {
  30043. var rand = nativeRandom();
  30044. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30045. }
  30046. return baseRandom(lower, upper);
  30047. }
  30048. /*------------------------------------------------------------------------*/
  30049. /**
  30050. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30051. *
  30052. * @static
  30053. * @memberOf _
  30054. * @since 3.0.0
  30055. * @category String
  30056. * @param {string} [string=''] The string to convert.
  30057. * @returns {string} Returns the camel cased string.
  30058. * @example
  30059. *
  30060. * _.camelCase('Foo Bar');
  30061. * // => 'fooBar'
  30062. *
  30063. * _.camelCase('--foo-bar--');
  30064. * // => 'fooBar'
  30065. *
  30066. * _.camelCase('__FOO_BAR__');
  30067. * // => 'fooBar'
  30068. */
  30069. var camelCase = createCompounder(function(result, word, index) {
  30070. word = word.toLowerCase();
  30071. return result + (index ? capitalize(word) : word);
  30072. });
  30073. /**
  30074. * Converts the first character of `string` to upper case and the remaining
  30075. * to lower case.
  30076. *
  30077. * @static
  30078. * @memberOf _
  30079. * @since 3.0.0
  30080. * @category String
  30081. * @param {string} [string=''] The string to capitalize.
  30082. * @returns {string} Returns the capitalized string.
  30083. * @example
  30084. *
  30085. * _.capitalize('FRED');
  30086. * // => 'Fred'
  30087. */
  30088. function capitalize(string) {
  30089. return upperFirst(toString(string).toLowerCase());
  30090. }
  30091. /**
  30092. * Deburrs `string` by converting
  30093. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30094. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30095. * letters to basic Latin letters and removing
  30096. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30097. *
  30098. * @static
  30099. * @memberOf _
  30100. * @since 3.0.0
  30101. * @category String
  30102. * @param {string} [string=''] The string to deburr.
  30103. * @returns {string} Returns the deburred string.
  30104. * @example
  30105. *
  30106. * _.deburr('déjà vu');
  30107. * // => 'deja vu'
  30108. */
  30109. function deburr(string) {
  30110. string = toString(string);
  30111. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30112. }
  30113. /**
  30114. * Checks if `string` ends with the given target string.
  30115. *
  30116. * @static
  30117. * @memberOf _
  30118. * @since 3.0.0
  30119. * @category String
  30120. * @param {string} [string=''] The string to inspect.
  30121. * @param {string} [target] The string to search for.
  30122. * @param {number} [position=string.length] The position to search up to.
  30123. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30124. * else `false`.
  30125. * @example
  30126. *
  30127. * _.endsWith('abc', 'c');
  30128. * // => true
  30129. *
  30130. * _.endsWith('abc', 'b');
  30131. * // => false
  30132. *
  30133. * _.endsWith('abc', 'b', 2);
  30134. * // => true
  30135. */
  30136. function endsWith(string, target, position) {
  30137. string = toString(string);
  30138. target = baseToString(target);
  30139. var length = string.length;
  30140. position = position === undefined
  30141. ? length
  30142. : baseClamp(toInteger(position), 0, length);
  30143. var end = position;
  30144. position -= target.length;
  30145. return position >= 0 && string.slice(position, end) == target;
  30146. }
  30147. /**
  30148. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30149. * corresponding HTML entities.
  30150. *
  30151. * **Note:** No other characters are escaped. To escape additional
  30152. * characters use a third-party library like [_he_](https://mths.be/he).
  30153. *
  30154. * Though the ">" character is escaped for symmetry, characters like
  30155. * ">" and "/" don't need escaping in HTML and have no special meaning
  30156. * unless they're part of a tag or unquoted attribute value. See
  30157. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30158. * (under "semi-related fun fact") for more details.
  30159. *
  30160. * When working with HTML you should always
  30161. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30162. * XSS vectors.
  30163. *
  30164. * @static
  30165. * @since 0.1.0
  30166. * @memberOf _
  30167. * @category String
  30168. * @param {string} [string=''] The string to escape.
  30169. * @returns {string} Returns the escaped string.
  30170. * @example
  30171. *
  30172. * _.escape('fred, barney, & pebbles');
  30173. * // => 'fred, barney, &amp; pebbles'
  30174. */
  30175. function escape(string) {
  30176. string = toString(string);
  30177. return (string && reHasUnescapedHtml.test(string))
  30178. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30179. : string;
  30180. }
  30181. /**
  30182. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30183. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30184. *
  30185. * @static
  30186. * @memberOf _
  30187. * @since 3.0.0
  30188. * @category String
  30189. * @param {string} [string=''] The string to escape.
  30190. * @returns {string} Returns the escaped string.
  30191. * @example
  30192. *
  30193. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30194. * // => '\[lodash\]\(https://lodash\.com/\)'
  30195. */
  30196. function escapeRegExp(string) {
  30197. string = toString(string);
  30198. return (string && reHasRegExpChar.test(string))
  30199. ? string.replace(reRegExpChar, '\\$&')
  30200. : string;
  30201. }
  30202. /**
  30203. * Converts `string` to
  30204. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30205. *
  30206. * @static
  30207. * @memberOf _
  30208. * @since 3.0.0
  30209. * @category String
  30210. * @param {string} [string=''] The string to convert.
  30211. * @returns {string} Returns the kebab cased string.
  30212. * @example
  30213. *
  30214. * _.kebabCase('Foo Bar');
  30215. * // => 'foo-bar'
  30216. *
  30217. * _.kebabCase('fooBar');
  30218. * // => 'foo-bar'
  30219. *
  30220. * _.kebabCase('__FOO_BAR__');
  30221. * // => 'foo-bar'
  30222. */
  30223. var kebabCase = createCompounder(function(result, word, index) {
  30224. return result + (index ? '-' : '') + word.toLowerCase();
  30225. });
  30226. /**
  30227. * Converts `string`, as space separated words, to lower case.
  30228. *
  30229. * @static
  30230. * @memberOf _
  30231. * @since 4.0.0
  30232. * @category String
  30233. * @param {string} [string=''] The string to convert.
  30234. * @returns {string} Returns the lower cased string.
  30235. * @example
  30236. *
  30237. * _.lowerCase('--Foo-Bar--');
  30238. * // => 'foo bar'
  30239. *
  30240. * _.lowerCase('fooBar');
  30241. * // => 'foo bar'
  30242. *
  30243. * _.lowerCase('__FOO_BAR__');
  30244. * // => 'foo bar'
  30245. */
  30246. var lowerCase = createCompounder(function(result, word, index) {
  30247. return result + (index ? ' ' : '') + word.toLowerCase();
  30248. });
  30249. /**
  30250. * Converts the first character of `string` to lower case.
  30251. *
  30252. * @static
  30253. * @memberOf _
  30254. * @since 4.0.0
  30255. * @category String
  30256. * @param {string} [string=''] The string to convert.
  30257. * @returns {string} Returns the converted string.
  30258. * @example
  30259. *
  30260. * _.lowerFirst('Fred');
  30261. * // => 'fred'
  30262. *
  30263. * _.lowerFirst('FRED');
  30264. * // => 'fRED'
  30265. */
  30266. var lowerFirst = createCaseFirst('toLowerCase');
  30267. /**
  30268. * Pads `string` on the left and right sides if it's shorter than `length`.
  30269. * Padding characters are truncated if they can't be evenly divided by `length`.
  30270. *
  30271. * @static
  30272. * @memberOf _
  30273. * @since 3.0.0
  30274. * @category String
  30275. * @param {string} [string=''] The string to pad.
  30276. * @param {number} [length=0] The padding length.
  30277. * @param {string} [chars=' '] The string used as padding.
  30278. * @returns {string} Returns the padded string.
  30279. * @example
  30280. *
  30281. * _.pad('abc', 8);
  30282. * // => ' abc '
  30283. *
  30284. * _.pad('abc', 8, '_-');
  30285. * // => '_-abc_-_'
  30286. *
  30287. * _.pad('abc', 3);
  30288. * // => 'abc'
  30289. */
  30290. function pad(string, length, chars) {
  30291. string = toString(string);
  30292. length = toInteger(length);
  30293. var strLength = length ? stringSize(string) : 0;
  30294. if (!length || strLength >= length) {
  30295. return string;
  30296. }
  30297. var mid = (length - strLength) / 2;
  30298. return (
  30299. createPadding(nativeFloor(mid), chars) +
  30300. string +
  30301. createPadding(nativeCeil(mid), chars)
  30302. );
  30303. }
  30304. /**
  30305. * Pads `string` on the right side if it's shorter than `length`. Padding
  30306. * characters are truncated if they exceed `length`.
  30307. *
  30308. * @static
  30309. * @memberOf _
  30310. * @since 4.0.0
  30311. * @category String
  30312. * @param {string} [string=''] The string to pad.
  30313. * @param {number} [length=0] The padding length.
  30314. * @param {string} [chars=' '] The string used as padding.
  30315. * @returns {string} Returns the padded string.
  30316. * @example
  30317. *
  30318. * _.padEnd('abc', 6);
  30319. * // => 'abc '
  30320. *
  30321. * _.padEnd('abc', 6, '_-');
  30322. * // => 'abc_-_'
  30323. *
  30324. * _.padEnd('abc', 3);
  30325. * // => 'abc'
  30326. */
  30327. function padEnd(string, length, chars) {
  30328. string = toString(string);
  30329. length = toInteger(length);
  30330. var strLength = length ? stringSize(string) : 0;
  30331. return (length && strLength < length)
  30332. ? (string + createPadding(length - strLength, chars))
  30333. : string;
  30334. }
  30335. /**
  30336. * Pads `string` on the left side if it's shorter than `length`. Padding
  30337. * characters are truncated if they exceed `length`.
  30338. *
  30339. * @static
  30340. * @memberOf _
  30341. * @since 4.0.0
  30342. * @category String
  30343. * @param {string} [string=''] The string to pad.
  30344. * @param {number} [length=0] The padding length.
  30345. * @param {string} [chars=' '] The string used as padding.
  30346. * @returns {string} Returns the padded string.
  30347. * @example
  30348. *
  30349. * _.padStart('abc', 6);
  30350. * // => ' abc'
  30351. *
  30352. * _.padStart('abc', 6, '_-');
  30353. * // => '_-_abc'
  30354. *
  30355. * _.padStart('abc', 3);
  30356. * // => 'abc'
  30357. */
  30358. function padStart(string, length, chars) {
  30359. string = toString(string);
  30360. length = toInteger(length);
  30361. var strLength = length ? stringSize(string) : 0;
  30362. return (length && strLength < length)
  30363. ? (createPadding(length - strLength, chars) + string)
  30364. : string;
  30365. }
  30366. /**
  30367. * Converts `string` to an integer of the specified radix. If `radix` is
  30368. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30369. * hexadecimal, in which case a `radix` of `16` is used.
  30370. *
  30371. * **Note:** This method aligns with the
  30372. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30373. *
  30374. * @static
  30375. * @memberOf _
  30376. * @since 1.1.0
  30377. * @category String
  30378. * @param {string} string The string to convert.
  30379. * @param {number} [radix=10] The radix to interpret `value` by.
  30380. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30381. * @returns {number} Returns the converted integer.
  30382. * @example
  30383. *
  30384. * _.parseInt('08');
  30385. * // => 8
  30386. *
  30387. * _.map(['6', '08', '10'], _.parseInt);
  30388. * // => [6, 8, 10]
  30389. */
  30390. function parseInt(string, radix, guard) {
  30391. if (guard || radix == null) {
  30392. radix = 0;
  30393. } else if (radix) {
  30394. radix = +radix;
  30395. }
  30396. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30397. }
  30398. /**
  30399. * Repeats the given string `n` times.
  30400. *
  30401. * @static
  30402. * @memberOf _
  30403. * @since 3.0.0
  30404. * @category String
  30405. * @param {string} [string=''] The string to repeat.
  30406. * @param {number} [n=1] The number of times to repeat the string.
  30407. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30408. * @returns {string} Returns the repeated string.
  30409. * @example
  30410. *
  30411. * _.repeat('*', 3);
  30412. * // => '***'
  30413. *
  30414. * _.repeat('abc', 2);
  30415. * // => 'abcabc'
  30416. *
  30417. * _.repeat('abc', 0);
  30418. * // => ''
  30419. */
  30420. function repeat(string, n, guard) {
  30421. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30422. n = 1;
  30423. } else {
  30424. n = toInteger(n);
  30425. }
  30426. return baseRepeat(toString(string), n);
  30427. }
  30428. /**
  30429. * Replaces matches for `pattern` in `string` with `replacement`.
  30430. *
  30431. * **Note:** This method is based on
  30432. * [`String#replace`](https://mdn.io/String/replace).
  30433. *
  30434. * @static
  30435. * @memberOf _
  30436. * @since 4.0.0
  30437. * @category String
  30438. * @param {string} [string=''] The string to modify.
  30439. * @param {RegExp|string} pattern The pattern to replace.
  30440. * @param {Function|string} replacement The match replacement.
  30441. * @returns {string} Returns the modified string.
  30442. * @example
  30443. *
  30444. * _.replace('Hi Fred', 'Fred', 'Barney');
  30445. * // => 'Hi Barney'
  30446. */
  30447. function replace() {
  30448. var args = arguments,
  30449. string = toString(args[0]);
  30450. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30451. }
  30452. /**
  30453. * Converts `string` to
  30454. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30455. *
  30456. * @static
  30457. * @memberOf _
  30458. * @since 3.0.0
  30459. * @category String
  30460. * @param {string} [string=''] The string to convert.
  30461. * @returns {string} Returns the snake cased string.
  30462. * @example
  30463. *
  30464. * _.snakeCase('Foo Bar');
  30465. * // => 'foo_bar'
  30466. *
  30467. * _.snakeCase('fooBar');
  30468. * // => 'foo_bar'
  30469. *
  30470. * _.snakeCase('--FOO-BAR--');
  30471. * // => 'foo_bar'
  30472. */
  30473. var snakeCase = createCompounder(function(result, word, index) {
  30474. return result + (index ? '_' : '') + word.toLowerCase();
  30475. });
  30476. /**
  30477. * Splits `string` by `separator`.
  30478. *
  30479. * **Note:** This method is based on
  30480. * [`String#split`](https://mdn.io/String/split).
  30481. *
  30482. * @static
  30483. * @memberOf _
  30484. * @since 4.0.0
  30485. * @category String
  30486. * @param {string} [string=''] The string to split.
  30487. * @param {RegExp|string} separator The separator pattern to split by.
  30488. * @param {number} [limit] The length to truncate results to.
  30489. * @returns {Array} Returns the string segments.
  30490. * @example
  30491. *
  30492. * _.split('a-b-c', '-', 2);
  30493. * // => ['a', 'b']
  30494. */
  30495. function split(string, separator, limit) {
  30496. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30497. separator = limit = undefined;
  30498. }
  30499. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30500. if (!limit) {
  30501. return [];
  30502. }
  30503. string = toString(string);
  30504. if (string && (
  30505. typeof separator == 'string' ||
  30506. (separator != null && !isRegExp(separator))
  30507. )) {
  30508. separator = baseToString(separator);
  30509. if (!separator && hasUnicode(string)) {
  30510. return castSlice(stringToArray(string), 0, limit);
  30511. }
  30512. }
  30513. return string.split(separator, limit);
  30514. }
  30515. /**
  30516. * Converts `string` to
  30517. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30518. *
  30519. * @static
  30520. * @memberOf _
  30521. * @since 3.1.0
  30522. * @category String
  30523. * @param {string} [string=''] The string to convert.
  30524. * @returns {string} Returns the start cased string.
  30525. * @example
  30526. *
  30527. * _.startCase('--foo-bar--');
  30528. * // => 'Foo Bar'
  30529. *
  30530. * _.startCase('fooBar');
  30531. * // => 'Foo Bar'
  30532. *
  30533. * _.startCase('__FOO_BAR__');
  30534. * // => 'FOO BAR'
  30535. */
  30536. var startCase = createCompounder(function(result, word, index) {
  30537. return result + (index ? ' ' : '') + upperFirst(word);
  30538. });
  30539. /**
  30540. * Checks if `string` starts with the given target string.
  30541. *
  30542. * @static
  30543. * @memberOf _
  30544. * @since 3.0.0
  30545. * @category String
  30546. * @param {string} [string=''] The string to inspect.
  30547. * @param {string} [target] The string to search for.
  30548. * @param {number} [position=0] The position to search from.
  30549. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30550. * else `false`.
  30551. * @example
  30552. *
  30553. * _.startsWith('abc', 'a');
  30554. * // => true
  30555. *
  30556. * _.startsWith('abc', 'b');
  30557. * // => false
  30558. *
  30559. * _.startsWith('abc', 'b', 1);
  30560. * // => true
  30561. */
  30562. function startsWith(string, target, position) {
  30563. string = toString(string);
  30564. position = position == null
  30565. ? 0
  30566. : baseClamp(toInteger(position), 0, string.length);
  30567. target = baseToString(target);
  30568. return string.slice(position, position + target.length) == target;
  30569. }
  30570. /**
  30571. * Creates a compiled template function that can interpolate data properties
  30572. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30573. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30574. * properties may be accessed as free variables in the template. If a setting
  30575. * object is given, it takes precedence over `_.templateSettings` values.
  30576. *
  30577. * **Note:** In the development build `_.template` utilizes
  30578. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30579. * for easier debugging.
  30580. *
  30581. * For more information on precompiling templates see
  30582. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30583. *
  30584. * For more information on Chrome extension sandboxes see
  30585. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30586. *
  30587. * @static
  30588. * @since 0.1.0
  30589. * @memberOf _
  30590. * @category String
  30591. * @param {string} [string=''] The template string.
  30592. * @param {Object} [options={}] The options object.
  30593. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30594. * The HTML "escape" delimiter.
  30595. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30596. * The "evaluate" delimiter.
  30597. * @param {Object} [options.imports=_.templateSettings.imports]
  30598. * An object to import into the template as free variables.
  30599. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30600. * The "interpolate" delimiter.
  30601. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30602. * The sourceURL of the compiled template.
  30603. * @param {string} [options.variable='obj']
  30604. * The data object variable name.
  30605. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30606. * @returns {Function} Returns the compiled template function.
  30607. * @example
  30608. *
  30609. * // Use the "interpolate" delimiter to create a compiled template.
  30610. * var compiled = _.template('hello <%= user %>!');
  30611. * compiled({ 'user': 'fred' });
  30612. * // => 'hello fred!'
  30613. *
  30614. * // Use the HTML "escape" delimiter to escape data property values.
  30615. * var compiled = _.template('<b><%- value %></b>');
  30616. * compiled({ 'value': '<script>' });
  30617. * // => '<b>&lt;script&gt;</b>'
  30618. *
  30619. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30620. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30621. * compiled({ 'users': ['fred', 'barney'] });
  30622. * // => '<li>fred</li><li>barney</li>'
  30623. *
  30624. * // Use the internal `print` function in "evaluate" delimiters.
  30625. * var compiled = _.template('<% print("hello " + user); %>!');
  30626. * compiled({ 'user': 'barney' });
  30627. * // => 'hello barney!'
  30628. *
  30629. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30630. * // Disable support by replacing the "interpolate" delimiter.
  30631. * var compiled = _.template('hello ${ user }!');
  30632. * compiled({ 'user': 'pebbles' });
  30633. * // => 'hello pebbles!'
  30634. *
  30635. * // Use backslashes to treat delimiters as plain text.
  30636. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30637. * compiled({ 'value': 'ignored' });
  30638. * // => '<%- value %>'
  30639. *
  30640. * // Use the `imports` option to import `jQuery` as `jq`.
  30641. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30642. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30643. * compiled({ 'users': ['fred', 'barney'] });
  30644. * // => '<li>fred</li><li>barney</li>'
  30645. *
  30646. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30647. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30648. * compiled(data);
  30649. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30650. *
  30651. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30652. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30653. * compiled.source;
  30654. * // => function(data) {
  30655. * // var __t, __p = '';
  30656. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30657. * // return __p;
  30658. * // }
  30659. *
  30660. * // Use custom template delimiters.
  30661. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30662. * var compiled = _.template('hello {{ user }}!');
  30663. * compiled({ 'user': 'mustache' });
  30664. * // => 'hello mustache!'
  30665. *
  30666. * // Use the `source` property to inline compiled templates for meaningful
  30667. * // line numbers in error messages and stack traces.
  30668. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30669. * var JST = {\
  30670. * "main": ' + _.template(mainText).source + '\
  30671. * };\
  30672. * ');
  30673. */
  30674. function template(string, options, guard) {
  30675. // Based on John Resig's `tmpl` implementation
  30676. // (http://ejohn.org/blog/javascript-micro-templating/)
  30677. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30678. var settings = lodash.templateSettings;
  30679. if (guard && isIterateeCall(string, options, guard)) {
  30680. options = undefined;
  30681. }
  30682. string = toString(string);
  30683. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30684. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30685. importsKeys = keys(imports),
  30686. importsValues = baseValues(imports, importsKeys);
  30687. var isEscaping,
  30688. isEvaluating,
  30689. index = 0,
  30690. interpolate = options.interpolate || reNoMatch,
  30691. source = "__p += '";
  30692. // Compile the regexp to match each delimiter.
  30693. var reDelimiters = RegExp(
  30694. (options.escape || reNoMatch).source + '|' +
  30695. interpolate.source + '|' +
  30696. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30697. (options.evaluate || reNoMatch).source + '|$'
  30698. , 'g');
  30699. // Use a sourceURL for easier debugging.
  30700. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30701. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30702. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30703. var sourceURL = '//# sourceURL=' +
  30704. (hasOwnProperty.call(options, 'sourceURL')
  30705. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30706. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30707. ) + '\n';
  30708. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30709. interpolateValue || (interpolateValue = esTemplateValue);
  30710. // Escape characters that can't be included in string literals.
  30711. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30712. // Replace delimiters with snippets.
  30713. if (escapeValue) {
  30714. isEscaping = true;
  30715. source += "' +\n__e(" + escapeValue + ") +\n'";
  30716. }
  30717. if (evaluateValue) {
  30718. isEvaluating = true;
  30719. source += "';\n" + evaluateValue + ";\n__p += '";
  30720. }
  30721. if (interpolateValue) {
  30722. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30723. }
  30724. index = offset + match.length;
  30725. // The JS engine embedded in Adobe products needs `match` returned in
  30726. // order to produce the correct `offset` value.
  30727. return match;
  30728. });
  30729. source += "';\n";
  30730. // If `variable` is not specified wrap a with-statement around the generated
  30731. // code to add the data object to the top of the scope chain.
  30732. // Like with sourceURL, we take care to not check the option's prototype,
  30733. // as this configuration is a code injection vector.
  30734. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30735. if (!variable) {
  30736. source = 'with (obj) {\n' + source + '\n}\n';
  30737. }
  30738. // Cleanup code by stripping empty strings.
  30739. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30740. .replace(reEmptyStringMiddle, '$1')
  30741. .replace(reEmptyStringTrailing, '$1;');
  30742. // Frame code as the function body.
  30743. source = 'function(' + (variable || 'obj') + ') {\n' +
  30744. (variable
  30745. ? ''
  30746. : 'obj || (obj = {});\n'
  30747. ) +
  30748. "var __t, __p = ''" +
  30749. (isEscaping
  30750. ? ', __e = _.escape'
  30751. : ''
  30752. ) +
  30753. (isEvaluating
  30754. ? ', __j = Array.prototype.join;\n' +
  30755. "function print() { __p += __j.call(arguments, '') }\n"
  30756. : ';\n'
  30757. ) +
  30758. source +
  30759. 'return __p\n}';
  30760. var result = attempt(function() {
  30761. return Function(importsKeys, sourceURL + 'return ' + source)
  30762. .apply(undefined, importsValues);
  30763. });
  30764. // Provide the compiled function's source by its `toString` method or
  30765. // the `source` property as a convenience for inlining compiled templates.
  30766. result.source = source;
  30767. if (isError(result)) {
  30768. throw result;
  30769. }
  30770. return result;
  30771. }
  30772. /**
  30773. * Converts `string`, as a whole, to lower case just like
  30774. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30775. *
  30776. * @static
  30777. * @memberOf _
  30778. * @since 4.0.0
  30779. * @category String
  30780. * @param {string} [string=''] The string to convert.
  30781. * @returns {string} Returns the lower cased string.
  30782. * @example
  30783. *
  30784. * _.toLower('--Foo-Bar--');
  30785. * // => '--foo-bar--'
  30786. *
  30787. * _.toLower('fooBar');
  30788. * // => 'foobar'
  30789. *
  30790. * _.toLower('__FOO_BAR__');
  30791. * // => '__foo_bar__'
  30792. */
  30793. function toLower(value) {
  30794. return toString(value).toLowerCase();
  30795. }
  30796. /**
  30797. * Converts `string`, as a whole, to upper case just like
  30798. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30799. *
  30800. * @static
  30801. * @memberOf _
  30802. * @since 4.0.0
  30803. * @category String
  30804. * @param {string} [string=''] The string to convert.
  30805. * @returns {string} Returns the upper cased string.
  30806. * @example
  30807. *
  30808. * _.toUpper('--foo-bar--');
  30809. * // => '--FOO-BAR--'
  30810. *
  30811. * _.toUpper('fooBar');
  30812. * // => 'FOOBAR'
  30813. *
  30814. * _.toUpper('__foo_bar__');
  30815. * // => '__FOO_BAR__'
  30816. */
  30817. function toUpper(value) {
  30818. return toString(value).toUpperCase();
  30819. }
  30820. /**
  30821. * Removes leading and trailing whitespace or specified characters from `string`.
  30822. *
  30823. * @static
  30824. * @memberOf _
  30825. * @since 3.0.0
  30826. * @category String
  30827. * @param {string} [string=''] The string to trim.
  30828. * @param {string} [chars=whitespace] The characters to trim.
  30829. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30830. * @returns {string} Returns the trimmed string.
  30831. * @example
  30832. *
  30833. * _.trim(' abc ');
  30834. * // => 'abc'
  30835. *
  30836. * _.trim('-_-abc-_-', '_-');
  30837. * // => 'abc'
  30838. *
  30839. * _.map([' foo ', ' bar '], _.trim);
  30840. * // => ['foo', 'bar']
  30841. */
  30842. function trim(string, chars, guard) {
  30843. string = toString(string);
  30844. if (string && (guard || chars === undefined)) {
  30845. return string.replace(reTrim, '');
  30846. }
  30847. if (!string || !(chars = baseToString(chars))) {
  30848. return string;
  30849. }
  30850. var strSymbols = stringToArray(string),
  30851. chrSymbols = stringToArray(chars),
  30852. start = charsStartIndex(strSymbols, chrSymbols),
  30853. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30854. return castSlice(strSymbols, start, end).join('');
  30855. }
  30856. /**
  30857. * Removes trailing whitespace or specified characters from `string`.
  30858. *
  30859. * @static
  30860. * @memberOf _
  30861. * @since 4.0.0
  30862. * @category String
  30863. * @param {string} [string=''] The string to trim.
  30864. * @param {string} [chars=whitespace] The characters to trim.
  30865. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30866. * @returns {string} Returns the trimmed string.
  30867. * @example
  30868. *
  30869. * _.trimEnd(' abc ');
  30870. * // => ' abc'
  30871. *
  30872. * _.trimEnd('-_-abc-_-', '_-');
  30873. * // => '-_-abc'
  30874. */
  30875. function trimEnd(string, chars, guard) {
  30876. string = toString(string);
  30877. if (string && (guard || chars === undefined)) {
  30878. return string.replace(reTrimEnd, '');
  30879. }
  30880. if (!string || !(chars = baseToString(chars))) {
  30881. return string;
  30882. }
  30883. var strSymbols = stringToArray(string),
  30884. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30885. return castSlice(strSymbols, 0, end).join('');
  30886. }
  30887. /**
  30888. * Removes leading whitespace or specified characters from `string`.
  30889. *
  30890. * @static
  30891. * @memberOf _
  30892. * @since 4.0.0
  30893. * @category String
  30894. * @param {string} [string=''] The string to trim.
  30895. * @param {string} [chars=whitespace] The characters to trim.
  30896. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30897. * @returns {string} Returns the trimmed string.
  30898. * @example
  30899. *
  30900. * _.trimStart(' abc ');
  30901. * // => 'abc '
  30902. *
  30903. * _.trimStart('-_-abc-_-', '_-');
  30904. * // => 'abc-_-'
  30905. */
  30906. function trimStart(string, chars, guard) {
  30907. string = toString(string);
  30908. if (string && (guard || chars === undefined)) {
  30909. return string.replace(reTrimStart, '');
  30910. }
  30911. if (!string || !(chars = baseToString(chars))) {
  30912. return string;
  30913. }
  30914. var strSymbols = stringToArray(string),
  30915. start = charsStartIndex(strSymbols, stringToArray(chars));
  30916. return castSlice(strSymbols, start).join('');
  30917. }
  30918. /**
  30919. * Truncates `string` if it's longer than the given maximum string length.
  30920. * The last characters of the truncated string are replaced with the omission
  30921. * string which defaults to "...".
  30922. *
  30923. * @static
  30924. * @memberOf _
  30925. * @since 4.0.0
  30926. * @category String
  30927. * @param {string} [string=''] The string to truncate.
  30928. * @param {Object} [options={}] The options object.
  30929. * @param {number} [options.length=30] The maximum string length.
  30930. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30931. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30932. * @returns {string} Returns the truncated string.
  30933. * @example
  30934. *
  30935. * _.truncate('hi-diddly-ho there, neighborino');
  30936. * // => 'hi-diddly-ho there, neighbo...'
  30937. *
  30938. * _.truncate('hi-diddly-ho there, neighborino', {
  30939. * 'length': 24,
  30940. * 'separator': ' '
  30941. * });
  30942. * // => 'hi-diddly-ho there,...'
  30943. *
  30944. * _.truncate('hi-diddly-ho there, neighborino', {
  30945. * 'length': 24,
  30946. * 'separator': /,? +/
  30947. * });
  30948. * // => 'hi-diddly-ho there...'
  30949. *
  30950. * _.truncate('hi-diddly-ho there, neighborino', {
  30951. * 'omission': ' [...]'
  30952. * });
  30953. * // => 'hi-diddly-ho there, neig [...]'
  30954. */
  30955. function truncate(string, options) {
  30956. var length = DEFAULT_TRUNC_LENGTH,
  30957. omission = DEFAULT_TRUNC_OMISSION;
  30958. if (isObject(options)) {
  30959. var separator = 'separator' in options ? options.separator : separator;
  30960. length = 'length' in options ? toInteger(options.length) : length;
  30961. omission = 'omission' in options ? baseToString(options.omission) : omission;
  30962. }
  30963. string = toString(string);
  30964. var strLength = string.length;
  30965. if (hasUnicode(string)) {
  30966. var strSymbols = stringToArray(string);
  30967. strLength = strSymbols.length;
  30968. }
  30969. if (length >= strLength) {
  30970. return string;
  30971. }
  30972. var end = length - stringSize(omission);
  30973. if (end < 1) {
  30974. return omission;
  30975. }
  30976. var result = strSymbols
  30977. ? castSlice(strSymbols, 0, end).join('')
  30978. : string.slice(0, end);
  30979. if (separator === undefined) {
  30980. return result + omission;
  30981. }
  30982. if (strSymbols) {
  30983. end += (result.length - end);
  30984. }
  30985. if (isRegExp(separator)) {
  30986. if (string.slice(end).search(separator)) {
  30987. var match,
  30988. substring = result;
  30989. if (!separator.global) {
  30990. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  30991. }
  30992. separator.lastIndex = 0;
  30993. while ((match = separator.exec(substring))) {
  30994. var newEnd = match.index;
  30995. }
  30996. result = result.slice(0, newEnd === undefined ? end : newEnd);
  30997. }
  30998. } else if (string.indexOf(baseToString(separator), end) != end) {
  30999. var index = result.lastIndexOf(separator);
  31000. if (index > -1) {
  31001. result = result.slice(0, index);
  31002. }
  31003. }
  31004. return result + omission;
  31005. }
  31006. /**
  31007. * The inverse of `_.escape`; this method converts the HTML entities
  31008. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31009. * their corresponding characters.
  31010. *
  31011. * **Note:** No other HTML entities are unescaped. To unescape additional
  31012. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31013. *
  31014. * @static
  31015. * @memberOf _
  31016. * @since 0.6.0
  31017. * @category String
  31018. * @param {string} [string=''] The string to unescape.
  31019. * @returns {string} Returns the unescaped string.
  31020. * @example
  31021. *
  31022. * _.unescape('fred, barney, &amp; pebbles');
  31023. * // => 'fred, barney, & pebbles'
  31024. */
  31025. function unescape(string) {
  31026. string = toString(string);
  31027. return (string && reHasEscapedHtml.test(string))
  31028. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31029. : string;
  31030. }
  31031. /**
  31032. * Converts `string`, as space separated words, to upper case.
  31033. *
  31034. * @static
  31035. * @memberOf _
  31036. * @since 4.0.0
  31037. * @category String
  31038. * @param {string} [string=''] The string to convert.
  31039. * @returns {string} Returns the upper cased string.
  31040. * @example
  31041. *
  31042. * _.upperCase('--foo-bar');
  31043. * // => 'FOO BAR'
  31044. *
  31045. * _.upperCase('fooBar');
  31046. * // => 'FOO BAR'
  31047. *
  31048. * _.upperCase('__foo_bar__');
  31049. * // => 'FOO BAR'
  31050. */
  31051. var upperCase = createCompounder(function(result, word, index) {
  31052. return result + (index ? ' ' : '') + word.toUpperCase();
  31053. });
  31054. /**
  31055. * Converts the first character of `string` to upper case.
  31056. *
  31057. * @static
  31058. * @memberOf _
  31059. * @since 4.0.0
  31060. * @category String
  31061. * @param {string} [string=''] The string to convert.
  31062. * @returns {string} Returns the converted string.
  31063. * @example
  31064. *
  31065. * _.upperFirst('fred');
  31066. * // => 'Fred'
  31067. *
  31068. * _.upperFirst('FRED');
  31069. * // => 'FRED'
  31070. */
  31071. var upperFirst = createCaseFirst('toUpperCase');
  31072. /**
  31073. * Splits `string` into an array of its words.
  31074. *
  31075. * @static
  31076. * @memberOf _
  31077. * @since 3.0.0
  31078. * @category String
  31079. * @param {string} [string=''] The string to inspect.
  31080. * @param {RegExp|string} [pattern] The pattern to match words.
  31081. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31082. * @returns {Array} Returns the words of `string`.
  31083. * @example
  31084. *
  31085. * _.words('fred, barney, & pebbles');
  31086. * // => ['fred', 'barney', 'pebbles']
  31087. *
  31088. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31089. * // => ['fred', 'barney', '&', 'pebbles']
  31090. */
  31091. function words(string, pattern, guard) {
  31092. string = toString(string);
  31093. pattern = guard ? undefined : pattern;
  31094. if (pattern === undefined) {
  31095. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31096. }
  31097. return string.match(pattern) || [];
  31098. }
  31099. /*------------------------------------------------------------------------*/
  31100. /**
  31101. * Attempts to invoke `func`, returning either the result or the caught error
  31102. * object. Any additional arguments are provided to `func` when it's invoked.
  31103. *
  31104. * @static
  31105. * @memberOf _
  31106. * @since 3.0.0
  31107. * @category Util
  31108. * @param {Function} func The function to attempt.
  31109. * @param {...*} [args] The arguments to invoke `func` with.
  31110. * @returns {*} Returns the `func` result or error object.
  31111. * @example
  31112. *
  31113. * // Avoid throwing errors for invalid selectors.
  31114. * var elements = _.attempt(function(selector) {
  31115. * return document.querySelectorAll(selector);
  31116. * }, '>_>');
  31117. *
  31118. * if (_.isError(elements)) {
  31119. * elements = [];
  31120. * }
  31121. */
  31122. var attempt = baseRest(function(func, args) {
  31123. try {
  31124. return apply(func, undefined, args);
  31125. } catch (e) {
  31126. return isError(e) ? e : new Error(e);
  31127. }
  31128. });
  31129. /**
  31130. * Binds methods of an object to the object itself, overwriting the existing
  31131. * method.
  31132. *
  31133. * **Note:** This method doesn't set the "length" property of bound functions.
  31134. *
  31135. * @static
  31136. * @since 0.1.0
  31137. * @memberOf _
  31138. * @category Util
  31139. * @param {Object} object The object to bind and assign the bound methods to.
  31140. * @param {...(string|string[])} methodNames The object method names to bind.
  31141. * @returns {Object} Returns `object`.
  31142. * @example
  31143. *
  31144. * var view = {
  31145. * 'label': 'docs',
  31146. * 'click': function() {
  31147. * console.log('clicked ' + this.label);
  31148. * }
  31149. * };
  31150. *
  31151. * _.bindAll(view, ['click']);
  31152. * jQuery(element).on('click', view.click);
  31153. * // => Logs 'clicked docs' when clicked.
  31154. */
  31155. var bindAll = flatRest(function(object, methodNames) {
  31156. arrayEach(methodNames, function(key) {
  31157. key = toKey(key);
  31158. baseAssignValue(object, key, bind(object[key], object));
  31159. });
  31160. return object;
  31161. });
  31162. /**
  31163. * Creates a function that iterates over `pairs` and invokes the corresponding
  31164. * function of the first predicate to return truthy. The predicate-function
  31165. * pairs are invoked with the `this` binding and arguments of the created
  31166. * function.
  31167. *
  31168. * @static
  31169. * @memberOf _
  31170. * @since 4.0.0
  31171. * @category Util
  31172. * @param {Array} pairs The predicate-function pairs.
  31173. * @returns {Function} Returns the new composite function.
  31174. * @example
  31175. *
  31176. * var func = _.cond([
  31177. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31178. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31179. * [_.stubTrue, _.constant('no match')]
  31180. * ]);
  31181. *
  31182. * func({ 'a': 1, 'b': 2 });
  31183. * // => 'matches A'
  31184. *
  31185. * func({ 'a': 0, 'b': 1 });
  31186. * // => 'matches B'
  31187. *
  31188. * func({ 'a': '1', 'b': '2' });
  31189. * // => 'no match'
  31190. */
  31191. function cond(pairs) {
  31192. var length = pairs == null ? 0 : pairs.length,
  31193. toIteratee = getIteratee();
  31194. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31195. if (typeof pair[1] != 'function') {
  31196. throw new TypeError(FUNC_ERROR_TEXT);
  31197. }
  31198. return [toIteratee(pair[0]), pair[1]];
  31199. });
  31200. return baseRest(function(args) {
  31201. var index = -1;
  31202. while (++index < length) {
  31203. var pair = pairs[index];
  31204. if (apply(pair[0], this, args)) {
  31205. return apply(pair[1], this, args);
  31206. }
  31207. }
  31208. });
  31209. }
  31210. /**
  31211. * Creates a function that invokes the predicate properties of `source` with
  31212. * the corresponding property values of a given object, returning `true` if
  31213. * all predicates return truthy, else `false`.
  31214. *
  31215. * **Note:** The created function is equivalent to `_.conformsTo` with
  31216. * `source` partially applied.
  31217. *
  31218. * @static
  31219. * @memberOf _
  31220. * @since 4.0.0
  31221. * @category Util
  31222. * @param {Object} source The object of property predicates to conform to.
  31223. * @returns {Function} Returns the new spec function.
  31224. * @example
  31225. *
  31226. * var objects = [
  31227. * { 'a': 2, 'b': 1 },
  31228. * { 'a': 1, 'b': 2 }
  31229. * ];
  31230. *
  31231. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31232. * // => [{ 'a': 1, 'b': 2 }]
  31233. */
  31234. function conforms(source) {
  31235. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31236. }
  31237. /**
  31238. * Creates a function that returns `value`.
  31239. *
  31240. * @static
  31241. * @memberOf _
  31242. * @since 2.4.0
  31243. * @category Util
  31244. * @param {*} value The value to return from the new function.
  31245. * @returns {Function} Returns the new constant function.
  31246. * @example
  31247. *
  31248. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31249. *
  31250. * console.log(objects);
  31251. * // => [{ 'a': 1 }, { 'a': 1 }]
  31252. *
  31253. * console.log(objects[0] === objects[1]);
  31254. * // => true
  31255. */
  31256. function constant(value) {
  31257. return function() {
  31258. return value;
  31259. };
  31260. }
  31261. /**
  31262. * Checks `value` to determine whether a default value should be returned in
  31263. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31264. * or `undefined`.
  31265. *
  31266. * @static
  31267. * @memberOf _
  31268. * @since 4.14.0
  31269. * @category Util
  31270. * @param {*} value The value to check.
  31271. * @param {*} defaultValue The default value.
  31272. * @returns {*} Returns the resolved value.
  31273. * @example
  31274. *
  31275. * _.defaultTo(1, 10);
  31276. * // => 1
  31277. *
  31278. * _.defaultTo(undefined, 10);
  31279. * // => 10
  31280. */
  31281. function defaultTo(value, defaultValue) {
  31282. return (value == null || value !== value) ? defaultValue : value;
  31283. }
  31284. /**
  31285. * Creates a function that returns the result of invoking the given functions
  31286. * with the `this` binding of the created function, where each successive
  31287. * invocation is supplied the return value of the previous.
  31288. *
  31289. * @static
  31290. * @memberOf _
  31291. * @since 3.0.0
  31292. * @category Util
  31293. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31294. * @returns {Function} Returns the new composite function.
  31295. * @see _.flowRight
  31296. * @example
  31297. *
  31298. * function square(n) {
  31299. * return n * n;
  31300. * }
  31301. *
  31302. * var addSquare = _.flow([_.add, square]);
  31303. * addSquare(1, 2);
  31304. * // => 9
  31305. */
  31306. var flow = createFlow();
  31307. /**
  31308. * This method is like `_.flow` except that it creates a function that
  31309. * invokes the given functions from right to left.
  31310. *
  31311. * @static
  31312. * @since 3.0.0
  31313. * @memberOf _
  31314. * @category Util
  31315. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31316. * @returns {Function} Returns the new composite function.
  31317. * @see _.flow
  31318. * @example
  31319. *
  31320. * function square(n) {
  31321. * return n * n;
  31322. * }
  31323. *
  31324. * var addSquare = _.flowRight([square, _.add]);
  31325. * addSquare(1, 2);
  31326. * // => 9
  31327. */
  31328. var flowRight = createFlow(true);
  31329. /**
  31330. * This method returns the first argument it receives.
  31331. *
  31332. * @static
  31333. * @since 0.1.0
  31334. * @memberOf _
  31335. * @category Util
  31336. * @param {*} value Any value.
  31337. * @returns {*} Returns `value`.
  31338. * @example
  31339. *
  31340. * var object = { 'a': 1 };
  31341. *
  31342. * console.log(_.identity(object) === object);
  31343. * // => true
  31344. */
  31345. function identity(value) {
  31346. return value;
  31347. }
  31348. /**
  31349. * Creates a function that invokes `func` with the arguments of the created
  31350. * function. If `func` is a property name, the created function returns the
  31351. * property value for a given element. If `func` is an array or object, the
  31352. * created function returns `true` for elements that contain the equivalent
  31353. * source properties, otherwise it returns `false`.
  31354. *
  31355. * @static
  31356. * @since 4.0.0
  31357. * @memberOf _
  31358. * @category Util
  31359. * @param {*} [func=_.identity] The value to convert to a callback.
  31360. * @returns {Function} Returns the callback.
  31361. * @example
  31362. *
  31363. * var users = [
  31364. * { 'user': 'barney', 'age': 36, 'active': true },
  31365. * { 'user': 'fred', 'age': 40, 'active': false }
  31366. * ];
  31367. *
  31368. * // The `_.matches` iteratee shorthand.
  31369. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31370. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31371. *
  31372. * // The `_.matchesProperty` iteratee shorthand.
  31373. * _.filter(users, _.iteratee(['user', 'fred']));
  31374. * // => [{ 'user': 'fred', 'age': 40 }]
  31375. *
  31376. * // The `_.property` iteratee shorthand.
  31377. * _.map(users, _.iteratee('user'));
  31378. * // => ['barney', 'fred']
  31379. *
  31380. * // Create custom iteratee shorthands.
  31381. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31382. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31383. * return func.test(string);
  31384. * };
  31385. * });
  31386. *
  31387. * _.filter(['abc', 'def'], /ef/);
  31388. * // => ['def']
  31389. */
  31390. function iteratee(func) {
  31391. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31392. }
  31393. /**
  31394. * Creates a function that performs a partial deep comparison between a given
  31395. * object and `source`, returning `true` if the given object has equivalent
  31396. * property values, else `false`.
  31397. *
  31398. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31399. * partially applied.
  31400. *
  31401. * Partial comparisons will match empty array and empty object `source`
  31402. * values against any array or object value, respectively. See `_.isEqual`
  31403. * for a list of supported value comparisons.
  31404. *
  31405. * @static
  31406. * @memberOf _
  31407. * @since 3.0.0
  31408. * @category Util
  31409. * @param {Object} source The object of property values to match.
  31410. * @returns {Function} Returns the new spec function.
  31411. * @example
  31412. *
  31413. * var objects = [
  31414. * { 'a': 1, 'b': 2, 'c': 3 },
  31415. * { 'a': 4, 'b': 5, 'c': 6 }
  31416. * ];
  31417. *
  31418. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31419. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31420. */
  31421. function matches(source) {
  31422. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31423. }
  31424. /**
  31425. * Creates a function that performs a partial deep comparison between the
  31426. * value at `path` of a given object to `srcValue`, returning `true` if the
  31427. * object value is equivalent, else `false`.
  31428. *
  31429. * **Note:** Partial comparisons will match empty array and empty object
  31430. * `srcValue` values against any array or object value, respectively. See
  31431. * `_.isEqual` for a list of supported value comparisons.
  31432. *
  31433. * @static
  31434. * @memberOf _
  31435. * @since 3.2.0
  31436. * @category Util
  31437. * @param {Array|string} path The path of the property to get.
  31438. * @param {*} srcValue The value to match.
  31439. * @returns {Function} Returns the new spec function.
  31440. * @example
  31441. *
  31442. * var objects = [
  31443. * { 'a': 1, 'b': 2, 'c': 3 },
  31444. * { 'a': 4, 'b': 5, 'c': 6 }
  31445. * ];
  31446. *
  31447. * _.find(objects, _.matchesProperty('a', 4));
  31448. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31449. */
  31450. function matchesProperty(path, srcValue) {
  31451. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31452. }
  31453. /**
  31454. * Creates a function that invokes the method at `path` of a given object.
  31455. * Any additional arguments are provided to the invoked method.
  31456. *
  31457. * @static
  31458. * @memberOf _
  31459. * @since 3.7.0
  31460. * @category Util
  31461. * @param {Array|string} path The path of the method to invoke.
  31462. * @param {...*} [args] The arguments to invoke the method with.
  31463. * @returns {Function} Returns the new invoker function.
  31464. * @example
  31465. *
  31466. * var objects = [
  31467. * { 'a': { 'b': _.constant(2) } },
  31468. * { 'a': { 'b': _.constant(1) } }
  31469. * ];
  31470. *
  31471. * _.map(objects, _.method('a.b'));
  31472. * // => [2, 1]
  31473. *
  31474. * _.map(objects, _.method(['a', 'b']));
  31475. * // => [2, 1]
  31476. */
  31477. var method = baseRest(function(path, args) {
  31478. return function(object) {
  31479. return baseInvoke(object, path, args);
  31480. };
  31481. });
  31482. /**
  31483. * The opposite of `_.method`; this method creates a function that invokes
  31484. * the method at a given path of `object`. Any additional arguments are
  31485. * provided to the invoked method.
  31486. *
  31487. * @static
  31488. * @memberOf _
  31489. * @since 3.7.0
  31490. * @category Util
  31491. * @param {Object} object The object to query.
  31492. * @param {...*} [args] The arguments to invoke the method with.
  31493. * @returns {Function} Returns the new invoker function.
  31494. * @example
  31495. *
  31496. * var array = _.times(3, _.constant),
  31497. * object = { 'a': array, 'b': array, 'c': array };
  31498. *
  31499. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31500. * // => [2, 0]
  31501. *
  31502. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31503. * // => [2, 0]
  31504. */
  31505. var methodOf = baseRest(function(object, args) {
  31506. return function(path) {
  31507. return baseInvoke(object, path, args);
  31508. };
  31509. });
  31510. /**
  31511. * Adds all own enumerable string keyed function properties of a source
  31512. * object to the destination object. If `object` is a function, then methods
  31513. * are added to its prototype as well.
  31514. *
  31515. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31516. * avoid conflicts caused by modifying the original.
  31517. *
  31518. * @static
  31519. * @since 0.1.0
  31520. * @memberOf _
  31521. * @category Util
  31522. * @param {Function|Object} [object=lodash] The destination object.
  31523. * @param {Object} source The object of functions to add.
  31524. * @param {Object} [options={}] The options object.
  31525. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31526. * @returns {Function|Object} Returns `object`.
  31527. * @example
  31528. *
  31529. * function vowels(string) {
  31530. * return _.filter(string, function(v) {
  31531. * return /[aeiou]/i.test(v);
  31532. * });
  31533. * }
  31534. *
  31535. * _.mixin({ 'vowels': vowels });
  31536. * _.vowels('fred');
  31537. * // => ['e']
  31538. *
  31539. * _('fred').vowels().value();
  31540. * // => ['e']
  31541. *
  31542. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31543. * _('fred').vowels();
  31544. * // => ['e']
  31545. */
  31546. function mixin(object, source, options) {
  31547. var props = keys(source),
  31548. methodNames = baseFunctions(source, props);
  31549. if (options == null &&
  31550. !(isObject(source) && (methodNames.length || !props.length))) {
  31551. options = source;
  31552. source = object;
  31553. object = this;
  31554. methodNames = baseFunctions(source, keys(source));
  31555. }
  31556. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31557. isFunc = isFunction(object);
  31558. arrayEach(methodNames, function(methodName) {
  31559. var func = source[methodName];
  31560. object[methodName] = func;
  31561. if (isFunc) {
  31562. object.prototype[methodName] = function() {
  31563. var chainAll = this.__chain__;
  31564. if (chain || chainAll) {
  31565. var result = object(this.__wrapped__),
  31566. actions = result.__actions__ = copyArray(this.__actions__);
  31567. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31568. result.__chain__ = chainAll;
  31569. return result;
  31570. }
  31571. return func.apply(object, arrayPush([this.value()], arguments));
  31572. };
  31573. }
  31574. });
  31575. return object;
  31576. }
  31577. /**
  31578. * Reverts the `_` variable to its previous value and returns a reference to
  31579. * the `lodash` function.
  31580. *
  31581. * @static
  31582. * @since 0.1.0
  31583. * @memberOf _
  31584. * @category Util
  31585. * @returns {Function} Returns the `lodash` function.
  31586. * @example
  31587. *
  31588. * var lodash = _.noConflict();
  31589. */
  31590. function noConflict() {
  31591. if (root._ === this) {
  31592. root._ = oldDash;
  31593. }
  31594. return this;
  31595. }
  31596. /**
  31597. * This method returns `undefined`.
  31598. *
  31599. * @static
  31600. * @memberOf _
  31601. * @since 2.3.0
  31602. * @category Util
  31603. * @example
  31604. *
  31605. * _.times(2, _.noop);
  31606. * // => [undefined, undefined]
  31607. */
  31608. function noop() {
  31609. // No operation performed.
  31610. }
  31611. /**
  31612. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31613. * the nth argument from the end is returned.
  31614. *
  31615. * @static
  31616. * @memberOf _
  31617. * @since 4.0.0
  31618. * @category Util
  31619. * @param {number} [n=0] The index of the argument to return.
  31620. * @returns {Function} Returns the new pass-thru function.
  31621. * @example
  31622. *
  31623. * var func = _.nthArg(1);
  31624. * func('a', 'b', 'c', 'd');
  31625. * // => 'b'
  31626. *
  31627. * var func = _.nthArg(-2);
  31628. * func('a', 'b', 'c', 'd');
  31629. * // => 'c'
  31630. */
  31631. function nthArg(n) {
  31632. n = toInteger(n);
  31633. return baseRest(function(args) {
  31634. return baseNth(args, n);
  31635. });
  31636. }
  31637. /**
  31638. * Creates a function that invokes `iteratees` with the arguments it receives
  31639. * and returns their results.
  31640. *
  31641. * @static
  31642. * @memberOf _
  31643. * @since 4.0.0
  31644. * @category Util
  31645. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31646. * The iteratees to invoke.
  31647. * @returns {Function} Returns the new function.
  31648. * @example
  31649. *
  31650. * var func = _.over([Math.max, Math.min]);
  31651. *
  31652. * func(1, 2, 3, 4);
  31653. * // => [4, 1]
  31654. */
  31655. var over = createOver(arrayMap);
  31656. /**
  31657. * Creates a function that checks if **all** of the `predicates` return
  31658. * truthy when invoked with the arguments it receives.
  31659. *
  31660. * @static
  31661. * @memberOf _
  31662. * @since 4.0.0
  31663. * @category Util
  31664. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31665. * The predicates to check.
  31666. * @returns {Function} Returns the new function.
  31667. * @example
  31668. *
  31669. * var func = _.overEvery([Boolean, isFinite]);
  31670. *
  31671. * func('1');
  31672. * // => true
  31673. *
  31674. * func(null);
  31675. * // => false
  31676. *
  31677. * func(NaN);
  31678. * // => false
  31679. */
  31680. var overEvery = createOver(arrayEvery);
  31681. /**
  31682. * Creates a function that checks if **any** of the `predicates` return
  31683. * truthy when invoked with the arguments it receives.
  31684. *
  31685. * @static
  31686. * @memberOf _
  31687. * @since 4.0.0
  31688. * @category Util
  31689. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31690. * The predicates to check.
  31691. * @returns {Function} Returns the new function.
  31692. * @example
  31693. *
  31694. * var func = _.overSome([Boolean, isFinite]);
  31695. *
  31696. * func('1');
  31697. * // => true
  31698. *
  31699. * func(null);
  31700. * // => true
  31701. *
  31702. * func(NaN);
  31703. * // => false
  31704. */
  31705. var overSome = createOver(arraySome);
  31706. /**
  31707. * Creates a function that returns the value at `path` of a given object.
  31708. *
  31709. * @static
  31710. * @memberOf _
  31711. * @since 2.4.0
  31712. * @category Util
  31713. * @param {Array|string} path The path of the property to get.
  31714. * @returns {Function} Returns the new accessor function.
  31715. * @example
  31716. *
  31717. * var objects = [
  31718. * { 'a': { 'b': 2 } },
  31719. * { 'a': { 'b': 1 } }
  31720. * ];
  31721. *
  31722. * _.map(objects, _.property('a.b'));
  31723. * // => [2, 1]
  31724. *
  31725. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31726. * // => [1, 2]
  31727. */
  31728. function property(path) {
  31729. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31730. }
  31731. /**
  31732. * The opposite of `_.property`; this method creates a function that returns
  31733. * the value at a given path of `object`.
  31734. *
  31735. * @static
  31736. * @memberOf _
  31737. * @since 3.0.0
  31738. * @category Util
  31739. * @param {Object} object The object to query.
  31740. * @returns {Function} Returns the new accessor function.
  31741. * @example
  31742. *
  31743. * var array = [0, 1, 2],
  31744. * object = { 'a': array, 'b': array, 'c': array };
  31745. *
  31746. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31747. * // => [2, 0]
  31748. *
  31749. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31750. * // => [2, 0]
  31751. */
  31752. function propertyOf(object) {
  31753. return function(path) {
  31754. return object == null ? undefined : baseGet(object, path);
  31755. };
  31756. }
  31757. /**
  31758. * Creates an array of numbers (positive and/or negative) progressing from
  31759. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31760. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31761. * it's set to `start` with `start` then set to `0`.
  31762. *
  31763. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31764. * floating-point values which can produce unexpected results.
  31765. *
  31766. * @static
  31767. * @since 0.1.0
  31768. * @memberOf _
  31769. * @category Util
  31770. * @param {number} [start=0] The start of the range.
  31771. * @param {number} end The end of the range.
  31772. * @param {number} [step=1] The value to increment or decrement by.
  31773. * @returns {Array} Returns the range of numbers.
  31774. * @see _.inRange, _.rangeRight
  31775. * @example
  31776. *
  31777. * _.range(4);
  31778. * // => [0, 1, 2, 3]
  31779. *
  31780. * _.range(-4);
  31781. * // => [0, -1, -2, -3]
  31782. *
  31783. * _.range(1, 5);
  31784. * // => [1, 2, 3, 4]
  31785. *
  31786. * _.range(0, 20, 5);
  31787. * // => [0, 5, 10, 15]
  31788. *
  31789. * _.range(0, -4, -1);
  31790. * // => [0, -1, -2, -3]
  31791. *
  31792. * _.range(1, 4, 0);
  31793. * // => [1, 1, 1]
  31794. *
  31795. * _.range(0);
  31796. * // => []
  31797. */
  31798. var range = createRange();
  31799. /**
  31800. * This method is like `_.range` except that it populates values in
  31801. * descending order.
  31802. *
  31803. * @static
  31804. * @memberOf _
  31805. * @since 4.0.0
  31806. * @category Util
  31807. * @param {number} [start=0] The start of the range.
  31808. * @param {number} end The end of the range.
  31809. * @param {number} [step=1] The value to increment or decrement by.
  31810. * @returns {Array} Returns the range of numbers.
  31811. * @see _.inRange, _.range
  31812. * @example
  31813. *
  31814. * _.rangeRight(4);
  31815. * // => [3, 2, 1, 0]
  31816. *
  31817. * _.rangeRight(-4);
  31818. * // => [-3, -2, -1, 0]
  31819. *
  31820. * _.rangeRight(1, 5);
  31821. * // => [4, 3, 2, 1]
  31822. *
  31823. * _.rangeRight(0, 20, 5);
  31824. * // => [15, 10, 5, 0]
  31825. *
  31826. * _.rangeRight(0, -4, -1);
  31827. * // => [-3, -2, -1, 0]
  31828. *
  31829. * _.rangeRight(1, 4, 0);
  31830. * // => [1, 1, 1]
  31831. *
  31832. * _.rangeRight(0);
  31833. * // => []
  31834. */
  31835. var rangeRight = createRange(true);
  31836. /**
  31837. * This method returns a new empty array.
  31838. *
  31839. * @static
  31840. * @memberOf _
  31841. * @since 4.13.0
  31842. * @category Util
  31843. * @returns {Array} Returns the new empty array.
  31844. * @example
  31845. *
  31846. * var arrays = _.times(2, _.stubArray);
  31847. *
  31848. * console.log(arrays);
  31849. * // => [[], []]
  31850. *
  31851. * console.log(arrays[0] === arrays[1]);
  31852. * // => false
  31853. */
  31854. function stubArray() {
  31855. return [];
  31856. }
  31857. /**
  31858. * This method returns `false`.
  31859. *
  31860. * @static
  31861. * @memberOf _
  31862. * @since 4.13.0
  31863. * @category Util
  31864. * @returns {boolean} Returns `false`.
  31865. * @example
  31866. *
  31867. * _.times(2, _.stubFalse);
  31868. * // => [false, false]
  31869. */
  31870. function stubFalse() {
  31871. return false;
  31872. }
  31873. /**
  31874. * This method returns a new empty object.
  31875. *
  31876. * @static
  31877. * @memberOf _
  31878. * @since 4.13.0
  31879. * @category Util
  31880. * @returns {Object} Returns the new empty object.
  31881. * @example
  31882. *
  31883. * var objects = _.times(2, _.stubObject);
  31884. *
  31885. * console.log(objects);
  31886. * // => [{}, {}]
  31887. *
  31888. * console.log(objects[0] === objects[1]);
  31889. * // => false
  31890. */
  31891. function stubObject() {
  31892. return {};
  31893. }
  31894. /**
  31895. * This method returns an empty string.
  31896. *
  31897. * @static
  31898. * @memberOf _
  31899. * @since 4.13.0
  31900. * @category Util
  31901. * @returns {string} Returns the empty string.
  31902. * @example
  31903. *
  31904. * _.times(2, _.stubString);
  31905. * // => ['', '']
  31906. */
  31907. function stubString() {
  31908. return '';
  31909. }
  31910. /**
  31911. * This method returns `true`.
  31912. *
  31913. * @static
  31914. * @memberOf _
  31915. * @since 4.13.0
  31916. * @category Util
  31917. * @returns {boolean} Returns `true`.
  31918. * @example
  31919. *
  31920. * _.times(2, _.stubTrue);
  31921. * // => [true, true]
  31922. */
  31923. function stubTrue() {
  31924. return true;
  31925. }
  31926. /**
  31927. * Invokes the iteratee `n` times, returning an array of the results of
  31928. * each invocation. The iteratee is invoked with one argument; (index).
  31929. *
  31930. * @static
  31931. * @since 0.1.0
  31932. * @memberOf _
  31933. * @category Util
  31934. * @param {number} n The number of times to invoke `iteratee`.
  31935. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31936. * @returns {Array} Returns the array of results.
  31937. * @example
  31938. *
  31939. * _.times(3, String);
  31940. * // => ['0', '1', '2']
  31941. *
  31942. * _.times(4, _.constant(0));
  31943. * // => [0, 0, 0, 0]
  31944. */
  31945. function times(n, iteratee) {
  31946. n = toInteger(n);
  31947. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31948. return [];
  31949. }
  31950. var index = MAX_ARRAY_LENGTH,
  31951. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31952. iteratee = getIteratee(iteratee);
  31953. n -= MAX_ARRAY_LENGTH;
  31954. var result = baseTimes(length, iteratee);
  31955. while (++index < n) {
  31956. iteratee(index);
  31957. }
  31958. return result;
  31959. }
  31960. /**
  31961. * Converts `value` to a property path array.
  31962. *
  31963. * @static
  31964. * @memberOf _
  31965. * @since 4.0.0
  31966. * @category Util
  31967. * @param {*} value The value to convert.
  31968. * @returns {Array} Returns the new property path array.
  31969. * @example
  31970. *
  31971. * _.toPath('a.b.c');
  31972. * // => ['a', 'b', 'c']
  31973. *
  31974. * _.toPath('a[0].b.c');
  31975. * // => ['a', '0', 'b', 'c']
  31976. */
  31977. function toPath(value) {
  31978. if (isArray(value)) {
  31979. return arrayMap(value, toKey);
  31980. }
  31981. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  31982. }
  31983. /**
  31984. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  31985. *
  31986. * @static
  31987. * @since 0.1.0
  31988. * @memberOf _
  31989. * @category Util
  31990. * @param {string} [prefix=''] The value to prefix the ID with.
  31991. * @returns {string} Returns the unique ID.
  31992. * @example
  31993. *
  31994. * _.uniqueId('contact_');
  31995. * // => 'contact_104'
  31996. *
  31997. * _.uniqueId();
  31998. * // => '105'
  31999. */
  32000. function uniqueId(prefix) {
  32001. var id = ++idCounter;
  32002. return toString(prefix) + id;
  32003. }
  32004. /*------------------------------------------------------------------------*/
  32005. /**
  32006. * Adds two numbers.
  32007. *
  32008. * @static
  32009. * @memberOf _
  32010. * @since 3.4.0
  32011. * @category Math
  32012. * @param {number} augend The first number in an addition.
  32013. * @param {number} addend The second number in an addition.
  32014. * @returns {number} Returns the total.
  32015. * @example
  32016. *
  32017. * _.add(6, 4);
  32018. * // => 10
  32019. */
  32020. var add = createMathOperation(function(augend, addend) {
  32021. return augend + addend;
  32022. }, 0);
  32023. /**
  32024. * Computes `number` rounded up to `precision`.
  32025. *
  32026. * @static
  32027. * @memberOf _
  32028. * @since 3.10.0
  32029. * @category Math
  32030. * @param {number} number The number to round up.
  32031. * @param {number} [precision=0] The precision to round up to.
  32032. * @returns {number} Returns the rounded up number.
  32033. * @example
  32034. *
  32035. * _.ceil(4.006);
  32036. * // => 5
  32037. *
  32038. * _.ceil(6.004, 2);
  32039. * // => 6.01
  32040. *
  32041. * _.ceil(6040, -2);
  32042. * // => 6100
  32043. */
  32044. var ceil = createRound('ceil');
  32045. /**
  32046. * Divide two numbers.
  32047. *
  32048. * @static
  32049. * @memberOf _
  32050. * @since 4.7.0
  32051. * @category Math
  32052. * @param {number} dividend The first number in a division.
  32053. * @param {number} divisor The second number in a division.
  32054. * @returns {number} Returns the quotient.
  32055. * @example
  32056. *
  32057. * _.divide(6, 4);
  32058. * // => 1.5
  32059. */
  32060. var divide = createMathOperation(function(dividend, divisor) {
  32061. return dividend / divisor;
  32062. }, 1);
  32063. /**
  32064. * Computes `number` rounded down to `precision`.
  32065. *
  32066. * @static
  32067. * @memberOf _
  32068. * @since 3.10.0
  32069. * @category Math
  32070. * @param {number} number The number to round down.
  32071. * @param {number} [precision=0] The precision to round down to.
  32072. * @returns {number} Returns the rounded down number.
  32073. * @example
  32074. *
  32075. * _.floor(4.006);
  32076. * // => 4
  32077. *
  32078. * _.floor(0.046, 2);
  32079. * // => 0.04
  32080. *
  32081. * _.floor(4060, -2);
  32082. * // => 4000
  32083. */
  32084. var floor = createRound('floor');
  32085. /**
  32086. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32087. * `undefined` is returned.
  32088. *
  32089. * @static
  32090. * @since 0.1.0
  32091. * @memberOf _
  32092. * @category Math
  32093. * @param {Array} array The array to iterate over.
  32094. * @returns {*} Returns the maximum value.
  32095. * @example
  32096. *
  32097. * _.max([4, 2, 8, 6]);
  32098. * // => 8
  32099. *
  32100. * _.max([]);
  32101. * // => undefined
  32102. */
  32103. function max(array) {
  32104. return (array && array.length)
  32105. ? baseExtremum(array, identity, baseGt)
  32106. : undefined;
  32107. }
  32108. /**
  32109. * This method is like `_.max` except that it accepts `iteratee` which is
  32110. * invoked for each element in `array` to generate the criterion by which
  32111. * the value is ranked. The iteratee is invoked with one argument: (value).
  32112. *
  32113. * @static
  32114. * @memberOf _
  32115. * @since 4.0.0
  32116. * @category Math
  32117. * @param {Array} array The array to iterate over.
  32118. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32119. * @returns {*} Returns the maximum value.
  32120. * @example
  32121. *
  32122. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32123. *
  32124. * _.maxBy(objects, function(o) { return o.n; });
  32125. * // => { 'n': 2 }
  32126. *
  32127. * // The `_.property` iteratee shorthand.
  32128. * _.maxBy(objects, 'n');
  32129. * // => { 'n': 2 }
  32130. */
  32131. function maxBy(array, iteratee) {
  32132. return (array && array.length)
  32133. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32134. : undefined;
  32135. }
  32136. /**
  32137. * Computes the mean of the values in `array`.
  32138. *
  32139. * @static
  32140. * @memberOf _
  32141. * @since 4.0.0
  32142. * @category Math
  32143. * @param {Array} array The array to iterate over.
  32144. * @returns {number} Returns the mean.
  32145. * @example
  32146. *
  32147. * _.mean([4, 2, 8, 6]);
  32148. * // => 5
  32149. */
  32150. function mean(array) {
  32151. return baseMean(array, identity);
  32152. }
  32153. /**
  32154. * This method is like `_.mean` except that it accepts `iteratee` which is
  32155. * invoked for each element in `array` to generate the value to be averaged.
  32156. * The iteratee is invoked with one argument: (value).
  32157. *
  32158. * @static
  32159. * @memberOf _
  32160. * @since 4.7.0
  32161. * @category Math
  32162. * @param {Array} array The array to iterate over.
  32163. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32164. * @returns {number} Returns the mean.
  32165. * @example
  32166. *
  32167. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32168. *
  32169. * _.meanBy(objects, function(o) { return o.n; });
  32170. * // => 5
  32171. *
  32172. * // The `_.property` iteratee shorthand.
  32173. * _.meanBy(objects, 'n');
  32174. * // => 5
  32175. */
  32176. function meanBy(array, iteratee) {
  32177. return baseMean(array, getIteratee(iteratee, 2));
  32178. }
  32179. /**
  32180. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32181. * `undefined` is returned.
  32182. *
  32183. * @static
  32184. * @since 0.1.0
  32185. * @memberOf _
  32186. * @category Math
  32187. * @param {Array} array The array to iterate over.
  32188. * @returns {*} Returns the minimum value.
  32189. * @example
  32190. *
  32191. * _.min([4, 2, 8, 6]);
  32192. * // => 2
  32193. *
  32194. * _.min([]);
  32195. * // => undefined
  32196. */
  32197. function min(array) {
  32198. return (array && array.length)
  32199. ? baseExtremum(array, identity, baseLt)
  32200. : undefined;
  32201. }
  32202. /**
  32203. * This method is like `_.min` except that it accepts `iteratee` which is
  32204. * invoked for each element in `array` to generate the criterion by which
  32205. * the value is ranked. The iteratee is invoked with one argument: (value).
  32206. *
  32207. * @static
  32208. * @memberOf _
  32209. * @since 4.0.0
  32210. * @category Math
  32211. * @param {Array} array The array to iterate over.
  32212. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32213. * @returns {*} Returns the minimum value.
  32214. * @example
  32215. *
  32216. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32217. *
  32218. * _.minBy(objects, function(o) { return o.n; });
  32219. * // => { 'n': 1 }
  32220. *
  32221. * // The `_.property` iteratee shorthand.
  32222. * _.minBy(objects, 'n');
  32223. * // => { 'n': 1 }
  32224. */
  32225. function minBy(array, iteratee) {
  32226. return (array && array.length)
  32227. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32228. : undefined;
  32229. }
  32230. /**
  32231. * Multiply two numbers.
  32232. *
  32233. * @static
  32234. * @memberOf _
  32235. * @since 4.7.0
  32236. * @category Math
  32237. * @param {number} multiplier The first number in a multiplication.
  32238. * @param {number} multiplicand The second number in a multiplication.
  32239. * @returns {number} Returns the product.
  32240. * @example
  32241. *
  32242. * _.multiply(6, 4);
  32243. * // => 24
  32244. */
  32245. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32246. return multiplier * multiplicand;
  32247. }, 1);
  32248. /**
  32249. * Computes `number` rounded to `precision`.
  32250. *
  32251. * @static
  32252. * @memberOf _
  32253. * @since 3.10.0
  32254. * @category Math
  32255. * @param {number} number The number to round.
  32256. * @param {number} [precision=0] The precision to round to.
  32257. * @returns {number} Returns the rounded number.
  32258. * @example
  32259. *
  32260. * _.round(4.006);
  32261. * // => 4
  32262. *
  32263. * _.round(4.006, 2);
  32264. * // => 4.01
  32265. *
  32266. * _.round(4060, -2);
  32267. * // => 4100
  32268. */
  32269. var round = createRound('round');
  32270. /**
  32271. * Subtract two numbers.
  32272. *
  32273. * @static
  32274. * @memberOf _
  32275. * @since 4.0.0
  32276. * @category Math
  32277. * @param {number} minuend The first number in a subtraction.
  32278. * @param {number} subtrahend The second number in a subtraction.
  32279. * @returns {number} Returns the difference.
  32280. * @example
  32281. *
  32282. * _.subtract(6, 4);
  32283. * // => 2
  32284. */
  32285. var subtract = createMathOperation(function(minuend, subtrahend) {
  32286. return minuend - subtrahend;
  32287. }, 0);
  32288. /**
  32289. * Computes the sum of the values in `array`.
  32290. *
  32291. * @static
  32292. * @memberOf _
  32293. * @since 3.4.0
  32294. * @category Math
  32295. * @param {Array} array The array to iterate over.
  32296. * @returns {number} Returns the sum.
  32297. * @example
  32298. *
  32299. * _.sum([4, 2, 8, 6]);
  32300. * // => 20
  32301. */
  32302. function sum(array) {
  32303. return (array && array.length)
  32304. ? baseSum(array, identity)
  32305. : 0;
  32306. }
  32307. /**
  32308. * This method is like `_.sum` except that it accepts `iteratee` which is
  32309. * invoked for each element in `array` to generate the value to be summed.
  32310. * The iteratee is invoked with one argument: (value).
  32311. *
  32312. * @static
  32313. * @memberOf _
  32314. * @since 4.0.0
  32315. * @category Math
  32316. * @param {Array} array The array to iterate over.
  32317. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32318. * @returns {number} Returns the sum.
  32319. * @example
  32320. *
  32321. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32322. *
  32323. * _.sumBy(objects, function(o) { return o.n; });
  32324. * // => 20
  32325. *
  32326. * // The `_.property` iteratee shorthand.
  32327. * _.sumBy(objects, 'n');
  32328. * // => 20
  32329. */
  32330. function sumBy(array, iteratee) {
  32331. return (array && array.length)
  32332. ? baseSum(array, getIteratee(iteratee, 2))
  32333. : 0;
  32334. }
  32335. /*------------------------------------------------------------------------*/
  32336. // Add methods that return wrapped values in chain sequences.
  32337. lodash.after = after;
  32338. lodash.ary = ary;
  32339. lodash.assign = assign;
  32340. lodash.assignIn = assignIn;
  32341. lodash.assignInWith = assignInWith;
  32342. lodash.assignWith = assignWith;
  32343. lodash.at = at;
  32344. lodash.before = before;
  32345. lodash.bind = bind;
  32346. lodash.bindAll = bindAll;
  32347. lodash.bindKey = bindKey;
  32348. lodash.castArray = castArray;
  32349. lodash.chain = chain;
  32350. lodash.chunk = chunk;
  32351. lodash.compact = compact;
  32352. lodash.concat = concat;
  32353. lodash.cond = cond;
  32354. lodash.conforms = conforms;
  32355. lodash.constant = constant;
  32356. lodash.countBy = countBy;
  32357. lodash.create = create;
  32358. lodash.curry = curry;
  32359. lodash.curryRight = curryRight;
  32360. lodash.debounce = debounce;
  32361. lodash.defaults = defaults;
  32362. lodash.defaultsDeep = defaultsDeep;
  32363. lodash.defer = defer;
  32364. lodash.delay = delay;
  32365. lodash.difference = difference;
  32366. lodash.differenceBy = differenceBy;
  32367. lodash.differenceWith = differenceWith;
  32368. lodash.drop = drop;
  32369. lodash.dropRight = dropRight;
  32370. lodash.dropRightWhile = dropRightWhile;
  32371. lodash.dropWhile = dropWhile;
  32372. lodash.fill = fill;
  32373. lodash.filter = filter;
  32374. lodash.flatMap = flatMap;
  32375. lodash.flatMapDeep = flatMapDeep;
  32376. lodash.flatMapDepth = flatMapDepth;
  32377. lodash.flatten = flatten;
  32378. lodash.flattenDeep = flattenDeep;
  32379. lodash.flattenDepth = flattenDepth;
  32380. lodash.flip = flip;
  32381. lodash.flow = flow;
  32382. lodash.flowRight = flowRight;
  32383. lodash.fromPairs = fromPairs;
  32384. lodash.functions = functions;
  32385. lodash.functionsIn = functionsIn;
  32386. lodash.groupBy = groupBy;
  32387. lodash.initial = initial;
  32388. lodash.intersection = intersection;
  32389. lodash.intersectionBy = intersectionBy;
  32390. lodash.intersectionWith = intersectionWith;
  32391. lodash.invert = invert;
  32392. lodash.invertBy = invertBy;
  32393. lodash.invokeMap = invokeMap;
  32394. lodash.iteratee = iteratee;
  32395. lodash.keyBy = keyBy;
  32396. lodash.keys = keys;
  32397. lodash.keysIn = keysIn;
  32398. lodash.map = map;
  32399. lodash.mapKeys = mapKeys;
  32400. lodash.mapValues = mapValues;
  32401. lodash.matches = matches;
  32402. lodash.matchesProperty = matchesProperty;
  32403. lodash.memoize = memoize;
  32404. lodash.merge = merge;
  32405. lodash.mergeWith = mergeWith;
  32406. lodash.method = method;
  32407. lodash.methodOf = methodOf;
  32408. lodash.mixin = mixin;
  32409. lodash.negate = negate;
  32410. lodash.nthArg = nthArg;
  32411. lodash.omit = omit;
  32412. lodash.omitBy = omitBy;
  32413. lodash.once = once;
  32414. lodash.orderBy = orderBy;
  32415. lodash.over = over;
  32416. lodash.overArgs = overArgs;
  32417. lodash.overEvery = overEvery;
  32418. lodash.overSome = overSome;
  32419. lodash.partial = partial;
  32420. lodash.partialRight = partialRight;
  32421. lodash.partition = partition;
  32422. lodash.pick = pick;
  32423. lodash.pickBy = pickBy;
  32424. lodash.property = property;
  32425. lodash.propertyOf = propertyOf;
  32426. lodash.pull = pull;
  32427. lodash.pullAll = pullAll;
  32428. lodash.pullAllBy = pullAllBy;
  32429. lodash.pullAllWith = pullAllWith;
  32430. lodash.pullAt = pullAt;
  32431. lodash.range = range;
  32432. lodash.rangeRight = rangeRight;
  32433. lodash.rearg = rearg;
  32434. lodash.reject = reject;
  32435. lodash.remove = remove;
  32436. lodash.rest = rest;
  32437. lodash.reverse = reverse;
  32438. lodash.sampleSize = sampleSize;
  32439. lodash.set = set;
  32440. lodash.setWith = setWith;
  32441. lodash.shuffle = shuffle;
  32442. lodash.slice = slice;
  32443. lodash.sortBy = sortBy;
  32444. lodash.sortedUniq = sortedUniq;
  32445. lodash.sortedUniqBy = sortedUniqBy;
  32446. lodash.split = split;
  32447. lodash.spread = spread;
  32448. lodash.tail = tail;
  32449. lodash.take = take;
  32450. lodash.takeRight = takeRight;
  32451. lodash.takeRightWhile = takeRightWhile;
  32452. lodash.takeWhile = takeWhile;
  32453. lodash.tap = tap;
  32454. lodash.throttle = throttle;
  32455. lodash.thru = thru;
  32456. lodash.toArray = toArray;
  32457. lodash.toPairs = toPairs;
  32458. lodash.toPairsIn = toPairsIn;
  32459. lodash.toPath = toPath;
  32460. lodash.toPlainObject = toPlainObject;
  32461. lodash.transform = transform;
  32462. lodash.unary = unary;
  32463. lodash.union = union;
  32464. lodash.unionBy = unionBy;
  32465. lodash.unionWith = unionWith;
  32466. lodash.uniq = uniq;
  32467. lodash.uniqBy = uniqBy;
  32468. lodash.uniqWith = uniqWith;
  32469. lodash.unset = unset;
  32470. lodash.unzip = unzip;
  32471. lodash.unzipWith = unzipWith;
  32472. lodash.update = update;
  32473. lodash.updateWith = updateWith;
  32474. lodash.values = values;
  32475. lodash.valuesIn = valuesIn;
  32476. lodash.without = without;
  32477. lodash.words = words;
  32478. lodash.wrap = wrap;
  32479. lodash.xor = xor;
  32480. lodash.xorBy = xorBy;
  32481. lodash.xorWith = xorWith;
  32482. lodash.zip = zip;
  32483. lodash.zipObject = zipObject;
  32484. lodash.zipObjectDeep = zipObjectDeep;
  32485. lodash.zipWith = zipWith;
  32486. // Add aliases.
  32487. lodash.entries = toPairs;
  32488. lodash.entriesIn = toPairsIn;
  32489. lodash.extend = assignIn;
  32490. lodash.extendWith = assignInWith;
  32491. // Add methods to `lodash.prototype`.
  32492. mixin(lodash, lodash);
  32493. /*------------------------------------------------------------------------*/
  32494. // Add methods that return unwrapped values in chain sequences.
  32495. lodash.add = add;
  32496. lodash.attempt = attempt;
  32497. lodash.camelCase = camelCase;
  32498. lodash.capitalize = capitalize;
  32499. lodash.ceil = ceil;
  32500. lodash.clamp = clamp;
  32501. lodash.clone = clone;
  32502. lodash.cloneDeep = cloneDeep;
  32503. lodash.cloneDeepWith = cloneDeepWith;
  32504. lodash.cloneWith = cloneWith;
  32505. lodash.conformsTo = conformsTo;
  32506. lodash.deburr = deburr;
  32507. lodash.defaultTo = defaultTo;
  32508. lodash.divide = divide;
  32509. lodash.endsWith = endsWith;
  32510. lodash.eq = eq;
  32511. lodash.escape = escape;
  32512. lodash.escapeRegExp = escapeRegExp;
  32513. lodash.every = every;
  32514. lodash.find = find;
  32515. lodash.findIndex = findIndex;
  32516. lodash.findKey = findKey;
  32517. lodash.findLast = findLast;
  32518. lodash.findLastIndex = findLastIndex;
  32519. lodash.findLastKey = findLastKey;
  32520. lodash.floor = floor;
  32521. lodash.forEach = forEach;
  32522. lodash.forEachRight = forEachRight;
  32523. lodash.forIn = forIn;
  32524. lodash.forInRight = forInRight;
  32525. lodash.forOwn = forOwn;
  32526. lodash.forOwnRight = forOwnRight;
  32527. lodash.get = get;
  32528. lodash.gt = gt;
  32529. lodash.gte = gte;
  32530. lodash.has = has;
  32531. lodash.hasIn = hasIn;
  32532. lodash.head = head;
  32533. lodash.identity = identity;
  32534. lodash.includes = includes;
  32535. lodash.indexOf = indexOf;
  32536. lodash.inRange = inRange;
  32537. lodash.invoke = invoke;
  32538. lodash.isArguments = isArguments;
  32539. lodash.isArray = isArray;
  32540. lodash.isArrayBuffer = isArrayBuffer;
  32541. lodash.isArrayLike = isArrayLike;
  32542. lodash.isArrayLikeObject = isArrayLikeObject;
  32543. lodash.isBoolean = isBoolean;
  32544. lodash.isBuffer = isBuffer;
  32545. lodash.isDate = isDate;
  32546. lodash.isElement = isElement;
  32547. lodash.isEmpty = isEmpty;
  32548. lodash.isEqual = isEqual;
  32549. lodash.isEqualWith = isEqualWith;
  32550. lodash.isError = isError;
  32551. lodash.isFinite = isFinite;
  32552. lodash.isFunction = isFunction;
  32553. lodash.isInteger = isInteger;
  32554. lodash.isLength = isLength;
  32555. lodash.isMap = isMap;
  32556. lodash.isMatch = isMatch;
  32557. lodash.isMatchWith = isMatchWith;
  32558. lodash.isNaN = isNaN;
  32559. lodash.isNative = isNative;
  32560. lodash.isNil = isNil;
  32561. lodash.isNull = isNull;
  32562. lodash.isNumber = isNumber;
  32563. lodash.isObject = isObject;
  32564. lodash.isObjectLike = isObjectLike;
  32565. lodash.isPlainObject = isPlainObject;
  32566. lodash.isRegExp = isRegExp;
  32567. lodash.isSafeInteger = isSafeInteger;
  32568. lodash.isSet = isSet;
  32569. lodash.isString = isString;
  32570. lodash.isSymbol = isSymbol;
  32571. lodash.isTypedArray = isTypedArray;
  32572. lodash.isUndefined = isUndefined;
  32573. lodash.isWeakMap = isWeakMap;
  32574. lodash.isWeakSet = isWeakSet;
  32575. lodash.join = join;
  32576. lodash.kebabCase = kebabCase;
  32577. lodash.last = last;
  32578. lodash.lastIndexOf = lastIndexOf;
  32579. lodash.lowerCase = lowerCase;
  32580. lodash.lowerFirst = lowerFirst;
  32581. lodash.lt = lt;
  32582. lodash.lte = lte;
  32583. lodash.max = max;
  32584. lodash.maxBy = maxBy;
  32585. lodash.mean = mean;
  32586. lodash.meanBy = meanBy;
  32587. lodash.min = min;
  32588. lodash.minBy = minBy;
  32589. lodash.stubArray = stubArray;
  32590. lodash.stubFalse = stubFalse;
  32591. lodash.stubObject = stubObject;
  32592. lodash.stubString = stubString;
  32593. lodash.stubTrue = stubTrue;
  32594. lodash.multiply = multiply;
  32595. lodash.nth = nth;
  32596. lodash.noConflict = noConflict;
  32597. lodash.noop = noop;
  32598. lodash.now = now;
  32599. lodash.pad = pad;
  32600. lodash.padEnd = padEnd;
  32601. lodash.padStart = padStart;
  32602. lodash.parseInt = parseInt;
  32603. lodash.random = random;
  32604. lodash.reduce = reduce;
  32605. lodash.reduceRight = reduceRight;
  32606. lodash.repeat = repeat;
  32607. lodash.replace = replace;
  32608. lodash.result = result;
  32609. lodash.round = round;
  32610. lodash.runInContext = runInContext;
  32611. lodash.sample = sample;
  32612. lodash.size = size;
  32613. lodash.snakeCase = snakeCase;
  32614. lodash.some = some;
  32615. lodash.sortedIndex = sortedIndex;
  32616. lodash.sortedIndexBy = sortedIndexBy;
  32617. lodash.sortedIndexOf = sortedIndexOf;
  32618. lodash.sortedLastIndex = sortedLastIndex;
  32619. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32620. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32621. lodash.startCase = startCase;
  32622. lodash.startsWith = startsWith;
  32623. lodash.subtract = subtract;
  32624. lodash.sum = sum;
  32625. lodash.sumBy = sumBy;
  32626. lodash.template = template;
  32627. lodash.times = times;
  32628. lodash.toFinite = toFinite;
  32629. lodash.toInteger = toInteger;
  32630. lodash.toLength = toLength;
  32631. lodash.toLower = toLower;
  32632. lodash.toNumber = toNumber;
  32633. lodash.toSafeInteger = toSafeInteger;
  32634. lodash.toString = toString;
  32635. lodash.toUpper = toUpper;
  32636. lodash.trim = trim;
  32637. lodash.trimEnd = trimEnd;
  32638. lodash.trimStart = trimStart;
  32639. lodash.truncate = truncate;
  32640. lodash.unescape = unescape;
  32641. lodash.uniqueId = uniqueId;
  32642. lodash.upperCase = upperCase;
  32643. lodash.upperFirst = upperFirst;
  32644. // Add aliases.
  32645. lodash.each = forEach;
  32646. lodash.eachRight = forEachRight;
  32647. lodash.first = head;
  32648. mixin(lodash, (function() {
  32649. var source = {};
  32650. baseForOwn(lodash, function(func, methodName) {
  32651. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32652. source[methodName] = func;
  32653. }
  32654. });
  32655. return source;
  32656. }()), { 'chain': false });
  32657. /*------------------------------------------------------------------------*/
  32658. /**
  32659. * The semantic version number.
  32660. *
  32661. * @static
  32662. * @memberOf _
  32663. * @type {string}
  32664. */
  32665. lodash.VERSION = VERSION;
  32666. // Assign default placeholders.
  32667. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32668. lodash[methodName].placeholder = lodash;
  32669. });
  32670. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32671. arrayEach(['drop', 'take'], function(methodName, index) {
  32672. LazyWrapper.prototype[methodName] = function(n) {
  32673. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32674. var result = (this.__filtered__ && !index)
  32675. ? new LazyWrapper(this)
  32676. : this.clone();
  32677. if (result.__filtered__) {
  32678. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32679. } else {
  32680. result.__views__.push({
  32681. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32682. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32683. });
  32684. }
  32685. return result;
  32686. };
  32687. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32688. return this.reverse()[methodName](n).reverse();
  32689. };
  32690. });
  32691. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32692. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32693. var type = index + 1,
  32694. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32695. LazyWrapper.prototype[methodName] = function(iteratee) {
  32696. var result = this.clone();
  32697. result.__iteratees__.push({
  32698. 'iteratee': getIteratee(iteratee, 3),
  32699. 'type': type
  32700. });
  32701. result.__filtered__ = result.__filtered__ || isFilter;
  32702. return result;
  32703. };
  32704. });
  32705. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32706. arrayEach(['head', 'last'], function(methodName, index) {
  32707. var takeName = 'take' + (index ? 'Right' : '');
  32708. LazyWrapper.prototype[methodName] = function() {
  32709. return this[takeName](1).value()[0];
  32710. };
  32711. });
  32712. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32713. arrayEach(['initial', 'tail'], function(methodName, index) {
  32714. var dropName = 'drop' + (index ? '' : 'Right');
  32715. LazyWrapper.prototype[methodName] = function() {
  32716. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32717. };
  32718. });
  32719. LazyWrapper.prototype.compact = function() {
  32720. return this.filter(identity);
  32721. };
  32722. LazyWrapper.prototype.find = function(predicate) {
  32723. return this.filter(predicate).head();
  32724. };
  32725. LazyWrapper.prototype.findLast = function(predicate) {
  32726. return this.reverse().find(predicate);
  32727. };
  32728. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32729. if (typeof path == 'function') {
  32730. return new LazyWrapper(this);
  32731. }
  32732. return this.map(function(value) {
  32733. return baseInvoke(value, path, args);
  32734. });
  32735. });
  32736. LazyWrapper.prototype.reject = function(predicate) {
  32737. return this.filter(negate(getIteratee(predicate)));
  32738. };
  32739. LazyWrapper.prototype.slice = function(start, end) {
  32740. start = toInteger(start);
  32741. var result = this;
  32742. if (result.__filtered__ && (start > 0 || end < 0)) {
  32743. return new LazyWrapper(result);
  32744. }
  32745. if (start < 0) {
  32746. result = result.takeRight(-start);
  32747. } else if (start) {
  32748. result = result.drop(start);
  32749. }
  32750. if (end !== undefined) {
  32751. end = toInteger(end);
  32752. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32753. }
  32754. return result;
  32755. };
  32756. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32757. return this.reverse().takeWhile(predicate).reverse();
  32758. };
  32759. LazyWrapper.prototype.toArray = function() {
  32760. return this.take(MAX_ARRAY_LENGTH);
  32761. };
  32762. // Add `LazyWrapper` methods to `lodash.prototype`.
  32763. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32764. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32765. isTaker = /^(?:head|last)$/.test(methodName),
  32766. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32767. retUnwrapped = isTaker || /^find/.test(methodName);
  32768. if (!lodashFunc) {
  32769. return;
  32770. }
  32771. lodash.prototype[methodName] = function() {
  32772. var value = this.__wrapped__,
  32773. args = isTaker ? [1] : arguments,
  32774. isLazy = value instanceof LazyWrapper,
  32775. iteratee = args[0],
  32776. useLazy = isLazy || isArray(value);
  32777. var interceptor = function(value) {
  32778. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32779. return (isTaker && chainAll) ? result[0] : result;
  32780. };
  32781. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32782. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32783. isLazy = useLazy = false;
  32784. }
  32785. var chainAll = this.__chain__,
  32786. isHybrid = !!this.__actions__.length,
  32787. isUnwrapped = retUnwrapped && !chainAll,
  32788. onlyLazy = isLazy && !isHybrid;
  32789. if (!retUnwrapped && useLazy) {
  32790. value = onlyLazy ? value : new LazyWrapper(this);
  32791. var result = func.apply(value, args);
  32792. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32793. return new LodashWrapper(result, chainAll);
  32794. }
  32795. if (isUnwrapped && onlyLazy) {
  32796. return func.apply(this, args);
  32797. }
  32798. result = this.thru(interceptor);
  32799. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32800. };
  32801. });
  32802. // Add `Array` methods to `lodash.prototype`.
  32803. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32804. var func = arrayProto[methodName],
  32805. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32806. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32807. lodash.prototype[methodName] = function() {
  32808. var args = arguments;
  32809. if (retUnwrapped && !this.__chain__) {
  32810. var value = this.value();
  32811. return func.apply(isArray(value) ? value : [], args);
  32812. }
  32813. return this[chainName](function(value) {
  32814. return func.apply(isArray(value) ? value : [], args);
  32815. });
  32816. };
  32817. });
  32818. // Map minified method names to their real names.
  32819. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32820. var lodashFunc = lodash[methodName];
  32821. if (lodashFunc) {
  32822. var key = lodashFunc.name + '';
  32823. if (!hasOwnProperty.call(realNames, key)) {
  32824. realNames[key] = [];
  32825. }
  32826. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32827. }
  32828. });
  32829. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32830. 'name': 'wrapper',
  32831. 'func': undefined
  32832. }];
  32833. // Add methods to `LazyWrapper`.
  32834. LazyWrapper.prototype.clone = lazyClone;
  32835. LazyWrapper.prototype.reverse = lazyReverse;
  32836. LazyWrapper.prototype.value = lazyValue;
  32837. // Add chain sequence methods to the `lodash` wrapper.
  32838. lodash.prototype.at = wrapperAt;
  32839. lodash.prototype.chain = wrapperChain;
  32840. lodash.prototype.commit = wrapperCommit;
  32841. lodash.prototype.next = wrapperNext;
  32842. lodash.prototype.plant = wrapperPlant;
  32843. lodash.prototype.reverse = wrapperReverse;
  32844. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32845. // Add lazy aliases.
  32846. lodash.prototype.first = lodash.prototype.head;
  32847. if (symIterator) {
  32848. lodash.prototype[symIterator] = wrapperToIterator;
  32849. }
  32850. return lodash;
  32851. });
  32852. /*--------------------------------------------------------------------------*/
  32853. // Export lodash.
  32854. var _ = runInContext();
  32855. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32856. if (true) {
  32857. // Expose Lodash on the global object to prevent errors when Lodash is
  32858. // loaded by a script tag in the presence of an AMD loader.
  32859. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32860. // Use `_.noConflict` to remove Lodash from the global object.
  32861. root._ = _;
  32862. // Define as an anonymous module so, through path mapping, it can be
  32863. // referenced as the "underscore" module.
  32864. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32865. return _;
  32866. }).call(exports, __webpack_require__, exports, module),
  32867. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32868. }
  32869. // Check for `exports` after `define` in case a build optimizer adds it.
  32870. else {}
  32871. }.call(this));
  32872. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  32873. /***/ }),
  32874. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32875. /*!***************************************************!*\
  32876. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32877. \***************************************************/
  32878. /*! exports provided: default */
  32879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32880. "use strict";
  32881. __webpack_require__.r(__webpack_exports__);
  32882. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32883. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32884. * @version 1.16.1
  32885. * @license
  32886. * Copyright (c) 2016 Federico Zivolo and contributors
  32887. *
  32888. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32889. * of this software and associated documentation files (the "Software"), to deal
  32890. * in the Software without restriction, including without limitation the rights
  32891. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32892. * copies of the Software, and to permit persons to whom the Software is
  32893. * furnished to do so, subject to the following conditions:
  32894. *
  32895. * The above copyright notice and this permission notice shall be included in all
  32896. * copies or substantial portions of the Software.
  32897. *
  32898. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32899. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32900. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32901. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32902. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32903. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32904. * SOFTWARE.
  32905. */
  32906. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32907. var timeoutDuration = function () {
  32908. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32909. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32910. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32911. return 1;
  32912. }
  32913. }
  32914. return 0;
  32915. }();
  32916. function microtaskDebounce(fn) {
  32917. var called = false;
  32918. return function () {
  32919. if (called) {
  32920. return;
  32921. }
  32922. called = true;
  32923. window.Promise.resolve().then(function () {
  32924. called = false;
  32925. fn();
  32926. });
  32927. };
  32928. }
  32929. function taskDebounce(fn) {
  32930. var scheduled = false;
  32931. return function () {
  32932. if (!scheduled) {
  32933. scheduled = true;
  32934. setTimeout(function () {
  32935. scheduled = false;
  32936. fn();
  32937. }, timeoutDuration);
  32938. }
  32939. };
  32940. }
  32941. var supportsMicroTasks = isBrowser && window.Promise;
  32942. /**
  32943. * Create a debounced version of a method, that's asynchronously deferred
  32944. * but called in the minimum time possible.
  32945. *
  32946. * @method
  32947. * @memberof Popper.Utils
  32948. * @argument {Function} fn
  32949. * @returns {Function}
  32950. */
  32951. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32952. /**
  32953. * Check if the given variable is a function
  32954. * @method
  32955. * @memberof Popper.Utils
  32956. * @argument {Any} functionToCheck - variable to check
  32957. * @returns {Boolean} answer to: is a function?
  32958. */
  32959. function isFunction(functionToCheck) {
  32960. var getType = {};
  32961. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  32962. }
  32963. /**
  32964. * Get CSS computed property of the given element
  32965. * @method
  32966. * @memberof Popper.Utils
  32967. * @argument {Eement} element
  32968. * @argument {String} property
  32969. */
  32970. function getStyleComputedProperty(element, property) {
  32971. if (element.nodeType !== 1) {
  32972. return [];
  32973. }
  32974. // NOTE: 1 DOM access here
  32975. var window = element.ownerDocument.defaultView;
  32976. var css = window.getComputedStyle(element, null);
  32977. return property ? css[property] : css;
  32978. }
  32979. /**
  32980. * Returns the parentNode or the host of the element
  32981. * @method
  32982. * @memberof Popper.Utils
  32983. * @argument {Element} element
  32984. * @returns {Element} parent
  32985. */
  32986. function getParentNode(element) {
  32987. if (element.nodeName === 'HTML') {
  32988. return element;
  32989. }
  32990. return element.parentNode || element.host;
  32991. }
  32992. /**
  32993. * Returns the scrolling parent of the given element
  32994. * @method
  32995. * @memberof Popper.Utils
  32996. * @argument {Element} element
  32997. * @returns {Element} scroll parent
  32998. */
  32999. function getScrollParent(element) {
  33000. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33001. if (!element) {
  33002. return document.body;
  33003. }
  33004. switch (element.nodeName) {
  33005. case 'HTML':
  33006. case 'BODY':
  33007. return element.ownerDocument.body;
  33008. case '#document':
  33009. return element.body;
  33010. }
  33011. // Firefox want us to check `-x` and `-y` variations as well
  33012. var _getStyleComputedProp = getStyleComputedProperty(element),
  33013. overflow = _getStyleComputedProp.overflow,
  33014. overflowX = _getStyleComputedProp.overflowX,
  33015. overflowY = _getStyleComputedProp.overflowY;
  33016. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33017. return element;
  33018. }
  33019. return getScrollParent(getParentNode(element));
  33020. }
  33021. /**
  33022. * Returns the reference node of the reference object, or the reference object itself.
  33023. * @method
  33024. * @memberof Popper.Utils
  33025. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33026. * @returns {Element} parent
  33027. */
  33028. function getReferenceNode(reference) {
  33029. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33030. }
  33031. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33032. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33033. /**
  33034. * Determines if the browser is Internet Explorer
  33035. * @method
  33036. * @memberof Popper.Utils
  33037. * @param {Number} version to check
  33038. * @returns {Boolean} isIE
  33039. */
  33040. function isIE(version) {
  33041. if (version === 11) {
  33042. return isIE11;
  33043. }
  33044. if (version === 10) {
  33045. return isIE10;
  33046. }
  33047. return isIE11 || isIE10;
  33048. }
  33049. /**
  33050. * Returns the offset parent of the given element
  33051. * @method
  33052. * @memberof Popper.Utils
  33053. * @argument {Element} element
  33054. * @returns {Element} offset parent
  33055. */
  33056. function getOffsetParent(element) {
  33057. if (!element) {
  33058. return document.documentElement;
  33059. }
  33060. var noOffsetParent = isIE(10) ? document.body : null;
  33061. // NOTE: 1 DOM access here
  33062. var offsetParent = element.offsetParent || null;
  33063. // Skip hidden elements which don't have an offsetParent
  33064. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33065. offsetParent = (element = element.nextElementSibling).offsetParent;
  33066. }
  33067. var nodeName = offsetParent && offsetParent.nodeName;
  33068. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33069. return element ? element.ownerDocument.documentElement : document.documentElement;
  33070. }
  33071. // .offsetParent will return the closest TH, TD or TABLE in case
  33072. // no offsetParent is present, I hate this job...
  33073. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33074. return getOffsetParent(offsetParent);
  33075. }
  33076. return offsetParent;
  33077. }
  33078. function isOffsetContainer(element) {
  33079. var nodeName = element.nodeName;
  33080. if (nodeName === 'BODY') {
  33081. return false;
  33082. }
  33083. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33084. }
  33085. /**
  33086. * Finds the root node (document, shadowDOM root) of the given element
  33087. * @method
  33088. * @memberof Popper.Utils
  33089. * @argument {Element} node
  33090. * @returns {Element} root node
  33091. */
  33092. function getRoot(node) {
  33093. if (node.parentNode !== null) {
  33094. return getRoot(node.parentNode);
  33095. }
  33096. return node;
  33097. }
  33098. /**
  33099. * Finds the offset parent common to the two provided nodes
  33100. * @method
  33101. * @memberof Popper.Utils
  33102. * @argument {Element} element1
  33103. * @argument {Element} element2
  33104. * @returns {Element} common offset parent
  33105. */
  33106. function findCommonOffsetParent(element1, element2) {
  33107. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33108. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33109. return document.documentElement;
  33110. }
  33111. // Here we make sure to give as "start" the element that comes first in the DOM
  33112. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33113. var start = order ? element1 : element2;
  33114. var end = order ? element2 : element1;
  33115. // Get common ancestor container
  33116. var range = document.createRange();
  33117. range.setStart(start, 0);
  33118. range.setEnd(end, 0);
  33119. var commonAncestorContainer = range.commonAncestorContainer;
  33120. // Both nodes are inside #document
  33121. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33122. if (isOffsetContainer(commonAncestorContainer)) {
  33123. return commonAncestorContainer;
  33124. }
  33125. return getOffsetParent(commonAncestorContainer);
  33126. }
  33127. // one of the nodes is inside shadowDOM, find which one
  33128. var element1root = getRoot(element1);
  33129. if (element1root.host) {
  33130. return findCommonOffsetParent(element1root.host, element2);
  33131. } else {
  33132. return findCommonOffsetParent(element1, getRoot(element2).host);
  33133. }
  33134. }
  33135. /**
  33136. * Gets the scroll value of the given element in the given side (top and left)
  33137. * @method
  33138. * @memberof Popper.Utils
  33139. * @argument {Element} element
  33140. * @argument {String} side `top` or `left`
  33141. * @returns {number} amount of scrolled pixels
  33142. */
  33143. function getScroll(element) {
  33144. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33145. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33146. var nodeName = element.nodeName;
  33147. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33148. var html = element.ownerDocument.documentElement;
  33149. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33150. return scrollingElement[upperSide];
  33151. }
  33152. return element[upperSide];
  33153. }
  33154. /*
  33155. * Sum or subtract the element scroll values (left and top) from a given rect object
  33156. * @method
  33157. * @memberof Popper.Utils
  33158. * @param {Object} rect - Rect object you want to change
  33159. * @param {HTMLElement} element - The element from the function reads the scroll values
  33160. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33161. * @return {Object} rect - The modifier rect object
  33162. */
  33163. function includeScroll(rect, element) {
  33164. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33165. var scrollTop = getScroll(element, 'top');
  33166. var scrollLeft = getScroll(element, 'left');
  33167. var modifier = subtract ? -1 : 1;
  33168. rect.top += scrollTop * modifier;
  33169. rect.bottom += scrollTop * modifier;
  33170. rect.left += scrollLeft * modifier;
  33171. rect.right += scrollLeft * modifier;
  33172. return rect;
  33173. }
  33174. /*
  33175. * Helper to detect borders of a given element
  33176. * @method
  33177. * @memberof Popper.Utils
  33178. * @param {CSSStyleDeclaration} styles
  33179. * Result of `getStyleComputedProperty` on the given element
  33180. * @param {String} axis - `x` or `y`
  33181. * @return {number} borders - The borders size of the given axis
  33182. */
  33183. function getBordersSize(styles, axis) {
  33184. var sideA = axis === 'x' ? 'Left' : 'Top';
  33185. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33186. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33187. }
  33188. function getSize(axis, body, html, computedStyle) {
  33189. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  33190. }
  33191. function getWindowSizes(document) {
  33192. var body = document.body;
  33193. var html = document.documentElement;
  33194. var computedStyle = isIE(10) && getComputedStyle(html);
  33195. return {
  33196. height: getSize('Height', body, html, computedStyle),
  33197. width: getSize('Width', body, html, computedStyle)
  33198. };
  33199. }
  33200. var classCallCheck = function (instance, Constructor) {
  33201. if (!(instance instanceof Constructor)) {
  33202. throw new TypeError("Cannot call a class as a function");
  33203. }
  33204. };
  33205. var createClass = function () {
  33206. function defineProperties(target, props) {
  33207. for (var i = 0; i < props.length; i++) {
  33208. var descriptor = props[i];
  33209. descriptor.enumerable = descriptor.enumerable || false;
  33210. descriptor.configurable = true;
  33211. if ("value" in descriptor) descriptor.writable = true;
  33212. Object.defineProperty(target, descriptor.key, descriptor);
  33213. }
  33214. }
  33215. return function (Constructor, protoProps, staticProps) {
  33216. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33217. if (staticProps) defineProperties(Constructor, staticProps);
  33218. return Constructor;
  33219. };
  33220. }();
  33221. var defineProperty = function (obj, key, value) {
  33222. if (key in obj) {
  33223. Object.defineProperty(obj, key, {
  33224. value: value,
  33225. enumerable: true,
  33226. configurable: true,
  33227. writable: true
  33228. });
  33229. } else {
  33230. obj[key] = value;
  33231. }
  33232. return obj;
  33233. };
  33234. var _extends = Object.assign || function (target) {
  33235. for (var i = 1; i < arguments.length; i++) {
  33236. var source = arguments[i];
  33237. for (var key in source) {
  33238. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33239. target[key] = source[key];
  33240. }
  33241. }
  33242. }
  33243. return target;
  33244. };
  33245. /**
  33246. * Given element offsets, generate an output similar to getBoundingClientRect
  33247. * @method
  33248. * @memberof Popper.Utils
  33249. * @argument {Object} offsets
  33250. * @returns {Object} ClientRect like output
  33251. */
  33252. function getClientRect(offsets) {
  33253. return _extends({}, offsets, {
  33254. right: offsets.left + offsets.width,
  33255. bottom: offsets.top + offsets.height
  33256. });
  33257. }
  33258. /**
  33259. * Get bounding client rect of given element
  33260. * @method
  33261. * @memberof Popper.Utils
  33262. * @param {HTMLElement} element
  33263. * @return {Object} client rect
  33264. */
  33265. function getBoundingClientRect(element) {
  33266. var rect = {};
  33267. // IE10 10 FIX: Please, don't ask, the element isn't
  33268. // considered in DOM in some circumstances...
  33269. // This isn't reproducible in IE10 compatibility mode of IE11
  33270. try {
  33271. if (isIE(10)) {
  33272. rect = element.getBoundingClientRect();
  33273. var scrollTop = getScroll(element, 'top');
  33274. var scrollLeft = getScroll(element, 'left');
  33275. rect.top += scrollTop;
  33276. rect.left += scrollLeft;
  33277. rect.bottom += scrollTop;
  33278. rect.right += scrollLeft;
  33279. } else {
  33280. rect = element.getBoundingClientRect();
  33281. }
  33282. } catch (e) {}
  33283. var result = {
  33284. left: rect.left,
  33285. top: rect.top,
  33286. width: rect.right - rect.left,
  33287. height: rect.bottom - rect.top
  33288. };
  33289. // subtract scrollbar size from sizes
  33290. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33291. var width = sizes.width || element.clientWidth || result.width;
  33292. var height = sizes.height || element.clientHeight || result.height;
  33293. var horizScrollbar = element.offsetWidth - width;
  33294. var vertScrollbar = element.offsetHeight - height;
  33295. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33296. // we make this check conditional for performance reasons
  33297. if (horizScrollbar || vertScrollbar) {
  33298. var styles = getStyleComputedProperty(element);
  33299. horizScrollbar -= getBordersSize(styles, 'x');
  33300. vertScrollbar -= getBordersSize(styles, 'y');
  33301. result.width -= horizScrollbar;
  33302. result.height -= vertScrollbar;
  33303. }
  33304. return getClientRect(result);
  33305. }
  33306. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33307. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33308. var isIE10 = isIE(10);
  33309. var isHTML = parent.nodeName === 'HTML';
  33310. var childrenRect = getBoundingClientRect(children);
  33311. var parentRect = getBoundingClientRect(parent);
  33312. var scrollParent = getScrollParent(children);
  33313. var styles = getStyleComputedProperty(parent);
  33314. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33315. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33316. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33317. if (fixedPosition && isHTML) {
  33318. parentRect.top = Math.max(parentRect.top, 0);
  33319. parentRect.left = Math.max(parentRect.left, 0);
  33320. }
  33321. var offsets = getClientRect({
  33322. top: childrenRect.top - parentRect.top - borderTopWidth,
  33323. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33324. width: childrenRect.width,
  33325. height: childrenRect.height
  33326. });
  33327. offsets.marginTop = 0;
  33328. offsets.marginLeft = 0;
  33329. // Subtract margins of documentElement in case it's being used as parent
  33330. // we do this only on HTML because it's the only element that behaves
  33331. // differently when margins are applied to it. The margins are included in
  33332. // the box of the documentElement, in the other cases not.
  33333. if (!isIE10 && isHTML) {
  33334. var marginTop = parseFloat(styles.marginTop);
  33335. var marginLeft = parseFloat(styles.marginLeft);
  33336. offsets.top -= borderTopWidth - marginTop;
  33337. offsets.bottom -= borderTopWidth - marginTop;
  33338. offsets.left -= borderLeftWidth - marginLeft;
  33339. offsets.right -= borderLeftWidth - marginLeft;
  33340. // Attach marginTop and marginLeft because in some circumstances we may need them
  33341. offsets.marginTop = marginTop;
  33342. offsets.marginLeft = marginLeft;
  33343. }
  33344. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33345. offsets = includeScroll(offsets, parent);
  33346. }
  33347. return offsets;
  33348. }
  33349. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33350. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33351. var html = element.ownerDocument.documentElement;
  33352. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33353. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33354. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33355. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33356. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33357. var offset = {
  33358. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33359. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33360. width: width,
  33361. height: height
  33362. };
  33363. return getClientRect(offset);
  33364. }
  33365. /**
  33366. * Check if the given element is fixed or is inside a fixed parent
  33367. * @method
  33368. * @memberof Popper.Utils
  33369. * @argument {Element} element
  33370. * @argument {Element} customContainer
  33371. * @returns {Boolean} answer to "isFixed?"
  33372. */
  33373. function isFixed(element) {
  33374. var nodeName = element.nodeName;
  33375. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33376. return false;
  33377. }
  33378. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33379. return true;
  33380. }
  33381. var parentNode = getParentNode(element);
  33382. if (!parentNode) {
  33383. return false;
  33384. }
  33385. return isFixed(parentNode);
  33386. }
  33387. /**
  33388. * Finds the first parent of an element that has a transformed property defined
  33389. * @method
  33390. * @memberof Popper.Utils
  33391. * @argument {Element} element
  33392. * @returns {Element} first transformed parent or documentElement
  33393. */
  33394. function getFixedPositionOffsetParent(element) {
  33395. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33396. if (!element || !element.parentElement || isIE()) {
  33397. return document.documentElement;
  33398. }
  33399. var el = element.parentElement;
  33400. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33401. el = el.parentElement;
  33402. }
  33403. return el || document.documentElement;
  33404. }
  33405. /**
  33406. * Computed the boundaries limits and return them
  33407. * @method
  33408. * @memberof Popper.Utils
  33409. * @param {HTMLElement} popper
  33410. * @param {HTMLElement} reference
  33411. * @param {number} padding
  33412. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33413. * @param {Boolean} fixedPosition - Is in fixed position mode
  33414. * @returns {Object} Coordinates of the boundaries
  33415. */
  33416. function getBoundaries(popper, reference, padding, boundariesElement) {
  33417. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33418. // NOTE: 1 DOM access here
  33419. var boundaries = { top: 0, left: 0 };
  33420. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33421. // Handle viewport case
  33422. if (boundariesElement === 'viewport') {
  33423. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33424. } else {
  33425. // Handle other cases based on DOM element used as boundaries
  33426. var boundariesNode = void 0;
  33427. if (boundariesElement === 'scrollParent') {
  33428. boundariesNode = getScrollParent(getParentNode(reference));
  33429. if (boundariesNode.nodeName === 'BODY') {
  33430. boundariesNode = popper.ownerDocument.documentElement;
  33431. }
  33432. } else if (boundariesElement === 'window') {
  33433. boundariesNode = popper.ownerDocument.documentElement;
  33434. } else {
  33435. boundariesNode = boundariesElement;
  33436. }
  33437. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33438. // In case of HTML, we need a different computation
  33439. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33440. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33441. height = _getWindowSizes.height,
  33442. width = _getWindowSizes.width;
  33443. boundaries.top += offsets.top - offsets.marginTop;
  33444. boundaries.bottom = height + offsets.top;
  33445. boundaries.left += offsets.left - offsets.marginLeft;
  33446. boundaries.right = width + offsets.left;
  33447. } else {
  33448. // for all the other DOM elements, this one is good
  33449. boundaries = offsets;
  33450. }
  33451. }
  33452. // Add paddings
  33453. padding = padding || 0;
  33454. var isPaddingNumber = typeof padding === 'number';
  33455. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33456. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33457. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33458. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33459. return boundaries;
  33460. }
  33461. function getArea(_ref) {
  33462. var width = _ref.width,
  33463. height = _ref.height;
  33464. return width * height;
  33465. }
  33466. /**
  33467. * Utility used to transform the `auto` placement to the placement with more
  33468. * available space.
  33469. * @method
  33470. * @memberof Popper.Utils
  33471. * @argument {Object} data - The data object generated by update method
  33472. * @argument {Object} options - Modifiers configuration and options
  33473. * @returns {Object} The data object, properly modified
  33474. */
  33475. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33476. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33477. if (placement.indexOf('auto') === -1) {
  33478. return placement;
  33479. }
  33480. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33481. var rects = {
  33482. top: {
  33483. width: boundaries.width,
  33484. height: refRect.top - boundaries.top
  33485. },
  33486. right: {
  33487. width: boundaries.right - refRect.right,
  33488. height: boundaries.height
  33489. },
  33490. bottom: {
  33491. width: boundaries.width,
  33492. height: boundaries.bottom - refRect.bottom
  33493. },
  33494. left: {
  33495. width: refRect.left - boundaries.left,
  33496. height: boundaries.height
  33497. }
  33498. };
  33499. var sortedAreas = Object.keys(rects).map(function (key) {
  33500. return _extends({
  33501. key: key
  33502. }, rects[key], {
  33503. area: getArea(rects[key])
  33504. });
  33505. }).sort(function (a, b) {
  33506. return b.area - a.area;
  33507. });
  33508. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33509. var width = _ref2.width,
  33510. height = _ref2.height;
  33511. return width >= popper.clientWidth && height >= popper.clientHeight;
  33512. });
  33513. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33514. var variation = placement.split('-')[1];
  33515. return computedPlacement + (variation ? '-' + variation : '');
  33516. }
  33517. /**
  33518. * Get offsets to the reference element
  33519. * @method
  33520. * @memberof Popper.Utils
  33521. * @param {Object} state
  33522. * @param {Element} popper - the popper element
  33523. * @param {Element} reference - the reference element (the popper will be relative to this)
  33524. * @param {Element} fixedPosition - is in fixed position mode
  33525. * @returns {Object} An object containing the offsets which will be applied to the popper
  33526. */
  33527. function getReferenceOffsets(state, popper, reference) {
  33528. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33529. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33530. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33531. }
  33532. /**
  33533. * Get the outer sizes of the given element (offset size + margins)
  33534. * @method
  33535. * @memberof Popper.Utils
  33536. * @argument {Element} element
  33537. * @returns {Object} object containing width and height properties
  33538. */
  33539. function getOuterSizes(element) {
  33540. var window = element.ownerDocument.defaultView;
  33541. var styles = window.getComputedStyle(element);
  33542. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33543. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33544. var result = {
  33545. width: element.offsetWidth + y,
  33546. height: element.offsetHeight + x
  33547. };
  33548. return result;
  33549. }
  33550. /**
  33551. * Get the opposite placement of the given one
  33552. * @method
  33553. * @memberof Popper.Utils
  33554. * @argument {String} placement
  33555. * @returns {String} flipped placement
  33556. */
  33557. function getOppositePlacement(placement) {
  33558. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33559. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33560. return hash[matched];
  33561. });
  33562. }
  33563. /**
  33564. * Get offsets to the popper
  33565. * @method
  33566. * @memberof Popper.Utils
  33567. * @param {Object} position - CSS position the Popper will get applied
  33568. * @param {HTMLElement} popper - the popper element
  33569. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33570. * @param {String} placement - one of the valid placement options
  33571. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33572. */
  33573. function getPopperOffsets(popper, referenceOffsets, placement) {
  33574. placement = placement.split('-')[0];
  33575. // Get popper node sizes
  33576. var popperRect = getOuterSizes(popper);
  33577. // Add position, width and height to our offsets object
  33578. var popperOffsets = {
  33579. width: popperRect.width,
  33580. height: popperRect.height
  33581. };
  33582. // depending by the popper placement we have to compute its offsets slightly differently
  33583. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33584. var mainSide = isHoriz ? 'top' : 'left';
  33585. var secondarySide = isHoriz ? 'left' : 'top';
  33586. var measurement = isHoriz ? 'height' : 'width';
  33587. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33588. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33589. if (placement === secondarySide) {
  33590. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33591. } else {
  33592. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33593. }
  33594. return popperOffsets;
  33595. }
  33596. /**
  33597. * Mimics the `find` method of Array
  33598. * @method
  33599. * @memberof Popper.Utils
  33600. * @argument {Array} arr
  33601. * @argument prop
  33602. * @argument value
  33603. * @returns index or -1
  33604. */
  33605. function find(arr, check) {
  33606. // use native find if supported
  33607. if (Array.prototype.find) {
  33608. return arr.find(check);
  33609. }
  33610. // use `filter` to obtain the same behavior of `find`
  33611. return arr.filter(check)[0];
  33612. }
  33613. /**
  33614. * Return the index of the matching object
  33615. * @method
  33616. * @memberof Popper.Utils
  33617. * @argument {Array} arr
  33618. * @argument prop
  33619. * @argument value
  33620. * @returns index or -1
  33621. */
  33622. function findIndex(arr, prop, value) {
  33623. // use native findIndex if supported
  33624. if (Array.prototype.findIndex) {
  33625. return arr.findIndex(function (cur) {
  33626. return cur[prop] === value;
  33627. });
  33628. }
  33629. // use `find` + `indexOf` if `findIndex` isn't supported
  33630. var match = find(arr, function (obj) {
  33631. return obj[prop] === value;
  33632. });
  33633. return arr.indexOf(match);
  33634. }
  33635. /**
  33636. * Loop trough the list of modifiers and run them in order,
  33637. * each of them will then edit the data object.
  33638. * @method
  33639. * @memberof Popper.Utils
  33640. * @param {dataObject} data
  33641. * @param {Array} modifiers
  33642. * @param {String} ends - Optional modifier name used as stopper
  33643. * @returns {dataObject}
  33644. */
  33645. function runModifiers(modifiers, data, ends) {
  33646. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33647. modifiersToRun.forEach(function (modifier) {
  33648. if (modifier['function']) {
  33649. // eslint-disable-line dot-notation
  33650. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33651. }
  33652. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33653. if (modifier.enabled && isFunction(fn)) {
  33654. // Add properties to offsets to make them a complete clientRect object
  33655. // we do this before each modifier to make sure the previous one doesn't
  33656. // mess with these values
  33657. data.offsets.popper = getClientRect(data.offsets.popper);
  33658. data.offsets.reference = getClientRect(data.offsets.reference);
  33659. data = fn(data, modifier);
  33660. }
  33661. });
  33662. return data;
  33663. }
  33664. /**
  33665. * Updates the position of the popper, computing the new offsets and applying
  33666. * the new style.<br />
  33667. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33668. * @method
  33669. * @memberof Popper
  33670. */
  33671. function update() {
  33672. // if popper is destroyed, don't perform any further update
  33673. if (this.state.isDestroyed) {
  33674. return;
  33675. }
  33676. var data = {
  33677. instance: this,
  33678. styles: {},
  33679. arrowStyles: {},
  33680. attributes: {},
  33681. flipped: false,
  33682. offsets: {}
  33683. };
  33684. // compute reference element offsets
  33685. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33686. // compute auto placement, store placement inside the data object,
  33687. // modifiers will be able to edit `placement` if needed
  33688. // and refer to originalPlacement to know the original value
  33689. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33690. // store the computed placement inside `originalPlacement`
  33691. data.originalPlacement = data.placement;
  33692. data.positionFixed = this.options.positionFixed;
  33693. // compute the popper offsets
  33694. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33695. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33696. // run the modifiers
  33697. data = runModifiers(this.modifiers, data);
  33698. // the first `update` will call `onCreate` callback
  33699. // the other ones will call `onUpdate` callback
  33700. if (!this.state.isCreated) {
  33701. this.state.isCreated = true;
  33702. this.options.onCreate(data);
  33703. } else {
  33704. this.options.onUpdate(data);
  33705. }
  33706. }
  33707. /**
  33708. * Helper used to know if the given modifier is enabled.
  33709. * @method
  33710. * @memberof Popper.Utils
  33711. * @returns {Boolean}
  33712. */
  33713. function isModifierEnabled(modifiers, modifierName) {
  33714. return modifiers.some(function (_ref) {
  33715. var name = _ref.name,
  33716. enabled = _ref.enabled;
  33717. return enabled && name === modifierName;
  33718. });
  33719. }
  33720. /**
  33721. * Get the prefixed supported property name
  33722. * @method
  33723. * @memberof Popper.Utils
  33724. * @argument {String} property (camelCase)
  33725. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33726. */
  33727. function getSupportedPropertyName(property) {
  33728. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33729. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33730. for (var i = 0; i < prefixes.length; i++) {
  33731. var prefix = prefixes[i];
  33732. var toCheck = prefix ? '' + prefix + upperProp : property;
  33733. if (typeof document.body.style[toCheck] !== 'undefined') {
  33734. return toCheck;
  33735. }
  33736. }
  33737. return null;
  33738. }
  33739. /**
  33740. * Destroys the popper.
  33741. * @method
  33742. * @memberof Popper
  33743. */
  33744. function destroy() {
  33745. this.state.isDestroyed = true;
  33746. // touch DOM only if `applyStyle` modifier is enabled
  33747. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33748. this.popper.removeAttribute('x-placement');
  33749. this.popper.style.position = '';
  33750. this.popper.style.top = '';
  33751. this.popper.style.left = '';
  33752. this.popper.style.right = '';
  33753. this.popper.style.bottom = '';
  33754. this.popper.style.willChange = '';
  33755. this.popper.style[getSupportedPropertyName('transform')] = '';
  33756. }
  33757. this.disableEventListeners();
  33758. // remove the popper if user explicitly asked for the deletion on destroy
  33759. // do not use `remove` because IE11 doesn't support it
  33760. if (this.options.removeOnDestroy) {
  33761. this.popper.parentNode.removeChild(this.popper);
  33762. }
  33763. return this;
  33764. }
  33765. /**
  33766. * Get the window associated with the element
  33767. * @argument {Element} element
  33768. * @returns {Window}
  33769. */
  33770. function getWindow(element) {
  33771. var ownerDocument = element.ownerDocument;
  33772. return ownerDocument ? ownerDocument.defaultView : window;
  33773. }
  33774. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33775. var isBody = scrollParent.nodeName === 'BODY';
  33776. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33777. target.addEventListener(event, callback, { passive: true });
  33778. if (!isBody) {
  33779. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33780. }
  33781. scrollParents.push(target);
  33782. }
  33783. /**
  33784. * Setup needed event listeners used to update the popper position
  33785. * @method
  33786. * @memberof Popper.Utils
  33787. * @private
  33788. */
  33789. function setupEventListeners(reference, options, state, updateBound) {
  33790. // Resize event listener on window
  33791. state.updateBound = updateBound;
  33792. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33793. // Scroll event listener on scroll parents
  33794. var scrollElement = getScrollParent(reference);
  33795. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33796. state.scrollElement = scrollElement;
  33797. state.eventsEnabled = true;
  33798. return state;
  33799. }
  33800. /**
  33801. * It will add resize/scroll events and start recalculating
  33802. * position of the popper element when they are triggered.
  33803. * @method
  33804. * @memberof Popper
  33805. */
  33806. function enableEventListeners() {
  33807. if (!this.state.eventsEnabled) {
  33808. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33809. }
  33810. }
  33811. /**
  33812. * Remove event listeners used to update the popper position
  33813. * @method
  33814. * @memberof Popper.Utils
  33815. * @private
  33816. */
  33817. function removeEventListeners(reference, state) {
  33818. // Remove resize event listener on window
  33819. getWindow(reference).removeEventListener('resize', state.updateBound);
  33820. // Remove scroll event listener on scroll parents
  33821. state.scrollParents.forEach(function (target) {
  33822. target.removeEventListener('scroll', state.updateBound);
  33823. });
  33824. // Reset state
  33825. state.updateBound = null;
  33826. state.scrollParents = [];
  33827. state.scrollElement = null;
  33828. state.eventsEnabled = false;
  33829. return state;
  33830. }
  33831. /**
  33832. * It will remove resize/scroll events and won't recalculate popper position
  33833. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33834. * unless you call `update` method manually.
  33835. * @method
  33836. * @memberof Popper
  33837. */
  33838. function disableEventListeners() {
  33839. if (this.state.eventsEnabled) {
  33840. cancelAnimationFrame(this.scheduleUpdate);
  33841. this.state = removeEventListeners(this.reference, this.state);
  33842. }
  33843. }
  33844. /**
  33845. * Tells if a given input is a number
  33846. * @method
  33847. * @memberof Popper.Utils
  33848. * @param {*} input to check
  33849. * @return {Boolean}
  33850. */
  33851. function isNumeric(n) {
  33852. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33853. }
  33854. /**
  33855. * Set the style to the given popper
  33856. * @method
  33857. * @memberof Popper.Utils
  33858. * @argument {Element} element - Element to apply the style to
  33859. * @argument {Object} styles
  33860. * Object with a list of properties and values which will be applied to the element
  33861. */
  33862. function setStyles(element, styles) {
  33863. Object.keys(styles).forEach(function (prop) {
  33864. var unit = '';
  33865. // add unit if the value is numeric and is one of the following
  33866. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33867. unit = 'px';
  33868. }
  33869. element.style[prop] = styles[prop] + unit;
  33870. });
  33871. }
  33872. /**
  33873. * Set the attributes to the given popper
  33874. * @method
  33875. * @memberof Popper.Utils
  33876. * @argument {Element} element - Element to apply the attributes to
  33877. * @argument {Object} styles
  33878. * Object with a list of properties and values which will be applied to the element
  33879. */
  33880. function setAttributes(element, attributes) {
  33881. Object.keys(attributes).forEach(function (prop) {
  33882. var value = attributes[prop];
  33883. if (value !== false) {
  33884. element.setAttribute(prop, attributes[prop]);
  33885. } else {
  33886. element.removeAttribute(prop);
  33887. }
  33888. });
  33889. }
  33890. /**
  33891. * @function
  33892. * @memberof Modifiers
  33893. * @argument {Object} data - The data object generated by `update` method
  33894. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33895. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33896. * @argument {Object} options - Modifiers configuration and options
  33897. * @returns {Object} The same data object
  33898. */
  33899. function applyStyle(data) {
  33900. // any property present in `data.styles` will be applied to the popper,
  33901. // in this way we can make the 3rd party modifiers add custom styles to it
  33902. // Be aware, modifiers could override the properties defined in the previous
  33903. // lines of this modifier!
  33904. setStyles(data.instance.popper, data.styles);
  33905. // any property present in `data.attributes` will be applied to the popper,
  33906. // they will be set as HTML attributes of the element
  33907. setAttributes(data.instance.popper, data.attributes);
  33908. // if arrowElement is defined and arrowStyles has some properties
  33909. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33910. setStyles(data.arrowElement, data.arrowStyles);
  33911. }
  33912. return data;
  33913. }
  33914. /**
  33915. * Set the x-placement attribute before everything else because it could be used
  33916. * to add margins to the popper margins needs to be calculated to get the
  33917. * correct popper offsets.
  33918. * @method
  33919. * @memberof Popper.modifiers
  33920. * @param {HTMLElement} reference - The reference element used to position the popper
  33921. * @param {HTMLElement} popper - The HTML element used as popper
  33922. * @param {Object} options - Popper.js options
  33923. */
  33924. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33925. // compute reference element offsets
  33926. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33927. // compute auto placement, store placement inside the data object,
  33928. // modifiers will be able to edit `placement` if needed
  33929. // and refer to originalPlacement to know the original value
  33930. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33931. popper.setAttribute('x-placement', placement);
  33932. // Apply `position` to popper before anything else because
  33933. // without the position applied we can't guarantee correct computations
  33934. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33935. return options;
  33936. }
  33937. /**
  33938. * @function
  33939. * @memberof Popper.Utils
  33940. * @argument {Object} data - The data object generated by `update` method
  33941. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33942. * @returns {Object} The popper's position offsets rounded
  33943. *
  33944. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33945. * good as it can be within reason.
  33946. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33947. *
  33948. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33949. * as well on High DPI screens).
  33950. *
  33951. * Firefox prefers no rounding for positioning and does not have blurriness on
  33952. * high DPI screens.
  33953. *
  33954. * Only horizontal placement and left/right values need to be considered.
  33955. */
  33956. function getRoundedOffsets(data, shouldRound) {
  33957. var _data$offsets = data.offsets,
  33958. popper = _data$offsets.popper,
  33959. reference = _data$offsets.reference;
  33960. var round = Math.round,
  33961. floor = Math.floor;
  33962. var noRound = function noRound(v) {
  33963. return v;
  33964. };
  33965. var referenceWidth = round(reference.width);
  33966. var popperWidth = round(popper.width);
  33967. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  33968. var isVariation = data.placement.indexOf('-') !== -1;
  33969. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  33970. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  33971. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  33972. var verticalToInteger = !shouldRound ? noRound : round;
  33973. return {
  33974. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  33975. top: verticalToInteger(popper.top),
  33976. bottom: verticalToInteger(popper.bottom),
  33977. right: horizontalToInteger(popper.right)
  33978. };
  33979. }
  33980. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  33981. /**
  33982. * @function
  33983. * @memberof Modifiers
  33984. * @argument {Object} data - The data object generated by `update` method
  33985. * @argument {Object} options - Modifiers configuration and options
  33986. * @returns {Object} The data object, properly modified
  33987. */
  33988. function computeStyle(data, options) {
  33989. var x = options.x,
  33990. y = options.y;
  33991. var popper = data.offsets.popper;
  33992. // Remove this legacy support in Popper.js v2
  33993. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  33994. return modifier.name === 'applyStyle';
  33995. }).gpuAcceleration;
  33996. if (legacyGpuAccelerationOption !== undefined) {
  33997. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  33998. }
  33999. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34000. var offsetParent = getOffsetParent(data.instance.popper);
  34001. var offsetParentRect = getBoundingClientRect(offsetParent);
  34002. // Styles
  34003. var styles = {
  34004. position: popper.position
  34005. };
  34006. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34007. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34008. var sideB = y === 'right' ? 'left' : 'right';
  34009. // if gpuAcceleration is set to `true` and transform is supported,
  34010. // we use `translate3d` to apply the position to the popper we
  34011. // automatically use the supported prefixed version if needed
  34012. var prefixedProperty = getSupportedPropertyName('transform');
  34013. // now, let's make a step back and look at this code closely (wtf?)
  34014. // If the content of the popper grows once it's been positioned, it
  34015. // may happen that the popper gets misplaced because of the new content
  34016. // overflowing its reference element
  34017. // To avoid this problem, we provide two options (x and y), which allow
  34018. // the consumer to define the offset origin.
  34019. // If we position a popper on top of a reference element, we can set
  34020. // `x` to `top` to make the popper grow towards its top instead of
  34021. // its bottom.
  34022. var left = void 0,
  34023. top = void 0;
  34024. if (sideA === 'bottom') {
  34025. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34026. // and not the bottom of the html element
  34027. if (offsetParent.nodeName === 'HTML') {
  34028. top = -offsetParent.clientHeight + offsets.bottom;
  34029. } else {
  34030. top = -offsetParentRect.height + offsets.bottom;
  34031. }
  34032. } else {
  34033. top = offsets.top;
  34034. }
  34035. if (sideB === 'right') {
  34036. if (offsetParent.nodeName === 'HTML') {
  34037. left = -offsetParent.clientWidth + offsets.right;
  34038. } else {
  34039. left = -offsetParentRect.width + offsets.right;
  34040. }
  34041. } else {
  34042. left = offsets.left;
  34043. }
  34044. if (gpuAcceleration && prefixedProperty) {
  34045. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34046. styles[sideA] = 0;
  34047. styles[sideB] = 0;
  34048. styles.willChange = 'transform';
  34049. } else {
  34050. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34051. var invertTop = sideA === 'bottom' ? -1 : 1;
  34052. var invertLeft = sideB === 'right' ? -1 : 1;
  34053. styles[sideA] = top * invertTop;
  34054. styles[sideB] = left * invertLeft;
  34055. styles.willChange = sideA + ', ' + sideB;
  34056. }
  34057. // Attributes
  34058. var attributes = {
  34059. 'x-placement': data.placement
  34060. };
  34061. // Update `data` attributes, styles and arrowStyles
  34062. data.attributes = _extends({}, attributes, data.attributes);
  34063. data.styles = _extends({}, styles, data.styles);
  34064. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34065. return data;
  34066. }
  34067. /**
  34068. * Helper used to know if the given modifier depends from another one.<br />
  34069. * It checks if the needed modifier is listed and enabled.
  34070. * @method
  34071. * @memberof Popper.Utils
  34072. * @param {Array} modifiers - list of modifiers
  34073. * @param {String} requestingName - name of requesting modifier
  34074. * @param {String} requestedName - name of requested modifier
  34075. * @returns {Boolean}
  34076. */
  34077. function isModifierRequired(modifiers, requestingName, requestedName) {
  34078. var requesting = find(modifiers, function (_ref) {
  34079. var name = _ref.name;
  34080. return name === requestingName;
  34081. });
  34082. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34083. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34084. });
  34085. if (!isRequired) {
  34086. var _requesting = '`' + requestingName + '`';
  34087. var requested = '`' + requestedName + '`';
  34088. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34089. }
  34090. return isRequired;
  34091. }
  34092. /**
  34093. * @function
  34094. * @memberof Modifiers
  34095. * @argument {Object} data - The data object generated by update method
  34096. * @argument {Object} options - Modifiers configuration and options
  34097. * @returns {Object} The data object, properly modified
  34098. */
  34099. function arrow(data, options) {
  34100. var _data$offsets$arrow;
  34101. // arrow depends on keepTogether in order to work
  34102. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34103. return data;
  34104. }
  34105. var arrowElement = options.element;
  34106. // if arrowElement is a string, suppose it's a CSS selector
  34107. if (typeof arrowElement === 'string') {
  34108. arrowElement = data.instance.popper.querySelector(arrowElement);
  34109. // if arrowElement is not found, don't run the modifier
  34110. if (!arrowElement) {
  34111. return data;
  34112. }
  34113. } else {
  34114. // if the arrowElement isn't a query selector we must check that the
  34115. // provided DOM node is child of its popper node
  34116. if (!data.instance.popper.contains(arrowElement)) {
  34117. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34118. return data;
  34119. }
  34120. }
  34121. var placement = data.placement.split('-')[0];
  34122. var _data$offsets = data.offsets,
  34123. popper = _data$offsets.popper,
  34124. reference = _data$offsets.reference;
  34125. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34126. var len = isVertical ? 'height' : 'width';
  34127. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34128. var side = sideCapitalized.toLowerCase();
  34129. var altSide = isVertical ? 'left' : 'top';
  34130. var opSide = isVertical ? 'bottom' : 'right';
  34131. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34132. //
  34133. // extends keepTogether behavior making sure the popper and its
  34134. // reference have enough pixels in conjunction
  34135. //
  34136. // top/left side
  34137. if (reference[opSide] - arrowElementSize < popper[side]) {
  34138. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34139. }
  34140. // bottom/right side
  34141. if (reference[side] + arrowElementSize > popper[opSide]) {
  34142. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34143. }
  34144. data.offsets.popper = getClientRect(data.offsets.popper);
  34145. // compute center of the popper
  34146. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34147. // Compute the sideValue using the updated popper offsets
  34148. // take popper margin in account because we don't have this info available
  34149. var css = getStyleComputedProperty(data.instance.popper);
  34150. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34151. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34152. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34153. // prevent arrowElement from being placed not contiguously to its popper
  34154. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34155. data.arrowElement = arrowElement;
  34156. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34157. return data;
  34158. }
  34159. /**
  34160. * Get the opposite placement variation of the given one
  34161. * @method
  34162. * @memberof Popper.Utils
  34163. * @argument {String} placement variation
  34164. * @returns {String} flipped placement variation
  34165. */
  34166. function getOppositeVariation(variation) {
  34167. if (variation === 'end') {
  34168. return 'start';
  34169. } else if (variation === 'start') {
  34170. return 'end';
  34171. }
  34172. return variation;
  34173. }
  34174. /**
  34175. * List of accepted placements to use as values of the `placement` option.<br />
  34176. * Valid placements are:
  34177. * - `auto`
  34178. * - `top`
  34179. * - `right`
  34180. * - `bottom`
  34181. * - `left`
  34182. *
  34183. * Each placement can have a variation from this list:
  34184. * - `-start`
  34185. * - `-end`
  34186. *
  34187. * Variations are interpreted easily if you think of them as the left to right
  34188. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34189. * is right.<br />
  34190. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34191. *
  34192. * Some valid examples are:
  34193. * - `top-end` (on top of reference, right aligned)
  34194. * - `right-start` (on right of reference, top aligned)
  34195. * - `bottom` (on bottom, centered)
  34196. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34197. *
  34198. * @static
  34199. * @type {Array}
  34200. * @enum {String}
  34201. * @readonly
  34202. * @method placements
  34203. * @memberof Popper
  34204. */
  34205. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
  34206. // Get rid of `auto` `auto-start` and `auto-end`
  34207. var validPlacements = placements.slice(3);
  34208. /**
  34209. * Given an initial placement, returns all the subsequent placements
  34210. * clockwise (or counter-clockwise).
  34211. *
  34212. * @method
  34213. * @memberof Popper.Utils
  34214. * @argument {String} placement - A valid placement (it accepts variations)
  34215. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34216. * @returns {Array} placements including their variations
  34217. */
  34218. function clockwise(placement) {
  34219. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34220. var index = validPlacements.indexOf(placement);
  34221. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34222. return counter ? arr.reverse() : arr;
  34223. }
  34224. var BEHAVIORS = {
  34225. FLIP: 'flip',
  34226. CLOCKWISE: 'clockwise',
  34227. COUNTERCLOCKWISE: 'counterclockwise'
  34228. };
  34229. /**
  34230. * @function
  34231. * @memberof Modifiers
  34232. * @argument {Object} data - The data object generated by update method
  34233. * @argument {Object} options - Modifiers configuration and options
  34234. * @returns {Object} The data object, properly modified
  34235. */
  34236. function flip(data, options) {
  34237. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34238. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34239. return data;
  34240. }
  34241. if (data.flipped && data.placement === data.originalPlacement) {
  34242. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34243. return data;
  34244. }
  34245. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34246. var placement = data.placement.split('-')[0];
  34247. var placementOpposite = getOppositePlacement(placement);
  34248. var variation = data.placement.split('-')[1] || '';
  34249. var flipOrder = [];
  34250. switch (options.behavior) {
  34251. case BEHAVIORS.FLIP:
  34252. flipOrder = [placement, placementOpposite];
  34253. break;
  34254. case BEHAVIORS.CLOCKWISE:
  34255. flipOrder = clockwise(placement);
  34256. break;
  34257. case BEHAVIORS.COUNTERCLOCKWISE:
  34258. flipOrder = clockwise(placement, true);
  34259. break;
  34260. default:
  34261. flipOrder = options.behavior;
  34262. }
  34263. flipOrder.forEach(function (step, index) {
  34264. if (placement !== step || flipOrder.length === index + 1) {
  34265. return data;
  34266. }
  34267. placement = data.placement.split('-')[0];
  34268. placementOpposite = getOppositePlacement(placement);
  34269. var popperOffsets = data.offsets.popper;
  34270. var refOffsets = data.offsets.reference;
  34271. // using floor because the reference offsets may contain decimals we are not going to consider here
  34272. var floor = Math.floor;
  34273. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  34274. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34275. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34276. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34277. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34278. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34279. // flip the variation if required
  34280. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34281. // flips variation if reference element overflows boundaries
  34282. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34283. // flips variation if popper content overflows boundaries
  34284. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34285. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34286. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34287. // this boolean to detect any flip loop
  34288. data.flipped = true;
  34289. if (overlapsRef || overflowsBoundaries) {
  34290. placement = flipOrder[index + 1];
  34291. }
  34292. if (flippedVariation) {
  34293. variation = getOppositeVariation(variation);
  34294. }
  34295. data.placement = placement + (variation ? '-' + variation : '');
  34296. // this object contains `position`, we want to preserve it along with
  34297. // any additional property we may add in the future
  34298. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34299. data = runModifiers(data.instance.modifiers, data, 'flip');
  34300. }
  34301. });
  34302. return data;
  34303. }
  34304. /**
  34305. * @function
  34306. * @memberof Modifiers
  34307. * @argument {Object} data - The data object generated by update method
  34308. * @argument {Object} options - Modifiers configuration and options
  34309. * @returns {Object} The data object, properly modified
  34310. */
  34311. function keepTogether(data) {
  34312. var _data$offsets = data.offsets,
  34313. popper = _data$offsets.popper,
  34314. reference = _data$offsets.reference;
  34315. var placement = data.placement.split('-')[0];
  34316. var floor = Math.floor;
  34317. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34318. var side = isVertical ? 'right' : 'bottom';
  34319. var opSide = isVertical ? 'left' : 'top';
  34320. var measurement = isVertical ? 'width' : 'height';
  34321. if (popper[side] < floor(reference[opSide])) {
  34322. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34323. }
  34324. if (popper[opSide] > floor(reference[side])) {
  34325. data.offsets.popper[opSide] = floor(reference[side]);
  34326. }
  34327. return data;
  34328. }
  34329. /**
  34330. * Converts a string containing value + unit into a px value number
  34331. * @function
  34332. * @memberof {modifiers~offset}
  34333. * @private
  34334. * @argument {String} str - Value + unit string
  34335. * @argument {String} measurement - `height` or `width`
  34336. * @argument {Object} popperOffsets
  34337. * @argument {Object} referenceOffsets
  34338. * @returns {Number|String}
  34339. * Value in pixels, or original string if no values were extracted
  34340. */
  34341. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34342. // separate value from unit
  34343. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34344. var value = +split[1];
  34345. var unit = split[2];
  34346. // If it's not a number it's an operator, I guess
  34347. if (!value) {
  34348. return str;
  34349. }
  34350. if (unit.indexOf('%') === 0) {
  34351. var element = void 0;
  34352. switch (unit) {
  34353. case '%p':
  34354. element = popperOffsets;
  34355. break;
  34356. case '%':
  34357. case '%r':
  34358. default:
  34359. element = referenceOffsets;
  34360. }
  34361. var rect = getClientRect(element);
  34362. return rect[measurement] / 100 * value;
  34363. } else if (unit === 'vh' || unit === 'vw') {
  34364. // if is a vh or vw, we calculate the size based on the viewport
  34365. var size = void 0;
  34366. if (unit === 'vh') {
  34367. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34368. } else {
  34369. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34370. }
  34371. return size / 100 * value;
  34372. } else {
  34373. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34374. // if is an implicit unit, it's px, and we return just the value
  34375. return value;
  34376. }
  34377. }
  34378. /**
  34379. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34380. * @function
  34381. * @memberof {modifiers~offset}
  34382. * @private
  34383. * @argument {String} offset
  34384. * @argument {Object} popperOffsets
  34385. * @argument {Object} referenceOffsets
  34386. * @argument {String} basePlacement
  34387. * @returns {Array} a two cells array with x and y offsets in numbers
  34388. */
  34389. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34390. var offsets = [0, 0];
  34391. // Use height if placement is left or right and index is 0 otherwise use width
  34392. // in this way the first offset will use an axis and the second one
  34393. // will use the other one
  34394. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34395. // Split the offset string to obtain a list of values and operands
  34396. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34397. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34398. return frag.trim();
  34399. });
  34400. // Detect if the offset string contains a pair of values or a single one
  34401. // they could be separated by comma or space
  34402. var divider = fragments.indexOf(find(fragments, function (frag) {
  34403. return frag.search(/,|\s/) !== -1;
  34404. }));
  34405. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34406. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34407. }
  34408. // If divider is found, we divide the list of values and operands to divide
  34409. // them by ofset X and Y.
  34410. var splitRegex = /\s*,\s*|\s+/;
  34411. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  34412. // Convert the values with units to absolute pixels to allow our computations
  34413. ops = ops.map(function (op, index) {
  34414. // Most of the units rely on the orientation of the popper
  34415. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34416. var mergeWithPrevious = false;
  34417. return op
  34418. // This aggregates any `+` or `-` sign that aren't considered operators
  34419. // e.g.: 10 + +5 => [10, +, +5]
  34420. .reduce(function (a, b) {
  34421. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34422. a[a.length - 1] = b;
  34423. mergeWithPrevious = true;
  34424. return a;
  34425. } else if (mergeWithPrevious) {
  34426. a[a.length - 1] += b;
  34427. mergeWithPrevious = false;
  34428. return a;
  34429. } else {
  34430. return a.concat(b);
  34431. }
  34432. }, [])
  34433. // Here we convert the string values into number values (in px)
  34434. .map(function (str) {
  34435. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34436. });
  34437. });
  34438. // Loop trough the offsets arrays and execute the operations
  34439. ops.forEach(function (op, index) {
  34440. op.forEach(function (frag, index2) {
  34441. if (isNumeric(frag)) {
  34442. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34443. }
  34444. });
  34445. });
  34446. return offsets;
  34447. }
  34448. /**
  34449. * @function
  34450. * @memberof Modifiers
  34451. * @argument {Object} data - The data object generated by update method
  34452. * @argument {Object} options - Modifiers configuration and options
  34453. * @argument {Number|String} options.offset=0
  34454. * The offset value as described in the modifier description
  34455. * @returns {Object} The data object, properly modified
  34456. */
  34457. function offset(data, _ref) {
  34458. var offset = _ref.offset;
  34459. var placement = data.placement,
  34460. _data$offsets = data.offsets,
  34461. popper = _data$offsets.popper,
  34462. reference = _data$offsets.reference;
  34463. var basePlacement = placement.split('-')[0];
  34464. var offsets = void 0;
  34465. if (isNumeric(+offset)) {
  34466. offsets = [+offset, 0];
  34467. } else {
  34468. offsets = parseOffset(offset, popper, reference, basePlacement);
  34469. }
  34470. if (basePlacement === 'left') {
  34471. popper.top += offsets[0];
  34472. popper.left -= offsets[1];
  34473. } else if (basePlacement === 'right') {
  34474. popper.top += offsets[0];
  34475. popper.left += offsets[1];
  34476. } else if (basePlacement === 'top') {
  34477. popper.left += offsets[0];
  34478. popper.top -= offsets[1];
  34479. } else if (basePlacement === 'bottom') {
  34480. popper.left += offsets[0];
  34481. popper.top += offsets[1];
  34482. }
  34483. data.popper = popper;
  34484. return data;
  34485. }
  34486. /**
  34487. * @function
  34488. * @memberof Modifiers
  34489. * @argument {Object} data - The data object generated by `update` method
  34490. * @argument {Object} options - Modifiers configuration and options
  34491. * @returns {Object} The data object, properly modified
  34492. */
  34493. function preventOverflow(data, options) {
  34494. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34495. // If offsetParent is the reference element, we really want to
  34496. // go one step up and use the next offsetParent as reference to
  34497. // avoid to make this modifier completely useless and look like broken
  34498. if (data.instance.reference === boundariesElement) {
  34499. boundariesElement = getOffsetParent(boundariesElement);
  34500. }
  34501. // NOTE: DOM access here
  34502. // resets the popper's position so that the document size can be calculated excluding
  34503. // the size of the popper element itself
  34504. var transformProp = getSupportedPropertyName('transform');
  34505. var popperStyles = data.instance.popper.style; // assignment to help minification
  34506. var top = popperStyles.top,
  34507. left = popperStyles.left,
  34508. transform = popperStyles[transformProp];
  34509. popperStyles.top = '';
  34510. popperStyles.left = '';
  34511. popperStyles[transformProp] = '';
  34512. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34513. // NOTE: DOM access here
  34514. // restores the original style properties after the offsets have been computed
  34515. popperStyles.top = top;
  34516. popperStyles.left = left;
  34517. popperStyles[transformProp] = transform;
  34518. options.boundaries = boundaries;
  34519. var order = options.priority;
  34520. var popper = data.offsets.popper;
  34521. var check = {
  34522. primary: function primary(placement) {
  34523. var value = popper[placement];
  34524. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34525. value = Math.max(popper[placement], boundaries[placement]);
  34526. }
  34527. return defineProperty({}, placement, value);
  34528. },
  34529. secondary: function secondary(placement) {
  34530. var mainSide = placement === 'right' ? 'left' : 'top';
  34531. var value = popper[mainSide];
  34532. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34533. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34534. }
  34535. return defineProperty({}, mainSide, value);
  34536. }
  34537. };
  34538. order.forEach(function (placement) {
  34539. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34540. popper = _extends({}, popper, check[side](placement));
  34541. });
  34542. data.offsets.popper = popper;
  34543. return data;
  34544. }
  34545. /**
  34546. * @function
  34547. * @memberof Modifiers
  34548. * @argument {Object} data - The data object generated by `update` method
  34549. * @argument {Object} options - Modifiers configuration and options
  34550. * @returns {Object} The data object, properly modified
  34551. */
  34552. function shift(data) {
  34553. var placement = data.placement;
  34554. var basePlacement = placement.split('-')[0];
  34555. var shiftvariation = placement.split('-')[1];
  34556. // if shift shiftvariation is specified, run the modifier
  34557. if (shiftvariation) {
  34558. var _data$offsets = data.offsets,
  34559. reference = _data$offsets.reference,
  34560. popper = _data$offsets.popper;
  34561. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34562. var side = isVertical ? 'left' : 'top';
  34563. var measurement = isVertical ? 'width' : 'height';
  34564. var shiftOffsets = {
  34565. start: defineProperty({}, side, reference[side]),
  34566. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34567. };
  34568. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34569. }
  34570. return data;
  34571. }
  34572. /**
  34573. * @function
  34574. * @memberof Modifiers
  34575. * @argument {Object} data - The data object generated by update method
  34576. * @argument {Object} options - Modifiers configuration and options
  34577. * @returns {Object} The data object, properly modified
  34578. */
  34579. function hide(data) {
  34580. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34581. return data;
  34582. }
  34583. var refRect = data.offsets.reference;
  34584. var bound = find(data.instance.modifiers, function (modifier) {
  34585. return modifier.name === 'preventOverflow';
  34586. }).boundaries;
  34587. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34588. // Avoid unnecessary DOM access if visibility hasn't changed
  34589. if (data.hide === true) {
  34590. return data;
  34591. }
  34592. data.hide = true;
  34593. data.attributes['x-out-of-boundaries'] = '';
  34594. } else {
  34595. // Avoid unnecessary DOM access if visibility hasn't changed
  34596. if (data.hide === false) {
  34597. return data;
  34598. }
  34599. data.hide = false;
  34600. data.attributes['x-out-of-boundaries'] = false;
  34601. }
  34602. return data;
  34603. }
  34604. /**
  34605. * @function
  34606. * @memberof Modifiers
  34607. * @argument {Object} data - The data object generated by `update` method
  34608. * @argument {Object} options - Modifiers configuration and options
  34609. * @returns {Object} The data object, properly modified
  34610. */
  34611. function inner(data) {
  34612. var placement = data.placement;
  34613. var basePlacement = placement.split('-')[0];
  34614. var _data$offsets = data.offsets,
  34615. popper = _data$offsets.popper,
  34616. reference = _data$offsets.reference;
  34617. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34618. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34619. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34620. data.placement = getOppositePlacement(placement);
  34621. data.offsets.popper = getClientRect(popper);
  34622. return data;
  34623. }
  34624. /**
  34625. * Modifier function, each modifier can have a function of this type assigned
  34626. * to its `fn` property.<br />
  34627. * These functions will be called on each update, this means that you must
  34628. * make sure they are performant enough to avoid performance bottlenecks.
  34629. *
  34630. * @function ModifierFn
  34631. * @argument {dataObject} data - The data object generated by `update` method
  34632. * @argument {Object} options - Modifiers configuration and options
  34633. * @returns {dataObject} The data object, properly modified
  34634. */
  34635. /**
  34636. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34637. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34638. * needed by the library.
  34639. *
  34640. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34641. * All the other properties are configurations that could be tweaked.
  34642. * @namespace modifiers
  34643. */
  34644. var modifiers = {
  34645. /**
  34646. * Modifier used to shift the popper on the start or end of its reference
  34647. * element.<br />
  34648. * It will read the variation of the `placement` property.<br />
  34649. * It can be one either `-end` or `-start`.
  34650. * @memberof modifiers
  34651. * @inner
  34652. */
  34653. shift: {
  34654. /** @prop {number} order=100 - Index used to define the order of execution */
  34655. order: 100,
  34656. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34657. enabled: true,
  34658. /** @prop {ModifierFn} */
  34659. fn: shift
  34660. },
  34661. /**
  34662. * The `offset` modifier can shift your popper on both its axis.
  34663. *
  34664. * It accepts the following units:
  34665. * - `px` or unit-less, interpreted as pixels
  34666. * - `%` or `%r`, percentage relative to the length of the reference element
  34667. * - `%p`, percentage relative to the length of the popper element
  34668. * - `vw`, CSS viewport width unit
  34669. * - `vh`, CSS viewport height unit
  34670. *
  34671. * For length is intended the main axis relative to the placement of the popper.<br />
  34672. * This means that if the placement is `top` or `bottom`, the length will be the
  34673. * `width`. In case of `left` or `right`, it will be the `height`.
  34674. *
  34675. * You can provide a single value (as `Number` or `String`), or a pair of values
  34676. * as `String` divided by a comma or one (or more) white spaces.<br />
  34677. * The latter is a deprecated method because it leads to confusion and will be
  34678. * removed in v2.<br />
  34679. * Additionally, it accepts additions and subtractions between different units.
  34680. * Note that multiplications and divisions aren't supported.
  34681. *
  34682. * Valid examples are:
  34683. * ```
  34684. * 10
  34685. * '10%'
  34686. * '10, 10'
  34687. * '10%, 10'
  34688. * '10 + 10%'
  34689. * '10 - 5vh + 3%'
  34690. * '-10px + 5vh, 5px - 6%'
  34691. * ```
  34692. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34693. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34694. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34695. *
  34696. * @memberof modifiers
  34697. * @inner
  34698. */
  34699. offset: {
  34700. /** @prop {number} order=200 - Index used to define the order of execution */
  34701. order: 200,
  34702. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34703. enabled: true,
  34704. /** @prop {ModifierFn} */
  34705. fn: offset,
  34706. /** @prop {Number|String} offset=0
  34707. * The offset value as described in the modifier description
  34708. */
  34709. offset: 0
  34710. },
  34711. /**
  34712. * Modifier used to prevent the popper from being positioned outside the boundary.
  34713. *
  34714. * A scenario exists where the reference itself is not within the boundaries.<br />
  34715. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34716. * In this case we need to decide whether the popper should either:
  34717. *
  34718. * - detach from the reference and remain "trapped" in the boundaries, or
  34719. * - if it should ignore the boundary and "escape with its reference"
  34720. *
  34721. * When `escapeWithReference` is set to`true` and reference is completely
  34722. * outside its boundaries, the popper will overflow (or completely leave)
  34723. * the boundaries in order to remain attached to the edge of the reference.
  34724. *
  34725. * @memberof modifiers
  34726. * @inner
  34727. */
  34728. preventOverflow: {
  34729. /** @prop {number} order=300 - Index used to define the order of execution */
  34730. order: 300,
  34731. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34732. enabled: true,
  34733. /** @prop {ModifierFn} */
  34734. fn: preventOverflow,
  34735. /**
  34736. * @prop {Array} [priority=['left','right','top','bottom']]
  34737. * Popper will try to prevent overflow following these priorities by default,
  34738. * then, it could overflow on the left and on top of the `boundariesElement`
  34739. */
  34740. priority: ['left', 'right', 'top', 'bottom'],
  34741. /**
  34742. * @prop {number} padding=5
  34743. * Amount of pixel used to define a minimum distance between the boundaries
  34744. * and the popper. This makes sure the popper always has a little padding
  34745. * between the edges of its container
  34746. */
  34747. padding: 5,
  34748. /**
  34749. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34750. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34751. * `viewport` or any DOM element.
  34752. */
  34753. boundariesElement: 'scrollParent'
  34754. },
  34755. /**
  34756. * Modifier used to make sure the reference and its popper stay near each other
  34757. * without leaving any gap between the two. Especially useful when the arrow is
  34758. * enabled and you want to ensure that it points to its reference element.
  34759. * It cares only about the first axis. You can still have poppers with margin
  34760. * between the popper and its reference element.
  34761. * @memberof modifiers
  34762. * @inner
  34763. */
  34764. keepTogether: {
  34765. /** @prop {number} order=400 - Index used to define the order of execution */
  34766. order: 400,
  34767. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34768. enabled: true,
  34769. /** @prop {ModifierFn} */
  34770. fn: keepTogether
  34771. },
  34772. /**
  34773. * This modifier is used to move the `arrowElement` of the popper to make
  34774. * sure it is positioned between the reference element and its popper element.
  34775. * It will read the outer size of the `arrowElement` node to detect how many
  34776. * pixels of conjunction are needed.
  34777. *
  34778. * It has no effect if no `arrowElement` is provided.
  34779. * @memberof modifiers
  34780. * @inner
  34781. */
  34782. arrow: {
  34783. /** @prop {number} order=500 - Index used to define the order of execution */
  34784. order: 500,
  34785. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34786. enabled: true,
  34787. /** @prop {ModifierFn} */
  34788. fn: arrow,
  34789. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34790. element: '[x-arrow]'
  34791. },
  34792. /**
  34793. * Modifier used to flip the popper's placement when it starts to overlap its
  34794. * reference element.
  34795. *
  34796. * Requires the `preventOverflow` modifier before it in order to work.
  34797. *
  34798. * **NOTE:** this modifier will interrupt the current update cycle and will
  34799. * restart it if it detects the need to flip the placement.
  34800. * @memberof modifiers
  34801. * @inner
  34802. */
  34803. flip: {
  34804. /** @prop {number} order=600 - Index used to define the order of execution */
  34805. order: 600,
  34806. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34807. enabled: true,
  34808. /** @prop {ModifierFn} */
  34809. fn: flip,
  34810. /**
  34811. * @prop {String|Array} behavior='flip'
  34812. * The behavior used to change the popper's placement. It can be one of
  34813. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34814. * placements (with optional variations)
  34815. */
  34816. behavior: 'flip',
  34817. /**
  34818. * @prop {number} padding=5
  34819. * The popper will flip if it hits the edges of the `boundariesElement`
  34820. */
  34821. padding: 5,
  34822. /**
  34823. * @prop {String|HTMLElement} boundariesElement='viewport'
  34824. * The element which will define the boundaries of the popper position.
  34825. * The popper will never be placed outside of the defined boundaries
  34826. * (except if `keepTogether` is enabled)
  34827. */
  34828. boundariesElement: 'viewport',
  34829. /**
  34830. * @prop {Boolean} flipVariations=false
  34831. * The popper will switch placement variation between `-start` and `-end` when
  34832. * the reference element overlaps its boundaries.
  34833. *
  34834. * The original placement should have a set variation.
  34835. */
  34836. flipVariations: false,
  34837. /**
  34838. * @prop {Boolean} flipVariationsByContent=false
  34839. * The popper will switch placement variation between `-start` and `-end` when
  34840. * the popper element overlaps its reference boundaries.
  34841. *
  34842. * The original placement should have a set variation.
  34843. */
  34844. flipVariationsByContent: false
  34845. },
  34846. /**
  34847. * Modifier used to make the popper flow toward the inner of the reference element.
  34848. * By default, when this modifier is disabled, the popper will be placed outside
  34849. * the reference element.
  34850. * @memberof modifiers
  34851. * @inner
  34852. */
  34853. inner: {
  34854. /** @prop {number} order=700 - Index used to define the order of execution */
  34855. order: 700,
  34856. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34857. enabled: false,
  34858. /** @prop {ModifierFn} */
  34859. fn: inner
  34860. },
  34861. /**
  34862. * Modifier used to hide the popper when its reference element is outside of the
  34863. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34864. * be used to hide with a CSS selector the popper when its reference is
  34865. * out of boundaries.
  34866. *
  34867. * Requires the `preventOverflow` modifier before it in order to work.
  34868. * @memberof modifiers
  34869. * @inner
  34870. */
  34871. hide: {
  34872. /** @prop {number} order=800 - Index used to define the order of execution */
  34873. order: 800,
  34874. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34875. enabled: true,
  34876. /** @prop {ModifierFn} */
  34877. fn: hide
  34878. },
  34879. /**
  34880. * Computes the style that will be applied to the popper element to gets
  34881. * properly positioned.
  34882. *
  34883. * Note that this modifier will not touch the DOM, it just prepares the styles
  34884. * so that `applyStyle` modifier can apply it. This separation is useful
  34885. * in case you need to replace `applyStyle` with a custom implementation.
  34886. *
  34887. * This modifier has `850` as `order` value to maintain backward compatibility
  34888. * with previous versions of Popper.js. Expect the modifiers ordering method
  34889. * to change in future major versions of the library.
  34890. *
  34891. * @memberof modifiers
  34892. * @inner
  34893. */
  34894. computeStyle: {
  34895. /** @prop {number} order=850 - Index used to define the order of execution */
  34896. order: 850,
  34897. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34898. enabled: true,
  34899. /** @prop {ModifierFn} */
  34900. fn: computeStyle,
  34901. /**
  34902. * @prop {Boolean} gpuAcceleration=true
  34903. * If true, it uses the CSS 3D transformation to position the popper.
  34904. * Otherwise, it will use the `top` and `left` properties
  34905. */
  34906. gpuAcceleration: true,
  34907. /**
  34908. * @prop {string} [x='bottom']
  34909. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34910. * Change this if your popper should grow in a direction different from `bottom`
  34911. */
  34912. x: 'bottom',
  34913. /**
  34914. * @prop {string} [x='left']
  34915. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34916. * Change this if your popper should grow in a direction different from `right`
  34917. */
  34918. y: 'right'
  34919. },
  34920. /**
  34921. * Applies the computed styles to the popper element.
  34922. *
  34923. * All the DOM manipulations are limited to this modifier. This is useful in case
  34924. * you want to integrate Popper.js inside a framework or view library and you
  34925. * want to delegate all the DOM manipulations to it.
  34926. *
  34927. * Note that if you disable this modifier, you must make sure the popper element
  34928. * has its position set to `absolute` before Popper.js can do its work!
  34929. *
  34930. * Just disable this modifier and define your own to achieve the desired effect.
  34931. *
  34932. * @memberof modifiers
  34933. * @inner
  34934. */
  34935. applyStyle: {
  34936. /** @prop {number} order=900 - Index used to define the order of execution */
  34937. order: 900,
  34938. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34939. enabled: true,
  34940. /** @prop {ModifierFn} */
  34941. fn: applyStyle,
  34942. /** @prop {Function} */
  34943. onLoad: applyStyleOnLoad,
  34944. /**
  34945. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34946. * @prop {Boolean} gpuAcceleration=true
  34947. * If true, it uses the CSS 3D transformation to position the popper.
  34948. * Otherwise, it will use the `top` and `left` properties
  34949. */
  34950. gpuAcceleration: undefined
  34951. }
  34952. };
  34953. /**
  34954. * The `dataObject` is an object containing all the information used by Popper.js.
  34955. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34956. * @name dataObject
  34957. * @property {Object} data.instance The Popper.js instance
  34958. * @property {String} data.placement Placement applied to popper
  34959. * @property {String} data.originalPlacement Placement originally defined on init
  34960. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34961. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  34962. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  34963. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34964. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34965. * @property {Object} data.boundaries Offsets of the popper boundaries
  34966. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  34967. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  34968. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  34969. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  34970. */
  34971. /**
  34972. * Default options provided to Popper.js constructor.<br />
  34973. * These can be overridden using the `options` argument of Popper.js.<br />
  34974. * To override an option, simply pass an object with the same
  34975. * structure of the `options` object, as the 3rd argument. For example:
  34976. * ```
  34977. * new Popper(ref, pop, {
  34978. * modifiers: {
  34979. * preventOverflow: { enabled: false }
  34980. * }
  34981. * })
  34982. * ```
  34983. * @type {Object}
  34984. * @static
  34985. * @memberof Popper
  34986. */
  34987. var Defaults = {
  34988. /**
  34989. * Popper's placement.
  34990. * @prop {Popper.placements} placement='bottom'
  34991. */
  34992. placement: 'bottom',
  34993. /**
  34994. * Set this to true if you want popper to position it self in 'fixed' mode
  34995. * @prop {Boolean} positionFixed=false
  34996. */
  34997. positionFixed: false,
  34998. /**
  34999. * Whether events (resize, scroll) are initially enabled.
  35000. * @prop {Boolean} eventsEnabled=true
  35001. */
  35002. eventsEnabled: true,
  35003. /**
  35004. * Set to true if you want to automatically remove the popper when
  35005. * you call the `destroy` method.
  35006. * @prop {Boolean} removeOnDestroy=false
  35007. */
  35008. removeOnDestroy: false,
  35009. /**
  35010. * Callback called when the popper is created.<br />
  35011. * By default, it is set to no-op.<br />
  35012. * Access Popper.js instance with `data.instance`.
  35013. * @prop {onCreate}
  35014. */
  35015. onCreate: function onCreate() {},
  35016. /**
  35017. * Callback called when the popper is updated. This callback is not called
  35018. * on the initialization/creation of the popper, but only on subsequent
  35019. * updates.<br />
  35020. * By default, it is set to no-op.<br />
  35021. * Access Popper.js instance with `data.instance`.
  35022. * @prop {onUpdate}
  35023. */
  35024. onUpdate: function onUpdate() {},
  35025. /**
  35026. * List of modifiers used to modify the offsets before they are applied to the popper.
  35027. * They provide most of the functionalities of Popper.js.
  35028. * @prop {modifiers}
  35029. */
  35030. modifiers: modifiers
  35031. };
  35032. /**
  35033. * @callback onCreate
  35034. * @param {dataObject} data
  35035. */
  35036. /**
  35037. * @callback onUpdate
  35038. * @param {dataObject} data
  35039. */
  35040. // Utils
  35041. // Methods
  35042. var Popper = function () {
  35043. /**
  35044. * Creates a new Popper.js instance.
  35045. * @class Popper
  35046. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35047. * @param {Element} popper - The HTML / XML element used as the popper
  35048. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35049. * @return {Object} instance - The generated Popper.js instance
  35050. */
  35051. function Popper(reference, popper) {
  35052. var _this = this;
  35053. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35054. classCallCheck(this, Popper);
  35055. this.scheduleUpdate = function () {
  35056. return requestAnimationFrame(_this.update);
  35057. };
  35058. // make update() debounced, so that it only runs at most once-per-tick
  35059. this.update = debounce(this.update.bind(this));
  35060. // with {} we create a new object with the options inside it
  35061. this.options = _extends({}, Popper.Defaults, options);
  35062. // init state
  35063. this.state = {
  35064. isDestroyed: false,
  35065. isCreated: false,
  35066. scrollParents: []
  35067. };
  35068. // get reference and popper elements (allow jQuery wrappers)
  35069. this.reference = reference && reference.jquery ? reference[0] : reference;
  35070. this.popper = popper && popper.jquery ? popper[0] : popper;
  35071. // Deep merge modifiers options
  35072. this.options.modifiers = {};
  35073. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35074. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35075. });
  35076. // Refactoring modifiers' list (Object => Array)
  35077. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35078. return _extends({
  35079. name: name
  35080. }, _this.options.modifiers[name]);
  35081. })
  35082. // sort the modifiers by order
  35083. .sort(function (a, b) {
  35084. return a.order - b.order;
  35085. });
  35086. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35087. // such code is executed in the same order of its modifier
  35088. // they could add new properties to their options configuration
  35089. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35090. this.modifiers.forEach(function (modifierOptions) {
  35091. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35092. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35093. }
  35094. });
  35095. // fire the first update to position the popper in the right place
  35096. this.update();
  35097. var eventsEnabled = this.options.eventsEnabled;
  35098. if (eventsEnabled) {
  35099. // setup event listeners, they will take care of update the position in specific situations
  35100. this.enableEventListeners();
  35101. }
  35102. this.state.eventsEnabled = eventsEnabled;
  35103. }
  35104. // We can't use class properties because they don't get listed in the
  35105. // class prototype and break stuff like Sinon stubs
  35106. createClass(Popper, [{
  35107. key: 'update',
  35108. value: function update$$1() {
  35109. return update.call(this);
  35110. }
  35111. }, {
  35112. key: 'destroy',
  35113. value: function destroy$$1() {
  35114. return destroy.call(this);
  35115. }
  35116. }, {
  35117. key: 'enableEventListeners',
  35118. value: function enableEventListeners$$1() {
  35119. return enableEventListeners.call(this);
  35120. }
  35121. }, {
  35122. key: 'disableEventListeners',
  35123. value: function disableEventListeners$$1() {
  35124. return disableEventListeners.call(this);
  35125. }
  35126. /**
  35127. * Schedules an update. It will run on the next UI update available.
  35128. * @method scheduleUpdate
  35129. * @memberof Popper
  35130. */
  35131. /**
  35132. * Collection of utilities useful when writing custom modifiers.
  35133. * Starting from version 1.7, this method is available only if you
  35134. * include `popper-utils.js` before `popper.js`.
  35135. *
  35136. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35137. * and will be removed in v2! Use the PopperUtils module directly instead.
  35138. * Due to the high instability of the methods contained in Utils, we can't
  35139. * guarantee them to follow semver. Use them at your own risk!
  35140. * @static
  35141. * @private
  35142. * @type {Object}
  35143. * @deprecated since version 1.8
  35144. * @member Utils
  35145. * @memberof Popper
  35146. */
  35147. }]);
  35148. return Popper;
  35149. }();
  35150. /**
  35151. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35152. * and lets you use it as replacement of a real DOM node.<br />
  35153. * You can use this method to position a popper relatively to a set of coordinates
  35154. * in case you don't have a DOM node to use as reference.
  35155. *
  35156. * ```
  35157. * new Popper(referenceObject, popperNode);
  35158. * ```
  35159. *
  35160. * NB: This feature isn't supported in Internet Explorer 10.
  35161. * @name referenceObject
  35162. * @property {Function} data.getBoundingClientRect
  35163. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35164. * @property {number} data.clientWidth
  35165. * An ES6 getter that will return the width of the virtual reference element.
  35166. * @property {number} data.clientHeight
  35167. * An ES6 getter that will return the height of the virtual reference element.
  35168. */
  35169. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35170. Popper.placements = placements;
  35171. Popper.Defaults = Defaults;
  35172. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35173. //# sourceMappingURL=popper.js.map
  35174. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35175. /***/ }),
  35176. /***/ "./node_modules/process/browser.js":
  35177. /*!*****************************************!*\
  35178. !*** ./node_modules/process/browser.js ***!
  35179. \*****************************************/
  35180. /*! no static exports found */
  35181. /***/ (function(module, exports) {
  35182. // shim for using process in browser
  35183. var process = module.exports = {};
  35184. // cached from whatever global is present so that test runners that stub it
  35185. // don't break things. But we need to wrap it in a try catch in case it is
  35186. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35187. // function because try/catches deoptimize in certain engines.
  35188. var cachedSetTimeout;
  35189. var cachedClearTimeout;
  35190. function defaultSetTimout() {
  35191. throw new Error('setTimeout has not been defined');
  35192. }
  35193. function defaultClearTimeout () {
  35194. throw new Error('clearTimeout has not been defined');
  35195. }
  35196. (function () {
  35197. try {
  35198. if (typeof setTimeout === 'function') {
  35199. cachedSetTimeout = setTimeout;
  35200. } else {
  35201. cachedSetTimeout = defaultSetTimout;
  35202. }
  35203. } catch (e) {
  35204. cachedSetTimeout = defaultSetTimout;
  35205. }
  35206. try {
  35207. if (typeof clearTimeout === 'function') {
  35208. cachedClearTimeout = clearTimeout;
  35209. } else {
  35210. cachedClearTimeout = defaultClearTimeout;
  35211. }
  35212. } catch (e) {
  35213. cachedClearTimeout = defaultClearTimeout;
  35214. }
  35215. } ())
  35216. function runTimeout(fun) {
  35217. if (cachedSetTimeout === setTimeout) {
  35218. //normal enviroments in sane situations
  35219. return setTimeout(fun, 0);
  35220. }
  35221. // if setTimeout wasn't available but was latter defined
  35222. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35223. cachedSetTimeout = setTimeout;
  35224. return setTimeout(fun, 0);
  35225. }
  35226. try {
  35227. // when when somebody has screwed with setTimeout but no I.E. maddness
  35228. return cachedSetTimeout(fun, 0);
  35229. } catch(e){
  35230. try {
  35231. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35232. return cachedSetTimeout.call(null, fun, 0);
  35233. } catch(e){
  35234. // 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
  35235. return cachedSetTimeout.call(this, fun, 0);
  35236. }
  35237. }
  35238. }
  35239. function runClearTimeout(marker) {
  35240. if (cachedClearTimeout === clearTimeout) {
  35241. //normal enviroments in sane situations
  35242. return clearTimeout(marker);
  35243. }
  35244. // if clearTimeout wasn't available but was latter defined
  35245. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35246. cachedClearTimeout = clearTimeout;
  35247. return clearTimeout(marker);
  35248. }
  35249. try {
  35250. // when when somebody has screwed with setTimeout but no I.E. maddness
  35251. return cachedClearTimeout(marker);
  35252. } catch (e){
  35253. try {
  35254. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35255. return cachedClearTimeout.call(null, marker);
  35256. } catch (e){
  35257. // 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.
  35258. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35259. return cachedClearTimeout.call(this, marker);
  35260. }
  35261. }
  35262. }
  35263. var queue = [];
  35264. var draining = false;
  35265. var currentQueue;
  35266. var queueIndex = -1;
  35267. function cleanUpNextTick() {
  35268. if (!draining || !currentQueue) {
  35269. return;
  35270. }
  35271. draining = false;
  35272. if (currentQueue.length) {
  35273. queue = currentQueue.concat(queue);
  35274. } else {
  35275. queueIndex = -1;
  35276. }
  35277. if (queue.length) {
  35278. drainQueue();
  35279. }
  35280. }
  35281. function drainQueue() {
  35282. if (draining) {
  35283. return;
  35284. }
  35285. var timeout = runTimeout(cleanUpNextTick);
  35286. draining = true;
  35287. var len = queue.length;
  35288. while(len) {
  35289. currentQueue = queue;
  35290. queue = [];
  35291. while (++queueIndex < len) {
  35292. if (currentQueue) {
  35293. currentQueue[queueIndex].run();
  35294. }
  35295. }
  35296. queueIndex = -1;
  35297. len = queue.length;
  35298. }
  35299. currentQueue = null;
  35300. draining = false;
  35301. runClearTimeout(timeout);
  35302. }
  35303. process.nextTick = function (fun) {
  35304. var args = new Array(arguments.length - 1);
  35305. if (arguments.length > 1) {
  35306. for (var i = 1; i < arguments.length; i++) {
  35307. args[i - 1] = arguments[i];
  35308. }
  35309. }
  35310. queue.push(new Item(fun, args));
  35311. if (queue.length === 1 && !draining) {
  35312. runTimeout(drainQueue);
  35313. }
  35314. };
  35315. // v8 likes predictible objects
  35316. function Item(fun, array) {
  35317. this.fun = fun;
  35318. this.array = array;
  35319. }
  35320. Item.prototype.run = function () {
  35321. this.fun.apply(null, this.array);
  35322. };
  35323. process.title = 'browser';
  35324. process.browser = true;
  35325. process.env = {};
  35326. process.argv = [];
  35327. process.version = ''; // empty string to avoid regexp issues
  35328. process.versions = {};
  35329. function noop() {}
  35330. process.on = noop;
  35331. process.addListener = noop;
  35332. process.once = noop;
  35333. process.off = noop;
  35334. process.removeListener = noop;
  35335. process.removeAllListeners = noop;
  35336. process.emit = noop;
  35337. process.prependListener = noop;
  35338. process.prependOnceListener = noop;
  35339. process.listeners = function (name) { return [] }
  35340. process.binding = function (name) {
  35341. throw new Error('process.binding is not supported');
  35342. };
  35343. process.cwd = function () { return '/' };
  35344. process.chdir = function (dir) {
  35345. throw new Error('process.chdir is not supported');
  35346. };
  35347. process.umask = function() { return 0; };
  35348. /***/ }),
  35349. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35350. /*!***************************************************!*\
  35351. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35352. \***************************************************/
  35353. /*! no static exports found */
  35354. /***/ (function(module, exports, __webpack_require__) {
  35355. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35356. * Pusher JavaScript Library v5.0.3
  35357. * https://pusher.com/
  35358. *
  35359. * Copyright 2017, Pusher
  35360. * Released under the MIT licence.
  35361. */
  35362. (function webpackUniversalModuleDefinition(root, factory) {
  35363. if(true)
  35364. module.exports = factory();
  35365. else {}
  35366. })(window, function() {
  35367. return /******/ (function(modules) { // webpackBootstrap
  35368. /******/ // The module cache
  35369. /******/ var installedModules = {};
  35370. /******/
  35371. /******/ // The require function
  35372. /******/ function __webpack_require__(moduleId) {
  35373. /******/
  35374. /******/ // Check if module is in cache
  35375. /******/ if(installedModules[moduleId]) {
  35376. /******/ return installedModules[moduleId].exports;
  35377. /******/ }
  35378. /******/ // Create a new module (and put it into the cache)
  35379. /******/ var module = installedModules[moduleId] = {
  35380. /******/ i: moduleId,
  35381. /******/ l: false,
  35382. /******/ exports: {}
  35383. /******/ };
  35384. /******/
  35385. /******/ // Execute the module function
  35386. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35387. /******/
  35388. /******/ // Flag the module as loaded
  35389. /******/ module.l = true;
  35390. /******/
  35391. /******/ // Return the exports of the module
  35392. /******/ return module.exports;
  35393. /******/ }
  35394. /******/
  35395. /******/
  35396. /******/ // expose the modules object (__webpack_modules__)
  35397. /******/ __webpack_require__.m = modules;
  35398. /******/
  35399. /******/ // expose the module cache
  35400. /******/ __webpack_require__.c = installedModules;
  35401. /******/
  35402. /******/ // define getter function for harmony exports
  35403. /******/ __webpack_require__.d = function(exports, name, getter) {
  35404. /******/ if(!__webpack_require__.o(exports, name)) {
  35405. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35406. /******/ }
  35407. /******/ };
  35408. /******/
  35409. /******/ // define __esModule on exports
  35410. /******/ __webpack_require__.r = function(exports) {
  35411. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35412. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35413. /******/ }
  35414. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35415. /******/ };
  35416. /******/
  35417. /******/ // create a fake namespace object
  35418. /******/ // mode & 1: value is a module id, require it
  35419. /******/ // mode & 2: merge all properties of value into the ns
  35420. /******/ // mode & 4: return value when already ns object
  35421. /******/ // mode & 8|1: behave like require
  35422. /******/ __webpack_require__.t = function(value, mode) {
  35423. /******/ if(mode & 1) value = __webpack_require__(value);
  35424. /******/ if(mode & 8) return value;
  35425. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35426. /******/ var ns = Object.create(null);
  35427. /******/ __webpack_require__.r(ns);
  35428. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35429. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35430. /******/ return ns;
  35431. /******/ };
  35432. /******/
  35433. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35434. /******/ __webpack_require__.n = function(module) {
  35435. /******/ var getter = module && module.__esModule ?
  35436. /******/ function getDefault() { return module['default']; } :
  35437. /******/ function getModuleExports() { return module; };
  35438. /******/ __webpack_require__.d(getter, 'a', getter);
  35439. /******/ return getter;
  35440. /******/ };
  35441. /******/
  35442. /******/ // Object.prototype.hasOwnProperty.call
  35443. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35444. /******/
  35445. /******/ // __webpack_public_path__
  35446. /******/ __webpack_require__.p = "";
  35447. /******/
  35448. /******/
  35449. /******/ // Load entry module and return exports
  35450. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35451. /******/ })
  35452. /************************************************************************/
  35453. /******/ ([
  35454. /* 0 */
  35455. /***/ (function(module, exports, __webpack_require__) {
  35456. (function(nacl) {
  35457. 'use strict';
  35458. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35459. // Public domain.
  35460. //
  35461. // Implementation derived from TweetNaCl version 20140427.
  35462. // See for details: http://tweetnacl.cr.yp.to/
  35463. var gf = function(init) {
  35464. var i, r = new Float64Array(16);
  35465. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35466. return r;
  35467. };
  35468. // Pluggable, initialized in high-level API below.
  35469. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35470. var _0 = new Uint8Array(16);
  35471. var _9 = new Uint8Array(32); _9[0] = 9;
  35472. var gf0 = gf(),
  35473. gf1 = gf([1]),
  35474. _121665 = gf([0xdb41, 1]),
  35475. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35476. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35477. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35478. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35479. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35480. function ts64(x, i, h, l) {
  35481. x[i] = (h >> 24) & 0xff;
  35482. x[i+1] = (h >> 16) & 0xff;
  35483. x[i+2] = (h >> 8) & 0xff;
  35484. x[i+3] = h & 0xff;
  35485. x[i+4] = (l >> 24) & 0xff;
  35486. x[i+5] = (l >> 16) & 0xff;
  35487. x[i+6] = (l >> 8) & 0xff;
  35488. x[i+7] = l & 0xff;
  35489. }
  35490. function vn(x, xi, y, yi, n) {
  35491. var i,d = 0;
  35492. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35493. return (1 & ((d - 1) >>> 8)) - 1;
  35494. }
  35495. function crypto_verify_16(x, xi, y, yi) {
  35496. return vn(x,xi,y,yi,16);
  35497. }
  35498. function crypto_verify_32(x, xi, y, yi) {
  35499. return vn(x,xi,y,yi,32);
  35500. }
  35501. function core_salsa20(o, p, k, c) {
  35502. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35503. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35504. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35505. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35506. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35507. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35508. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35509. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35510. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35511. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35512. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35513. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35514. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35515. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35516. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35517. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35518. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35519. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35520. x15 = j15, u;
  35521. for (var i = 0; i < 20; i += 2) {
  35522. u = x0 + x12 | 0;
  35523. x4 ^= u<<7 | u>>>(32-7);
  35524. u = x4 + x0 | 0;
  35525. x8 ^= u<<9 | u>>>(32-9);
  35526. u = x8 + x4 | 0;
  35527. x12 ^= u<<13 | u>>>(32-13);
  35528. u = x12 + x8 | 0;
  35529. x0 ^= u<<18 | u>>>(32-18);
  35530. u = x5 + x1 | 0;
  35531. x9 ^= u<<7 | u>>>(32-7);
  35532. u = x9 + x5 | 0;
  35533. x13 ^= u<<9 | u>>>(32-9);
  35534. u = x13 + x9 | 0;
  35535. x1 ^= u<<13 | u>>>(32-13);
  35536. u = x1 + x13 | 0;
  35537. x5 ^= u<<18 | u>>>(32-18);
  35538. u = x10 + x6 | 0;
  35539. x14 ^= u<<7 | u>>>(32-7);
  35540. u = x14 + x10 | 0;
  35541. x2 ^= u<<9 | u>>>(32-9);
  35542. u = x2 + x14 | 0;
  35543. x6 ^= u<<13 | u>>>(32-13);
  35544. u = x6 + x2 | 0;
  35545. x10 ^= u<<18 | u>>>(32-18);
  35546. u = x15 + x11 | 0;
  35547. x3 ^= u<<7 | u>>>(32-7);
  35548. u = x3 + x15 | 0;
  35549. x7 ^= u<<9 | u>>>(32-9);
  35550. u = x7 + x3 | 0;
  35551. x11 ^= u<<13 | u>>>(32-13);
  35552. u = x11 + x7 | 0;
  35553. x15 ^= u<<18 | u>>>(32-18);
  35554. u = x0 + x3 | 0;
  35555. x1 ^= u<<7 | u>>>(32-7);
  35556. u = x1 + x0 | 0;
  35557. x2 ^= u<<9 | u>>>(32-9);
  35558. u = x2 + x1 | 0;
  35559. x3 ^= u<<13 | u>>>(32-13);
  35560. u = x3 + x2 | 0;
  35561. x0 ^= u<<18 | u>>>(32-18);
  35562. u = x5 + x4 | 0;
  35563. x6 ^= u<<7 | u>>>(32-7);
  35564. u = x6 + x5 | 0;
  35565. x7 ^= u<<9 | u>>>(32-9);
  35566. u = x7 + x6 | 0;
  35567. x4 ^= u<<13 | u>>>(32-13);
  35568. u = x4 + x7 | 0;
  35569. x5 ^= u<<18 | u>>>(32-18);
  35570. u = x10 + x9 | 0;
  35571. x11 ^= u<<7 | u>>>(32-7);
  35572. u = x11 + x10 | 0;
  35573. x8 ^= u<<9 | u>>>(32-9);
  35574. u = x8 + x11 | 0;
  35575. x9 ^= u<<13 | u>>>(32-13);
  35576. u = x9 + x8 | 0;
  35577. x10 ^= u<<18 | u>>>(32-18);
  35578. u = x15 + x14 | 0;
  35579. x12 ^= u<<7 | u>>>(32-7);
  35580. u = x12 + x15 | 0;
  35581. x13 ^= u<<9 | u>>>(32-9);
  35582. u = x13 + x12 | 0;
  35583. x14 ^= u<<13 | u>>>(32-13);
  35584. u = x14 + x13 | 0;
  35585. x15 ^= u<<18 | u>>>(32-18);
  35586. }
  35587. x0 = x0 + j0 | 0;
  35588. x1 = x1 + j1 | 0;
  35589. x2 = x2 + j2 | 0;
  35590. x3 = x3 + j3 | 0;
  35591. x4 = x4 + j4 | 0;
  35592. x5 = x5 + j5 | 0;
  35593. x6 = x6 + j6 | 0;
  35594. x7 = x7 + j7 | 0;
  35595. x8 = x8 + j8 | 0;
  35596. x9 = x9 + j9 | 0;
  35597. x10 = x10 + j10 | 0;
  35598. x11 = x11 + j11 | 0;
  35599. x12 = x12 + j12 | 0;
  35600. x13 = x13 + j13 | 0;
  35601. x14 = x14 + j14 | 0;
  35602. x15 = x15 + j15 | 0;
  35603. o[ 0] = x0 >>> 0 & 0xff;
  35604. o[ 1] = x0 >>> 8 & 0xff;
  35605. o[ 2] = x0 >>> 16 & 0xff;
  35606. o[ 3] = x0 >>> 24 & 0xff;
  35607. o[ 4] = x1 >>> 0 & 0xff;
  35608. o[ 5] = x1 >>> 8 & 0xff;
  35609. o[ 6] = x1 >>> 16 & 0xff;
  35610. o[ 7] = x1 >>> 24 & 0xff;
  35611. o[ 8] = x2 >>> 0 & 0xff;
  35612. o[ 9] = x2 >>> 8 & 0xff;
  35613. o[10] = x2 >>> 16 & 0xff;
  35614. o[11] = x2 >>> 24 & 0xff;
  35615. o[12] = x3 >>> 0 & 0xff;
  35616. o[13] = x3 >>> 8 & 0xff;
  35617. o[14] = x3 >>> 16 & 0xff;
  35618. o[15] = x3 >>> 24 & 0xff;
  35619. o[16] = x4 >>> 0 & 0xff;
  35620. o[17] = x4 >>> 8 & 0xff;
  35621. o[18] = x4 >>> 16 & 0xff;
  35622. o[19] = x4 >>> 24 & 0xff;
  35623. o[20] = x5 >>> 0 & 0xff;
  35624. o[21] = x5 >>> 8 & 0xff;
  35625. o[22] = x5 >>> 16 & 0xff;
  35626. o[23] = x5 >>> 24 & 0xff;
  35627. o[24] = x6 >>> 0 & 0xff;
  35628. o[25] = x6 >>> 8 & 0xff;
  35629. o[26] = x6 >>> 16 & 0xff;
  35630. o[27] = x6 >>> 24 & 0xff;
  35631. o[28] = x7 >>> 0 & 0xff;
  35632. o[29] = x7 >>> 8 & 0xff;
  35633. o[30] = x7 >>> 16 & 0xff;
  35634. o[31] = x7 >>> 24 & 0xff;
  35635. o[32] = x8 >>> 0 & 0xff;
  35636. o[33] = x8 >>> 8 & 0xff;
  35637. o[34] = x8 >>> 16 & 0xff;
  35638. o[35] = x8 >>> 24 & 0xff;
  35639. o[36] = x9 >>> 0 & 0xff;
  35640. o[37] = x9 >>> 8 & 0xff;
  35641. o[38] = x9 >>> 16 & 0xff;
  35642. o[39] = x9 >>> 24 & 0xff;
  35643. o[40] = x10 >>> 0 & 0xff;
  35644. o[41] = x10 >>> 8 & 0xff;
  35645. o[42] = x10 >>> 16 & 0xff;
  35646. o[43] = x10 >>> 24 & 0xff;
  35647. o[44] = x11 >>> 0 & 0xff;
  35648. o[45] = x11 >>> 8 & 0xff;
  35649. o[46] = x11 >>> 16 & 0xff;
  35650. o[47] = x11 >>> 24 & 0xff;
  35651. o[48] = x12 >>> 0 & 0xff;
  35652. o[49] = x12 >>> 8 & 0xff;
  35653. o[50] = x12 >>> 16 & 0xff;
  35654. o[51] = x12 >>> 24 & 0xff;
  35655. o[52] = x13 >>> 0 & 0xff;
  35656. o[53] = x13 >>> 8 & 0xff;
  35657. o[54] = x13 >>> 16 & 0xff;
  35658. o[55] = x13 >>> 24 & 0xff;
  35659. o[56] = x14 >>> 0 & 0xff;
  35660. o[57] = x14 >>> 8 & 0xff;
  35661. o[58] = x14 >>> 16 & 0xff;
  35662. o[59] = x14 >>> 24 & 0xff;
  35663. o[60] = x15 >>> 0 & 0xff;
  35664. o[61] = x15 >>> 8 & 0xff;
  35665. o[62] = x15 >>> 16 & 0xff;
  35666. o[63] = x15 >>> 24 & 0xff;
  35667. }
  35668. function core_hsalsa20(o,p,k,c) {
  35669. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35670. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35671. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35672. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35673. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35674. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35675. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35676. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35677. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35678. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35679. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35680. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35681. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35682. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35683. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35684. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35685. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35686. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35687. x15 = j15, u;
  35688. for (var i = 0; i < 20; i += 2) {
  35689. u = x0 + x12 | 0;
  35690. x4 ^= u<<7 | u>>>(32-7);
  35691. u = x4 + x0 | 0;
  35692. x8 ^= u<<9 | u>>>(32-9);
  35693. u = x8 + x4 | 0;
  35694. x12 ^= u<<13 | u>>>(32-13);
  35695. u = x12 + x8 | 0;
  35696. x0 ^= u<<18 | u>>>(32-18);
  35697. u = x5 + x1 | 0;
  35698. x9 ^= u<<7 | u>>>(32-7);
  35699. u = x9 + x5 | 0;
  35700. x13 ^= u<<9 | u>>>(32-9);
  35701. u = x13 + x9 | 0;
  35702. x1 ^= u<<13 | u>>>(32-13);
  35703. u = x1 + x13 | 0;
  35704. x5 ^= u<<18 | u>>>(32-18);
  35705. u = x10 + x6 | 0;
  35706. x14 ^= u<<7 | u>>>(32-7);
  35707. u = x14 + x10 | 0;
  35708. x2 ^= u<<9 | u>>>(32-9);
  35709. u = x2 + x14 | 0;
  35710. x6 ^= u<<13 | u>>>(32-13);
  35711. u = x6 + x2 | 0;
  35712. x10 ^= u<<18 | u>>>(32-18);
  35713. u = x15 + x11 | 0;
  35714. x3 ^= u<<7 | u>>>(32-7);
  35715. u = x3 + x15 | 0;
  35716. x7 ^= u<<9 | u>>>(32-9);
  35717. u = x7 + x3 | 0;
  35718. x11 ^= u<<13 | u>>>(32-13);
  35719. u = x11 + x7 | 0;
  35720. x15 ^= u<<18 | u>>>(32-18);
  35721. u = x0 + x3 | 0;
  35722. x1 ^= u<<7 | u>>>(32-7);
  35723. u = x1 + x0 | 0;
  35724. x2 ^= u<<9 | u>>>(32-9);
  35725. u = x2 + x1 | 0;
  35726. x3 ^= u<<13 | u>>>(32-13);
  35727. u = x3 + x2 | 0;
  35728. x0 ^= u<<18 | u>>>(32-18);
  35729. u = x5 + x4 | 0;
  35730. x6 ^= u<<7 | u>>>(32-7);
  35731. u = x6 + x5 | 0;
  35732. x7 ^= u<<9 | u>>>(32-9);
  35733. u = x7 + x6 | 0;
  35734. x4 ^= u<<13 | u>>>(32-13);
  35735. u = x4 + x7 | 0;
  35736. x5 ^= u<<18 | u>>>(32-18);
  35737. u = x10 + x9 | 0;
  35738. x11 ^= u<<7 | u>>>(32-7);
  35739. u = x11 + x10 | 0;
  35740. x8 ^= u<<9 | u>>>(32-9);
  35741. u = x8 + x11 | 0;
  35742. x9 ^= u<<13 | u>>>(32-13);
  35743. u = x9 + x8 | 0;
  35744. x10 ^= u<<18 | u>>>(32-18);
  35745. u = x15 + x14 | 0;
  35746. x12 ^= u<<7 | u>>>(32-7);
  35747. u = x12 + x15 | 0;
  35748. x13 ^= u<<9 | u>>>(32-9);
  35749. u = x13 + x12 | 0;
  35750. x14 ^= u<<13 | u>>>(32-13);
  35751. u = x14 + x13 | 0;
  35752. x15 ^= u<<18 | u>>>(32-18);
  35753. }
  35754. o[ 0] = x0 >>> 0 & 0xff;
  35755. o[ 1] = x0 >>> 8 & 0xff;
  35756. o[ 2] = x0 >>> 16 & 0xff;
  35757. o[ 3] = x0 >>> 24 & 0xff;
  35758. o[ 4] = x5 >>> 0 & 0xff;
  35759. o[ 5] = x5 >>> 8 & 0xff;
  35760. o[ 6] = x5 >>> 16 & 0xff;
  35761. o[ 7] = x5 >>> 24 & 0xff;
  35762. o[ 8] = x10 >>> 0 & 0xff;
  35763. o[ 9] = x10 >>> 8 & 0xff;
  35764. o[10] = x10 >>> 16 & 0xff;
  35765. o[11] = x10 >>> 24 & 0xff;
  35766. o[12] = x15 >>> 0 & 0xff;
  35767. o[13] = x15 >>> 8 & 0xff;
  35768. o[14] = x15 >>> 16 & 0xff;
  35769. o[15] = x15 >>> 24 & 0xff;
  35770. o[16] = x6 >>> 0 & 0xff;
  35771. o[17] = x6 >>> 8 & 0xff;
  35772. o[18] = x6 >>> 16 & 0xff;
  35773. o[19] = x6 >>> 24 & 0xff;
  35774. o[20] = x7 >>> 0 & 0xff;
  35775. o[21] = x7 >>> 8 & 0xff;
  35776. o[22] = x7 >>> 16 & 0xff;
  35777. o[23] = x7 >>> 24 & 0xff;
  35778. o[24] = x8 >>> 0 & 0xff;
  35779. o[25] = x8 >>> 8 & 0xff;
  35780. o[26] = x8 >>> 16 & 0xff;
  35781. o[27] = x8 >>> 24 & 0xff;
  35782. o[28] = x9 >>> 0 & 0xff;
  35783. o[29] = x9 >>> 8 & 0xff;
  35784. o[30] = x9 >>> 16 & 0xff;
  35785. o[31] = x9 >>> 24 & 0xff;
  35786. }
  35787. function crypto_core_salsa20(out,inp,k,c) {
  35788. core_salsa20(out,inp,k,c);
  35789. }
  35790. function crypto_core_hsalsa20(out,inp,k,c) {
  35791. core_hsalsa20(out,inp,k,c);
  35792. }
  35793. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35794. // "expand 32-byte k"
  35795. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35796. var z = new Uint8Array(16), x = new Uint8Array(64);
  35797. var u, i;
  35798. for (i = 0; i < 16; i++) z[i] = 0;
  35799. for (i = 0; i < 8; i++) z[i] = n[i];
  35800. while (b >= 64) {
  35801. crypto_core_salsa20(x,z,k,sigma);
  35802. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35803. u = 1;
  35804. for (i = 8; i < 16; i++) {
  35805. u = u + (z[i] & 0xff) | 0;
  35806. z[i] = u & 0xff;
  35807. u >>>= 8;
  35808. }
  35809. b -= 64;
  35810. cpos += 64;
  35811. mpos += 64;
  35812. }
  35813. if (b > 0) {
  35814. crypto_core_salsa20(x,z,k,sigma);
  35815. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35816. }
  35817. return 0;
  35818. }
  35819. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35820. var z = new Uint8Array(16), x = new Uint8Array(64);
  35821. var u, i;
  35822. for (i = 0; i < 16; i++) z[i] = 0;
  35823. for (i = 0; i < 8; i++) z[i] = n[i];
  35824. while (b >= 64) {
  35825. crypto_core_salsa20(x,z,k,sigma);
  35826. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35827. u = 1;
  35828. for (i = 8; i < 16; i++) {
  35829. u = u + (z[i] & 0xff) | 0;
  35830. z[i] = u & 0xff;
  35831. u >>>= 8;
  35832. }
  35833. b -= 64;
  35834. cpos += 64;
  35835. }
  35836. if (b > 0) {
  35837. crypto_core_salsa20(x,z,k,sigma);
  35838. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35839. }
  35840. return 0;
  35841. }
  35842. function crypto_stream(c,cpos,d,n,k) {
  35843. var s = new Uint8Array(32);
  35844. crypto_core_hsalsa20(s,n,k,sigma);
  35845. var sn = new Uint8Array(8);
  35846. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35847. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35848. }
  35849. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35850. var s = new Uint8Array(32);
  35851. crypto_core_hsalsa20(s,n,k,sigma);
  35852. var sn = new Uint8Array(8);
  35853. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35854. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35855. }
  35856. /*
  35857. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35858. * https://github.com/floodyberry/poly1305-donna
  35859. */
  35860. var poly1305 = function(key) {
  35861. this.buffer = new Uint8Array(16);
  35862. this.r = new Uint16Array(10);
  35863. this.h = new Uint16Array(10);
  35864. this.pad = new Uint16Array(8);
  35865. this.leftover = 0;
  35866. this.fin = 0;
  35867. var t0, t1, t2, t3, t4, t5, t6, t7;
  35868. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35869. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35870. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35871. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35872. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35873. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35874. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35875. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35876. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35877. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35878. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35879. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35880. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35881. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35882. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35883. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35884. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35885. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35886. };
  35887. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35888. var hibit = this.fin ? 0 : (1 << 11);
  35889. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35890. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35891. var h0 = this.h[0],
  35892. h1 = this.h[1],
  35893. h2 = this.h[2],
  35894. h3 = this.h[3],
  35895. h4 = this.h[4],
  35896. h5 = this.h[5],
  35897. h6 = this.h[6],
  35898. h7 = this.h[7],
  35899. h8 = this.h[8],
  35900. h9 = this.h[9];
  35901. var r0 = this.r[0],
  35902. r1 = this.r[1],
  35903. r2 = this.r[2],
  35904. r3 = this.r[3],
  35905. r4 = this.r[4],
  35906. r5 = this.r[5],
  35907. r6 = this.r[6],
  35908. r7 = this.r[7],
  35909. r8 = this.r[8],
  35910. r9 = this.r[9];
  35911. while (bytes >= 16) {
  35912. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35913. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35914. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35915. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35916. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35917. h5 += ((t4 >>> 1)) & 0x1fff;
  35918. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35919. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35920. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35921. h9 += ((t7 >>> 5)) | hibit;
  35922. c = 0;
  35923. d0 = c;
  35924. d0 += h0 * r0;
  35925. d0 += h1 * (5 * r9);
  35926. d0 += h2 * (5 * r8);
  35927. d0 += h3 * (5 * r7);
  35928. d0 += h4 * (5 * r6);
  35929. c = (d0 >>> 13); d0 &= 0x1fff;
  35930. d0 += h5 * (5 * r5);
  35931. d0 += h6 * (5 * r4);
  35932. d0 += h7 * (5 * r3);
  35933. d0 += h8 * (5 * r2);
  35934. d0 += h9 * (5 * r1);
  35935. c += (d0 >>> 13); d0 &= 0x1fff;
  35936. d1 = c;
  35937. d1 += h0 * r1;
  35938. d1 += h1 * r0;
  35939. d1 += h2 * (5 * r9);
  35940. d1 += h3 * (5 * r8);
  35941. d1 += h4 * (5 * r7);
  35942. c = (d1 >>> 13); d1 &= 0x1fff;
  35943. d1 += h5 * (5 * r6);
  35944. d1 += h6 * (5 * r5);
  35945. d1 += h7 * (5 * r4);
  35946. d1 += h8 * (5 * r3);
  35947. d1 += h9 * (5 * r2);
  35948. c += (d1 >>> 13); d1 &= 0x1fff;
  35949. d2 = c;
  35950. d2 += h0 * r2;
  35951. d2 += h1 * r1;
  35952. d2 += h2 * r0;
  35953. d2 += h3 * (5 * r9);
  35954. d2 += h4 * (5 * r8);
  35955. c = (d2 >>> 13); d2 &= 0x1fff;
  35956. d2 += h5 * (5 * r7);
  35957. d2 += h6 * (5 * r6);
  35958. d2 += h7 * (5 * r5);
  35959. d2 += h8 * (5 * r4);
  35960. d2 += h9 * (5 * r3);
  35961. c += (d2 >>> 13); d2 &= 0x1fff;
  35962. d3 = c;
  35963. d3 += h0 * r3;
  35964. d3 += h1 * r2;
  35965. d3 += h2 * r1;
  35966. d3 += h3 * r0;
  35967. d3 += h4 * (5 * r9);
  35968. c = (d3 >>> 13); d3 &= 0x1fff;
  35969. d3 += h5 * (5 * r8);
  35970. d3 += h6 * (5 * r7);
  35971. d3 += h7 * (5 * r6);
  35972. d3 += h8 * (5 * r5);
  35973. d3 += h9 * (5 * r4);
  35974. c += (d3 >>> 13); d3 &= 0x1fff;
  35975. d4 = c;
  35976. d4 += h0 * r4;
  35977. d4 += h1 * r3;
  35978. d4 += h2 * r2;
  35979. d4 += h3 * r1;
  35980. d4 += h4 * r0;
  35981. c = (d4 >>> 13); d4 &= 0x1fff;
  35982. d4 += h5 * (5 * r9);
  35983. d4 += h6 * (5 * r8);
  35984. d4 += h7 * (5 * r7);
  35985. d4 += h8 * (5 * r6);
  35986. d4 += h9 * (5 * r5);
  35987. c += (d4 >>> 13); d4 &= 0x1fff;
  35988. d5 = c;
  35989. d5 += h0 * r5;
  35990. d5 += h1 * r4;
  35991. d5 += h2 * r3;
  35992. d5 += h3 * r2;
  35993. d5 += h4 * r1;
  35994. c = (d5 >>> 13); d5 &= 0x1fff;
  35995. d5 += h5 * r0;
  35996. d5 += h6 * (5 * r9);
  35997. d5 += h7 * (5 * r8);
  35998. d5 += h8 * (5 * r7);
  35999. d5 += h9 * (5 * r6);
  36000. c += (d5 >>> 13); d5 &= 0x1fff;
  36001. d6 = c;
  36002. d6 += h0 * r6;
  36003. d6 += h1 * r5;
  36004. d6 += h2 * r4;
  36005. d6 += h3 * r3;
  36006. d6 += h4 * r2;
  36007. c = (d6 >>> 13); d6 &= 0x1fff;
  36008. d6 += h5 * r1;
  36009. d6 += h6 * r0;
  36010. d6 += h7 * (5 * r9);
  36011. d6 += h8 * (5 * r8);
  36012. d6 += h9 * (5 * r7);
  36013. c += (d6 >>> 13); d6 &= 0x1fff;
  36014. d7 = c;
  36015. d7 += h0 * r7;
  36016. d7 += h1 * r6;
  36017. d7 += h2 * r5;
  36018. d7 += h3 * r4;
  36019. d7 += h4 * r3;
  36020. c = (d7 >>> 13); d7 &= 0x1fff;
  36021. d7 += h5 * r2;
  36022. d7 += h6 * r1;
  36023. d7 += h7 * r0;
  36024. d7 += h8 * (5 * r9);
  36025. d7 += h9 * (5 * r8);
  36026. c += (d7 >>> 13); d7 &= 0x1fff;
  36027. d8 = c;
  36028. d8 += h0 * r8;
  36029. d8 += h1 * r7;
  36030. d8 += h2 * r6;
  36031. d8 += h3 * r5;
  36032. d8 += h4 * r4;
  36033. c = (d8 >>> 13); d8 &= 0x1fff;
  36034. d8 += h5 * r3;
  36035. d8 += h6 * r2;
  36036. d8 += h7 * r1;
  36037. d8 += h8 * r0;
  36038. d8 += h9 * (5 * r9);
  36039. c += (d8 >>> 13); d8 &= 0x1fff;
  36040. d9 = c;
  36041. d9 += h0 * r9;
  36042. d9 += h1 * r8;
  36043. d9 += h2 * r7;
  36044. d9 += h3 * r6;
  36045. d9 += h4 * r5;
  36046. c = (d9 >>> 13); d9 &= 0x1fff;
  36047. d9 += h5 * r4;
  36048. d9 += h6 * r3;
  36049. d9 += h7 * r2;
  36050. d9 += h8 * r1;
  36051. d9 += h9 * r0;
  36052. c += (d9 >>> 13); d9 &= 0x1fff;
  36053. c = (((c << 2) + c)) | 0;
  36054. c = (c + d0) | 0;
  36055. d0 = c & 0x1fff;
  36056. c = (c >>> 13);
  36057. d1 += c;
  36058. h0 = d0;
  36059. h1 = d1;
  36060. h2 = d2;
  36061. h3 = d3;
  36062. h4 = d4;
  36063. h5 = d5;
  36064. h6 = d6;
  36065. h7 = d7;
  36066. h8 = d8;
  36067. h9 = d9;
  36068. mpos += 16;
  36069. bytes -= 16;
  36070. }
  36071. this.h[0] = h0;
  36072. this.h[1] = h1;
  36073. this.h[2] = h2;
  36074. this.h[3] = h3;
  36075. this.h[4] = h4;
  36076. this.h[5] = h5;
  36077. this.h[6] = h6;
  36078. this.h[7] = h7;
  36079. this.h[8] = h8;
  36080. this.h[9] = h9;
  36081. };
  36082. poly1305.prototype.finish = function(mac, macpos) {
  36083. var g = new Uint16Array(10);
  36084. var c, mask, f, i;
  36085. if (this.leftover) {
  36086. i = this.leftover;
  36087. this.buffer[i++] = 1;
  36088. for (; i < 16; i++) this.buffer[i] = 0;
  36089. this.fin = 1;
  36090. this.blocks(this.buffer, 0, 16);
  36091. }
  36092. c = this.h[1] >>> 13;
  36093. this.h[1] &= 0x1fff;
  36094. for (i = 2; i < 10; i++) {
  36095. this.h[i] += c;
  36096. c = this.h[i] >>> 13;
  36097. this.h[i] &= 0x1fff;
  36098. }
  36099. this.h[0] += (c * 5);
  36100. c = this.h[0] >>> 13;
  36101. this.h[0] &= 0x1fff;
  36102. this.h[1] += c;
  36103. c = this.h[1] >>> 13;
  36104. this.h[1] &= 0x1fff;
  36105. this.h[2] += c;
  36106. g[0] = this.h[0] + 5;
  36107. c = g[0] >>> 13;
  36108. g[0] &= 0x1fff;
  36109. for (i = 1; i < 10; i++) {
  36110. g[i] = this.h[i] + c;
  36111. c = g[i] >>> 13;
  36112. g[i] &= 0x1fff;
  36113. }
  36114. g[9] -= (1 << 13);
  36115. mask = (c ^ 1) - 1;
  36116. for (i = 0; i < 10; i++) g[i] &= mask;
  36117. mask = ~mask;
  36118. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36119. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36120. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36121. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36122. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36123. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36124. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36125. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36126. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36127. f = this.h[0] + this.pad[0];
  36128. this.h[0] = f & 0xffff;
  36129. for (i = 1; i < 8; i++) {
  36130. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36131. this.h[i] = f & 0xffff;
  36132. }
  36133. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36134. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36135. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36136. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36137. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36138. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36139. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36140. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36141. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36142. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36143. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36144. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36145. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36146. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36147. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36148. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36149. };
  36150. poly1305.prototype.update = function(m, mpos, bytes) {
  36151. var i, want;
  36152. if (this.leftover) {
  36153. want = (16 - this.leftover);
  36154. if (want > bytes)
  36155. want = bytes;
  36156. for (i = 0; i < want; i++)
  36157. this.buffer[this.leftover + i] = m[mpos+i];
  36158. bytes -= want;
  36159. mpos += want;
  36160. this.leftover += want;
  36161. if (this.leftover < 16)
  36162. return;
  36163. this.blocks(this.buffer, 0, 16);
  36164. this.leftover = 0;
  36165. }
  36166. if (bytes >= 16) {
  36167. want = bytes - (bytes % 16);
  36168. this.blocks(m, mpos, want);
  36169. mpos += want;
  36170. bytes -= want;
  36171. }
  36172. if (bytes) {
  36173. for (i = 0; i < bytes; i++)
  36174. this.buffer[this.leftover + i] = m[mpos+i];
  36175. this.leftover += bytes;
  36176. }
  36177. };
  36178. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36179. var s = new poly1305(k);
  36180. s.update(m, mpos, n);
  36181. s.finish(out, outpos);
  36182. return 0;
  36183. }
  36184. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36185. var x = new Uint8Array(16);
  36186. crypto_onetimeauth(x,0,m,mpos,n,k);
  36187. return crypto_verify_16(h,hpos,x,0);
  36188. }
  36189. function crypto_secretbox(c,m,d,n,k) {
  36190. var i;
  36191. if (d < 32) return -1;
  36192. crypto_stream_xor(c,0,m,0,d,n,k);
  36193. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36194. for (i = 0; i < 16; i++) c[i] = 0;
  36195. return 0;
  36196. }
  36197. function crypto_secretbox_open(m,c,d,n,k) {
  36198. var i;
  36199. var x = new Uint8Array(32);
  36200. if (d < 32) return -1;
  36201. crypto_stream(x,0,32,n,k);
  36202. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36203. crypto_stream_xor(m,0,c,0,d,n,k);
  36204. for (i = 0; i < 32; i++) m[i] = 0;
  36205. return 0;
  36206. }
  36207. function set25519(r, a) {
  36208. var i;
  36209. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36210. }
  36211. function car25519(o) {
  36212. var i, v, c = 1;
  36213. for (i = 0; i < 16; i++) {
  36214. v = o[i] + c + 65535;
  36215. c = Math.floor(v / 65536);
  36216. o[i] = v - c * 65536;
  36217. }
  36218. o[0] += c-1 + 37 * (c-1);
  36219. }
  36220. function sel25519(p, q, b) {
  36221. var t, c = ~(b-1);
  36222. for (var i = 0; i < 16; i++) {
  36223. t = c & (p[i] ^ q[i]);
  36224. p[i] ^= t;
  36225. q[i] ^= t;
  36226. }
  36227. }
  36228. function pack25519(o, n) {
  36229. var i, j, b;
  36230. var m = gf(), t = gf();
  36231. for (i = 0; i < 16; i++) t[i] = n[i];
  36232. car25519(t);
  36233. car25519(t);
  36234. car25519(t);
  36235. for (j = 0; j < 2; j++) {
  36236. m[0] = t[0] - 0xffed;
  36237. for (i = 1; i < 15; i++) {
  36238. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36239. m[i-1] &= 0xffff;
  36240. }
  36241. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36242. b = (m[15]>>16) & 1;
  36243. m[14] &= 0xffff;
  36244. sel25519(t, m, 1-b);
  36245. }
  36246. for (i = 0; i < 16; i++) {
  36247. o[2*i] = t[i] & 0xff;
  36248. o[2*i+1] = t[i]>>8;
  36249. }
  36250. }
  36251. function neq25519(a, b) {
  36252. var c = new Uint8Array(32), d = new Uint8Array(32);
  36253. pack25519(c, a);
  36254. pack25519(d, b);
  36255. return crypto_verify_32(c, 0, d, 0);
  36256. }
  36257. function par25519(a) {
  36258. var d = new Uint8Array(32);
  36259. pack25519(d, a);
  36260. return d[0] & 1;
  36261. }
  36262. function unpack25519(o, n) {
  36263. var i;
  36264. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36265. o[15] &= 0x7fff;
  36266. }
  36267. function A(o, a, b) {
  36268. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36269. }
  36270. function Z(o, a, b) {
  36271. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36272. }
  36273. function M(o, a, b) {
  36274. var v, c,
  36275. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36276. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36277. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36278. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36279. b0 = b[0],
  36280. b1 = b[1],
  36281. b2 = b[2],
  36282. b3 = b[3],
  36283. b4 = b[4],
  36284. b5 = b[5],
  36285. b6 = b[6],
  36286. b7 = b[7],
  36287. b8 = b[8],
  36288. b9 = b[9],
  36289. b10 = b[10],
  36290. b11 = b[11],
  36291. b12 = b[12],
  36292. b13 = b[13],
  36293. b14 = b[14],
  36294. b15 = b[15];
  36295. v = a[0];
  36296. t0 += v * b0;
  36297. t1 += v * b1;
  36298. t2 += v * b2;
  36299. t3 += v * b3;
  36300. t4 += v * b4;
  36301. t5 += v * b5;
  36302. t6 += v * b6;
  36303. t7 += v * b7;
  36304. t8 += v * b8;
  36305. t9 += v * b9;
  36306. t10 += v * b10;
  36307. t11 += v * b11;
  36308. t12 += v * b12;
  36309. t13 += v * b13;
  36310. t14 += v * b14;
  36311. t15 += v * b15;
  36312. v = a[1];
  36313. t1 += v * b0;
  36314. t2 += v * b1;
  36315. t3 += v * b2;
  36316. t4 += v * b3;
  36317. t5 += v * b4;
  36318. t6 += v * b5;
  36319. t7 += v * b6;
  36320. t8 += v * b7;
  36321. t9 += v * b8;
  36322. t10 += v * b9;
  36323. t11 += v * b10;
  36324. t12 += v * b11;
  36325. t13 += v * b12;
  36326. t14 += v * b13;
  36327. t15 += v * b14;
  36328. t16 += v * b15;
  36329. v = a[2];
  36330. t2 += v * b0;
  36331. t3 += v * b1;
  36332. t4 += v * b2;
  36333. t5 += v * b3;
  36334. t6 += v * b4;
  36335. t7 += v * b5;
  36336. t8 += v * b6;
  36337. t9 += v * b7;
  36338. t10 += v * b8;
  36339. t11 += v * b9;
  36340. t12 += v * b10;
  36341. t13 += v * b11;
  36342. t14 += v * b12;
  36343. t15 += v * b13;
  36344. t16 += v * b14;
  36345. t17 += v * b15;
  36346. v = a[3];
  36347. t3 += v * b0;
  36348. t4 += v * b1;
  36349. t5 += v * b2;
  36350. t6 += v * b3;
  36351. t7 += v * b4;
  36352. t8 += v * b5;
  36353. t9 += v * b6;
  36354. t10 += v * b7;
  36355. t11 += v * b8;
  36356. t12 += v * b9;
  36357. t13 += v * b10;
  36358. t14 += v * b11;
  36359. t15 += v * b12;
  36360. t16 += v * b13;
  36361. t17 += v * b14;
  36362. t18 += v * b15;
  36363. v = a[4];
  36364. t4 += v * b0;
  36365. t5 += v * b1;
  36366. t6 += v * b2;
  36367. t7 += v * b3;
  36368. t8 += v * b4;
  36369. t9 += v * b5;
  36370. t10 += v * b6;
  36371. t11 += v * b7;
  36372. t12 += v * b8;
  36373. t13 += v * b9;
  36374. t14 += v * b10;
  36375. t15 += v * b11;
  36376. t16 += v * b12;
  36377. t17 += v * b13;
  36378. t18 += v * b14;
  36379. t19 += v * b15;
  36380. v = a[5];
  36381. t5 += v * b0;
  36382. t6 += v * b1;
  36383. t7 += v * b2;
  36384. t8 += v * b3;
  36385. t9 += v * b4;
  36386. t10 += v * b5;
  36387. t11 += v * b6;
  36388. t12 += v * b7;
  36389. t13 += v * b8;
  36390. t14 += v * b9;
  36391. t15 += v * b10;
  36392. t16 += v * b11;
  36393. t17 += v * b12;
  36394. t18 += v * b13;
  36395. t19 += v * b14;
  36396. t20 += v * b15;
  36397. v = a[6];
  36398. t6 += v * b0;
  36399. t7 += v * b1;
  36400. t8 += v * b2;
  36401. t9 += v * b3;
  36402. t10 += v * b4;
  36403. t11 += v * b5;
  36404. t12 += v * b6;
  36405. t13 += v * b7;
  36406. t14 += v * b8;
  36407. t15 += v * b9;
  36408. t16 += v * b10;
  36409. t17 += v * b11;
  36410. t18 += v * b12;
  36411. t19 += v * b13;
  36412. t20 += v * b14;
  36413. t21 += v * b15;
  36414. v = a[7];
  36415. t7 += v * b0;
  36416. t8 += v * b1;
  36417. t9 += v * b2;
  36418. t10 += v * b3;
  36419. t11 += v * b4;
  36420. t12 += v * b5;
  36421. t13 += v * b6;
  36422. t14 += v * b7;
  36423. t15 += v * b8;
  36424. t16 += v * b9;
  36425. t17 += v * b10;
  36426. t18 += v * b11;
  36427. t19 += v * b12;
  36428. t20 += v * b13;
  36429. t21 += v * b14;
  36430. t22 += v * b15;
  36431. v = a[8];
  36432. t8 += v * b0;
  36433. t9 += v * b1;
  36434. t10 += v * b2;
  36435. t11 += v * b3;
  36436. t12 += v * b4;
  36437. t13 += v * b5;
  36438. t14 += v * b6;
  36439. t15 += v * b7;
  36440. t16 += v * b8;
  36441. t17 += v * b9;
  36442. t18 += v * b10;
  36443. t19 += v * b11;
  36444. t20 += v * b12;
  36445. t21 += v * b13;
  36446. t22 += v * b14;
  36447. t23 += v * b15;
  36448. v = a[9];
  36449. t9 += v * b0;
  36450. t10 += v * b1;
  36451. t11 += v * b2;
  36452. t12 += v * b3;
  36453. t13 += v * b4;
  36454. t14 += v * b5;
  36455. t15 += v * b6;
  36456. t16 += v * b7;
  36457. t17 += v * b8;
  36458. t18 += v * b9;
  36459. t19 += v * b10;
  36460. t20 += v * b11;
  36461. t21 += v * b12;
  36462. t22 += v * b13;
  36463. t23 += v * b14;
  36464. t24 += v * b15;
  36465. v = a[10];
  36466. t10 += v * b0;
  36467. t11 += v * b1;
  36468. t12 += v * b2;
  36469. t13 += v * b3;
  36470. t14 += v * b4;
  36471. t15 += v * b5;
  36472. t16 += v * b6;
  36473. t17 += v * b7;
  36474. t18 += v * b8;
  36475. t19 += v * b9;
  36476. t20 += v * b10;
  36477. t21 += v * b11;
  36478. t22 += v * b12;
  36479. t23 += v * b13;
  36480. t24 += v * b14;
  36481. t25 += v * b15;
  36482. v = a[11];
  36483. t11 += v * b0;
  36484. t12 += v * b1;
  36485. t13 += v * b2;
  36486. t14 += v * b3;
  36487. t15 += v * b4;
  36488. t16 += v * b5;
  36489. t17 += v * b6;
  36490. t18 += v * b7;
  36491. t19 += v * b8;
  36492. t20 += v * b9;
  36493. t21 += v * b10;
  36494. t22 += v * b11;
  36495. t23 += v * b12;
  36496. t24 += v * b13;
  36497. t25 += v * b14;
  36498. t26 += v * b15;
  36499. v = a[12];
  36500. t12 += v * b0;
  36501. t13 += v * b1;
  36502. t14 += v * b2;
  36503. t15 += v * b3;
  36504. t16 += v * b4;
  36505. t17 += v * b5;
  36506. t18 += v * b6;
  36507. t19 += v * b7;
  36508. t20 += v * b8;
  36509. t21 += v * b9;
  36510. t22 += v * b10;
  36511. t23 += v * b11;
  36512. t24 += v * b12;
  36513. t25 += v * b13;
  36514. t26 += v * b14;
  36515. t27 += v * b15;
  36516. v = a[13];
  36517. t13 += v * b0;
  36518. t14 += v * b1;
  36519. t15 += v * b2;
  36520. t16 += v * b3;
  36521. t17 += v * b4;
  36522. t18 += v * b5;
  36523. t19 += v * b6;
  36524. t20 += v * b7;
  36525. t21 += v * b8;
  36526. t22 += v * b9;
  36527. t23 += v * b10;
  36528. t24 += v * b11;
  36529. t25 += v * b12;
  36530. t26 += v * b13;
  36531. t27 += v * b14;
  36532. t28 += v * b15;
  36533. v = a[14];
  36534. t14 += v * b0;
  36535. t15 += v * b1;
  36536. t16 += v * b2;
  36537. t17 += v * b3;
  36538. t18 += v * b4;
  36539. t19 += v * b5;
  36540. t20 += v * b6;
  36541. t21 += v * b7;
  36542. t22 += v * b8;
  36543. t23 += v * b9;
  36544. t24 += v * b10;
  36545. t25 += v * b11;
  36546. t26 += v * b12;
  36547. t27 += v * b13;
  36548. t28 += v * b14;
  36549. t29 += v * b15;
  36550. v = a[15];
  36551. t15 += v * b0;
  36552. t16 += v * b1;
  36553. t17 += v * b2;
  36554. t18 += v * b3;
  36555. t19 += v * b4;
  36556. t20 += v * b5;
  36557. t21 += v * b6;
  36558. t22 += v * b7;
  36559. t23 += v * b8;
  36560. t24 += v * b9;
  36561. t25 += v * b10;
  36562. t26 += v * b11;
  36563. t27 += v * b12;
  36564. t28 += v * b13;
  36565. t29 += v * b14;
  36566. t30 += v * b15;
  36567. t0 += 38 * t16;
  36568. t1 += 38 * t17;
  36569. t2 += 38 * t18;
  36570. t3 += 38 * t19;
  36571. t4 += 38 * t20;
  36572. t5 += 38 * t21;
  36573. t6 += 38 * t22;
  36574. t7 += 38 * t23;
  36575. t8 += 38 * t24;
  36576. t9 += 38 * t25;
  36577. t10 += 38 * t26;
  36578. t11 += 38 * t27;
  36579. t12 += 38 * t28;
  36580. t13 += 38 * t29;
  36581. t14 += 38 * t30;
  36582. // t15 left as is
  36583. // first car
  36584. c = 1;
  36585. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36586. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36587. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36588. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36589. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36590. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36591. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36592. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36593. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36594. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36595. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36596. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36597. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36598. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36599. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36600. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36601. t0 += c-1 + 37 * (c-1);
  36602. // second car
  36603. c = 1;
  36604. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36605. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36606. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36607. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36608. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36609. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36610. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36611. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36612. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36613. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36614. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36615. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36616. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36617. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36618. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36619. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36620. t0 += c-1 + 37 * (c-1);
  36621. o[ 0] = t0;
  36622. o[ 1] = t1;
  36623. o[ 2] = t2;
  36624. o[ 3] = t3;
  36625. o[ 4] = t4;
  36626. o[ 5] = t5;
  36627. o[ 6] = t6;
  36628. o[ 7] = t7;
  36629. o[ 8] = t8;
  36630. o[ 9] = t9;
  36631. o[10] = t10;
  36632. o[11] = t11;
  36633. o[12] = t12;
  36634. o[13] = t13;
  36635. o[14] = t14;
  36636. o[15] = t15;
  36637. }
  36638. function S(o, a) {
  36639. M(o, a, a);
  36640. }
  36641. function inv25519(o, i) {
  36642. var c = gf();
  36643. var a;
  36644. for (a = 0; a < 16; a++) c[a] = i[a];
  36645. for (a = 253; a >= 0; a--) {
  36646. S(c, c);
  36647. if(a !== 2 && a !== 4) M(c, c, i);
  36648. }
  36649. for (a = 0; a < 16; a++) o[a] = c[a];
  36650. }
  36651. function pow2523(o, i) {
  36652. var c = gf();
  36653. var a;
  36654. for (a = 0; a < 16; a++) c[a] = i[a];
  36655. for (a = 250; a >= 0; a--) {
  36656. S(c, c);
  36657. if(a !== 1) M(c, c, i);
  36658. }
  36659. for (a = 0; a < 16; a++) o[a] = c[a];
  36660. }
  36661. function crypto_scalarmult(q, n, p) {
  36662. var z = new Uint8Array(32);
  36663. var x = new Float64Array(80), r, i;
  36664. var a = gf(), b = gf(), c = gf(),
  36665. d = gf(), e = gf(), f = gf();
  36666. for (i = 0; i < 31; i++) z[i] = n[i];
  36667. z[31]=(n[31]&127)|64;
  36668. z[0]&=248;
  36669. unpack25519(x,p);
  36670. for (i = 0; i < 16; i++) {
  36671. b[i]=x[i];
  36672. d[i]=a[i]=c[i]=0;
  36673. }
  36674. a[0]=d[0]=1;
  36675. for (i=254; i>=0; --i) {
  36676. r=(z[i>>>3]>>>(i&7))&1;
  36677. sel25519(a,b,r);
  36678. sel25519(c,d,r);
  36679. A(e,a,c);
  36680. Z(a,a,c);
  36681. A(c,b,d);
  36682. Z(b,b,d);
  36683. S(d,e);
  36684. S(f,a);
  36685. M(a,c,a);
  36686. M(c,b,e);
  36687. A(e,a,c);
  36688. Z(a,a,c);
  36689. S(b,a);
  36690. Z(c,d,f);
  36691. M(a,c,_121665);
  36692. A(a,a,d);
  36693. M(c,c,a);
  36694. M(a,d,f);
  36695. M(d,b,x);
  36696. S(b,e);
  36697. sel25519(a,b,r);
  36698. sel25519(c,d,r);
  36699. }
  36700. for (i = 0; i < 16; i++) {
  36701. x[i+16]=a[i];
  36702. x[i+32]=c[i];
  36703. x[i+48]=b[i];
  36704. x[i+64]=d[i];
  36705. }
  36706. var x32 = x.subarray(32);
  36707. var x16 = x.subarray(16);
  36708. inv25519(x32,x32);
  36709. M(x16,x16,x32);
  36710. pack25519(q,x16);
  36711. return 0;
  36712. }
  36713. function crypto_scalarmult_base(q, n) {
  36714. return crypto_scalarmult(q, n, _9);
  36715. }
  36716. function crypto_box_keypair(y, x) {
  36717. randombytes(x, 32);
  36718. return crypto_scalarmult_base(y, x);
  36719. }
  36720. function crypto_box_beforenm(k, y, x) {
  36721. var s = new Uint8Array(32);
  36722. crypto_scalarmult(s, x, y);
  36723. return crypto_core_hsalsa20(k, _0, s, sigma);
  36724. }
  36725. var crypto_box_afternm = crypto_secretbox;
  36726. var crypto_box_open_afternm = crypto_secretbox_open;
  36727. function crypto_box(c, m, d, n, y, x) {
  36728. var k = new Uint8Array(32);
  36729. crypto_box_beforenm(k, y, x);
  36730. return crypto_box_afternm(c, m, d, n, k);
  36731. }
  36732. function crypto_box_open(m, c, d, n, y, x) {
  36733. var k = new Uint8Array(32);
  36734. crypto_box_beforenm(k, y, x);
  36735. return crypto_box_open_afternm(m, c, d, n, k);
  36736. }
  36737. var K = [
  36738. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36739. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36740. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36741. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36742. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36743. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36744. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36745. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36746. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36747. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36748. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36749. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36750. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36751. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36752. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36753. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36754. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36755. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36756. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36757. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36758. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36759. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36760. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36761. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36762. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36763. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36764. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36765. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36766. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36767. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36768. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36769. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36770. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36771. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36772. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36773. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36774. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36775. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36776. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36777. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36778. ];
  36779. function crypto_hashblocks_hl(hh, hl, m, n) {
  36780. var wh = new Int32Array(16), wl = new Int32Array(16),
  36781. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36782. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36783. th, tl, i, j, h, l, a, b, c, d;
  36784. var ah0 = hh[0],
  36785. ah1 = hh[1],
  36786. ah2 = hh[2],
  36787. ah3 = hh[3],
  36788. ah4 = hh[4],
  36789. ah5 = hh[5],
  36790. ah6 = hh[6],
  36791. ah7 = hh[7],
  36792. al0 = hl[0],
  36793. al1 = hl[1],
  36794. al2 = hl[2],
  36795. al3 = hl[3],
  36796. al4 = hl[4],
  36797. al5 = hl[5],
  36798. al6 = hl[6],
  36799. al7 = hl[7];
  36800. var pos = 0;
  36801. while (n >= 128) {
  36802. for (i = 0; i < 16; i++) {
  36803. j = 8 * i + pos;
  36804. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36805. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36806. }
  36807. for (i = 0; i < 80; i++) {
  36808. bh0 = ah0;
  36809. bh1 = ah1;
  36810. bh2 = ah2;
  36811. bh3 = ah3;
  36812. bh4 = ah4;
  36813. bh5 = ah5;
  36814. bh6 = ah6;
  36815. bh7 = ah7;
  36816. bl0 = al0;
  36817. bl1 = al1;
  36818. bl2 = al2;
  36819. bl3 = al3;
  36820. bl4 = al4;
  36821. bl5 = al5;
  36822. bl6 = al6;
  36823. bl7 = al7;
  36824. // add
  36825. h = ah7;
  36826. l = al7;
  36827. a = l & 0xffff; b = l >>> 16;
  36828. c = h & 0xffff; d = h >>> 16;
  36829. // Sigma1
  36830. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36831. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36832. a += l & 0xffff; b += l >>> 16;
  36833. c += h & 0xffff; d += h >>> 16;
  36834. // Ch
  36835. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36836. l = (al4 & al5) ^ (~al4 & al6);
  36837. a += l & 0xffff; b += l >>> 16;
  36838. c += h & 0xffff; d += h >>> 16;
  36839. // K
  36840. h = K[i*2];
  36841. l = K[i*2+1];
  36842. a += l & 0xffff; b += l >>> 16;
  36843. c += h & 0xffff; d += h >>> 16;
  36844. // w
  36845. h = wh[i%16];
  36846. l = wl[i%16];
  36847. a += l & 0xffff; b += l >>> 16;
  36848. c += h & 0xffff; d += h >>> 16;
  36849. b += a >>> 16;
  36850. c += b >>> 16;
  36851. d += c >>> 16;
  36852. th = c & 0xffff | d << 16;
  36853. tl = a & 0xffff | b << 16;
  36854. // add
  36855. h = th;
  36856. l = tl;
  36857. a = l & 0xffff; b = l >>> 16;
  36858. c = h & 0xffff; d = h >>> 16;
  36859. // Sigma0
  36860. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36861. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36862. a += l & 0xffff; b += l >>> 16;
  36863. c += h & 0xffff; d += h >>> 16;
  36864. // Maj
  36865. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36866. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36867. a += l & 0xffff; b += l >>> 16;
  36868. c += h & 0xffff; d += h >>> 16;
  36869. b += a >>> 16;
  36870. c += b >>> 16;
  36871. d += c >>> 16;
  36872. bh7 = (c & 0xffff) | (d << 16);
  36873. bl7 = (a & 0xffff) | (b << 16);
  36874. // add
  36875. h = bh3;
  36876. l = bl3;
  36877. a = l & 0xffff; b = l >>> 16;
  36878. c = h & 0xffff; d = h >>> 16;
  36879. h = th;
  36880. l = tl;
  36881. a += l & 0xffff; b += l >>> 16;
  36882. c += h & 0xffff; d += h >>> 16;
  36883. b += a >>> 16;
  36884. c += b >>> 16;
  36885. d += c >>> 16;
  36886. bh3 = (c & 0xffff) | (d << 16);
  36887. bl3 = (a & 0xffff) | (b << 16);
  36888. ah1 = bh0;
  36889. ah2 = bh1;
  36890. ah3 = bh2;
  36891. ah4 = bh3;
  36892. ah5 = bh4;
  36893. ah6 = bh5;
  36894. ah7 = bh6;
  36895. ah0 = bh7;
  36896. al1 = bl0;
  36897. al2 = bl1;
  36898. al3 = bl2;
  36899. al4 = bl3;
  36900. al5 = bl4;
  36901. al6 = bl5;
  36902. al7 = bl6;
  36903. al0 = bl7;
  36904. if (i%16 === 15) {
  36905. for (j = 0; j < 16; j++) {
  36906. // add
  36907. h = wh[j];
  36908. l = wl[j];
  36909. a = l & 0xffff; b = l >>> 16;
  36910. c = h & 0xffff; d = h >>> 16;
  36911. h = wh[(j+9)%16];
  36912. l = wl[(j+9)%16];
  36913. a += l & 0xffff; b += l >>> 16;
  36914. c += h & 0xffff; d += h >>> 16;
  36915. // sigma0
  36916. th = wh[(j+1)%16];
  36917. tl = wl[(j+1)%16];
  36918. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36919. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36920. a += l & 0xffff; b += l >>> 16;
  36921. c += h & 0xffff; d += h >>> 16;
  36922. // sigma1
  36923. th = wh[(j+14)%16];
  36924. tl = wl[(j+14)%16];
  36925. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36926. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36927. a += l & 0xffff; b += l >>> 16;
  36928. c += h & 0xffff; d += h >>> 16;
  36929. b += a >>> 16;
  36930. c += b >>> 16;
  36931. d += c >>> 16;
  36932. wh[j] = (c & 0xffff) | (d << 16);
  36933. wl[j] = (a & 0xffff) | (b << 16);
  36934. }
  36935. }
  36936. }
  36937. // add
  36938. h = ah0;
  36939. l = al0;
  36940. a = l & 0xffff; b = l >>> 16;
  36941. c = h & 0xffff; d = h >>> 16;
  36942. h = hh[0];
  36943. l = hl[0];
  36944. a += l & 0xffff; b += l >>> 16;
  36945. c += h & 0xffff; d += h >>> 16;
  36946. b += a >>> 16;
  36947. c += b >>> 16;
  36948. d += c >>> 16;
  36949. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36950. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36951. h = ah1;
  36952. l = al1;
  36953. a = l & 0xffff; b = l >>> 16;
  36954. c = h & 0xffff; d = h >>> 16;
  36955. h = hh[1];
  36956. l = hl[1];
  36957. a += l & 0xffff; b += l >>> 16;
  36958. c += h & 0xffff; d += h >>> 16;
  36959. b += a >>> 16;
  36960. c += b >>> 16;
  36961. d += c >>> 16;
  36962. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  36963. hl[1] = al1 = (a & 0xffff) | (b << 16);
  36964. h = ah2;
  36965. l = al2;
  36966. a = l & 0xffff; b = l >>> 16;
  36967. c = h & 0xffff; d = h >>> 16;
  36968. h = hh[2];
  36969. l = hl[2];
  36970. a += l & 0xffff; b += l >>> 16;
  36971. c += h & 0xffff; d += h >>> 16;
  36972. b += a >>> 16;
  36973. c += b >>> 16;
  36974. d += c >>> 16;
  36975. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  36976. hl[2] = al2 = (a & 0xffff) | (b << 16);
  36977. h = ah3;
  36978. l = al3;
  36979. a = l & 0xffff; b = l >>> 16;
  36980. c = h & 0xffff; d = h >>> 16;
  36981. h = hh[3];
  36982. l = hl[3];
  36983. a += l & 0xffff; b += l >>> 16;
  36984. c += h & 0xffff; d += h >>> 16;
  36985. b += a >>> 16;
  36986. c += b >>> 16;
  36987. d += c >>> 16;
  36988. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  36989. hl[3] = al3 = (a & 0xffff) | (b << 16);
  36990. h = ah4;
  36991. l = al4;
  36992. a = l & 0xffff; b = l >>> 16;
  36993. c = h & 0xffff; d = h >>> 16;
  36994. h = hh[4];
  36995. l = hl[4];
  36996. a += l & 0xffff; b += l >>> 16;
  36997. c += h & 0xffff; d += h >>> 16;
  36998. b += a >>> 16;
  36999. c += b >>> 16;
  37000. d += c >>> 16;
  37001. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37002. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37003. h = ah5;
  37004. l = al5;
  37005. a = l & 0xffff; b = l >>> 16;
  37006. c = h & 0xffff; d = h >>> 16;
  37007. h = hh[5];
  37008. l = hl[5];
  37009. a += l & 0xffff; b += l >>> 16;
  37010. c += h & 0xffff; d += h >>> 16;
  37011. b += a >>> 16;
  37012. c += b >>> 16;
  37013. d += c >>> 16;
  37014. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37015. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37016. h = ah6;
  37017. l = al6;
  37018. a = l & 0xffff; b = l >>> 16;
  37019. c = h & 0xffff; d = h >>> 16;
  37020. h = hh[6];
  37021. l = hl[6];
  37022. a += l & 0xffff; b += l >>> 16;
  37023. c += h & 0xffff; d += h >>> 16;
  37024. b += a >>> 16;
  37025. c += b >>> 16;
  37026. d += c >>> 16;
  37027. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37028. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37029. h = ah7;
  37030. l = al7;
  37031. a = l & 0xffff; b = l >>> 16;
  37032. c = h & 0xffff; d = h >>> 16;
  37033. h = hh[7];
  37034. l = hl[7];
  37035. a += l & 0xffff; b += l >>> 16;
  37036. c += h & 0xffff; d += h >>> 16;
  37037. b += a >>> 16;
  37038. c += b >>> 16;
  37039. d += c >>> 16;
  37040. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37041. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37042. pos += 128;
  37043. n -= 128;
  37044. }
  37045. return n;
  37046. }
  37047. function crypto_hash(out, m, n) {
  37048. var hh = new Int32Array(8),
  37049. hl = new Int32Array(8),
  37050. x = new Uint8Array(256),
  37051. i, b = n;
  37052. hh[0] = 0x6a09e667;
  37053. hh[1] = 0xbb67ae85;
  37054. hh[2] = 0x3c6ef372;
  37055. hh[3] = 0xa54ff53a;
  37056. hh[4] = 0x510e527f;
  37057. hh[5] = 0x9b05688c;
  37058. hh[6] = 0x1f83d9ab;
  37059. hh[7] = 0x5be0cd19;
  37060. hl[0] = 0xf3bcc908;
  37061. hl[1] = 0x84caa73b;
  37062. hl[2] = 0xfe94f82b;
  37063. hl[3] = 0x5f1d36f1;
  37064. hl[4] = 0xade682d1;
  37065. hl[5] = 0x2b3e6c1f;
  37066. hl[6] = 0xfb41bd6b;
  37067. hl[7] = 0x137e2179;
  37068. crypto_hashblocks_hl(hh, hl, m, n);
  37069. n %= 128;
  37070. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37071. x[n] = 128;
  37072. n = 256-128*(n<112?1:0);
  37073. x[n-9] = 0;
  37074. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37075. crypto_hashblocks_hl(hh, hl, x, n);
  37076. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37077. return 0;
  37078. }
  37079. function add(p, q) {
  37080. var a = gf(), b = gf(), c = gf(),
  37081. d = gf(), e = gf(), f = gf(),
  37082. g = gf(), h = gf(), t = gf();
  37083. Z(a, p[1], p[0]);
  37084. Z(t, q[1], q[0]);
  37085. M(a, a, t);
  37086. A(b, p[0], p[1]);
  37087. A(t, q[0], q[1]);
  37088. M(b, b, t);
  37089. M(c, p[3], q[3]);
  37090. M(c, c, D2);
  37091. M(d, p[2], q[2]);
  37092. A(d, d, d);
  37093. Z(e, b, a);
  37094. Z(f, d, c);
  37095. A(g, d, c);
  37096. A(h, b, a);
  37097. M(p[0], e, f);
  37098. M(p[1], h, g);
  37099. M(p[2], g, f);
  37100. M(p[3], e, h);
  37101. }
  37102. function cswap(p, q, b) {
  37103. var i;
  37104. for (i = 0; i < 4; i++) {
  37105. sel25519(p[i], q[i], b);
  37106. }
  37107. }
  37108. function pack(r, p) {
  37109. var tx = gf(), ty = gf(), zi = gf();
  37110. inv25519(zi, p[2]);
  37111. M(tx, p[0], zi);
  37112. M(ty, p[1], zi);
  37113. pack25519(r, ty);
  37114. r[31] ^= par25519(tx) << 7;
  37115. }
  37116. function scalarmult(p, q, s) {
  37117. var b, i;
  37118. set25519(p[0], gf0);
  37119. set25519(p[1], gf1);
  37120. set25519(p[2], gf1);
  37121. set25519(p[3], gf0);
  37122. for (i = 255; i >= 0; --i) {
  37123. b = (s[(i/8)|0] >> (i&7)) & 1;
  37124. cswap(p, q, b);
  37125. add(q, p);
  37126. add(p, p);
  37127. cswap(p, q, b);
  37128. }
  37129. }
  37130. function scalarbase(p, s) {
  37131. var q = [gf(), gf(), gf(), gf()];
  37132. set25519(q[0], X);
  37133. set25519(q[1], Y);
  37134. set25519(q[2], gf1);
  37135. M(q[3], X, Y);
  37136. scalarmult(p, q, s);
  37137. }
  37138. function crypto_sign_keypair(pk, sk, seeded) {
  37139. var d = new Uint8Array(64);
  37140. var p = [gf(), gf(), gf(), gf()];
  37141. var i;
  37142. if (!seeded) randombytes(sk, 32);
  37143. crypto_hash(d, sk, 32);
  37144. d[0] &= 248;
  37145. d[31] &= 127;
  37146. d[31] |= 64;
  37147. scalarbase(p, d);
  37148. pack(pk, p);
  37149. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37150. return 0;
  37151. }
  37152. var L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
  37153. function modL(r, x) {
  37154. var carry, i, j, k;
  37155. for (i = 63; i >= 32; --i) {
  37156. carry = 0;
  37157. for (j = i - 32, k = i - 12; j < k; ++j) {
  37158. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37159. carry = (x[j] + 128) >> 8;
  37160. x[j] -= carry * 256;
  37161. }
  37162. x[j] += carry;
  37163. x[i] = 0;
  37164. }
  37165. carry = 0;
  37166. for (j = 0; j < 32; j++) {
  37167. x[j] += carry - (x[31] >> 4) * L[j];
  37168. carry = x[j] >> 8;
  37169. x[j] &= 255;
  37170. }
  37171. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37172. for (i = 0; i < 32; i++) {
  37173. x[i+1] += x[i] >> 8;
  37174. r[i] = x[i] & 255;
  37175. }
  37176. }
  37177. function reduce(r) {
  37178. var x = new Float64Array(64), i;
  37179. for (i = 0; i < 64; i++) x[i] = r[i];
  37180. for (i = 0; i < 64; i++) r[i] = 0;
  37181. modL(r, x);
  37182. }
  37183. // Note: difference from C - smlen returned, not passed as argument.
  37184. function crypto_sign(sm, m, n, sk) {
  37185. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37186. var i, j, x = new Float64Array(64);
  37187. var p = [gf(), gf(), gf(), gf()];
  37188. crypto_hash(d, sk, 32);
  37189. d[0] &= 248;
  37190. d[31] &= 127;
  37191. d[31] |= 64;
  37192. var smlen = n + 64;
  37193. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37194. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37195. crypto_hash(r, sm.subarray(32), n+32);
  37196. reduce(r);
  37197. scalarbase(p, r);
  37198. pack(sm, p);
  37199. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37200. crypto_hash(h, sm, n + 64);
  37201. reduce(h);
  37202. for (i = 0; i < 64; i++) x[i] = 0;
  37203. for (i = 0; i < 32; i++) x[i] = r[i];
  37204. for (i = 0; i < 32; i++) {
  37205. for (j = 0; j < 32; j++) {
  37206. x[i+j] += h[i] * d[j];
  37207. }
  37208. }
  37209. modL(sm.subarray(32), x);
  37210. return smlen;
  37211. }
  37212. function unpackneg(r, p) {
  37213. var t = gf(), chk = gf(), num = gf(),
  37214. den = gf(), den2 = gf(), den4 = gf(),
  37215. den6 = gf();
  37216. set25519(r[2], gf1);
  37217. unpack25519(r[1], p);
  37218. S(num, r[1]);
  37219. M(den, num, D);
  37220. Z(num, num, r[2]);
  37221. A(den, r[2], den);
  37222. S(den2, den);
  37223. S(den4, den2);
  37224. M(den6, den4, den2);
  37225. M(t, den6, num);
  37226. M(t, t, den);
  37227. pow2523(t, t);
  37228. M(t, t, num);
  37229. M(t, t, den);
  37230. M(t, t, den);
  37231. M(r[0], t, den);
  37232. S(chk, r[0]);
  37233. M(chk, chk, den);
  37234. if (neq25519(chk, num)) M(r[0], r[0], I);
  37235. S(chk, r[0]);
  37236. M(chk, chk, den);
  37237. if (neq25519(chk, num)) return -1;
  37238. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37239. M(r[3], r[0], r[1]);
  37240. return 0;
  37241. }
  37242. function crypto_sign_open(m, sm, n, pk) {
  37243. var i, mlen;
  37244. var t = new Uint8Array(32), h = new Uint8Array(64);
  37245. var p = [gf(), gf(), gf(), gf()],
  37246. q = [gf(), gf(), gf(), gf()];
  37247. mlen = -1;
  37248. if (n < 64) return -1;
  37249. if (unpackneg(q, pk)) return -1;
  37250. for (i = 0; i < n; i++) m[i] = sm[i];
  37251. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37252. crypto_hash(h, m, n);
  37253. reduce(h);
  37254. scalarmult(p, q, h);
  37255. scalarbase(q, sm.subarray(32));
  37256. add(p, q);
  37257. pack(t, p);
  37258. n -= 64;
  37259. if (crypto_verify_32(sm, 0, t, 0)) {
  37260. for (i = 0; i < n; i++) m[i] = 0;
  37261. return -1;
  37262. }
  37263. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37264. mlen = n;
  37265. return mlen;
  37266. }
  37267. var crypto_secretbox_KEYBYTES = 32,
  37268. crypto_secretbox_NONCEBYTES = 24,
  37269. crypto_secretbox_ZEROBYTES = 32,
  37270. crypto_secretbox_BOXZEROBYTES = 16,
  37271. crypto_scalarmult_BYTES = 32,
  37272. crypto_scalarmult_SCALARBYTES = 32,
  37273. crypto_box_PUBLICKEYBYTES = 32,
  37274. crypto_box_SECRETKEYBYTES = 32,
  37275. crypto_box_BEFORENMBYTES = 32,
  37276. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37277. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37278. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37279. crypto_sign_BYTES = 64,
  37280. crypto_sign_PUBLICKEYBYTES = 32,
  37281. crypto_sign_SECRETKEYBYTES = 64,
  37282. crypto_sign_SEEDBYTES = 32,
  37283. crypto_hash_BYTES = 64;
  37284. nacl.lowlevel = {
  37285. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37286. crypto_stream_xor: crypto_stream_xor,
  37287. crypto_stream: crypto_stream,
  37288. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37289. crypto_stream_salsa20: crypto_stream_salsa20,
  37290. crypto_onetimeauth: crypto_onetimeauth,
  37291. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37292. crypto_verify_16: crypto_verify_16,
  37293. crypto_verify_32: crypto_verify_32,
  37294. crypto_secretbox: crypto_secretbox,
  37295. crypto_secretbox_open: crypto_secretbox_open,
  37296. crypto_scalarmult: crypto_scalarmult,
  37297. crypto_scalarmult_base: crypto_scalarmult_base,
  37298. crypto_box_beforenm: crypto_box_beforenm,
  37299. crypto_box_afternm: crypto_box_afternm,
  37300. crypto_box: crypto_box,
  37301. crypto_box_open: crypto_box_open,
  37302. crypto_box_keypair: crypto_box_keypair,
  37303. crypto_hash: crypto_hash,
  37304. crypto_sign: crypto_sign,
  37305. crypto_sign_keypair: crypto_sign_keypair,
  37306. crypto_sign_open: crypto_sign_open,
  37307. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37308. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37309. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37310. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37311. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37312. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37313. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37314. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37315. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37316. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37317. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37318. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37319. crypto_sign_BYTES: crypto_sign_BYTES,
  37320. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37321. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37322. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37323. crypto_hash_BYTES: crypto_hash_BYTES
  37324. };
  37325. /* High-level API */
  37326. function checkLengths(k, n) {
  37327. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37328. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37329. }
  37330. function checkBoxLengths(pk, sk) {
  37331. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37332. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37333. }
  37334. function checkArrayTypes() {
  37335. for (var i = 0; i < arguments.length; i++) {
  37336. if (!(arguments[i] instanceof Uint8Array))
  37337. throw new TypeError('unexpected type, use Uint8Array');
  37338. }
  37339. }
  37340. function cleanup(arr) {
  37341. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37342. }
  37343. nacl.randomBytes = function(n) {
  37344. var b = new Uint8Array(n);
  37345. randombytes(b, n);
  37346. return b;
  37347. };
  37348. nacl.secretbox = function(msg, nonce, key) {
  37349. checkArrayTypes(msg, nonce, key);
  37350. checkLengths(key, nonce);
  37351. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37352. var c = new Uint8Array(m.length);
  37353. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37354. crypto_secretbox(c, m, m.length, nonce, key);
  37355. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37356. };
  37357. nacl.secretbox.open = function(box, nonce, key) {
  37358. checkArrayTypes(box, nonce, key);
  37359. checkLengths(key, nonce);
  37360. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37361. var m = new Uint8Array(c.length);
  37362. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37363. if (c.length < 32) return null;
  37364. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37365. return m.subarray(crypto_secretbox_ZEROBYTES);
  37366. };
  37367. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37368. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37369. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37370. nacl.scalarMult = function(n, p) {
  37371. checkArrayTypes(n, p);
  37372. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37373. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37374. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37375. crypto_scalarmult(q, n, p);
  37376. return q;
  37377. };
  37378. nacl.scalarMult.base = function(n) {
  37379. checkArrayTypes(n);
  37380. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37381. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37382. crypto_scalarmult_base(q, n);
  37383. return q;
  37384. };
  37385. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37386. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37387. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37388. var k = nacl.box.before(publicKey, secretKey);
  37389. return nacl.secretbox(msg, nonce, k);
  37390. };
  37391. nacl.box.before = function(publicKey, secretKey) {
  37392. checkArrayTypes(publicKey, secretKey);
  37393. checkBoxLengths(publicKey, secretKey);
  37394. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37395. crypto_box_beforenm(k, publicKey, secretKey);
  37396. return k;
  37397. };
  37398. nacl.box.after = nacl.secretbox;
  37399. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37400. var k = nacl.box.before(publicKey, secretKey);
  37401. return nacl.secretbox.open(msg, nonce, k);
  37402. };
  37403. nacl.box.open.after = nacl.secretbox.open;
  37404. nacl.box.keyPair = function() {
  37405. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37406. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37407. crypto_box_keypair(pk, sk);
  37408. return {publicKey: pk, secretKey: sk};
  37409. };
  37410. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37411. checkArrayTypes(secretKey);
  37412. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37413. throw new Error('bad secret key size');
  37414. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37415. crypto_scalarmult_base(pk, secretKey);
  37416. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37417. };
  37418. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37419. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37420. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37421. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37422. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37423. nacl.sign = function(msg, secretKey) {
  37424. checkArrayTypes(msg, secretKey);
  37425. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37426. throw new Error('bad secret key size');
  37427. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37428. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37429. return signedMsg;
  37430. };
  37431. nacl.sign.open = function(signedMsg, publicKey) {
  37432. checkArrayTypes(signedMsg, publicKey);
  37433. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37434. throw new Error('bad public key size');
  37435. var tmp = new Uint8Array(signedMsg.length);
  37436. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37437. if (mlen < 0) return null;
  37438. var m = new Uint8Array(mlen);
  37439. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37440. return m;
  37441. };
  37442. nacl.sign.detached = function(msg, secretKey) {
  37443. var signedMsg = nacl.sign(msg, secretKey);
  37444. var sig = new Uint8Array(crypto_sign_BYTES);
  37445. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37446. return sig;
  37447. };
  37448. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37449. checkArrayTypes(msg, sig, publicKey);
  37450. if (sig.length !== crypto_sign_BYTES)
  37451. throw new Error('bad signature size');
  37452. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37453. throw new Error('bad public key size');
  37454. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37455. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37456. var i;
  37457. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37458. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37459. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37460. };
  37461. nacl.sign.keyPair = function() {
  37462. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37463. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37464. crypto_sign_keypair(pk, sk);
  37465. return {publicKey: pk, secretKey: sk};
  37466. };
  37467. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37468. checkArrayTypes(secretKey);
  37469. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37470. throw new Error('bad secret key size');
  37471. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37472. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37473. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37474. };
  37475. nacl.sign.keyPair.fromSeed = function(seed) {
  37476. checkArrayTypes(seed);
  37477. if (seed.length !== crypto_sign_SEEDBYTES)
  37478. throw new Error('bad seed size');
  37479. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37480. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37481. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37482. crypto_sign_keypair(pk, sk, true);
  37483. return {publicKey: pk, secretKey: sk};
  37484. };
  37485. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37486. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37487. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37488. nacl.sign.signatureLength = crypto_sign_BYTES;
  37489. nacl.hash = function(msg) {
  37490. checkArrayTypes(msg);
  37491. var h = new Uint8Array(crypto_hash_BYTES);
  37492. crypto_hash(h, msg, msg.length);
  37493. return h;
  37494. };
  37495. nacl.hash.hashLength = crypto_hash_BYTES;
  37496. nacl.verify = function(x, y) {
  37497. checkArrayTypes(x, y);
  37498. // Zero length arguments are considered not equal.
  37499. if (x.length === 0 || y.length === 0) return false;
  37500. if (x.length !== y.length) return false;
  37501. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37502. };
  37503. nacl.setPRNG = function(fn) {
  37504. randombytes = fn;
  37505. };
  37506. (function() {
  37507. // Initialize PRNG if environment provides CSPRNG.
  37508. // If not, methods calling randombytes will throw.
  37509. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37510. if (crypto && crypto.getRandomValues) {
  37511. // Browsers.
  37512. var QUOTA = 65536;
  37513. nacl.setPRNG(function(x, n) {
  37514. var i, v = new Uint8Array(n);
  37515. for (i = 0; i < n; i += QUOTA) {
  37516. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37517. }
  37518. for (i = 0; i < n; i++) x[i] = v[i];
  37519. cleanup(v);
  37520. });
  37521. } else if (true) {
  37522. // Node.js.
  37523. crypto = __webpack_require__(3);
  37524. if (crypto && crypto.randomBytes) {
  37525. nacl.setPRNG(function(x, n) {
  37526. var i, v = crypto.randomBytes(n);
  37527. for (i = 0; i < n; i++) x[i] = v[i];
  37528. cleanup(v);
  37529. });
  37530. }
  37531. }
  37532. })();
  37533. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37534. /***/ }),
  37535. /* 1 */
  37536. /***/ (function(module, exports, __webpack_require__) {
  37537. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37538. // Public domain.
  37539. (function(root, f) {
  37540. 'use strict';
  37541. if ( true && module.exports) module.exports = f();
  37542. else if (root.nacl) root.nacl.util = f();
  37543. else {
  37544. root.nacl = {};
  37545. root.nacl.util = f();
  37546. }
  37547. }(this, function() {
  37548. 'use strict';
  37549. var util = {};
  37550. function validateBase64(s) {
  37551. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37552. throw new TypeError('invalid encoding');
  37553. }
  37554. }
  37555. util.decodeUTF8 = function(s) {
  37556. if (typeof s !== 'string') throw new TypeError('expected string');
  37557. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37558. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37559. return b;
  37560. };
  37561. util.encodeUTF8 = function(arr) {
  37562. var i, s = [];
  37563. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37564. return decodeURIComponent(escape(s.join('')));
  37565. };
  37566. if (typeof atob === 'undefined') {
  37567. // Node.js
  37568. if (typeof Buffer.from !== 'undefined') {
  37569. // Node v6 and later
  37570. util.encodeBase64 = function (arr) { // v6 and later
  37571. return Buffer.from(arr).toString('base64');
  37572. };
  37573. util.decodeBase64 = function (s) {
  37574. validateBase64(s);
  37575. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37576. };
  37577. } else {
  37578. // Node earlier than v6
  37579. util.encodeBase64 = function (arr) { // v6 and later
  37580. return (new Buffer(arr)).toString('base64');
  37581. };
  37582. util.decodeBase64 = function(s) {
  37583. validateBase64(s);
  37584. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37585. };
  37586. }
  37587. } else {
  37588. // Browsers
  37589. util.encodeBase64 = function(arr) {
  37590. var i, s = [], len = arr.length;
  37591. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37592. return btoa(s.join(''));
  37593. };
  37594. util.decodeBase64 = function(s) {
  37595. validateBase64(s);
  37596. var i, d = atob(s), b = new Uint8Array(d.length);
  37597. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37598. return b;
  37599. };
  37600. }
  37601. return util;
  37602. }));
  37603. /***/ }),
  37604. /* 2 */
  37605. /***/ (function(module, exports, __webpack_require__) {
  37606. // required so we don't have to do require('pusher').default etc.
  37607. module.exports = __webpack_require__(4).default;
  37608. /***/ }),
  37609. /* 3 */
  37610. /***/ (function(module, exports) {
  37611. /* (ignored) */
  37612. /***/ }),
  37613. /* 4 */
  37614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37615. "use strict";
  37616. __webpack_require__.r(__webpack_exports__);
  37617. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37618. var ScriptReceiverFactory = (function () {
  37619. function ScriptReceiverFactory(prefix, name) {
  37620. this.lastId = 0;
  37621. this.prefix = prefix;
  37622. this.name = name;
  37623. }
  37624. ScriptReceiverFactory.prototype.create = function (callback) {
  37625. this.lastId++;
  37626. var number = this.lastId;
  37627. var id = this.prefix + number;
  37628. var name = this.name + "[" + number + "]";
  37629. var called = false;
  37630. var callbackWrapper = function () {
  37631. if (!called) {
  37632. callback.apply(null, arguments);
  37633. called = true;
  37634. }
  37635. };
  37636. this[number] = callbackWrapper;
  37637. return { number: number, id: id, name: name, callback: callbackWrapper };
  37638. };
  37639. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37640. delete this[receiver.number];
  37641. };
  37642. return ScriptReceiverFactory;
  37643. }());
  37644. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37645. // CONCATENATED MODULE: ./src/core/defaults.ts
  37646. var Defaults = {
  37647. VERSION: "5.0.3",
  37648. PROTOCOL: 7,
  37649. host: 'ws.pusherapp.com',
  37650. ws_port: 80,
  37651. wss_port: 443,
  37652. ws_path: '',
  37653. sockjs_host: 'sockjs.pusher.com',
  37654. sockjs_http_port: 80,
  37655. sockjs_https_port: 443,
  37656. sockjs_path: '/pusher',
  37657. stats_host: 'stats.pusher.com',
  37658. channel_auth_endpoint: '/pusher/auth',
  37659. channel_auth_transport: 'ajax',
  37660. activity_timeout: 120000,
  37661. pong_timeout: 30000,
  37662. unavailable_timeout: 10000,
  37663. cdn_http: "http://js.pusher.com",
  37664. cdn_https: "https://js.pusher.com",
  37665. dependency_suffix: ""
  37666. };
  37667. /* harmony default export */ var defaults = (Defaults);
  37668. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37669. var dependency_loader_DependencyLoader = (function () {
  37670. function DependencyLoader(options) {
  37671. this.options = options;
  37672. this.receivers = options.receivers || ScriptReceivers;
  37673. this.loading = {};
  37674. }
  37675. DependencyLoader.prototype.load = function (name, options, callback) {
  37676. var self = this;
  37677. if (self.loading[name] && self.loading[name].length > 0) {
  37678. self.loading[name].push(callback);
  37679. }
  37680. else {
  37681. self.loading[name] = [callback];
  37682. var request = runtime.createScriptRequest(self.getPath(name, options));
  37683. var receiver = self.receivers.create(function (error) {
  37684. self.receivers.remove(receiver);
  37685. if (self.loading[name]) {
  37686. var callbacks = self.loading[name];
  37687. delete self.loading[name];
  37688. var successCallback = function (wasSuccessful) {
  37689. if (!wasSuccessful) {
  37690. request.cleanup();
  37691. }
  37692. };
  37693. for (var i = 0; i < callbacks.length; i++) {
  37694. callbacks[i](error, successCallback);
  37695. }
  37696. }
  37697. });
  37698. request.send(receiver);
  37699. }
  37700. };
  37701. DependencyLoader.prototype.getRoot = function (options) {
  37702. var cdn;
  37703. var protocol = runtime.getDocument().location.protocol;
  37704. if ((options && options.useTLS) || protocol === "https:") {
  37705. cdn = this.options.cdn_https;
  37706. }
  37707. else {
  37708. cdn = this.options.cdn_http;
  37709. }
  37710. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37711. };
  37712. DependencyLoader.prototype.getPath = function (name, options) {
  37713. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37714. };
  37715. ;
  37716. return DependencyLoader;
  37717. }());
  37718. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37719. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37720. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37721. var Dependencies = new dependency_loader({
  37722. cdn_http: defaults.cdn_http,
  37723. cdn_https: defaults.cdn_https,
  37724. version: defaults.VERSION,
  37725. suffix: defaults.dependency_suffix,
  37726. receivers: DependenciesReceivers
  37727. });
  37728. // CONCATENATED MODULE: ./src/core/base64.ts
  37729. function encode(s) {
  37730. return btoa(utob(s));
  37731. }
  37732. var fromCharCode = String.fromCharCode;
  37733. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37734. var b64tab = {};
  37735. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37736. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37737. }
  37738. var cb_utob = function (c) {
  37739. var cc = c.charCodeAt(0);
  37740. return cc < 0x80
  37741. ? c
  37742. : cc < 0x800
  37743. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37744. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37745. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37746. fromCharCode(0x80 | (cc & 0x3f));
  37747. };
  37748. var utob = function (u) {
  37749. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37750. };
  37751. var cb_encode = function (ccc) {
  37752. var padlen = [0, 2, 1][ccc.length % 3];
  37753. var ord = (ccc.charCodeAt(0) << 16) |
  37754. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37755. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37756. var chars = [
  37757. b64chars.charAt(ord >>> 18),
  37758. b64chars.charAt((ord >>> 12) & 63),
  37759. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37760. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37761. ];
  37762. return chars.join('');
  37763. };
  37764. var btoa = window.btoa ||
  37765. function (b) {
  37766. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37767. };
  37768. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37769. var Timer = (function () {
  37770. function Timer(set, clear, delay, callback) {
  37771. var _this = this;
  37772. this.clear = clear;
  37773. this.timer = set(function () {
  37774. if (_this.timer) {
  37775. _this.timer = callback(_this.timer);
  37776. }
  37777. }, delay);
  37778. }
  37779. Timer.prototype.isRunning = function () {
  37780. return this.timer !== null;
  37781. };
  37782. Timer.prototype.ensureAborted = function () {
  37783. if (this.timer) {
  37784. this.clear(this.timer);
  37785. this.timer = null;
  37786. }
  37787. };
  37788. return Timer;
  37789. }());
  37790. /* harmony default export */ var abstract_timer = (Timer);
  37791. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37792. var __extends = (undefined && undefined.__extends) || (function () {
  37793. var extendStatics = function (d, b) {
  37794. extendStatics = Object.setPrototypeOf ||
  37795. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37796. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37797. return extendStatics(d, b);
  37798. };
  37799. return function (d, b) {
  37800. extendStatics(d, b);
  37801. function __() { this.constructor = d; }
  37802. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37803. };
  37804. })();
  37805. function timers_clearTimeout(timer) {
  37806. window.clearTimeout(timer);
  37807. }
  37808. function timers_clearInterval(timer) {
  37809. window.clearInterval(timer);
  37810. }
  37811. var OneOffTimer = (function (_super) {
  37812. __extends(OneOffTimer, _super);
  37813. function OneOffTimer(delay, callback) {
  37814. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37815. callback();
  37816. return null;
  37817. }) || this;
  37818. }
  37819. return OneOffTimer;
  37820. }(abstract_timer));
  37821. var PeriodicTimer = (function (_super) {
  37822. __extends(PeriodicTimer, _super);
  37823. function PeriodicTimer(delay, callback) {
  37824. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37825. callback();
  37826. return timer;
  37827. }) || this;
  37828. }
  37829. return PeriodicTimer;
  37830. }(abstract_timer));
  37831. // CONCATENATED MODULE: ./src/core/util.ts
  37832. var Util = {
  37833. now: function () {
  37834. if (Date.now) {
  37835. return Date.now();
  37836. }
  37837. else {
  37838. return new Date().valueOf();
  37839. }
  37840. },
  37841. defer: function (callback) {
  37842. return new OneOffTimer(0, callback);
  37843. },
  37844. method: function (name) {
  37845. var args = [];
  37846. for (var _i = 1; _i < arguments.length; _i++) {
  37847. args[_i - 1] = arguments[_i];
  37848. }
  37849. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37850. return function (object) {
  37851. return object[name].apply(object, boundArguments.concat(arguments));
  37852. };
  37853. }
  37854. };
  37855. /* harmony default export */ var util = (Util);
  37856. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37857. function extend(target) {
  37858. var sources = [];
  37859. for (var _i = 1; _i < arguments.length; _i++) {
  37860. sources[_i - 1] = arguments[_i];
  37861. }
  37862. for (var i = 0; i < sources.length; i++) {
  37863. var extensions = sources[i];
  37864. for (var property in extensions) {
  37865. if (extensions[property] && extensions[property].constructor &&
  37866. extensions[property].constructor === Object) {
  37867. target[property] = extend(target[property] || {}, extensions[property]);
  37868. }
  37869. else {
  37870. target[property] = extensions[property];
  37871. }
  37872. }
  37873. }
  37874. return target;
  37875. }
  37876. function stringify() {
  37877. var m = ["Pusher"];
  37878. for (var i = 0; i < arguments.length; i++) {
  37879. if (typeof arguments[i] === "string") {
  37880. m.push(arguments[i]);
  37881. }
  37882. else {
  37883. m.push(safeJSONStringify(arguments[i]));
  37884. }
  37885. }
  37886. return m.join(" : ");
  37887. }
  37888. function arrayIndexOf(array, item) {
  37889. var nativeIndexOf = Array.prototype.indexOf;
  37890. if (array === null) {
  37891. return -1;
  37892. }
  37893. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37894. return array.indexOf(item);
  37895. }
  37896. for (var i = 0, l = array.length; i < l; i++) {
  37897. if (array[i] === item) {
  37898. return i;
  37899. }
  37900. }
  37901. return -1;
  37902. }
  37903. function objectApply(object, f) {
  37904. for (var key in object) {
  37905. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37906. f(object[key], key, object);
  37907. }
  37908. }
  37909. }
  37910. function keys(object) {
  37911. var keys = [];
  37912. objectApply(object, function (_, key) {
  37913. keys.push(key);
  37914. });
  37915. return keys;
  37916. }
  37917. function values(object) {
  37918. var values = [];
  37919. objectApply(object, function (value) {
  37920. values.push(value);
  37921. });
  37922. return values;
  37923. }
  37924. function apply(array, f, context) {
  37925. for (var i = 0; i < array.length; i++) {
  37926. f.call(context || window, array[i], i, array);
  37927. }
  37928. }
  37929. function map(array, f) {
  37930. var result = [];
  37931. for (var i = 0; i < array.length; i++) {
  37932. result.push(f(array[i], i, array, result));
  37933. }
  37934. return result;
  37935. }
  37936. function mapObject(object, f) {
  37937. var result = {};
  37938. objectApply(object, function (value, key) {
  37939. result[key] = f(value);
  37940. });
  37941. return result;
  37942. }
  37943. function filter(array, test) {
  37944. test = test || function (value) { return !!value; };
  37945. var result = [];
  37946. for (var i = 0; i < array.length; i++) {
  37947. if (test(array[i], i, array, result)) {
  37948. result.push(array[i]);
  37949. }
  37950. }
  37951. return result;
  37952. }
  37953. function filterObject(object, test) {
  37954. var result = {};
  37955. objectApply(object, function (value, key) {
  37956. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37957. result[key] = value;
  37958. }
  37959. });
  37960. return result;
  37961. }
  37962. function flatten(object) {
  37963. var result = [];
  37964. objectApply(object, function (value, key) {
  37965. result.push([key, value]);
  37966. });
  37967. return result;
  37968. }
  37969. function any(array, test) {
  37970. for (var i = 0; i < array.length; i++) {
  37971. if (test(array[i], i, array)) {
  37972. return true;
  37973. }
  37974. }
  37975. return false;
  37976. }
  37977. function collections_all(array, test) {
  37978. for (var i = 0; i < array.length; i++) {
  37979. if (!test(array[i], i, array)) {
  37980. return false;
  37981. }
  37982. }
  37983. return true;
  37984. }
  37985. function encodeParamsObject(data) {
  37986. return mapObject(data, function (value) {
  37987. if (typeof value === "object") {
  37988. value = safeJSONStringify(value);
  37989. }
  37990. return encodeURIComponent(encode(value.toString()));
  37991. });
  37992. }
  37993. function buildQueryString(data) {
  37994. var params = filterObject(data, function (value) {
  37995. return value !== undefined;
  37996. });
  37997. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  37998. return query;
  37999. }
  38000. function decycleObject(object) {
  38001. var objects = [], paths = [];
  38002. return (function derez(value, path) {
  38003. var i, name, nu;
  38004. switch (typeof value) {
  38005. case 'object':
  38006. if (!value) {
  38007. return null;
  38008. }
  38009. for (i = 0; i < objects.length; i += 1) {
  38010. if (objects[i] === value) {
  38011. return { $ref: paths[i] };
  38012. }
  38013. }
  38014. objects.push(value);
  38015. paths.push(path);
  38016. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38017. nu = [];
  38018. for (i = 0; i < value.length; i += 1) {
  38019. nu[i] = derez(value[i], path + '[' + i + ']');
  38020. }
  38021. }
  38022. else {
  38023. nu = {};
  38024. for (name in value) {
  38025. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38026. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38027. }
  38028. }
  38029. }
  38030. return nu;
  38031. case 'number':
  38032. case 'string':
  38033. case 'boolean':
  38034. return value;
  38035. }
  38036. }(object, '$'));
  38037. }
  38038. function safeJSONStringify(source) {
  38039. try {
  38040. return JSON.stringify(source);
  38041. }
  38042. catch (e) {
  38043. return JSON.stringify(decycleObject(source));
  38044. }
  38045. }
  38046. // CONCATENATED MODULE: ./src/core/logger.ts
  38047. var logger_Logger = (function () {
  38048. function Logger() {
  38049. this.globalLog = function (message) {
  38050. if (window.console && window.console.log) {
  38051. window.console.log(message);
  38052. }
  38053. };
  38054. }
  38055. Logger.prototype.debug = function () {
  38056. var args = [];
  38057. for (var _i = 0; _i < arguments.length; _i++) {
  38058. args[_i] = arguments[_i];
  38059. }
  38060. this.log(this.globalLog, args);
  38061. };
  38062. Logger.prototype.warn = function () {
  38063. var args = [];
  38064. for (var _i = 0; _i < arguments.length; _i++) {
  38065. args[_i] = arguments[_i];
  38066. }
  38067. this.log(this.globalLogWarn, args);
  38068. };
  38069. Logger.prototype.error = function () {
  38070. var args = [];
  38071. for (var _i = 0; _i < arguments.length; _i++) {
  38072. args[_i] = arguments[_i];
  38073. }
  38074. this.log(this.globalLogError, args);
  38075. };
  38076. Logger.prototype.globalLogWarn = function (message) {
  38077. if (window.console && window.console.warn) {
  38078. window.console.warn(message);
  38079. }
  38080. else {
  38081. this.globalLog(message);
  38082. }
  38083. };
  38084. Logger.prototype.globalLogError = function (message) {
  38085. if (window.console && window.console.error) {
  38086. window.console.error(message);
  38087. }
  38088. else {
  38089. this.globalLogWarn(message);
  38090. }
  38091. };
  38092. Logger.prototype.log = function (defaultLoggingFunction) {
  38093. var args = [];
  38094. for (var _i = 1; _i < arguments.length; _i++) {
  38095. args[_i - 1] = arguments[_i];
  38096. }
  38097. var message = stringify.apply(this, arguments);
  38098. if (core_pusher.log) {
  38099. core_pusher.log(message);
  38100. }
  38101. else if (core_pusher.logToConsole) {
  38102. var log = defaultLoggingFunction.bind(this);
  38103. log(message);
  38104. }
  38105. };
  38106. return Logger;
  38107. }());
  38108. /* harmony default export */ var logger = (new logger_Logger());
  38109. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38110. var urlStore = {
  38111. baseUrl: "https://pusher.com",
  38112. urls: {
  38113. authenticationEndpoint: {
  38114. path: "/docs/authenticating_users",
  38115. },
  38116. javascriptQuickStart: {
  38117. path: "/docs/javascript_quick_start"
  38118. },
  38119. triggeringClientEvents: {
  38120. path: "/docs/client_api_guide/client_events#trigger-events"
  38121. }
  38122. }
  38123. };
  38124. var buildLogSuffix = function (key) {
  38125. var urlPrefix = "See:";
  38126. var urlObj = urlStore.urls[key];
  38127. if (!urlObj)
  38128. return "";
  38129. var url;
  38130. if (urlObj.fullUrl) {
  38131. url = urlObj.fullUrl;
  38132. }
  38133. else if (urlObj.path) {
  38134. url = urlStore.baseUrl + urlObj.path;
  38135. }
  38136. if (!url)
  38137. return "";
  38138. return urlPrefix + " " + url;
  38139. };
  38140. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38141. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38142. var ajax = function (context, socketId, callback) {
  38143. var self = this, xhr;
  38144. xhr = runtime.createXHR();
  38145. xhr.open("POST", self.options.authEndpoint, true);
  38146. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38147. for (var headerName in this.authOptions.headers) {
  38148. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38149. }
  38150. xhr.onreadystatechange = function () {
  38151. if (xhr.readyState === 4) {
  38152. if (xhr.status === 200) {
  38153. var data, parsed = false;
  38154. try {
  38155. data = JSON.parse(xhr.responseText);
  38156. parsed = true;
  38157. }
  38158. catch (e) {
  38159. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38160. }
  38161. if (parsed) {
  38162. callback(false, data);
  38163. }
  38164. }
  38165. else {
  38166. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38167. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38168. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38169. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38170. callback(true, xhr.status);
  38171. }
  38172. }
  38173. };
  38174. xhr.send(this.composeQuery(socketId));
  38175. return xhr;
  38176. };
  38177. /* harmony default export */ var xhr_auth = (ajax);
  38178. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38179. var jsonp = function (context, socketId, callback) {
  38180. if (this.authOptions.headers !== undefined) {
  38181. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38182. }
  38183. var callbackName = context.nextAuthCallbackID.toString();
  38184. context.nextAuthCallbackID++;
  38185. var document = context.getDocument();
  38186. var script = document.createElement("script");
  38187. context.auth_callbacks[callbackName] = function (data) {
  38188. callback(false, data);
  38189. };
  38190. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38191. script.src = this.options.authEndpoint +
  38192. '?callback=' +
  38193. encodeURIComponent(callback_name) +
  38194. '&' +
  38195. this.composeQuery(socketId);
  38196. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38197. head.insertBefore(script, head.firstChild);
  38198. };
  38199. /* harmony default export */ var jsonp_auth = (jsonp);
  38200. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38201. var ScriptRequest = (function () {
  38202. function ScriptRequest(src) {
  38203. this.src = src;
  38204. }
  38205. ScriptRequest.prototype.send = function (receiver) {
  38206. var self = this;
  38207. var errorString = "Error loading " + self.src;
  38208. self.script = document.createElement("script");
  38209. self.script.id = receiver.id;
  38210. self.script.src = self.src;
  38211. self.script.type = "text/javascript";
  38212. self.script.charset = "UTF-8";
  38213. if (self.script.addEventListener) {
  38214. self.script.onerror = function () {
  38215. receiver.callback(errorString);
  38216. };
  38217. self.script.onload = function () {
  38218. receiver.callback(null);
  38219. };
  38220. }
  38221. else {
  38222. self.script.onreadystatechange = function () {
  38223. if (self.script.readyState === 'loaded' ||
  38224. self.script.readyState === 'complete') {
  38225. receiver.callback(null);
  38226. }
  38227. };
  38228. }
  38229. if (self.script.async === undefined && document.attachEvent &&
  38230. /opera/i.test(navigator.userAgent)) {
  38231. self.errorScript = document.createElement("script");
  38232. self.errorScript.id = receiver.id + "_error";
  38233. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38234. self.script.async = self.errorScript.async = false;
  38235. }
  38236. else {
  38237. self.script.async = true;
  38238. }
  38239. var head = document.getElementsByTagName('head')[0];
  38240. head.insertBefore(self.script, head.firstChild);
  38241. if (self.errorScript) {
  38242. head.insertBefore(self.errorScript, self.script.nextSibling);
  38243. }
  38244. };
  38245. ScriptRequest.prototype.cleanup = function () {
  38246. if (this.script) {
  38247. this.script.onload = this.script.onerror = null;
  38248. this.script.onreadystatechange = null;
  38249. }
  38250. if (this.script && this.script.parentNode) {
  38251. this.script.parentNode.removeChild(this.script);
  38252. }
  38253. if (this.errorScript && this.errorScript.parentNode) {
  38254. this.errorScript.parentNode.removeChild(this.errorScript);
  38255. }
  38256. this.script = null;
  38257. this.errorScript = null;
  38258. };
  38259. return ScriptRequest;
  38260. }());
  38261. /* harmony default export */ var script_request = (ScriptRequest);
  38262. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38263. var jsonp_request_JSONPRequest = (function () {
  38264. function JSONPRequest(url, data) {
  38265. this.url = url;
  38266. this.data = data;
  38267. }
  38268. JSONPRequest.prototype.send = function (receiver) {
  38269. if (this.request) {
  38270. return;
  38271. }
  38272. var query = buildQueryString(this.data);
  38273. var url = this.url + "/" + receiver.number + "?" + query;
  38274. this.request = runtime.createScriptRequest(url);
  38275. this.request.send(receiver);
  38276. };
  38277. JSONPRequest.prototype.cleanup = function () {
  38278. if (this.request) {
  38279. this.request.cleanup();
  38280. }
  38281. };
  38282. return JSONPRequest;
  38283. }());
  38284. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38285. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38286. var getAgent = function (sender, useTLS) {
  38287. return function (data, callback) {
  38288. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38289. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38290. var request = runtime.createJSONPRequest(url, data);
  38291. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38292. ScriptReceivers.remove(receiver);
  38293. request.cleanup();
  38294. if (result && result.host) {
  38295. sender.host = result.host;
  38296. }
  38297. if (callback) {
  38298. callback(error, result);
  38299. }
  38300. });
  38301. request.send(receiver);
  38302. };
  38303. };
  38304. var jsonp_timeline_jsonp = {
  38305. name: 'jsonp',
  38306. getAgent: getAgent
  38307. };
  38308. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38309. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38310. function getGenericURL(baseScheme, params, path) {
  38311. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38312. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38313. return scheme + "://" + host + path;
  38314. }
  38315. function getGenericPath(key, queryString) {
  38316. var path = "/app/" + key;
  38317. var query = "?protocol=" + defaults.PROTOCOL +
  38318. "&client=js" +
  38319. "&version=" + defaults.VERSION +
  38320. (queryString ? ("&" + queryString) : "");
  38321. return path + query;
  38322. }
  38323. var ws = {
  38324. getInitial: function (key, params) {
  38325. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38326. return getGenericURL("ws", params, path);
  38327. }
  38328. };
  38329. var http = {
  38330. getInitial: function (key, params) {
  38331. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38332. return getGenericURL("http", params, path);
  38333. }
  38334. };
  38335. var sockjs = {
  38336. getInitial: function (key, params) {
  38337. return getGenericURL("http", params, params.httpPath || "/pusher");
  38338. },
  38339. getPath: function (key, params) {
  38340. return getGenericPath(key);
  38341. }
  38342. };
  38343. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38344. var callback_registry_CallbackRegistry = (function () {
  38345. function CallbackRegistry() {
  38346. this._callbacks = {};
  38347. }
  38348. CallbackRegistry.prototype.get = function (name) {
  38349. return this._callbacks[prefix(name)];
  38350. };
  38351. CallbackRegistry.prototype.add = function (name, callback, context) {
  38352. var prefixedEventName = prefix(name);
  38353. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38354. this._callbacks[prefixedEventName].push({
  38355. fn: callback,
  38356. context: context
  38357. });
  38358. };
  38359. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38360. if (!name && !callback && !context) {
  38361. this._callbacks = {};
  38362. return;
  38363. }
  38364. var names = name ? [prefix(name)] : keys(this._callbacks);
  38365. if (callback || context) {
  38366. this.removeCallback(names, callback, context);
  38367. }
  38368. else {
  38369. this.removeAllCallbacks(names);
  38370. }
  38371. };
  38372. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38373. apply(names, function (name) {
  38374. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38375. return (callback && callback !== binding.fn) ||
  38376. (context && context !== binding.context);
  38377. });
  38378. if (this._callbacks[name].length === 0) {
  38379. delete this._callbacks[name];
  38380. }
  38381. }, this);
  38382. };
  38383. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38384. apply(names, function (name) {
  38385. delete this._callbacks[name];
  38386. }, this);
  38387. };
  38388. return CallbackRegistry;
  38389. }());
  38390. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38391. function prefix(name) {
  38392. return "_" + name;
  38393. }
  38394. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38395. var dispatcher_Dispatcher = (function () {
  38396. function Dispatcher(failThrough) {
  38397. this.callbacks = new callback_registry();
  38398. this.global_callbacks = [];
  38399. this.failThrough = failThrough;
  38400. }
  38401. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38402. this.callbacks.add(eventName, callback, context);
  38403. return this;
  38404. };
  38405. Dispatcher.prototype.bind_global = function (callback) {
  38406. this.global_callbacks.push(callback);
  38407. return this;
  38408. };
  38409. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38410. this.callbacks.remove(eventName, callback, context);
  38411. return this;
  38412. };
  38413. Dispatcher.prototype.unbind_global = function (callback) {
  38414. if (!callback) {
  38415. this.global_callbacks = [];
  38416. return this;
  38417. }
  38418. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38419. return this;
  38420. };
  38421. Dispatcher.prototype.unbind_all = function () {
  38422. this.unbind();
  38423. this.unbind_global();
  38424. return this;
  38425. };
  38426. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38427. for (var i = 0; i < this.global_callbacks.length; i++) {
  38428. this.global_callbacks[i](eventName, data);
  38429. }
  38430. var callbacks = this.callbacks.get(eventName);
  38431. var args = [];
  38432. if (metadata) {
  38433. args.push(data, metadata);
  38434. }
  38435. else if (data) {
  38436. args.push(data);
  38437. }
  38438. if (callbacks && callbacks.length > 0) {
  38439. for (var i = 0; i < callbacks.length; i++) {
  38440. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38441. }
  38442. }
  38443. else if (this.failThrough) {
  38444. this.failThrough(eventName, data);
  38445. }
  38446. return this;
  38447. };
  38448. return Dispatcher;
  38449. }());
  38450. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38451. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38452. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38453. var extendStatics = function (d, b) {
  38454. extendStatics = Object.setPrototypeOf ||
  38455. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38456. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38457. return extendStatics(d, b);
  38458. };
  38459. return function (d, b) {
  38460. extendStatics(d, b);
  38461. function __() { this.constructor = d; }
  38462. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38463. };
  38464. })();
  38465. var transport_connection_TransportConnection = (function (_super) {
  38466. transport_connection_extends(TransportConnection, _super);
  38467. function TransportConnection(hooks, name, priority, key, options) {
  38468. var _this = _super.call(this) || this;
  38469. _this.initialize = runtime.transportConnectionInitializer;
  38470. _this.hooks = hooks;
  38471. _this.name = name;
  38472. _this.priority = priority;
  38473. _this.key = key;
  38474. _this.options = options;
  38475. _this.state = "new";
  38476. _this.timeline = options.timeline;
  38477. _this.activityTimeout = options.activityTimeout;
  38478. _this.id = _this.timeline.generateUniqueID();
  38479. return _this;
  38480. }
  38481. TransportConnection.prototype.handlesActivityChecks = function () {
  38482. return Boolean(this.hooks.handlesActivityChecks);
  38483. };
  38484. TransportConnection.prototype.supportsPing = function () {
  38485. return Boolean(this.hooks.supportsPing);
  38486. };
  38487. TransportConnection.prototype.connect = function () {
  38488. var _this = this;
  38489. if (this.socket || this.state !== "initialized") {
  38490. return false;
  38491. }
  38492. var url = this.hooks.urls.getInitial(this.key, this.options);
  38493. try {
  38494. this.socket = this.hooks.getSocket(url, this.options);
  38495. }
  38496. catch (e) {
  38497. util.defer(function () {
  38498. _this.onError(e);
  38499. _this.changeState("closed");
  38500. });
  38501. return false;
  38502. }
  38503. this.bindListeners();
  38504. logger.debug("Connecting", { transport: this.name, url: url });
  38505. this.changeState("connecting");
  38506. return true;
  38507. };
  38508. TransportConnection.prototype.close = function () {
  38509. if (this.socket) {
  38510. this.socket.close();
  38511. return true;
  38512. }
  38513. else {
  38514. return false;
  38515. }
  38516. };
  38517. TransportConnection.prototype.send = function (data) {
  38518. var _this = this;
  38519. if (this.state === "open") {
  38520. util.defer(function () {
  38521. if (_this.socket) {
  38522. _this.socket.send(data);
  38523. }
  38524. });
  38525. return true;
  38526. }
  38527. else {
  38528. return false;
  38529. }
  38530. };
  38531. TransportConnection.prototype.ping = function () {
  38532. if (this.state === "open" && this.supportsPing()) {
  38533. this.socket.ping();
  38534. }
  38535. };
  38536. TransportConnection.prototype.onOpen = function () {
  38537. if (this.hooks.beforeOpen) {
  38538. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38539. }
  38540. this.changeState("open");
  38541. this.socket.onopen = undefined;
  38542. };
  38543. TransportConnection.prototype.onError = function (error) {
  38544. this.emit("error", { type: 'WebSocketError', error: error });
  38545. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38546. };
  38547. TransportConnection.prototype.onClose = function (closeEvent) {
  38548. if (closeEvent) {
  38549. this.changeState("closed", {
  38550. code: closeEvent.code,
  38551. reason: closeEvent.reason,
  38552. wasClean: closeEvent.wasClean
  38553. });
  38554. }
  38555. else {
  38556. this.changeState("closed");
  38557. }
  38558. this.unbindListeners();
  38559. this.socket = undefined;
  38560. };
  38561. TransportConnection.prototype.onMessage = function (message) {
  38562. this.emit("message", message);
  38563. };
  38564. TransportConnection.prototype.onActivity = function () {
  38565. this.emit("activity");
  38566. };
  38567. TransportConnection.prototype.bindListeners = function () {
  38568. var _this = this;
  38569. this.socket.onopen = function () {
  38570. _this.onOpen();
  38571. };
  38572. this.socket.onerror = function (error) {
  38573. _this.onError(error);
  38574. };
  38575. this.socket.onclose = function (closeEvent) {
  38576. _this.onClose(closeEvent);
  38577. };
  38578. this.socket.onmessage = function (message) {
  38579. _this.onMessage(message);
  38580. };
  38581. if (this.supportsPing()) {
  38582. this.socket.onactivity = function () { _this.onActivity(); };
  38583. }
  38584. };
  38585. TransportConnection.prototype.unbindListeners = function () {
  38586. if (this.socket) {
  38587. this.socket.onopen = undefined;
  38588. this.socket.onerror = undefined;
  38589. this.socket.onclose = undefined;
  38590. this.socket.onmessage = undefined;
  38591. if (this.supportsPing()) {
  38592. this.socket.onactivity = undefined;
  38593. }
  38594. }
  38595. };
  38596. TransportConnection.prototype.changeState = function (state, params) {
  38597. this.state = state;
  38598. this.timeline.info(this.buildTimelineMessage({
  38599. state: state,
  38600. params: params
  38601. }));
  38602. this.emit(state, params);
  38603. };
  38604. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38605. return extend({ cid: this.id }, message);
  38606. };
  38607. return TransportConnection;
  38608. }(dispatcher));
  38609. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38610. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38611. var transport_Transport = (function () {
  38612. function Transport(hooks) {
  38613. this.hooks = hooks;
  38614. }
  38615. Transport.prototype.isSupported = function (environment) {
  38616. return this.hooks.isSupported(environment);
  38617. };
  38618. Transport.prototype.createConnection = function (name, priority, key, options) {
  38619. return new transport_connection(this.hooks, name, priority, key, options);
  38620. };
  38621. return Transport;
  38622. }());
  38623. /* harmony default export */ var transports_transport = (transport_Transport);
  38624. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38625. var WSTransport = new transports_transport({
  38626. urls: ws,
  38627. handlesActivityChecks: false,
  38628. supportsPing: false,
  38629. isInitialized: function () {
  38630. return Boolean(runtime.getWebSocketAPI());
  38631. },
  38632. isSupported: function () {
  38633. return Boolean(runtime.getWebSocketAPI());
  38634. },
  38635. getSocket: function (url) {
  38636. return runtime.createWebSocket(url);
  38637. }
  38638. });
  38639. var httpConfiguration = {
  38640. urls: http,
  38641. handlesActivityChecks: false,
  38642. supportsPing: true,
  38643. isInitialized: function () {
  38644. return true;
  38645. }
  38646. };
  38647. var streamingConfiguration = extend({ getSocket: function (url) {
  38648. return runtime.HTTPFactory.createStreamingSocket(url);
  38649. }
  38650. }, httpConfiguration);
  38651. var pollingConfiguration = extend({ getSocket: function (url) {
  38652. return runtime.HTTPFactory.createPollingSocket(url);
  38653. }
  38654. }, httpConfiguration);
  38655. var xhrConfiguration = {
  38656. isSupported: function () {
  38657. return runtime.isXHRSupported();
  38658. }
  38659. };
  38660. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38661. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38662. var Transports = {
  38663. ws: WSTransport,
  38664. xhr_streaming: XHRStreamingTransport,
  38665. xhr_polling: XHRPollingTransport
  38666. };
  38667. /* harmony default export */ var transports = (Transports);
  38668. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38669. var SockJSTransport = new transports_transport({
  38670. file: "sockjs",
  38671. urls: sockjs,
  38672. handlesActivityChecks: true,
  38673. supportsPing: false,
  38674. isSupported: function () {
  38675. return true;
  38676. },
  38677. isInitialized: function () {
  38678. return window.SockJS !== undefined;
  38679. },
  38680. getSocket: function (url, options) {
  38681. return new window.SockJS(url, null, {
  38682. js_path: Dependencies.getPath("sockjs", {
  38683. useTLS: options.useTLS
  38684. }),
  38685. ignore_null_origin: options.ignoreNullOrigin
  38686. });
  38687. },
  38688. beforeOpen: function (socket, path) {
  38689. socket.send(JSON.stringify({
  38690. path: path
  38691. }));
  38692. }
  38693. });
  38694. var xdrConfiguration = {
  38695. isSupported: function (environment) {
  38696. var yes = runtime.isXDRSupported(environment.useTLS);
  38697. return yes;
  38698. }
  38699. };
  38700. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38701. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38702. transports.xdr_streaming = XDRStreamingTransport;
  38703. transports.xdr_polling = XDRPollingTransport;
  38704. transports.sockjs = SockJSTransport;
  38705. /* harmony default export */ var transports_transports = (transports);
  38706. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38707. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38708. var extendStatics = function (d, b) {
  38709. extendStatics = Object.setPrototypeOf ||
  38710. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38711. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38712. return extendStatics(d, b);
  38713. };
  38714. return function (d, b) {
  38715. extendStatics(d, b);
  38716. function __() { this.constructor = d; }
  38717. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38718. };
  38719. })();
  38720. var NetInfo = (function (_super) {
  38721. net_info_extends(NetInfo, _super);
  38722. function NetInfo() {
  38723. var _this = _super.call(this) || this;
  38724. var self = _this;
  38725. if (window.addEventListener !== undefined) {
  38726. window.addEventListener("online", function () {
  38727. self.emit('online');
  38728. }, false);
  38729. window.addEventListener("offline", function () {
  38730. self.emit('offline');
  38731. }, false);
  38732. }
  38733. return _this;
  38734. }
  38735. NetInfo.prototype.isOnline = function () {
  38736. if (window.navigator.onLine === undefined) {
  38737. return true;
  38738. }
  38739. else {
  38740. return window.navigator.onLine;
  38741. }
  38742. };
  38743. return NetInfo;
  38744. }(dispatcher));
  38745. var net_info_Network = new NetInfo();
  38746. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38747. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38748. function AssistantToTheTransportManager(manager, transport, options) {
  38749. this.manager = manager;
  38750. this.transport = transport;
  38751. this.minPingDelay = options.minPingDelay;
  38752. this.maxPingDelay = options.maxPingDelay;
  38753. this.pingDelay = undefined;
  38754. }
  38755. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38756. var _this = this;
  38757. options = extend({}, options, {
  38758. activityTimeout: this.pingDelay
  38759. });
  38760. var connection = this.transport.createConnection(name, priority, key, options);
  38761. var openTimestamp = null;
  38762. var onOpen = function () {
  38763. connection.unbind("open", onOpen);
  38764. connection.bind("closed", onClosed);
  38765. openTimestamp = util.now();
  38766. };
  38767. var onClosed = function (closeEvent) {
  38768. connection.unbind("closed", onClosed);
  38769. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38770. _this.manager.reportDeath();
  38771. }
  38772. else if (!closeEvent.wasClean && openTimestamp) {
  38773. var lifespan = util.now() - openTimestamp;
  38774. if (lifespan < 2 * _this.maxPingDelay) {
  38775. _this.manager.reportDeath();
  38776. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38777. }
  38778. }
  38779. };
  38780. connection.bind("open", onOpen);
  38781. return connection;
  38782. };
  38783. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38784. return this.manager.isAlive() && this.transport.isSupported(environment);
  38785. };
  38786. return AssistantToTheTransportManager;
  38787. }());
  38788. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38789. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38790. var Protocol = {
  38791. decodeMessage: function (messageEvent) {
  38792. try {
  38793. var messageData = JSON.parse(messageEvent.data);
  38794. var pusherEventData = messageData.data;
  38795. if (typeof pusherEventData === 'string') {
  38796. try {
  38797. pusherEventData = JSON.parse(messageData.data);
  38798. }
  38799. catch (e) { }
  38800. }
  38801. var pusherEvent = {
  38802. event: messageData.event,
  38803. channel: messageData.channel,
  38804. data: pusherEventData,
  38805. };
  38806. if (messageData.user_id) {
  38807. pusherEvent.user_id = messageData.user_id;
  38808. }
  38809. return pusherEvent;
  38810. }
  38811. catch (e) {
  38812. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38813. }
  38814. },
  38815. encodeMessage: function (event) {
  38816. return JSON.stringify(event);
  38817. },
  38818. processHandshake: function (messageEvent) {
  38819. var message = Protocol.decodeMessage(messageEvent);
  38820. if (message.event === "pusher:connection_established") {
  38821. if (!message.data.activity_timeout) {
  38822. throw "No activity timeout specified in handshake";
  38823. }
  38824. return {
  38825. action: "connected",
  38826. id: message.data.socket_id,
  38827. activityTimeout: message.data.activity_timeout * 1000
  38828. };
  38829. }
  38830. else if (message.event === "pusher:error") {
  38831. return {
  38832. action: this.getCloseAction(message.data),
  38833. error: this.getCloseError(message.data)
  38834. };
  38835. }
  38836. else {
  38837. throw "Invalid handshake";
  38838. }
  38839. },
  38840. getCloseAction: function (closeEvent) {
  38841. if (closeEvent.code < 4000) {
  38842. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38843. return "backoff";
  38844. }
  38845. else {
  38846. return null;
  38847. }
  38848. }
  38849. else if (closeEvent.code === 4000) {
  38850. return "tls_only";
  38851. }
  38852. else if (closeEvent.code < 4100) {
  38853. return "refused";
  38854. }
  38855. else if (closeEvent.code < 4200) {
  38856. return "backoff";
  38857. }
  38858. else if (closeEvent.code < 4300) {
  38859. return "retry";
  38860. }
  38861. else {
  38862. return "refused";
  38863. }
  38864. },
  38865. getCloseError: function (closeEvent) {
  38866. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38867. return {
  38868. type: 'PusherError',
  38869. data: {
  38870. code: closeEvent.code,
  38871. message: closeEvent.reason || closeEvent.message
  38872. }
  38873. };
  38874. }
  38875. else {
  38876. return null;
  38877. }
  38878. }
  38879. };
  38880. /* harmony default export */ var protocol_protocol = (Protocol);
  38881. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38882. var connection_extends = (undefined && undefined.__extends) || (function () {
  38883. var extendStatics = function (d, b) {
  38884. extendStatics = Object.setPrototypeOf ||
  38885. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38886. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38887. return extendStatics(d, b);
  38888. };
  38889. return function (d, b) {
  38890. extendStatics(d, b);
  38891. function __() { this.constructor = d; }
  38892. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38893. };
  38894. })();
  38895. var connection_Connection = (function (_super) {
  38896. connection_extends(Connection, _super);
  38897. function Connection(id, transport) {
  38898. var _this = _super.call(this) || this;
  38899. _this.id = id;
  38900. _this.transport = transport;
  38901. _this.activityTimeout = transport.activityTimeout;
  38902. _this.bindListeners();
  38903. return _this;
  38904. }
  38905. Connection.prototype.handlesActivityChecks = function () {
  38906. return this.transport.handlesActivityChecks();
  38907. };
  38908. Connection.prototype.send = function (data) {
  38909. return this.transport.send(data);
  38910. };
  38911. Connection.prototype.send_event = function (name, data, channel) {
  38912. var event = { event: name, data: data };
  38913. if (channel) {
  38914. event.channel = channel;
  38915. }
  38916. logger.debug('Event sent', event);
  38917. return this.send(protocol_protocol.encodeMessage(event));
  38918. };
  38919. Connection.prototype.ping = function () {
  38920. if (this.transport.supportsPing()) {
  38921. this.transport.ping();
  38922. }
  38923. else {
  38924. this.send_event('pusher:ping', {});
  38925. }
  38926. };
  38927. Connection.prototype.close = function () {
  38928. this.transport.close();
  38929. };
  38930. Connection.prototype.bindListeners = function () {
  38931. var _this = this;
  38932. var listeners = {
  38933. message: function (messageEvent) {
  38934. var pusherEvent;
  38935. try {
  38936. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38937. }
  38938. catch (e) {
  38939. _this.emit('error', {
  38940. type: 'MessageParseError',
  38941. error: e,
  38942. data: messageEvent.data
  38943. });
  38944. }
  38945. if (pusherEvent !== undefined) {
  38946. logger.debug('Event recd', pusherEvent);
  38947. switch (pusherEvent.event) {
  38948. case 'pusher:error':
  38949. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38950. break;
  38951. case 'pusher:ping':
  38952. _this.emit("ping");
  38953. break;
  38954. case 'pusher:pong':
  38955. _this.emit("pong");
  38956. break;
  38957. }
  38958. _this.emit('message', pusherEvent);
  38959. }
  38960. },
  38961. activity: function () {
  38962. _this.emit("activity");
  38963. },
  38964. error: function (error) {
  38965. _this.emit("error", { type: "WebSocketError", error: error });
  38966. },
  38967. closed: function (closeEvent) {
  38968. unbindListeners();
  38969. if (closeEvent && closeEvent.code) {
  38970. _this.handleCloseEvent(closeEvent);
  38971. }
  38972. _this.transport = null;
  38973. _this.emit("closed");
  38974. }
  38975. };
  38976. var unbindListeners = function () {
  38977. objectApply(listeners, function (listener, event) {
  38978. _this.transport.unbind(event, listener);
  38979. });
  38980. };
  38981. objectApply(listeners, function (listener, event) {
  38982. _this.transport.bind(event, listener);
  38983. });
  38984. };
  38985. Connection.prototype.handleCloseEvent = function (closeEvent) {
  38986. var action = protocol_protocol.getCloseAction(closeEvent);
  38987. var error = protocol_protocol.getCloseError(closeEvent);
  38988. if (error) {
  38989. this.emit('error', error);
  38990. }
  38991. if (action) {
  38992. this.emit(action, { action: action, error: error });
  38993. }
  38994. };
  38995. return Connection;
  38996. }(dispatcher));
  38997. /* harmony default export */ var connection_connection = (connection_Connection);
  38998. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  38999. var handshake_Handshake = (function () {
  39000. function Handshake(transport, callback) {
  39001. this.transport = transport;
  39002. this.callback = callback;
  39003. this.bindListeners();
  39004. }
  39005. Handshake.prototype.close = function () {
  39006. this.unbindListeners();
  39007. this.transport.close();
  39008. };
  39009. Handshake.prototype.bindListeners = function () {
  39010. var _this = this;
  39011. this.onMessage = function (m) {
  39012. _this.unbindListeners();
  39013. var result;
  39014. try {
  39015. result = protocol_protocol.processHandshake(m);
  39016. }
  39017. catch (e) {
  39018. _this.finish("error", { error: e });
  39019. _this.transport.close();
  39020. return;
  39021. }
  39022. if (result.action === "connected") {
  39023. _this.finish("connected", {
  39024. connection: new connection_connection(result.id, _this.transport),
  39025. activityTimeout: result.activityTimeout
  39026. });
  39027. }
  39028. else {
  39029. _this.finish(result.action, { error: result.error });
  39030. _this.transport.close();
  39031. }
  39032. };
  39033. this.onClosed = function (closeEvent) {
  39034. _this.unbindListeners();
  39035. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39036. var error = protocol_protocol.getCloseError(closeEvent);
  39037. _this.finish(action, { error: error });
  39038. };
  39039. this.transport.bind("message", this.onMessage);
  39040. this.transport.bind("closed", this.onClosed);
  39041. };
  39042. Handshake.prototype.unbindListeners = function () {
  39043. this.transport.unbind("message", this.onMessage);
  39044. this.transport.unbind("closed", this.onClosed);
  39045. };
  39046. Handshake.prototype.finish = function (action, params) {
  39047. this.callback(extend({ transport: this.transport, action: action }, params));
  39048. };
  39049. return Handshake;
  39050. }());
  39051. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39052. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39053. var pusher_authorizer_PusherAuthorizer = (function () {
  39054. function PusherAuthorizer(channel, options) {
  39055. this.channel = channel;
  39056. var authTransport = options.authTransport;
  39057. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39058. throw "'" + authTransport + "' is not a recognized auth transport";
  39059. }
  39060. this.type = authTransport;
  39061. this.options = options;
  39062. this.authOptions = (options || {}).auth || {};
  39063. }
  39064. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39065. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39066. '&channel_name=' + encodeURIComponent(this.channel.name);
  39067. for (var i in this.authOptions.params) {
  39068. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39069. }
  39070. return query;
  39071. };
  39072. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39073. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39074. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39075. };
  39076. return PusherAuthorizer;
  39077. }());
  39078. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39079. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39080. var timeline_sender_TimelineSender = (function () {
  39081. function TimelineSender(timeline, options) {
  39082. this.timeline = timeline;
  39083. this.options = options || {};
  39084. }
  39085. TimelineSender.prototype.send = function (useTLS, callback) {
  39086. if (this.timeline.isEmpty()) {
  39087. return;
  39088. }
  39089. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39090. };
  39091. return TimelineSender;
  39092. }());
  39093. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39094. // CONCATENATED MODULE: ./src/core/errors.ts
  39095. var errors_extends = (undefined && undefined.__extends) || (function () {
  39096. var extendStatics = function (d, b) {
  39097. extendStatics = Object.setPrototypeOf ||
  39098. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39099. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39100. return extendStatics(d, b);
  39101. };
  39102. return function (d, b) {
  39103. extendStatics(d, b);
  39104. function __() { this.constructor = d; }
  39105. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39106. };
  39107. })();
  39108. var BadEventName = (function (_super) {
  39109. errors_extends(BadEventName, _super);
  39110. function BadEventName(msg) {
  39111. var _newTarget = this.constructor;
  39112. var _this = _super.call(this, msg) || this;
  39113. Object.setPrototypeOf(_this, _newTarget.prototype);
  39114. return _this;
  39115. }
  39116. return BadEventName;
  39117. }(Error));
  39118. var RequestTimedOut = (function (_super) {
  39119. errors_extends(RequestTimedOut, _super);
  39120. function RequestTimedOut(msg) {
  39121. var _newTarget = this.constructor;
  39122. var _this = _super.call(this, msg) || this;
  39123. Object.setPrototypeOf(_this, _newTarget.prototype);
  39124. return _this;
  39125. }
  39126. return RequestTimedOut;
  39127. }(Error));
  39128. var TransportPriorityTooLow = (function (_super) {
  39129. errors_extends(TransportPriorityTooLow, _super);
  39130. function TransportPriorityTooLow(msg) {
  39131. var _newTarget = this.constructor;
  39132. var _this = _super.call(this, msg) || this;
  39133. Object.setPrototypeOf(_this, _newTarget.prototype);
  39134. return _this;
  39135. }
  39136. return TransportPriorityTooLow;
  39137. }(Error));
  39138. var TransportClosed = (function (_super) {
  39139. errors_extends(TransportClosed, _super);
  39140. function TransportClosed(msg) {
  39141. var _newTarget = this.constructor;
  39142. var _this = _super.call(this, msg) || this;
  39143. Object.setPrototypeOf(_this, _newTarget.prototype);
  39144. return _this;
  39145. }
  39146. return TransportClosed;
  39147. }(Error));
  39148. var UnsupportedFeature = (function (_super) {
  39149. errors_extends(UnsupportedFeature, _super);
  39150. function UnsupportedFeature(msg) {
  39151. var _newTarget = this.constructor;
  39152. var _this = _super.call(this, msg) || this;
  39153. Object.setPrototypeOf(_this, _newTarget.prototype);
  39154. return _this;
  39155. }
  39156. return UnsupportedFeature;
  39157. }(Error));
  39158. var UnsupportedTransport = (function (_super) {
  39159. errors_extends(UnsupportedTransport, _super);
  39160. function UnsupportedTransport(msg) {
  39161. var _newTarget = this.constructor;
  39162. var _this = _super.call(this, msg) || this;
  39163. Object.setPrototypeOf(_this, _newTarget.prototype);
  39164. return _this;
  39165. }
  39166. return UnsupportedTransport;
  39167. }(Error));
  39168. var UnsupportedStrategy = (function (_super) {
  39169. errors_extends(UnsupportedStrategy, _super);
  39170. function UnsupportedStrategy(msg) {
  39171. var _newTarget = this.constructor;
  39172. var _this = _super.call(this, msg) || this;
  39173. Object.setPrototypeOf(_this, _newTarget.prototype);
  39174. return _this;
  39175. }
  39176. return UnsupportedStrategy;
  39177. }(Error));
  39178. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39179. var channel_extends = (undefined && undefined.__extends) || (function () {
  39180. var extendStatics = function (d, b) {
  39181. extendStatics = Object.setPrototypeOf ||
  39182. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39183. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39184. return extendStatics(d, b);
  39185. };
  39186. return function (d, b) {
  39187. extendStatics(d, b);
  39188. function __() { this.constructor = d; }
  39189. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39190. };
  39191. })();
  39192. var channel_Channel = (function (_super) {
  39193. channel_extends(Channel, _super);
  39194. function Channel(name, pusher) {
  39195. var _this = _super.call(this, function (event, data) {
  39196. logger.debug('No callbacks on ' + name + ' for ' + event);
  39197. }) || this;
  39198. _this.name = name;
  39199. _this.pusher = pusher;
  39200. _this.subscribed = false;
  39201. _this.subscriptionPending = false;
  39202. _this.subscriptionCancelled = false;
  39203. return _this;
  39204. }
  39205. Channel.prototype.authorize = function (socketId, callback) {
  39206. return callback(false, {});
  39207. };
  39208. Channel.prototype.trigger = function (event, data) {
  39209. if (event.indexOf("client-") !== 0) {
  39210. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39211. }
  39212. if (!this.subscribed) {
  39213. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39214. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39215. }
  39216. return this.pusher.send_event(event, data, this.name);
  39217. };
  39218. Channel.prototype.disconnect = function () {
  39219. this.subscribed = false;
  39220. this.subscriptionPending = false;
  39221. };
  39222. Channel.prototype.handleEvent = function (event) {
  39223. var eventName = event.event;
  39224. var data = event.data;
  39225. if (eventName === "pusher_internal:subscription_succeeded") {
  39226. this.handleSubscriptionSucceededEvent(event);
  39227. }
  39228. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39229. var metadata = {};
  39230. this.emit(eventName, data, metadata);
  39231. }
  39232. };
  39233. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39234. this.subscriptionPending = false;
  39235. this.subscribed = true;
  39236. if (this.subscriptionCancelled) {
  39237. this.pusher.unsubscribe(this.name);
  39238. }
  39239. else {
  39240. this.emit("pusher:subscription_succeeded", event.data);
  39241. }
  39242. };
  39243. Channel.prototype.subscribe = function () {
  39244. var _this = this;
  39245. if (this.subscribed) {
  39246. return;
  39247. }
  39248. this.subscriptionPending = true;
  39249. this.subscriptionCancelled = false;
  39250. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39251. if (error) {
  39252. logger.error(data);
  39253. _this.emit('pusher:subscription_error', data);
  39254. }
  39255. else {
  39256. _this.pusher.send_event('pusher:subscribe', {
  39257. auth: data.auth,
  39258. channel_data: data.channel_data,
  39259. channel: _this.name
  39260. });
  39261. }
  39262. });
  39263. };
  39264. Channel.prototype.unsubscribe = function () {
  39265. this.subscribed = false;
  39266. this.pusher.send_event('pusher:unsubscribe', {
  39267. channel: this.name
  39268. });
  39269. };
  39270. Channel.prototype.cancelSubscription = function () {
  39271. this.subscriptionCancelled = true;
  39272. };
  39273. Channel.prototype.reinstateSubscription = function () {
  39274. this.subscriptionCancelled = false;
  39275. };
  39276. return Channel;
  39277. }(dispatcher));
  39278. /* harmony default export */ var channels_channel = (channel_Channel);
  39279. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39280. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39281. var extendStatics = function (d, b) {
  39282. extendStatics = Object.setPrototypeOf ||
  39283. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39284. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39285. return extendStatics(d, b);
  39286. };
  39287. return function (d, b) {
  39288. extendStatics(d, b);
  39289. function __() { this.constructor = d; }
  39290. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39291. };
  39292. })();
  39293. var private_channel_PrivateChannel = (function (_super) {
  39294. private_channel_extends(PrivateChannel, _super);
  39295. function PrivateChannel() {
  39296. return _super !== null && _super.apply(this, arguments) || this;
  39297. }
  39298. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39299. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39300. return authorizer.authorize(socketId, callback);
  39301. };
  39302. return PrivateChannel;
  39303. }(channels_channel));
  39304. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39305. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39306. var members_Members = (function () {
  39307. function Members() {
  39308. this.reset();
  39309. }
  39310. Members.prototype.get = function (id) {
  39311. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39312. return {
  39313. id: id,
  39314. info: this.members[id]
  39315. };
  39316. }
  39317. else {
  39318. return null;
  39319. }
  39320. };
  39321. Members.prototype.each = function (callback) {
  39322. var _this = this;
  39323. objectApply(this.members, function (member, id) {
  39324. callback(_this.get(id));
  39325. });
  39326. };
  39327. Members.prototype.setMyID = function (id) {
  39328. this.myID = id;
  39329. };
  39330. Members.prototype.onSubscription = function (subscriptionData) {
  39331. this.members = subscriptionData.presence.hash;
  39332. this.count = subscriptionData.presence.count;
  39333. this.me = this.get(this.myID);
  39334. };
  39335. Members.prototype.addMember = function (memberData) {
  39336. if (this.get(memberData.user_id) === null) {
  39337. this.count++;
  39338. }
  39339. this.members[memberData.user_id] = memberData.user_info;
  39340. return this.get(memberData.user_id);
  39341. };
  39342. Members.prototype.removeMember = function (memberData) {
  39343. var member = this.get(memberData.user_id);
  39344. if (member) {
  39345. delete this.members[memberData.user_id];
  39346. this.count--;
  39347. }
  39348. return member;
  39349. };
  39350. Members.prototype.reset = function () {
  39351. this.members = {};
  39352. this.count = 0;
  39353. this.myID = null;
  39354. this.me = null;
  39355. };
  39356. return Members;
  39357. }());
  39358. /* harmony default export */ var members = (members_Members);
  39359. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39360. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39361. var extendStatics = function (d, b) {
  39362. extendStatics = Object.setPrototypeOf ||
  39363. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39364. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39365. return extendStatics(d, b);
  39366. };
  39367. return function (d, b) {
  39368. extendStatics(d, b);
  39369. function __() { this.constructor = d; }
  39370. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39371. };
  39372. })();
  39373. var presence_channel_PresenceChannel = (function (_super) {
  39374. presence_channel_extends(PresenceChannel, _super);
  39375. function PresenceChannel(name, pusher) {
  39376. var _this = _super.call(this, name, pusher) || this;
  39377. _this.members = new members();
  39378. return _this;
  39379. }
  39380. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39381. var _this = this;
  39382. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39383. if (!error) {
  39384. if (authData.channel_data === undefined) {
  39385. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39386. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39387. ("expected 'channel_data' field. " + suffix));
  39388. callback("Invalid auth response");
  39389. return;
  39390. }
  39391. var channelData = JSON.parse(authData.channel_data);
  39392. _this.members.setMyID(channelData.user_id);
  39393. }
  39394. callback(error, authData);
  39395. });
  39396. };
  39397. PresenceChannel.prototype.handleEvent = function (event) {
  39398. var eventName = event.event;
  39399. if (eventName.indexOf("pusher_internal:") === 0) {
  39400. this.handleInternalEvent(event);
  39401. }
  39402. else {
  39403. var data = event.data;
  39404. var metadata = {};
  39405. if (event.user_id) {
  39406. metadata.user_id = event.user_id;
  39407. }
  39408. this.emit(eventName, data, metadata);
  39409. }
  39410. };
  39411. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39412. var eventName = event.event;
  39413. var data = event.data;
  39414. switch (eventName) {
  39415. case "pusher_internal:subscription_succeeded":
  39416. this.handleSubscriptionSucceededEvent(event);
  39417. break;
  39418. case "pusher_internal:member_added":
  39419. var addedMember = this.members.addMember(data);
  39420. this.emit('pusher:member_added', addedMember);
  39421. break;
  39422. case "pusher_internal:member_removed":
  39423. var removedMember = this.members.removeMember(data);
  39424. if (removedMember) {
  39425. this.emit('pusher:member_removed', removedMember);
  39426. }
  39427. break;
  39428. }
  39429. };
  39430. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39431. this.subscriptionPending = false;
  39432. this.subscribed = true;
  39433. if (this.subscriptionCancelled) {
  39434. this.pusher.unsubscribe(this.name);
  39435. }
  39436. else {
  39437. this.members.onSubscription(event.data);
  39438. this.emit("pusher:subscription_succeeded", this.members);
  39439. }
  39440. };
  39441. PresenceChannel.prototype.disconnect = function () {
  39442. this.members.reset();
  39443. _super.prototype.disconnect.call(this);
  39444. };
  39445. return PresenceChannel;
  39446. }(private_channel));
  39447. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39448. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39449. var nacl_fast = __webpack_require__(0);
  39450. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39451. var nacl_util = __webpack_require__(1);
  39452. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39453. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39454. var extendStatics = function (d, b) {
  39455. extendStatics = Object.setPrototypeOf ||
  39456. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39457. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39458. return extendStatics(d, b);
  39459. };
  39460. return function (d, b) {
  39461. extendStatics(d, b);
  39462. function __() { this.constructor = d; }
  39463. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39464. };
  39465. })();
  39466. var encrypted_channel_EncryptedChannel = (function (_super) {
  39467. encrypted_channel_extends(EncryptedChannel, _super);
  39468. function EncryptedChannel() {
  39469. var _this = _super !== null && _super.apply(this, arguments) || this;
  39470. _this.key = null;
  39471. return _this;
  39472. }
  39473. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39474. var _this = this;
  39475. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39476. if (error) {
  39477. callback(true, authData);
  39478. return;
  39479. }
  39480. var sharedSecret = authData["shared_secret"];
  39481. if (!sharedSecret) {
  39482. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39483. callback(true, errorMsg);
  39484. return;
  39485. }
  39486. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39487. delete authData["shared_secret"];
  39488. callback(false, authData);
  39489. });
  39490. };
  39491. EncryptedChannel.prototype.trigger = function (event, data) {
  39492. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39493. };
  39494. EncryptedChannel.prototype.handleEvent = function (event) {
  39495. var eventName = event.event;
  39496. var data = event.data;
  39497. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39498. _super.prototype.handleEvent.call(this, event);
  39499. return;
  39500. }
  39501. this.handleEncryptedEvent(eventName, data);
  39502. };
  39503. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39504. var _this = this;
  39505. if (!this.key) {
  39506. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39507. return;
  39508. }
  39509. if (!data.ciphertext || !data.nonce) {
  39510. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39511. return;
  39512. }
  39513. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39514. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39515. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39516. return;
  39517. }
  39518. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39519. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39520. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39521. return;
  39522. }
  39523. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39524. if (bytes === null) {
  39525. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39526. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39527. if (error) {
  39528. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39529. return;
  39530. }
  39531. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39532. if (bytes === null) {
  39533. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39534. return;
  39535. }
  39536. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39537. return;
  39538. });
  39539. return;
  39540. }
  39541. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39542. };
  39543. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39544. try {
  39545. this.emit(eventName, JSON.parse(data));
  39546. }
  39547. catch (e) {
  39548. this.emit(eventName, data);
  39549. }
  39550. return this;
  39551. };
  39552. return EncryptedChannel;
  39553. }(private_channel));
  39554. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39555. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39556. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39557. var extendStatics = function (d, b) {
  39558. extendStatics = Object.setPrototypeOf ||
  39559. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39560. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39561. return extendStatics(d, b);
  39562. };
  39563. return function (d, b) {
  39564. extendStatics(d, b);
  39565. function __() { this.constructor = d; }
  39566. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39567. };
  39568. })();
  39569. var connection_manager_ConnectionManager = (function (_super) {
  39570. connection_manager_extends(ConnectionManager, _super);
  39571. function ConnectionManager(key, options) {
  39572. var _this = _super.call(this) || this;
  39573. _this.key = key;
  39574. _this.options = options || {};
  39575. _this.state = "initialized";
  39576. _this.connection = null;
  39577. _this.usingTLS = !!options.useTLS;
  39578. _this.timeline = _this.options.timeline;
  39579. _this.errorCallbacks = _this.buildErrorCallbacks();
  39580. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39581. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39582. var Network = runtime.getNetwork();
  39583. Network.bind("online", function () {
  39584. _this.timeline.info({ netinfo: "online" });
  39585. if (_this.state === "connecting" || _this.state === "unavailable") {
  39586. _this.retryIn(0);
  39587. }
  39588. });
  39589. Network.bind("offline", function () {
  39590. _this.timeline.info({ netinfo: "offline" });
  39591. if (_this.connection) {
  39592. _this.sendActivityCheck();
  39593. }
  39594. });
  39595. _this.updateStrategy();
  39596. return _this;
  39597. }
  39598. ConnectionManager.prototype.connect = function () {
  39599. if (this.connection || this.runner) {
  39600. return;
  39601. }
  39602. if (!this.strategy.isSupported()) {
  39603. this.updateState("failed");
  39604. return;
  39605. }
  39606. this.updateState("connecting");
  39607. this.startConnecting();
  39608. this.setUnavailableTimer();
  39609. };
  39610. ;
  39611. ConnectionManager.prototype.send = function (data) {
  39612. if (this.connection) {
  39613. return this.connection.send(data);
  39614. }
  39615. else {
  39616. return false;
  39617. }
  39618. };
  39619. ;
  39620. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39621. if (this.connection) {
  39622. return this.connection.send_event(name, data, channel);
  39623. }
  39624. else {
  39625. return false;
  39626. }
  39627. };
  39628. ;
  39629. ConnectionManager.prototype.disconnect = function () {
  39630. this.disconnectInternally();
  39631. this.updateState("disconnected");
  39632. };
  39633. ;
  39634. ConnectionManager.prototype.isUsingTLS = function () {
  39635. return this.usingTLS;
  39636. };
  39637. ;
  39638. ConnectionManager.prototype.startConnecting = function () {
  39639. var _this = this;
  39640. var callback = function (error, handshake) {
  39641. if (error) {
  39642. _this.runner = _this.strategy.connect(0, callback);
  39643. }
  39644. else {
  39645. if (handshake.action === "error") {
  39646. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39647. _this.timeline.error({ handshakeError: handshake.error });
  39648. }
  39649. else {
  39650. _this.abortConnecting();
  39651. _this.handshakeCallbacks[handshake.action](handshake);
  39652. }
  39653. }
  39654. };
  39655. this.runner = this.strategy.connect(0, callback);
  39656. };
  39657. ;
  39658. ConnectionManager.prototype.abortConnecting = function () {
  39659. if (this.runner) {
  39660. this.runner.abort();
  39661. this.runner = null;
  39662. }
  39663. };
  39664. ;
  39665. ConnectionManager.prototype.disconnectInternally = function () {
  39666. this.abortConnecting();
  39667. this.clearRetryTimer();
  39668. this.clearUnavailableTimer();
  39669. if (this.connection) {
  39670. var connection = this.abandonConnection();
  39671. connection.close();
  39672. }
  39673. };
  39674. ;
  39675. ConnectionManager.prototype.updateStrategy = function () {
  39676. this.strategy = this.options.getStrategy({
  39677. key: this.key,
  39678. timeline: this.timeline,
  39679. useTLS: this.usingTLS
  39680. });
  39681. };
  39682. ;
  39683. ConnectionManager.prototype.retryIn = function (delay) {
  39684. var _this = this;
  39685. this.timeline.info({ action: "retry", delay: delay });
  39686. if (delay > 0) {
  39687. this.emit("connecting_in", Math.round(delay / 1000));
  39688. }
  39689. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39690. _this.disconnectInternally();
  39691. _this.connect();
  39692. });
  39693. };
  39694. ;
  39695. ConnectionManager.prototype.clearRetryTimer = function () {
  39696. if (this.retryTimer) {
  39697. this.retryTimer.ensureAborted();
  39698. this.retryTimer = null;
  39699. }
  39700. };
  39701. ;
  39702. ConnectionManager.prototype.setUnavailableTimer = function () {
  39703. var _this = this;
  39704. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39705. _this.updateState("unavailable");
  39706. });
  39707. };
  39708. ;
  39709. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39710. if (this.unavailableTimer) {
  39711. this.unavailableTimer.ensureAborted();
  39712. }
  39713. };
  39714. ;
  39715. ConnectionManager.prototype.sendActivityCheck = function () {
  39716. var _this = this;
  39717. this.stopActivityCheck();
  39718. this.connection.ping();
  39719. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39720. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39721. _this.retryIn(0);
  39722. });
  39723. };
  39724. ;
  39725. ConnectionManager.prototype.resetActivityCheck = function () {
  39726. var _this = this;
  39727. this.stopActivityCheck();
  39728. if (this.connection && !this.connection.handlesActivityChecks()) {
  39729. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39730. _this.sendActivityCheck();
  39731. });
  39732. }
  39733. };
  39734. ;
  39735. ConnectionManager.prototype.stopActivityCheck = function () {
  39736. if (this.activityTimer) {
  39737. this.activityTimer.ensureAborted();
  39738. }
  39739. };
  39740. ;
  39741. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39742. var _this = this;
  39743. return extend({}, errorCallbacks, {
  39744. message: function (message) {
  39745. _this.resetActivityCheck();
  39746. _this.emit('message', message);
  39747. },
  39748. ping: function () {
  39749. _this.send_event('pusher:pong', {});
  39750. },
  39751. activity: function () {
  39752. _this.resetActivityCheck();
  39753. },
  39754. error: function (error) {
  39755. _this.emit("error", { type: "WebSocketError", error: error });
  39756. },
  39757. closed: function () {
  39758. _this.abandonConnection();
  39759. if (_this.shouldRetry()) {
  39760. _this.retryIn(1000);
  39761. }
  39762. }
  39763. });
  39764. };
  39765. ;
  39766. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39767. var _this = this;
  39768. return extend({}, errorCallbacks, {
  39769. connected: function (handshake) {
  39770. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39771. _this.clearUnavailableTimer();
  39772. _this.setConnection(handshake.connection);
  39773. _this.socket_id = _this.connection.id;
  39774. _this.updateState("connected", { socket_id: _this.socket_id });
  39775. }
  39776. });
  39777. };
  39778. ;
  39779. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39780. var _this = this;
  39781. var withErrorEmitted = function (callback) {
  39782. return function (result) {
  39783. if (result.error) {
  39784. _this.emit("error", { type: "WebSocketError", error: result.error });
  39785. }
  39786. callback(result);
  39787. };
  39788. };
  39789. return {
  39790. tls_only: withErrorEmitted(function () {
  39791. _this.usingTLS = true;
  39792. _this.updateStrategy();
  39793. _this.retryIn(0);
  39794. }),
  39795. refused: withErrorEmitted(function () {
  39796. _this.disconnect();
  39797. }),
  39798. backoff: withErrorEmitted(function () {
  39799. _this.retryIn(1000);
  39800. }),
  39801. retry: withErrorEmitted(function () {
  39802. _this.retryIn(0);
  39803. })
  39804. };
  39805. };
  39806. ;
  39807. ConnectionManager.prototype.setConnection = function (connection) {
  39808. this.connection = connection;
  39809. for (var event in this.connectionCallbacks) {
  39810. this.connection.bind(event, this.connectionCallbacks[event]);
  39811. }
  39812. this.resetActivityCheck();
  39813. };
  39814. ;
  39815. ConnectionManager.prototype.abandonConnection = function () {
  39816. if (!this.connection) {
  39817. return;
  39818. }
  39819. this.stopActivityCheck();
  39820. for (var event in this.connectionCallbacks) {
  39821. this.connection.unbind(event, this.connectionCallbacks[event]);
  39822. }
  39823. var connection = this.connection;
  39824. this.connection = null;
  39825. return connection;
  39826. };
  39827. ConnectionManager.prototype.updateState = function (newState, data) {
  39828. var previousState = this.state;
  39829. this.state = newState;
  39830. if (previousState !== newState) {
  39831. var newStateDescription = newState;
  39832. if (newStateDescription === "connected") {
  39833. newStateDescription += " with new socket ID " + data.socket_id;
  39834. }
  39835. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39836. this.timeline.info({ state: newState, params: data });
  39837. this.emit('state_change', { previous: previousState, current: newState });
  39838. this.emit(newState, data);
  39839. }
  39840. };
  39841. ConnectionManager.prototype.shouldRetry = function () {
  39842. return this.state === "connecting" || this.state === "connected";
  39843. };
  39844. return ConnectionManager;
  39845. }(dispatcher));
  39846. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39847. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39848. var channels_Channels = (function () {
  39849. function Channels() {
  39850. this.channels = {};
  39851. }
  39852. Channels.prototype.add = function (name, pusher) {
  39853. if (!this.channels[name]) {
  39854. this.channels[name] = createChannel(name, pusher);
  39855. }
  39856. return this.channels[name];
  39857. };
  39858. Channels.prototype.all = function () {
  39859. return values(this.channels);
  39860. };
  39861. Channels.prototype.find = function (name) {
  39862. return this.channels[name];
  39863. };
  39864. Channels.prototype.remove = function (name) {
  39865. var channel = this.channels[name];
  39866. delete this.channels[name];
  39867. return channel;
  39868. };
  39869. Channels.prototype.disconnect = function () {
  39870. objectApply(this.channels, function (channel) {
  39871. channel.disconnect();
  39872. });
  39873. };
  39874. return Channels;
  39875. }());
  39876. /* harmony default export */ var channels = (channels_Channels);
  39877. function createChannel(name, pusher) {
  39878. if (name.indexOf('private-encrypted-') === 0) {
  39879. if (false) { var errorMsg; }
  39880. return factory.createEncryptedChannel(name, pusher);
  39881. }
  39882. else if (name.indexOf('private-') === 0) {
  39883. return factory.createPrivateChannel(name, pusher);
  39884. }
  39885. else if (name.indexOf('presence-') === 0) {
  39886. return factory.createPresenceChannel(name, pusher);
  39887. }
  39888. else {
  39889. return factory.createChannel(name, pusher);
  39890. }
  39891. }
  39892. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39893. var Factory = {
  39894. createChannels: function () {
  39895. return new channels();
  39896. },
  39897. createConnectionManager: function (key, options) {
  39898. return new connection_manager(key, options);
  39899. },
  39900. createChannel: function (name, pusher) {
  39901. return new channels_channel(name, pusher);
  39902. },
  39903. createPrivateChannel: function (name, pusher) {
  39904. return new private_channel(name, pusher);
  39905. },
  39906. createPresenceChannel: function (name, pusher) {
  39907. return new presence_channel(name, pusher);
  39908. },
  39909. createEncryptedChannel: function (name, pusher) {
  39910. return new encrypted_channel(name, pusher);
  39911. },
  39912. createTimelineSender: function (timeline, options) {
  39913. return new timeline_sender(timeline, options);
  39914. },
  39915. createAuthorizer: function (channel, options) {
  39916. if (options.authorizer) {
  39917. return options.authorizer(channel, options);
  39918. }
  39919. return new pusher_authorizer(channel, options);
  39920. },
  39921. createHandshake: function (transport, callback) {
  39922. return new connection_handshake(transport, callback);
  39923. },
  39924. createAssistantToTheTransportManager: function (manager, transport, options) {
  39925. return new assistant_to_the_transport_manager(manager, transport, options);
  39926. }
  39927. };
  39928. /* harmony default export */ var factory = (Factory);
  39929. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39930. var transport_manager_TransportManager = (function () {
  39931. function TransportManager(options) {
  39932. this.options = options || {};
  39933. this.livesLeft = this.options.lives || Infinity;
  39934. }
  39935. TransportManager.prototype.getAssistant = function (transport) {
  39936. return factory.createAssistantToTheTransportManager(this, transport, {
  39937. minPingDelay: this.options.minPingDelay,
  39938. maxPingDelay: this.options.maxPingDelay
  39939. });
  39940. };
  39941. TransportManager.prototype.isAlive = function () {
  39942. return this.livesLeft > 0;
  39943. };
  39944. TransportManager.prototype.reportDeath = function () {
  39945. this.livesLeft -= 1;
  39946. };
  39947. return TransportManager;
  39948. }());
  39949. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39950. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39951. var sequential_strategy_SequentialStrategy = (function () {
  39952. function SequentialStrategy(strategies, options) {
  39953. this.strategies = strategies;
  39954. this.loop = Boolean(options.loop);
  39955. this.failFast = Boolean(options.failFast);
  39956. this.timeout = options.timeout;
  39957. this.timeoutLimit = options.timeoutLimit;
  39958. }
  39959. SequentialStrategy.prototype.isSupported = function () {
  39960. return any(this.strategies, util.method("isSupported"));
  39961. };
  39962. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  39963. var _this = this;
  39964. var strategies = this.strategies;
  39965. var current = 0;
  39966. var timeout = this.timeout;
  39967. var runner = null;
  39968. var tryNextStrategy = function (error, handshake) {
  39969. if (handshake) {
  39970. callback(null, handshake);
  39971. }
  39972. else {
  39973. current = current + 1;
  39974. if (_this.loop) {
  39975. current = current % strategies.length;
  39976. }
  39977. if (current < strategies.length) {
  39978. if (timeout) {
  39979. timeout = timeout * 2;
  39980. if (_this.timeoutLimit) {
  39981. timeout = Math.min(timeout, _this.timeoutLimit);
  39982. }
  39983. }
  39984. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  39985. }
  39986. else {
  39987. callback(true);
  39988. }
  39989. }
  39990. };
  39991. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  39992. return {
  39993. abort: function () {
  39994. runner.abort();
  39995. },
  39996. forceMinPriority: function (p) {
  39997. minPriority = p;
  39998. if (runner) {
  39999. runner.forceMinPriority(p);
  40000. }
  40001. }
  40002. };
  40003. };
  40004. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40005. var timer = null;
  40006. var runner = null;
  40007. if (options.timeout > 0) {
  40008. timer = new OneOffTimer(options.timeout, function () {
  40009. runner.abort();
  40010. callback(true);
  40011. });
  40012. }
  40013. runner = strategy.connect(minPriority, function (error, handshake) {
  40014. if (error && timer && timer.isRunning() && !options.failFast) {
  40015. return;
  40016. }
  40017. if (timer) {
  40018. timer.ensureAborted();
  40019. }
  40020. callback(error, handshake);
  40021. });
  40022. return {
  40023. abort: function () {
  40024. if (timer) {
  40025. timer.ensureAborted();
  40026. }
  40027. runner.abort();
  40028. },
  40029. forceMinPriority: function (p) {
  40030. runner.forceMinPriority(p);
  40031. }
  40032. };
  40033. };
  40034. return SequentialStrategy;
  40035. }());
  40036. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40037. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40038. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40039. function BestConnectedEverStrategy(strategies) {
  40040. this.strategies = strategies;
  40041. }
  40042. BestConnectedEverStrategy.prototype.isSupported = function () {
  40043. return any(this.strategies, util.method("isSupported"));
  40044. };
  40045. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40046. return connect(this.strategies, minPriority, function (i, runners) {
  40047. return function (error, handshake) {
  40048. runners[i].error = error;
  40049. if (error) {
  40050. if (allRunnersFailed(runners)) {
  40051. callback(true);
  40052. }
  40053. return;
  40054. }
  40055. apply(runners, function (runner) {
  40056. runner.forceMinPriority(handshake.transport.priority);
  40057. });
  40058. callback(null, handshake);
  40059. };
  40060. });
  40061. };
  40062. return BestConnectedEverStrategy;
  40063. }());
  40064. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40065. function connect(strategies, minPriority, callbackBuilder) {
  40066. var runners = map(strategies, function (strategy, i, _, rs) {
  40067. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40068. });
  40069. return {
  40070. abort: function () {
  40071. apply(runners, abortRunner);
  40072. },
  40073. forceMinPriority: function (p) {
  40074. apply(runners, function (runner) {
  40075. runner.forceMinPriority(p);
  40076. });
  40077. }
  40078. };
  40079. }
  40080. function allRunnersFailed(runners) {
  40081. return collections_all(runners, function (runner) {
  40082. return Boolean(runner.error);
  40083. });
  40084. }
  40085. function abortRunner(runner) {
  40086. if (!runner.error && !runner.aborted) {
  40087. runner.abort();
  40088. runner.aborted = true;
  40089. }
  40090. }
  40091. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40092. var cached_strategy_CachedStrategy = (function () {
  40093. function CachedStrategy(strategy, transports, options) {
  40094. this.strategy = strategy;
  40095. this.transports = transports;
  40096. this.ttl = options.ttl || 1800 * 1000;
  40097. this.usingTLS = options.useTLS;
  40098. this.timeline = options.timeline;
  40099. }
  40100. CachedStrategy.prototype.isSupported = function () {
  40101. return this.strategy.isSupported();
  40102. };
  40103. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40104. var usingTLS = this.usingTLS;
  40105. var info = fetchTransportCache(usingTLS);
  40106. var strategies = [this.strategy];
  40107. if (info && info.timestamp + this.ttl >= util.now()) {
  40108. var transport = this.transports[info.transport];
  40109. if (transport) {
  40110. this.timeline.info({
  40111. cached: true,
  40112. transport: info.transport,
  40113. latency: info.latency
  40114. });
  40115. strategies.push(new sequential_strategy([transport], {
  40116. timeout: info.latency * 2 + 1000,
  40117. failFast: true
  40118. }));
  40119. }
  40120. }
  40121. var startTimestamp = util.now();
  40122. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40123. if (error) {
  40124. flushTransportCache(usingTLS);
  40125. if (strategies.length > 0) {
  40126. startTimestamp = util.now();
  40127. runner = strategies.pop().connect(minPriority, cb);
  40128. }
  40129. else {
  40130. callback(error);
  40131. }
  40132. }
  40133. else {
  40134. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40135. callback(null, handshake);
  40136. }
  40137. });
  40138. return {
  40139. abort: function () {
  40140. runner.abort();
  40141. },
  40142. forceMinPriority: function (p) {
  40143. minPriority = p;
  40144. if (runner) {
  40145. runner.forceMinPriority(p);
  40146. }
  40147. }
  40148. };
  40149. };
  40150. return CachedStrategy;
  40151. }());
  40152. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40153. function getTransportCacheKey(usingTLS) {
  40154. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40155. }
  40156. function fetchTransportCache(usingTLS) {
  40157. var storage = runtime.getLocalStorage();
  40158. if (storage) {
  40159. try {
  40160. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40161. if (serializedCache) {
  40162. return JSON.parse(serializedCache);
  40163. }
  40164. }
  40165. catch (e) {
  40166. flushTransportCache(usingTLS);
  40167. }
  40168. }
  40169. return null;
  40170. }
  40171. function storeTransportCache(usingTLS, transport, latency) {
  40172. var storage = runtime.getLocalStorage();
  40173. if (storage) {
  40174. try {
  40175. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40176. timestamp: util.now(),
  40177. transport: transport,
  40178. latency: latency
  40179. });
  40180. }
  40181. catch (e) {
  40182. }
  40183. }
  40184. }
  40185. function flushTransportCache(usingTLS) {
  40186. var storage = runtime.getLocalStorage();
  40187. if (storage) {
  40188. try {
  40189. delete storage[getTransportCacheKey(usingTLS)];
  40190. }
  40191. catch (e) {
  40192. }
  40193. }
  40194. }
  40195. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40196. var delayed_strategy_DelayedStrategy = (function () {
  40197. function DelayedStrategy(strategy, _a) {
  40198. var number = _a.delay;
  40199. this.strategy = strategy;
  40200. this.options = { delay: number };
  40201. }
  40202. DelayedStrategy.prototype.isSupported = function () {
  40203. return this.strategy.isSupported();
  40204. };
  40205. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40206. var strategy = this.strategy;
  40207. var runner;
  40208. var timer = new OneOffTimer(this.options.delay, function () {
  40209. runner = strategy.connect(minPriority, callback);
  40210. });
  40211. return {
  40212. abort: function () {
  40213. timer.ensureAborted();
  40214. if (runner) {
  40215. runner.abort();
  40216. }
  40217. },
  40218. forceMinPriority: function (p) {
  40219. minPriority = p;
  40220. if (runner) {
  40221. runner.forceMinPriority(p);
  40222. }
  40223. }
  40224. };
  40225. };
  40226. return DelayedStrategy;
  40227. }());
  40228. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40229. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40230. var IfStrategy = (function () {
  40231. function IfStrategy(test, trueBranch, falseBranch) {
  40232. this.test = test;
  40233. this.trueBranch = trueBranch;
  40234. this.falseBranch = falseBranch;
  40235. }
  40236. IfStrategy.prototype.isSupported = function () {
  40237. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40238. return branch.isSupported();
  40239. };
  40240. IfStrategy.prototype.connect = function (minPriority, callback) {
  40241. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40242. return branch.connect(minPriority, callback);
  40243. };
  40244. return IfStrategy;
  40245. }());
  40246. /* harmony default export */ var if_strategy = (IfStrategy);
  40247. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40248. var FirstConnectedStrategy = (function () {
  40249. function FirstConnectedStrategy(strategy) {
  40250. this.strategy = strategy;
  40251. }
  40252. FirstConnectedStrategy.prototype.isSupported = function () {
  40253. return this.strategy.isSupported();
  40254. };
  40255. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40256. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40257. if (handshake) {
  40258. runner.abort();
  40259. }
  40260. callback(error, handshake);
  40261. });
  40262. return runner;
  40263. };
  40264. return FirstConnectedStrategy;
  40265. }());
  40266. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40267. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40268. function testSupportsStrategy(strategy) {
  40269. return function () {
  40270. return strategy.isSupported();
  40271. };
  40272. }
  40273. var getDefaultStrategy = function (config, defineTransport) {
  40274. var definedTransports = {};
  40275. function defineTransportStrategy(name, type, priority, options, manager) {
  40276. var transport = defineTransport(config, name, type, priority, options, manager);
  40277. definedTransports[name] = transport;
  40278. return transport;
  40279. }
  40280. var ws_options = {
  40281. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40282. hostTLS: config.wsHost + ":" + config.wssPort,
  40283. httpPath: config.wsPath
  40284. };
  40285. var wss_options = extend({}, ws_options, {
  40286. useTLS: true
  40287. });
  40288. var sockjs_options = {
  40289. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40290. hostTLS: config.httpHost + ":" + config.httpsPort,
  40291. httpPath: config.httpPath
  40292. };
  40293. var timeouts = {
  40294. loop: true,
  40295. timeout: 15000,
  40296. timeoutLimit: 60000
  40297. };
  40298. var ws_manager = new transport_manager({
  40299. lives: 2,
  40300. minPingDelay: 10000,
  40301. maxPingDelay: config.activity_timeout
  40302. });
  40303. var streaming_manager = new transport_manager({
  40304. lives: 2,
  40305. minPingDelay: 10000,
  40306. maxPingDelay: config.activity_timeout
  40307. });
  40308. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40309. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40310. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40311. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40312. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40313. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40314. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40315. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40316. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40317. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40318. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40319. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40320. var http_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy([streaming_loop, new delayed_strategy(polling_loop, { delay: 4000 })]), polling_loop)], timeouts);
  40321. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40322. var wsStrategy;
  40323. if (config.useTLS) {
  40324. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40325. }
  40326. else {
  40327. wsStrategy = new best_connected_ever_strategy([
  40328. ws_loop,
  40329. new delayed_strategy(wss_loop, { delay: 2000 }),
  40330. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40331. ]);
  40332. }
  40333. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40334. ttl: 1800000,
  40335. timeline: config.timeline,
  40336. useTLS: config.useTLS
  40337. });
  40338. };
  40339. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40340. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40341. /* harmony default export */ var transport_connection_initializer = (function () {
  40342. var self = this;
  40343. self.timeline.info(self.buildTimelineMessage({
  40344. transport: self.name + (self.options.useTLS ? "s" : "")
  40345. }));
  40346. if (self.hooks.isInitialized()) {
  40347. self.changeState("initialized");
  40348. }
  40349. else if (self.hooks.file) {
  40350. self.changeState("initializing");
  40351. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40352. if (self.hooks.isInitialized()) {
  40353. self.changeState("initialized");
  40354. callback(true);
  40355. }
  40356. else {
  40357. if (error) {
  40358. self.onError(error);
  40359. }
  40360. self.onClose();
  40361. callback(false);
  40362. }
  40363. });
  40364. }
  40365. else {
  40366. self.onClose();
  40367. }
  40368. });
  40369. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40370. var http_xdomain_request_hooks = {
  40371. getRequest: function (socket) {
  40372. var xdr = new window.XDomainRequest();
  40373. xdr.ontimeout = function () {
  40374. socket.emit("error", new RequestTimedOut());
  40375. socket.close();
  40376. };
  40377. xdr.onerror = function (e) {
  40378. socket.emit("error", e);
  40379. socket.close();
  40380. };
  40381. xdr.onprogress = function () {
  40382. if (xdr.responseText && xdr.responseText.length > 0) {
  40383. socket.onChunk(200, xdr.responseText);
  40384. }
  40385. };
  40386. xdr.onload = function () {
  40387. if (xdr.responseText && xdr.responseText.length > 0) {
  40388. socket.onChunk(200, xdr.responseText);
  40389. }
  40390. socket.emit("finished", 200);
  40391. socket.close();
  40392. };
  40393. return xdr;
  40394. },
  40395. abortRequest: function (xdr) {
  40396. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40397. xdr.abort();
  40398. }
  40399. };
  40400. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40401. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40402. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40403. var extendStatics = function (d, b) {
  40404. extendStatics = Object.setPrototypeOf ||
  40405. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40406. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40407. return extendStatics(d, b);
  40408. };
  40409. return function (d, b) {
  40410. extendStatics(d, b);
  40411. function __() { this.constructor = d; }
  40412. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40413. };
  40414. })();
  40415. var MAX_BUFFER_LENGTH = 256 * 1024;
  40416. var http_request_HTTPRequest = (function (_super) {
  40417. http_request_extends(HTTPRequest, _super);
  40418. function HTTPRequest(hooks, method, url) {
  40419. var _this = _super.call(this) || this;
  40420. _this.hooks = hooks;
  40421. _this.method = method;
  40422. _this.url = url;
  40423. return _this;
  40424. }
  40425. HTTPRequest.prototype.start = function (payload) {
  40426. var _this = this;
  40427. this.position = 0;
  40428. this.xhr = this.hooks.getRequest(this);
  40429. this.unloader = function () {
  40430. _this.close();
  40431. };
  40432. runtime.addUnloadListener(this.unloader);
  40433. this.xhr.open(this.method, this.url, true);
  40434. if (this.xhr.setRequestHeader) {
  40435. this.xhr.setRequestHeader("Content-Type", "application/json");
  40436. }
  40437. this.xhr.send(payload);
  40438. };
  40439. HTTPRequest.prototype.close = function () {
  40440. if (this.unloader) {
  40441. runtime.removeUnloadListener(this.unloader);
  40442. this.unloader = null;
  40443. }
  40444. if (this.xhr) {
  40445. this.hooks.abortRequest(this.xhr);
  40446. this.xhr = null;
  40447. }
  40448. };
  40449. HTTPRequest.prototype.onChunk = function (status, data) {
  40450. while (true) {
  40451. var chunk = this.advanceBuffer(data);
  40452. if (chunk) {
  40453. this.emit("chunk", { status: status, data: chunk });
  40454. }
  40455. else {
  40456. break;
  40457. }
  40458. }
  40459. if (this.isBufferTooLong(data)) {
  40460. this.emit("buffer_too_long");
  40461. }
  40462. };
  40463. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40464. var unreadData = buffer.slice(this.position);
  40465. var endOfLinePosition = unreadData.indexOf("\n");
  40466. if (endOfLinePosition !== -1) {
  40467. this.position += endOfLinePosition + 1;
  40468. return unreadData.slice(0, endOfLinePosition);
  40469. }
  40470. else {
  40471. return null;
  40472. }
  40473. };
  40474. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40475. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40476. };
  40477. return HTTPRequest;
  40478. }(dispatcher));
  40479. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40480. // CONCATENATED MODULE: ./src/core/http/state.ts
  40481. var State;
  40482. (function (State) {
  40483. State[State["CONNECTING"] = 0] = "CONNECTING";
  40484. State[State["OPEN"] = 1] = "OPEN";
  40485. State[State["CLOSED"] = 3] = "CLOSED";
  40486. })(State || (State = {}));
  40487. /* harmony default export */ var state = (State);
  40488. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40489. var autoIncrement = 1;
  40490. var http_socket_HTTPSocket = (function () {
  40491. function HTTPSocket(hooks, url) {
  40492. this.hooks = hooks;
  40493. this.session = randomNumber(1000) + "/" + randomString(8);
  40494. this.location = getLocation(url);
  40495. this.readyState = state.CONNECTING;
  40496. this.openStream();
  40497. }
  40498. HTTPSocket.prototype.send = function (payload) {
  40499. return this.sendRaw(JSON.stringify([payload]));
  40500. };
  40501. HTTPSocket.prototype.ping = function () {
  40502. this.hooks.sendHeartbeat(this);
  40503. };
  40504. HTTPSocket.prototype.close = function (code, reason) {
  40505. this.onClose(code, reason, true);
  40506. };
  40507. HTTPSocket.prototype.sendRaw = function (payload) {
  40508. if (this.readyState === state.OPEN) {
  40509. try {
  40510. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40511. return true;
  40512. }
  40513. catch (e) {
  40514. return false;
  40515. }
  40516. }
  40517. else {
  40518. return false;
  40519. }
  40520. };
  40521. HTTPSocket.prototype.reconnect = function () {
  40522. this.closeStream();
  40523. this.openStream();
  40524. };
  40525. ;
  40526. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40527. this.closeStream();
  40528. this.readyState = state.CLOSED;
  40529. if (this.onclose) {
  40530. this.onclose({
  40531. code: code,
  40532. reason: reason,
  40533. wasClean: wasClean
  40534. });
  40535. }
  40536. };
  40537. HTTPSocket.prototype.onChunk = function (chunk) {
  40538. if (chunk.status !== 200) {
  40539. return;
  40540. }
  40541. if (this.readyState === state.OPEN) {
  40542. this.onActivity();
  40543. }
  40544. var payload;
  40545. var type = chunk.data.slice(0, 1);
  40546. switch (type) {
  40547. case 'o':
  40548. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40549. this.onOpen(payload);
  40550. break;
  40551. case 'a':
  40552. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40553. for (var i = 0; i < payload.length; i++) {
  40554. this.onEvent(payload[i]);
  40555. }
  40556. break;
  40557. case 'm':
  40558. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40559. this.onEvent(payload);
  40560. break;
  40561. case 'h':
  40562. this.hooks.onHeartbeat(this);
  40563. break;
  40564. case 'c':
  40565. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40566. this.onClose(payload[0], payload[1], true);
  40567. break;
  40568. }
  40569. };
  40570. HTTPSocket.prototype.onOpen = function (options) {
  40571. if (this.readyState === state.CONNECTING) {
  40572. if (options && options.hostname) {
  40573. this.location.base = replaceHost(this.location.base, options.hostname);
  40574. }
  40575. this.readyState = state.OPEN;
  40576. if (this.onopen) {
  40577. this.onopen();
  40578. }
  40579. }
  40580. else {
  40581. this.onClose(1006, "Server lost session", true);
  40582. }
  40583. };
  40584. HTTPSocket.prototype.onEvent = function (event) {
  40585. if (this.readyState === state.OPEN && this.onmessage) {
  40586. this.onmessage({ data: event });
  40587. }
  40588. };
  40589. HTTPSocket.prototype.onActivity = function () {
  40590. if (this.onactivity) {
  40591. this.onactivity();
  40592. }
  40593. };
  40594. HTTPSocket.prototype.onError = function (error) {
  40595. if (this.onerror) {
  40596. this.onerror(error);
  40597. }
  40598. };
  40599. HTTPSocket.prototype.openStream = function () {
  40600. var _this = this;
  40601. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40602. this.stream.bind("chunk", function (chunk) {
  40603. _this.onChunk(chunk);
  40604. });
  40605. this.stream.bind("finished", function (status) {
  40606. _this.hooks.onFinished(_this, status);
  40607. });
  40608. this.stream.bind("buffer_too_long", function () {
  40609. _this.reconnect();
  40610. });
  40611. try {
  40612. this.stream.start();
  40613. }
  40614. catch (error) {
  40615. util.defer(function () {
  40616. _this.onError(error);
  40617. _this.onClose(1006, "Could not start streaming", false);
  40618. });
  40619. }
  40620. };
  40621. HTTPSocket.prototype.closeStream = function () {
  40622. if (this.stream) {
  40623. this.stream.unbind_all();
  40624. this.stream.close();
  40625. this.stream = null;
  40626. }
  40627. };
  40628. return HTTPSocket;
  40629. }());
  40630. function getLocation(url) {
  40631. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40632. return {
  40633. base: parts[1],
  40634. queryString: parts[2]
  40635. };
  40636. }
  40637. function getSendURL(url, session) {
  40638. return url.base + "/" + session + "/xhr_send";
  40639. }
  40640. function getUniqueURL(url) {
  40641. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40642. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40643. }
  40644. function replaceHost(url, hostname) {
  40645. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40646. return urlParts[1] + hostname + urlParts[3];
  40647. }
  40648. function randomNumber(max) {
  40649. return Math.floor(Math.random() * max);
  40650. }
  40651. function randomString(length) {
  40652. var result = [];
  40653. for (var i = 0; i < length; i++) {
  40654. result.push(randomNumber(32).toString(32));
  40655. }
  40656. return result.join('');
  40657. }
  40658. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40659. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40660. var http_streaming_socket_hooks = {
  40661. getReceiveURL: function (url, session) {
  40662. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40663. },
  40664. onHeartbeat: function (socket) {
  40665. socket.sendRaw("[]");
  40666. },
  40667. sendHeartbeat: function (socket) {
  40668. socket.sendRaw("[]");
  40669. },
  40670. onFinished: function (socket, status) {
  40671. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40672. }
  40673. };
  40674. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40675. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40676. var http_polling_socket_hooks = {
  40677. getReceiveURL: function (url, session) {
  40678. return url.base + "/" + session + "/xhr" + url.queryString;
  40679. },
  40680. onHeartbeat: function () {
  40681. },
  40682. sendHeartbeat: function (socket) {
  40683. socket.sendRaw("[]");
  40684. },
  40685. onFinished: function (socket, status) {
  40686. if (status === 200) {
  40687. socket.reconnect();
  40688. }
  40689. else {
  40690. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40691. }
  40692. }
  40693. };
  40694. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40695. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40696. var http_xhr_request_hooks = {
  40697. getRequest: function (socket) {
  40698. var Constructor = runtime.getXHRAPI();
  40699. var xhr = new Constructor();
  40700. xhr.onreadystatechange = xhr.onprogress = function () {
  40701. switch (xhr.readyState) {
  40702. case 3:
  40703. if (xhr.responseText && xhr.responseText.length > 0) {
  40704. socket.onChunk(xhr.status, xhr.responseText);
  40705. }
  40706. break;
  40707. case 4:
  40708. if (xhr.responseText && xhr.responseText.length > 0) {
  40709. socket.onChunk(xhr.status, xhr.responseText);
  40710. }
  40711. socket.emit("finished", xhr.status);
  40712. socket.close();
  40713. break;
  40714. }
  40715. };
  40716. return xhr;
  40717. },
  40718. abortRequest: function (xhr) {
  40719. xhr.onreadystatechange = null;
  40720. xhr.abort();
  40721. }
  40722. };
  40723. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40724. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40725. var HTTP = {
  40726. createStreamingSocket: function (url) {
  40727. return this.createSocket(http_streaming_socket, url);
  40728. },
  40729. createPollingSocket: function (url) {
  40730. return this.createSocket(http_polling_socket, url);
  40731. },
  40732. createSocket: function (hooks, url) {
  40733. return new http_socket(hooks, url);
  40734. },
  40735. createXHR: function (method, url) {
  40736. return this.createRequest(http_xhr_request, method, url);
  40737. },
  40738. createRequest: function (hooks, method, url) {
  40739. return new http_request(hooks, method, url);
  40740. }
  40741. };
  40742. /* harmony default export */ var http_http = (HTTP);
  40743. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40744. http_http.createXDR = function (method, url) {
  40745. return this.createRequest(http_xdomain_request, method, url);
  40746. };
  40747. /* harmony default export */ var web_http_http = (http_http);
  40748. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40749. var Runtime = {
  40750. nextAuthCallbackID: 1,
  40751. auth_callbacks: {},
  40752. ScriptReceivers: ScriptReceivers,
  40753. DependenciesReceivers: DependenciesReceivers,
  40754. getDefaultStrategy: default_strategy,
  40755. Transports: transports_transports,
  40756. transportConnectionInitializer: transport_connection_initializer,
  40757. HTTPFactory: web_http_http,
  40758. TimelineTransport: jsonp_timeline,
  40759. getXHRAPI: function () {
  40760. return window.XMLHttpRequest;
  40761. },
  40762. getWebSocketAPI: function () {
  40763. return window.WebSocket || window.MozWebSocket;
  40764. },
  40765. setup: function (PusherClass) {
  40766. var _this = this;
  40767. window.Pusher = PusherClass;
  40768. var initializeOnDocumentBody = function () {
  40769. _this.onDocumentBody(PusherClass.ready);
  40770. };
  40771. if (!window.JSON) {
  40772. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40773. }
  40774. else {
  40775. initializeOnDocumentBody();
  40776. }
  40777. },
  40778. getDocument: function () {
  40779. return document;
  40780. },
  40781. getProtocol: function () {
  40782. return this.getDocument().location.protocol;
  40783. },
  40784. getAuthorizers: function () {
  40785. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40786. },
  40787. onDocumentBody: function (callback) {
  40788. var _this = this;
  40789. if (document.body) {
  40790. callback();
  40791. }
  40792. else {
  40793. setTimeout(function () {
  40794. _this.onDocumentBody(callback);
  40795. }, 0);
  40796. }
  40797. },
  40798. createJSONPRequest: function (url, data) {
  40799. return new jsonp_request(url, data);
  40800. },
  40801. createScriptRequest: function (src) {
  40802. return new script_request(src);
  40803. },
  40804. getLocalStorage: function () {
  40805. try {
  40806. return window.localStorage;
  40807. }
  40808. catch (e) {
  40809. return undefined;
  40810. }
  40811. },
  40812. createXHR: function () {
  40813. if (this.getXHRAPI()) {
  40814. return this.createXMLHttpRequest();
  40815. }
  40816. else {
  40817. return this.createMicrosoftXHR();
  40818. }
  40819. },
  40820. createXMLHttpRequest: function () {
  40821. var Constructor = this.getXHRAPI();
  40822. return new Constructor();
  40823. },
  40824. createMicrosoftXHR: function () {
  40825. return new ActiveXObject("Microsoft.XMLHTTP");
  40826. },
  40827. getNetwork: function () {
  40828. return net_info_Network;
  40829. },
  40830. createWebSocket: function (url) {
  40831. var Constructor = this.getWebSocketAPI();
  40832. return new Constructor(url);
  40833. },
  40834. createSocketRequest: function (method, url) {
  40835. if (this.isXHRSupported()) {
  40836. return this.HTTPFactory.createXHR(method, url);
  40837. }
  40838. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40839. return this.HTTPFactory.createXDR(method, url);
  40840. }
  40841. else {
  40842. throw "Cross-origin HTTP requests are not supported";
  40843. }
  40844. },
  40845. isXHRSupported: function () {
  40846. var Constructor = this.getXHRAPI();
  40847. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40848. },
  40849. isXDRSupported: function (useTLS) {
  40850. var protocol = useTLS ? "https:" : "http:";
  40851. var documentProtocol = this.getProtocol();
  40852. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40853. },
  40854. addUnloadListener: function (listener) {
  40855. if (window.addEventListener !== undefined) {
  40856. window.addEventListener("unload", listener, false);
  40857. }
  40858. else if (window.attachEvent !== undefined) {
  40859. window.attachEvent("onunload", listener);
  40860. }
  40861. },
  40862. removeUnloadListener: function (listener) {
  40863. if (window.addEventListener !== undefined) {
  40864. window.removeEventListener("unload", listener, false);
  40865. }
  40866. else if (window.detachEvent !== undefined) {
  40867. window.detachEvent("onunload", listener);
  40868. }
  40869. }
  40870. };
  40871. /* harmony default export */ var runtime = (Runtime);
  40872. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40873. var TimelineLevel;
  40874. (function (TimelineLevel) {
  40875. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40876. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40877. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40878. })(TimelineLevel || (TimelineLevel = {}));
  40879. /* harmony default export */ var timeline_level = (TimelineLevel);
  40880. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40881. var timeline_Timeline = (function () {
  40882. function Timeline(key, session, options) {
  40883. this.key = key;
  40884. this.session = session;
  40885. this.events = [];
  40886. this.options = options || {};
  40887. this.sent = 0;
  40888. this.uniqueID = 0;
  40889. }
  40890. Timeline.prototype.log = function (level, event) {
  40891. if (level <= this.options.level) {
  40892. this.events.push(extend({}, event, { timestamp: util.now() }));
  40893. if (this.options.limit && this.events.length > this.options.limit) {
  40894. this.events.shift();
  40895. }
  40896. }
  40897. };
  40898. Timeline.prototype.error = function (event) {
  40899. this.log(timeline_level.ERROR, event);
  40900. };
  40901. Timeline.prototype.info = function (event) {
  40902. this.log(timeline_level.INFO, event);
  40903. };
  40904. Timeline.prototype.debug = function (event) {
  40905. this.log(timeline_level.DEBUG, event);
  40906. };
  40907. Timeline.prototype.isEmpty = function () {
  40908. return this.events.length === 0;
  40909. };
  40910. Timeline.prototype.send = function (sendfn, callback) {
  40911. var _this = this;
  40912. var data = extend({
  40913. session: this.session,
  40914. bundle: this.sent + 1,
  40915. key: this.key,
  40916. lib: "js",
  40917. version: this.options.version,
  40918. cluster: this.options.cluster,
  40919. features: this.options.features,
  40920. timeline: this.events
  40921. }, this.options.params);
  40922. this.events = [];
  40923. sendfn(data, function (error, result) {
  40924. if (!error) {
  40925. _this.sent++;
  40926. }
  40927. if (callback) {
  40928. callback(error, result);
  40929. }
  40930. });
  40931. return true;
  40932. };
  40933. Timeline.prototype.generateUniqueID = function () {
  40934. this.uniqueID++;
  40935. return this.uniqueID;
  40936. };
  40937. return Timeline;
  40938. }());
  40939. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40940. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40941. var transport_strategy_TransportStrategy = (function () {
  40942. function TransportStrategy(name, priority, transport, options) {
  40943. this.name = name;
  40944. this.priority = priority;
  40945. this.transport = transport;
  40946. this.options = options || {};
  40947. }
  40948. TransportStrategy.prototype.isSupported = function () {
  40949. return this.transport.isSupported({
  40950. useTLS: this.options.useTLS
  40951. });
  40952. };
  40953. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40954. var _this = this;
  40955. if (!this.isSupported()) {
  40956. return failAttempt(new UnsupportedStrategy(), callback);
  40957. }
  40958. else if (this.priority < minPriority) {
  40959. return failAttempt(new TransportPriorityTooLow(), callback);
  40960. }
  40961. var connected = false;
  40962. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  40963. var handshake = null;
  40964. var onInitialized = function () {
  40965. transport.unbind("initialized", onInitialized);
  40966. transport.connect();
  40967. };
  40968. var onOpen = function () {
  40969. handshake = factory.createHandshake(transport, function (result) {
  40970. connected = true;
  40971. unbindListeners();
  40972. callback(null, result);
  40973. });
  40974. };
  40975. var onError = function (error) {
  40976. unbindListeners();
  40977. callback(error);
  40978. };
  40979. var onClosed = function () {
  40980. unbindListeners();
  40981. var serializedTransport;
  40982. serializedTransport = safeJSONStringify(transport);
  40983. callback(new TransportClosed(serializedTransport));
  40984. };
  40985. var unbindListeners = function () {
  40986. transport.unbind("initialized", onInitialized);
  40987. transport.unbind("open", onOpen);
  40988. transport.unbind("error", onError);
  40989. transport.unbind("closed", onClosed);
  40990. };
  40991. transport.bind("initialized", onInitialized);
  40992. transport.bind("open", onOpen);
  40993. transport.bind("error", onError);
  40994. transport.bind("closed", onClosed);
  40995. transport.initialize();
  40996. return {
  40997. abort: function () {
  40998. if (connected) {
  40999. return;
  41000. }
  41001. unbindListeners();
  41002. if (handshake) {
  41003. handshake.close();
  41004. }
  41005. else {
  41006. transport.close();
  41007. }
  41008. },
  41009. forceMinPriority: function (p) {
  41010. if (connected) {
  41011. return;
  41012. }
  41013. if (_this.priority < p) {
  41014. if (handshake) {
  41015. handshake.close();
  41016. }
  41017. else {
  41018. transport.close();
  41019. }
  41020. }
  41021. }
  41022. };
  41023. };
  41024. return TransportStrategy;
  41025. }());
  41026. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41027. function failAttempt(error, callback) {
  41028. util.defer(function () {
  41029. callback(error);
  41030. });
  41031. return {
  41032. abort: function () { },
  41033. forceMinPriority: function () { }
  41034. };
  41035. }
  41036. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41037. var strategy_builder_Transports = runtime.Transports;
  41038. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41039. var transportClass = strategy_builder_Transports[type];
  41040. if (!transportClass) {
  41041. throw new UnsupportedTransport(type);
  41042. }
  41043. var enabled = (!config.enabledTransports ||
  41044. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41045. (!config.disabledTransports ||
  41046. arrayIndexOf(config.disabledTransports, name) === -1);
  41047. var transport;
  41048. if (enabled) {
  41049. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41050. key: config.key,
  41051. useTLS: config.useTLS,
  41052. timeline: config.timeline,
  41053. ignoreNullOrigin: config.ignoreNullOrigin
  41054. }, options));
  41055. }
  41056. else {
  41057. transport = strategy_builder_UnsupportedStrategy;
  41058. }
  41059. return transport;
  41060. };
  41061. var strategy_builder_UnsupportedStrategy = {
  41062. isSupported: function () {
  41063. return false;
  41064. },
  41065. connect: function (_, callback) {
  41066. var deferred = util.defer(function () {
  41067. callback(new UnsupportedStrategy());
  41068. });
  41069. return {
  41070. abort: function () {
  41071. deferred.ensureAborted();
  41072. },
  41073. forceMinPriority: function () { }
  41074. };
  41075. }
  41076. };
  41077. // CONCATENATED MODULE: ./src/core/config.ts
  41078. var getGlobalConfig = function () {
  41079. return {
  41080. wsHost: defaults.host,
  41081. wsPort: defaults.ws_port,
  41082. wssPort: defaults.wss_port,
  41083. wsPath: defaults.ws_path,
  41084. httpHost: defaults.sockjs_host,
  41085. httpPort: defaults.sockjs_http_port,
  41086. httpsPort: defaults.sockjs_https_port,
  41087. httpPath: defaults.sockjs_path,
  41088. statsHost: defaults.stats_host,
  41089. authEndpoint: defaults.channel_auth_endpoint,
  41090. authTransport: defaults.channel_auth_transport,
  41091. activity_timeout: defaults.activity_timeout,
  41092. pong_timeout: defaults.pong_timeout,
  41093. unavailable_timeout: defaults.unavailable_timeout
  41094. };
  41095. };
  41096. var getClusterConfig = function (clusterName) {
  41097. return {
  41098. wsHost: 'ws-' + clusterName + '.pusher.com',
  41099. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41100. };
  41101. };
  41102. // CONCATENATED MODULE: ./src/core/pusher.ts
  41103. var pusher_Pusher = (function () {
  41104. function Pusher(app_key, options) {
  41105. var _this = this;
  41106. checkAppKey(app_key);
  41107. options = options || {};
  41108. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41109. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41110. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41111. }
  41112. this.key = app_key;
  41113. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41114. this.channels = factory.createChannels();
  41115. this.global_emitter = new dispatcher();
  41116. this.sessionID = Math.floor(Math.random() * 1000000000);
  41117. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41118. cluster: this.config.cluster,
  41119. features: Pusher.getClientFeatures(),
  41120. params: this.config.timelineParams || {},
  41121. limit: 50,
  41122. level: timeline_level.INFO,
  41123. version: defaults.VERSION
  41124. });
  41125. if (!this.config.disableStats) {
  41126. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41127. host: this.config.statsHost,
  41128. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41129. });
  41130. }
  41131. var getStrategy = function (options) {
  41132. var config = extend({}, _this.config, options);
  41133. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41134. };
  41135. this.connection = factory.createConnectionManager(this.key, extend({
  41136. getStrategy: getStrategy,
  41137. timeline: this.timeline,
  41138. activityTimeout: this.config.activity_timeout,
  41139. pongTimeout: this.config.pong_timeout,
  41140. unavailableTimeout: this.config.unavailable_timeout
  41141. }, this.config, { useTLS: this.shouldUseTLS() }));
  41142. this.connection.bind('connected', function () {
  41143. _this.subscribeAll();
  41144. if (_this.timelineSender) {
  41145. _this.timelineSender.send(_this.connection.isUsingTLS());
  41146. }
  41147. });
  41148. this.connection.bind('message', function (event) {
  41149. var eventName = event.event;
  41150. var internal = eventName.indexOf('pusher_internal:') === 0;
  41151. if (event.channel) {
  41152. var channel = _this.channel(event.channel);
  41153. if (channel) {
  41154. channel.handleEvent(event);
  41155. }
  41156. }
  41157. if (!internal) {
  41158. _this.global_emitter.emit(event.event, event.data);
  41159. }
  41160. });
  41161. this.connection.bind('connecting', function () {
  41162. _this.channels.disconnect();
  41163. });
  41164. this.connection.bind('disconnected', function () {
  41165. _this.channels.disconnect();
  41166. });
  41167. this.connection.bind('error', function (err) {
  41168. logger.warn(err);
  41169. });
  41170. Pusher.instances.push(this);
  41171. this.timeline.info({ instances: Pusher.instances.length });
  41172. if (Pusher.isReady) {
  41173. this.connect();
  41174. }
  41175. }
  41176. Pusher.ready = function () {
  41177. Pusher.isReady = true;
  41178. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41179. Pusher.instances[i].connect();
  41180. }
  41181. };
  41182. Pusher.getClientFeatures = function () {
  41183. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41184. return t.isSupported({});
  41185. }));
  41186. };
  41187. Pusher.prototype.channel = function (name) {
  41188. return this.channels.find(name);
  41189. };
  41190. Pusher.prototype.allChannels = function () {
  41191. return this.channels.all();
  41192. };
  41193. Pusher.prototype.connect = function () {
  41194. this.connection.connect();
  41195. if (this.timelineSender) {
  41196. if (!this.timelineSenderTimer) {
  41197. var usingTLS = this.connection.isUsingTLS();
  41198. var timelineSender = this.timelineSender;
  41199. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41200. timelineSender.send(usingTLS);
  41201. });
  41202. }
  41203. }
  41204. };
  41205. Pusher.prototype.disconnect = function () {
  41206. this.connection.disconnect();
  41207. if (this.timelineSenderTimer) {
  41208. this.timelineSenderTimer.ensureAborted();
  41209. this.timelineSenderTimer = null;
  41210. }
  41211. };
  41212. Pusher.prototype.bind = function (event_name, callback, context) {
  41213. this.global_emitter.bind(event_name, callback, context);
  41214. return this;
  41215. };
  41216. Pusher.prototype.unbind = function (event_name, callback, context) {
  41217. this.global_emitter.unbind(event_name, callback, context);
  41218. return this;
  41219. };
  41220. Pusher.prototype.bind_global = function (callback) {
  41221. this.global_emitter.bind_global(callback);
  41222. return this;
  41223. };
  41224. Pusher.prototype.unbind_global = function (callback) {
  41225. this.global_emitter.unbind_global(callback);
  41226. return this;
  41227. };
  41228. Pusher.prototype.unbind_all = function (callback) {
  41229. this.global_emitter.unbind_all();
  41230. return this;
  41231. };
  41232. Pusher.prototype.subscribeAll = function () {
  41233. var channelName;
  41234. for (channelName in this.channels.channels) {
  41235. if (this.channels.channels.hasOwnProperty(channelName)) {
  41236. this.subscribe(channelName);
  41237. }
  41238. }
  41239. };
  41240. Pusher.prototype.subscribe = function (channel_name) {
  41241. var channel = this.channels.add(channel_name, this);
  41242. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41243. channel.reinstateSubscription();
  41244. }
  41245. else if (!channel.subscriptionPending &&
  41246. this.connection.state === 'connected') {
  41247. channel.subscribe();
  41248. }
  41249. return channel;
  41250. };
  41251. Pusher.prototype.unsubscribe = function (channel_name) {
  41252. var channel = this.channels.find(channel_name);
  41253. if (channel && channel.subscriptionPending) {
  41254. channel.cancelSubscription();
  41255. }
  41256. else {
  41257. channel = this.channels.remove(channel_name);
  41258. if (channel && this.connection.state === 'connected') {
  41259. channel.unsubscribe();
  41260. }
  41261. }
  41262. };
  41263. Pusher.prototype.send_event = function (event_name, data, channel) {
  41264. return this.connection.send_event(event_name, data, channel);
  41265. };
  41266. Pusher.prototype.shouldUseTLS = function () {
  41267. if (runtime.getProtocol() === 'https:') {
  41268. return true;
  41269. }
  41270. else if (this.config.forceTLS === true) {
  41271. return true;
  41272. }
  41273. else {
  41274. return Boolean(this.config.encrypted);
  41275. }
  41276. };
  41277. Pusher.instances = [];
  41278. Pusher.isReady = false;
  41279. Pusher.logToConsole = false;
  41280. Pusher.Runtime = runtime;
  41281. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41282. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41283. Pusher.auth_callbacks = runtime.auth_callbacks;
  41284. return Pusher;
  41285. }());
  41286. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41287. function checkAppKey(key) {
  41288. if (key === null || key === undefined) {
  41289. throw 'You must pass your app key when you instantiate Pusher.';
  41290. }
  41291. }
  41292. runtime.setup(pusher_Pusher);
  41293. /***/ })
  41294. /******/ ]);
  41295. });
  41296. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41297. /***/ }),
  41298. /***/ "./node_modules/setimmediate/setImmediate.js":
  41299. /*!***************************************************!*\
  41300. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41301. \***************************************************/
  41302. /*! no static exports found */
  41303. /***/ (function(module, exports, __webpack_require__) {
  41304. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41305. "use strict";
  41306. if (global.setImmediate) {
  41307. return;
  41308. }
  41309. var nextHandle = 1; // Spec says greater than zero
  41310. var tasksByHandle = {};
  41311. var currentlyRunningATask = false;
  41312. var doc = global.document;
  41313. var registerImmediate;
  41314. function setImmediate(callback) {
  41315. // Callback can either be a function or a string
  41316. if (typeof callback !== "function") {
  41317. callback = new Function("" + callback);
  41318. }
  41319. // Copy function arguments
  41320. var args = new Array(arguments.length - 1);
  41321. for (var i = 0; i < args.length; i++) {
  41322. args[i] = arguments[i + 1];
  41323. }
  41324. // Store and register the task
  41325. var task = { callback: callback, args: args };
  41326. tasksByHandle[nextHandle] = task;
  41327. registerImmediate(nextHandle);
  41328. return nextHandle++;
  41329. }
  41330. function clearImmediate(handle) {
  41331. delete tasksByHandle[handle];
  41332. }
  41333. function run(task) {
  41334. var callback = task.callback;
  41335. var args = task.args;
  41336. switch (args.length) {
  41337. case 0:
  41338. callback();
  41339. break;
  41340. case 1:
  41341. callback(args[0]);
  41342. break;
  41343. case 2:
  41344. callback(args[0], args[1]);
  41345. break;
  41346. case 3:
  41347. callback(args[0], args[1], args[2]);
  41348. break;
  41349. default:
  41350. callback.apply(undefined, args);
  41351. break;
  41352. }
  41353. }
  41354. function runIfPresent(handle) {
  41355. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41356. // So if we're currently running a task, we'll need to delay this invocation.
  41357. if (currentlyRunningATask) {
  41358. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41359. // "too much recursion" error.
  41360. setTimeout(runIfPresent, 0, handle);
  41361. } else {
  41362. var task = tasksByHandle[handle];
  41363. if (task) {
  41364. currentlyRunningATask = true;
  41365. try {
  41366. run(task);
  41367. } finally {
  41368. clearImmediate(handle);
  41369. currentlyRunningATask = false;
  41370. }
  41371. }
  41372. }
  41373. }
  41374. function installNextTickImplementation() {
  41375. registerImmediate = function(handle) {
  41376. process.nextTick(function () { runIfPresent(handle); });
  41377. };
  41378. }
  41379. function canUsePostMessage() {
  41380. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41381. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41382. if (global.postMessage && !global.importScripts) {
  41383. var postMessageIsAsynchronous = true;
  41384. var oldOnMessage = global.onmessage;
  41385. global.onmessage = function() {
  41386. postMessageIsAsynchronous = false;
  41387. };
  41388. global.postMessage("", "*");
  41389. global.onmessage = oldOnMessage;
  41390. return postMessageIsAsynchronous;
  41391. }
  41392. }
  41393. function installPostMessageImplementation() {
  41394. // Installs an event handler on `global` for the `message` event: see
  41395. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41396. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41397. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41398. var onGlobalMessage = function(event) {
  41399. if (event.source === global &&
  41400. typeof event.data === "string" &&
  41401. event.data.indexOf(messagePrefix) === 0) {
  41402. runIfPresent(+event.data.slice(messagePrefix.length));
  41403. }
  41404. };
  41405. if (global.addEventListener) {
  41406. global.addEventListener("message", onGlobalMessage, false);
  41407. } else {
  41408. global.attachEvent("onmessage", onGlobalMessage);
  41409. }
  41410. registerImmediate = function(handle) {
  41411. global.postMessage(messagePrefix + handle, "*");
  41412. };
  41413. }
  41414. function installMessageChannelImplementation() {
  41415. var channel = new MessageChannel();
  41416. channel.port1.onmessage = function(event) {
  41417. var handle = event.data;
  41418. runIfPresent(handle);
  41419. };
  41420. registerImmediate = function(handle) {
  41421. channel.port2.postMessage(handle);
  41422. };
  41423. }
  41424. function installReadyStateChangeImplementation() {
  41425. var html = doc.documentElement;
  41426. registerImmediate = function(handle) {
  41427. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41428. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41429. var script = doc.createElement("script");
  41430. script.onreadystatechange = function () {
  41431. runIfPresent(handle);
  41432. script.onreadystatechange = null;
  41433. html.removeChild(script);
  41434. script = null;
  41435. };
  41436. html.appendChild(script);
  41437. };
  41438. }
  41439. function installSetTimeoutImplementation() {
  41440. registerImmediate = function(handle) {
  41441. setTimeout(runIfPresent, 0, handle);
  41442. };
  41443. }
  41444. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41445. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41446. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41447. // Don't get fooled by e.g. browserify environments.
  41448. if ({}.toString.call(global.process) === "[object process]") {
  41449. // For Node.js before 0.9
  41450. installNextTickImplementation();
  41451. } else if (canUsePostMessage()) {
  41452. // For non-IE10 modern browsers
  41453. installPostMessageImplementation();
  41454. } else if (global.MessageChannel) {
  41455. // For web workers, where supported
  41456. installMessageChannelImplementation();
  41457. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41458. // For IE 6–8
  41459. installReadyStateChangeImplementation();
  41460. } else {
  41461. // For older browsers
  41462. installSetTimeoutImplementation();
  41463. }
  41464. attachTo.setImmediate = setImmediate;
  41465. attachTo.clearImmediate = clearImmediate;
  41466. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41467. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../process/browser.js */ "./node_modules/process/browser.js")))
  41468. /***/ }),
  41469. /***/ "./node_modules/timers-browserify/main.js":
  41470. /*!************************************************!*\
  41471. !*** ./node_modules/timers-browserify/main.js ***!
  41472. \************************************************/
  41473. /*! no static exports found */
  41474. /***/ (function(module, exports, __webpack_require__) {
  41475. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41476. (typeof self !== "undefined" && self) ||
  41477. window;
  41478. var apply = Function.prototype.apply;
  41479. // DOM APIs, for completeness
  41480. exports.setTimeout = function() {
  41481. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41482. };
  41483. exports.setInterval = function() {
  41484. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41485. };
  41486. exports.clearTimeout =
  41487. exports.clearInterval = function(timeout) {
  41488. if (timeout) {
  41489. timeout.close();
  41490. }
  41491. };
  41492. function Timeout(id, clearFn) {
  41493. this._id = id;
  41494. this._clearFn = clearFn;
  41495. }
  41496. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41497. Timeout.prototype.close = function() {
  41498. this._clearFn.call(scope, this._id);
  41499. };
  41500. // Does not start the time, just sets up the members needed.
  41501. exports.enroll = function(item, msecs) {
  41502. clearTimeout(item._idleTimeoutId);
  41503. item._idleTimeout = msecs;
  41504. };
  41505. exports.unenroll = function(item) {
  41506. clearTimeout(item._idleTimeoutId);
  41507. item._idleTimeout = -1;
  41508. };
  41509. exports._unrefActive = exports.active = function(item) {
  41510. clearTimeout(item._idleTimeoutId);
  41511. var msecs = item._idleTimeout;
  41512. if (msecs >= 0) {
  41513. item._idleTimeoutId = setTimeout(function onTimeout() {
  41514. if (item._onTimeout)
  41515. item._onTimeout();
  41516. }, msecs);
  41517. }
  41518. };
  41519. // setimmediate attaches itself to the global object
  41520. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41521. // On some exotic environments, it's not clear which object `setimmediate` was
  41522. // able to install onto. Search each possibility in the same order as the
  41523. // `setimmediate` library.
  41524. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41525. (typeof global !== "undefined" && global.setImmediate) ||
  41526. (this && this.setImmediate);
  41527. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41528. (typeof global !== "undefined" && global.clearImmediate) ||
  41529. (this && this.clearImmediate);
  41530. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41531. /***/ }),
  41532. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  41533. /*!*******************************************************************************************************************************************************************************************************************!*\
  41534. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  41535. \*******************************************************************************************************************************************************************************************************************/
  41536. /*! exports provided: render, staticRenderFns */
  41537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41538. "use strict";
  41539. __webpack_require__.r(__webpack_exports__);
  41540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41542. var render = function() {
  41543. var _vm = this
  41544. var _h = _vm.$createElement
  41545. var _c = _vm._self._c || _h
  41546. return _vm._m(0)
  41547. }
  41548. var staticRenderFns = [
  41549. function() {
  41550. var _vm = this
  41551. var _h = _vm.$createElement
  41552. var _c = _vm._self._c || _h
  41553. return _c("div", { staticClass: "container" }, [
  41554. _c("div", { staticClass: "row justify-content-center" }, [
  41555. _c("div", { staticClass: "col-md-8" }, [
  41556. _c("div", { staticClass: "card" }, [
  41557. _c("div", { staticClass: "card-header" }, [
  41558. _vm._v("Example Component")
  41559. ]),
  41560. _vm._v(" "),
  41561. _c("div", { staticClass: "card-body" }, [
  41562. _vm._v(
  41563. "\n I'm an example component.\n "
  41564. )
  41565. ])
  41566. ])
  41567. ])
  41568. ])
  41569. ])
  41570. }
  41571. ]
  41572. render._withStripped = true
  41573. /***/ }),
  41574. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&":
  41575. /*!***********************************************************************************************************************************************************************************************************!*\
  41576. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e& ***!
  41577. \***********************************************************************************************************************************************************************************************************/
  41578. /*! exports provided: render, staticRenderFns */
  41579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41580. "use strict";
  41581. __webpack_require__.r(__webpack_exports__);
  41582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41584. var render = function() {
  41585. var _vm = this
  41586. var _h = _vm.$createElement
  41587. var _c = _vm._self._c || _h
  41588. return _c("div", { staticClass: "list-items" }, [
  41589. _vm._v("\r\n Problem Description: "),
  41590. _c("div", { domProps: { textContent: _vm._s(this.probdesc) } }),
  41591. _vm._v("\r\n Suggested Solution: "),
  41592. _c("div", { domProps: { textContent: _vm._s(this.suggested) } })
  41593. ])
  41594. }
  41595. var staticRenderFns = []
  41596. render._withStripped = true
  41597. /***/ }),
  41598. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41599. /*!********************************************************************!*\
  41600. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41601. \********************************************************************/
  41602. /*! exports provided: default */
  41603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41604. "use strict";
  41605. __webpack_require__.r(__webpack_exports__);
  41606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41607. /* globals __VUE_SSR_CONTEXT__ */
  41608. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41609. // This module is a runtime utility for cleaner component module output and will
  41610. // be included in the final webpack user bundle.
  41611. function normalizeComponent (
  41612. scriptExports,
  41613. render,
  41614. staticRenderFns,
  41615. functionalTemplate,
  41616. injectStyles,
  41617. scopeId,
  41618. moduleIdentifier, /* server only */
  41619. shadowMode /* vue-cli only */
  41620. ) {
  41621. // Vue.extend constructor export interop
  41622. var options = typeof scriptExports === 'function'
  41623. ? scriptExports.options
  41624. : scriptExports
  41625. // render functions
  41626. if (render) {
  41627. options.render = render
  41628. options.staticRenderFns = staticRenderFns
  41629. options._compiled = true
  41630. }
  41631. // functional template
  41632. if (functionalTemplate) {
  41633. options.functional = true
  41634. }
  41635. // scopedId
  41636. if (scopeId) {
  41637. options._scopeId = 'data-v-' + scopeId
  41638. }
  41639. var hook
  41640. if (moduleIdentifier) { // server build
  41641. hook = function (context) {
  41642. // 2.3 injection
  41643. context =
  41644. context || // cached call
  41645. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41646. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41647. // 2.2 with runInNewContext: true
  41648. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41649. context = __VUE_SSR_CONTEXT__
  41650. }
  41651. // inject component styles
  41652. if (injectStyles) {
  41653. injectStyles.call(this, context)
  41654. }
  41655. // register component module identifier for async chunk inferrence
  41656. if (context && context._registeredComponents) {
  41657. context._registeredComponents.add(moduleIdentifier)
  41658. }
  41659. }
  41660. // used by ssr in case component is cached and beforeCreate
  41661. // never gets called
  41662. options._ssrRegister = hook
  41663. } else if (injectStyles) {
  41664. hook = shadowMode
  41665. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41666. : injectStyles
  41667. }
  41668. if (hook) {
  41669. if (options.functional) {
  41670. // for template-only hot-reload because in that case the render fn doesn't
  41671. // go through the normalizer
  41672. options._injectStyles = hook
  41673. // register for functioal component in vue file
  41674. var originalRender = options.render
  41675. options.render = function renderWithStyleInjection (h, context) {
  41676. hook.call(context)
  41677. return originalRender(h, context)
  41678. }
  41679. } else {
  41680. // inject component registration as beforeCreate hook
  41681. var existing = options.beforeCreate
  41682. options.beforeCreate = existing
  41683. ? [].concat(existing, hook)
  41684. : [hook]
  41685. }
  41686. }
  41687. return {
  41688. exports: scriptExports,
  41689. options: options
  41690. }
  41691. }
  41692. /***/ }),
  41693. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41694. /*!*************************************************!*\
  41695. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41696. \*************************************************/
  41697. /*! no static exports found */
  41698. /***/ (function(module, exports, __webpack_require__) {
  41699. "use strict";
  41700. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41701. * Vue.js v2.6.11
  41702. * (c) 2014-2019 Evan You
  41703. * Released under the MIT License.
  41704. */
  41705. /* */
  41706. var emptyObject = Object.freeze({});
  41707. // These helpers produce better VM code in JS engines due to their
  41708. // explicitness and function inlining.
  41709. function isUndef (v) {
  41710. return v === undefined || v === null
  41711. }
  41712. function isDef (v) {
  41713. return v !== undefined && v !== null
  41714. }
  41715. function isTrue (v) {
  41716. return v === true
  41717. }
  41718. function isFalse (v) {
  41719. return v === false
  41720. }
  41721. /**
  41722. * Check if value is primitive.
  41723. */
  41724. function isPrimitive (value) {
  41725. return (
  41726. typeof value === 'string' ||
  41727. typeof value === 'number' ||
  41728. // $flow-disable-line
  41729. typeof value === 'symbol' ||
  41730. typeof value === 'boolean'
  41731. )
  41732. }
  41733. /**
  41734. * Quick object check - this is primarily used to tell
  41735. * Objects from primitive values when we know the value
  41736. * is a JSON-compliant type.
  41737. */
  41738. function isObject (obj) {
  41739. return obj !== null && typeof obj === 'object'
  41740. }
  41741. /**
  41742. * Get the raw type string of a value, e.g., [object Object].
  41743. */
  41744. var _toString = Object.prototype.toString;
  41745. function toRawType (value) {
  41746. return _toString.call(value).slice(8, -1)
  41747. }
  41748. /**
  41749. * Strict object type check. Only returns true
  41750. * for plain JavaScript objects.
  41751. */
  41752. function isPlainObject (obj) {
  41753. return _toString.call(obj) === '[object Object]'
  41754. }
  41755. function isRegExp (v) {
  41756. return _toString.call(v) === '[object RegExp]'
  41757. }
  41758. /**
  41759. * Check if val is a valid array index.
  41760. */
  41761. function isValidArrayIndex (val) {
  41762. var n = parseFloat(String(val));
  41763. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41764. }
  41765. function isPromise (val) {
  41766. return (
  41767. isDef(val) &&
  41768. typeof val.then === 'function' &&
  41769. typeof val.catch === 'function'
  41770. )
  41771. }
  41772. /**
  41773. * Convert a value to a string that is actually rendered.
  41774. */
  41775. function toString (val) {
  41776. return val == null
  41777. ? ''
  41778. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41779. ? JSON.stringify(val, null, 2)
  41780. : String(val)
  41781. }
  41782. /**
  41783. * Convert an input value to a number for persistence.
  41784. * If the conversion fails, return original string.
  41785. */
  41786. function toNumber (val) {
  41787. var n = parseFloat(val);
  41788. return isNaN(n) ? val : n
  41789. }
  41790. /**
  41791. * Make a map and return a function for checking if a key
  41792. * is in that map.
  41793. */
  41794. function makeMap (
  41795. str,
  41796. expectsLowerCase
  41797. ) {
  41798. var map = Object.create(null);
  41799. var list = str.split(',');
  41800. for (var i = 0; i < list.length; i++) {
  41801. map[list[i]] = true;
  41802. }
  41803. return expectsLowerCase
  41804. ? function (val) { return map[val.toLowerCase()]; }
  41805. : function (val) { return map[val]; }
  41806. }
  41807. /**
  41808. * Check if a tag is a built-in tag.
  41809. */
  41810. var isBuiltInTag = makeMap('slot,component', true);
  41811. /**
  41812. * Check if an attribute is a reserved attribute.
  41813. */
  41814. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41815. /**
  41816. * Remove an item from an array.
  41817. */
  41818. function remove (arr, item) {
  41819. if (arr.length) {
  41820. var index = arr.indexOf(item);
  41821. if (index > -1) {
  41822. return arr.splice(index, 1)
  41823. }
  41824. }
  41825. }
  41826. /**
  41827. * Check whether an object has the property.
  41828. */
  41829. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41830. function hasOwn (obj, key) {
  41831. return hasOwnProperty.call(obj, key)
  41832. }
  41833. /**
  41834. * Create a cached version of a pure function.
  41835. */
  41836. function cached (fn) {
  41837. var cache = Object.create(null);
  41838. return (function cachedFn (str) {
  41839. var hit = cache[str];
  41840. return hit || (cache[str] = fn(str))
  41841. })
  41842. }
  41843. /**
  41844. * Camelize a hyphen-delimited string.
  41845. */
  41846. var camelizeRE = /-(\w)/g;
  41847. var camelize = cached(function (str) {
  41848. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41849. });
  41850. /**
  41851. * Capitalize a string.
  41852. */
  41853. var capitalize = cached(function (str) {
  41854. return str.charAt(0).toUpperCase() + str.slice(1)
  41855. });
  41856. /**
  41857. * Hyphenate a camelCase string.
  41858. */
  41859. var hyphenateRE = /\B([A-Z])/g;
  41860. var hyphenate = cached(function (str) {
  41861. return str.replace(hyphenateRE, '-$1').toLowerCase()
  41862. });
  41863. /**
  41864. * Simple bind polyfill for environments that do not support it,
  41865. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  41866. * since native bind is now performant enough in most browsers.
  41867. * But removing it would mean breaking code that was able to run in
  41868. * PhantomJS 1.x, so this must be kept for backward compatibility.
  41869. */
  41870. /* istanbul ignore next */
  41871. function polyfillBind (fn, ctx) {
  41872. function boundFn (a) {
  41873. var l = arguments.length;
  41874. return l
  41875. ? l > 1
  41876. ? fn.apply(ctx, arguments)
  41877. : fn.call(ctx, a)
  41878. : fn.call(ctx)
  41879. }
  41880. boundFn._length = fn.length;
  41881. return boundFn
  41882. }
  41883. function nativeBind (fn, ctx) {
  41884. return fn.bind(ctx)
  41885. }
  41886. var bind = Function.prototype.bind
  41887. ? nativeBind
  41888. : polyfillBind;
  41889. /**
  41890. * Convert an Array-like object to a real Array.
  41891. */
  41892. function toArray (list, start) {
  41893. start = start || 0;
  41894. var i = list.length - start;
  41895. var ret = new Array(i);
  41896. while (i--) {
  41897. ret[i] = list[i + start];
  41898. }
  41899. return ret
  41900. }
  41901. /**
  41902. * Mix properties into target object.
  41903. */
  41904. function extend (to, _from) {
  41905. for (var key in _from) {
  41906. to[key] = _from[key];
  41907. }
  41908. return to
  41909. }
  41910. /**
  41911. * Merge an Array of Objects into a single Object.
  41912. */
  41913. function toObject (arr) {
  41914. var res = {};
  41915. for (var i = 0; i < arr.length; i++) {
  41916. if (arr[i]) {
  41917. extend(res, arr[i]);
  41918. }
  41919. }
  41920. return res
  41921. }
  41922. /* eslint-disable no-unused-vars */
  41923. /**
  41924. * Perform no operation.
  41925. * Stubbing args to make Flow happy without leaving useless transpiled code
  41926. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  41927. */
  41928. function noop (a, b, c) {}
  41929. /**
  41930. * Always return false.
  41931. */
  41932. var no = function (a, b, c) { return false; };
  41933. /* eslint-enable no-unused-vars */
  41934. /**
  41935. * Return the same value.
  41936. */
  41937. var identity = function (_) { return _; };
  41938. /**
  41939. * Generate a string containing static keys from compiler modules.
  41940. */
  41941. function genStaticKeys (modules) {
  41942. return modules.reduce(function (keys, m) {
  41943. return keys.concat(m.staticKeys || [])
  41944. }, []).join(',')
  41945. }
  41946. /**
  41947. * Check if two values are loosely equal - that is,
  41948. * if they are plain objects, do they have the same shape?
  41949. */
  41950. function looseEqual (a, b) {
  41951. if (a === b) { return true }
  41952. var isObjectA = isObject(a);
  41953. var isObjectB = isObject(b);
  41954. if (isObjectA && isObjectB) {
  41955. try {
  41956. var isArrayA = Array.isArray(a);
  41957. var isArrayB = Array.isArray(b);
  41958. if (isArrayA && isArrayB) {
  41959. return a.length === b.length && a.every(function (e, i) {
  41960. return looseEqual(e, b[i])
  41961. })
  41962. } else if (a instanceof Date && b instanceof Date) {
  41963. return a.getTime() === b.getTime()
  41964. } else if (!isArrayA && !isArrayB) {
  41965. var keysA = Object.keys(a);
  41966. var keysB = Object.keys(b);
  41967. return keysA.length === keysB.length && keysA.every(function (key) {
  41968. return looseEqual(a[key], b[key])
  41969. })
  41970. } else {
  41971. /* istanbul ignore next */
  41972. return false
  41973. }
  41974. } catch (e) {
  41975. /* istanbul ignore next */
  41976. return false
  41977. }
  41978. } else if (!isObjectA && !isObjectB) {
  41979. return String(a) === String(b)
  41980. } else {
  41981. return false
  41982. }
  41983. }
  41984. /**
  41985. * Return the first index at which a loosely equal value can be
  41986. * found in the array (if value is a plain object, the array must
  41987. * contain an object of the same shape), or -1 if it is not present.
  41988. */
  41989. function looseIndexOf (arr, val) {
  41990. for (var i = 0; i < arr.length; i++) {
  41991. if (looseEqual(arr[i], val)) { return i }
  41992. }
  41993. return -1
  41994. }
  41995. /**
  41996. * Ensure a function is called only once.
  41997. */
  41998. function once (fn) {
  41999. var called = false;
  42000. return function () {
  42001. if (!called) {
  42002. called = true;
  42003. fn.apply(this, arguments);
  42004. }
  42005. }
  42006. }
  42007. var SSR_ATTR = 'data-server-rendered';
  42008. var ASSET_TYPES = [
  42009. 'component',
  42010. 'directive',
  42011. 'filter'
  42012. ];
  42013. var LIFECYCLE_HOOKS = [
  42014. 'beforeCreate',
  42015. 'created',
  42016. 'beforeMount',
  42017. 'mounted',
  42018. 'beforeUpdate',
  42019. 'updated',
  42020. 'beforeDestroy',
  42021. 'destroyed',
  42022. 'activated',
  42023. 'deactivated',
  42024. 'errorCaptured',
  42025. 'serverPrefetch'
  42026. ];
  42027. /* */
  42028. var config = ({
  42029. /**
  42030. * Option merge strategies (used in core/util/options)
  42031. */
  42032. // $flow-disable-line
  42033. optionMergeStrategies: Object.create(null),
  42034. /**
  42035. * Whether to suppress warnings.
  42036. */
  42037. silent: false,
  42038. /**
  42039. * Show production mode tip message on boot?
  42040. */
  42041. productionTip: "development" !== 'production',
  42042. /**
  42043. * Whether to enable devtools
  42044. */
  42045. devtools: "development" !== 'production',
  42046. /**
  42047. * Whether to record perf
  42048. */
  42049. performance: false,
  42050. /**
  42051. * Error handler for watcher errors
  42052. */
  42053. errorHandler: null,
  42054. /**
  42055. * Warn handler for watcher warns
  42056. */
  42057. warnHandler: null,
  42058. /**
  42059. * Ignore certain custom elements
  42060. */
  42061. ignoredElements: [],
  42062. /**
  42063. * Custom user key aliases for v-on
  42064. */
  42065. // $flow-disable-line
  42066. keyCodes: Object.create(null),
  42067. /**
  42068. * Check if a tag is reserved so that it cannot be registered as a
  42069. * component. This is platform-dependent and may be overwritten.
  42070. */
  42071. isReservedTag: no,
  42072. /**
  42073. * Check if an attribute is reserved so that it cannot be used as a component
  42074. * prop. This is platform-dependent and may be overwritten.
  42075. */
  42076. isReservedAttr: no,
  42077. /**
  42078. * Check if a tag is an unknown element.
  42079. * Platform-dependent.
  42080. */
  42081. isUnknownElement: no,
  42082. /**
  42083. * Get the namespace of an element
  42084. */
  42085. getTagNamespace: noop,
  42086. /**
  42087. * Parse the real tag name for the specific platform.
  42088. */
  42089. parsePlatformTagName: identity,
  42090. /**
  42091. * Check if an attribute must be bound using property, e.g. value
  42092. * Platform-dependent.
  42093. */
  42094. mustUseProp: no,
  42095. /**
  42096. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42097. * This will significantly reduce performance if set to false.
  42098. */
  42099. async: true,
  42100. /**
  42101. * Exposed for legacy reasons
  42102. */
  42103. _lifecycleHooks: LIFECYCLE_HOOKS
  42104. });
  42105. /* */
  42106. /**
  42107. * unicode letters used for parsing html tags, component names and property paths.
  42108. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42109. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42110. */
  42111. var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  42112. /**
  42113. * Check if a string starts with $ or _
  42114. */
  42115. function isReserved (str) {
  42116. var c = (str + '').charCodeAt(0);
  42117. return c === 0x24 || c === 0x5F
  42118. }
  42119. /**
  42120. * Define a property.
  42121. */
  42122. function def (obj, key, val, enumerable) {
  42123. Object.defineProperty(obj, key, {
  42124. value: val,
  42125. enumerable: !!enumerable,
  42126. writable: true,
  42127. configurable: true
  42128. });
  42129. }
  42130. /**
  42131. * Parse simple path.
  42132. */
  42133. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42134. function parsePath (path) {
  42135. if (bailRE.test(path)) {
  42136. return
  42137. }
  42138. var segments = path.split('.');
  42139. return function (obj) {
  42140. for (var i = 0; i < segments.length; i++) {
  42141. if (!obj) { return }
  42142. obj = obj[segments[i]];
  42143. }
  42144. return obj
  42145. }
  42146. }
  42147. /* */
  42148. // can we use __proto__?
  42149. var hasProto = '__proto__' in {};
  42150. // Browser environment sniffing
  42151. var inBrowser = typeof window !== 'undefined';
  42152. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42153. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42154. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42155. var isIE = UA && /msie|trident/.test(UA);
  42156. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42157. var isEdge = UA && UA.indexOf('edge/') > 0;
  42158. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42159. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42160. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42161. var isPhantomJS = UA && /phantomjs/.test(UA);
  42162. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42163. // Firefox has a "watch" function on Object.prototype...
  42164. var nativeWatch = ({}).watch;
  42165. var supportsPassive = false;
  42166. if (inBrowser) {
  42167. try {
  42168. var opts = {};
  42169. Object.defineProperty(opts, 'passive', ({
  42170. get: function get () {
  42171. /* istanbul ignore next */
  42172. supportsPassive = true;
  42173. }
  42174. })); // https://github.com/facebook/flow/issues/285
  42175. window.addEventListener('test-passive', null, opts);
  42176. } catch (e) {}
  42177. }
  42178. // this needs to be lazy-evaled because vue may be required before
  42179. // vue-server-renderer can set VUE_ENV
  42180. var _isServer;
  42181. var isServerRendering = function () {
  42182. if (_isServer === undefined) {
  42183. /* istanbul ignore if */
  42184. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42185. // detect presence of vue-server-renderer and avoid
  42186. // Webpack shimming the process
  42187. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42188. } else {
  42189. _isServer = false;
  42190. }
  42191. }
  42192. return _isServer
  42193. };
  42194. // detect devtools
  42195. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42196. /* istanbul ignore next */
  42197. function isNative (Ctor) {
  42198. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42199. }
  42200. var hasSymbol =
  42201. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42202. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42203. var _Set;
  42204. /* istanbul ignore if */ // $flow-disable-line
  42205. if (typeof Set !== 'undefined' && isNative(Set)) {
  42206. // use native Set when available.
  42207. _Set = Set;
  42208. } else {
  42209. // a non-standard Set polyfill that only works with primitive keys.
  42210. _Set = /*@__PURE__*/(function () {
  42211. function Set () {
  42212. this.set = Object.create(null);
  42213. }
  42214. Set.prototype.has = function has (key) {
  42215. return this.set[key] === true
  42216. };
  42217. Set.prototype.add = function add (key) {
  42218. this.set[key] = true;
  42219. };
  42220. Set.prototype.clear = function clear () {
  42221. this.set = Object.create(null);
  42222. };
  42223. return Set;
  42224. }());
  42225. }
  42226. /* */
  42227. var warn = noop;
  42228. var tip = noop;
  42229. var generateComponentTrace = (noop); // work around flow check
  42230. var formatComponentName = (noop);
  42231. {
  42232. var hasConsole = typeof console !== 'undefined';
  42233. var classifyRE = /(?:^|[-_])(\w)/g;
  42234. var classify = function (str) { return str
  42235. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42236. .replace(/[-_]/g, ''); };
  42237. warn = function (msg, vm) {
  42238. var trace = vm ? generateComponentTrace(vm) : '';
  42239. if (config.warnHandler) {
  42240. config.warnHandler.call(null, msg, vm, trace);
  42241. } else if (hasConsole && (!config.silent)) {
  42242. console.error(("[Vue warn]: " + msg + trace));
  42243. }
  42244. };
  42245. tip = function (msg, vm) {
  42246. if (hasConsole && (!config.silent)) {
  42247. console.warn("[Vue tip]: " + msg + (
  42248. vm ? generateComponentTrace(vm) : ''
  42249. ));
  42250. }
  42251. };
  42252. formatComponentName = function (vm, includeFile) {
  42253. if (vm.$root === vm) {
  42254. return '<Root>'
  42255. }
  42256. var options = typeof vm === 'function' && vm.cid != null
  42257. ? vm.options
  42258. : vm._isVue
  42259. ? vm.$options || vm.constructor.options
  42260. : vm;
  42261. var name = options.name || options._componentTag;
  42262. var file = options.__file;
  42263. if (!name && file) {
  42264. var match = file.match(/([^/\\]+)\.vue$/);
  42265. name = match && match[1];
  42266. }
  42267. return (
  42268. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42269. (file && includeFile !== false ? (" at " + file) : '')
  42270. )
  42271. };
  42272. var repeat = function (str, n) {
  42273. var res = '';
  42274. while (n) {
  42275. if (n % 2 === 1) { res += str; }
  42276. if (n > 1) { str += str; }
  42277. n >>= 1;
  42278. }
  42279. return res
  42280. };
  42281. generateComponentTrace = function (vm) {
  42282. if (vm._isVue && vm.$parent) {
  42283. var tree = [];
  42284. var currentRecursiveSequence = 0;
  42285. while (vm) {
  42286. if (tree.length > 0) {
  42287. var last = tree[tree.length - 1];
  42288. if (last.constructor === vm.constructor) {
  42289. currentRecursiveSequence++;
  42290. vm = vm.$parent;
  42291. continue
  42292. } else if (currentRecursiveSequence > 0) {
  42293. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42294. currentRecursiveSequence = 0;
  42295. }
  42296. }
  42297. tree.push(vm);
  42298. vm = vm.$parent;
  42299. }
  42300. return '\n\nfound in\n\n' + tree
  42301. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42302. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42303. : formatComponentName(vm))); })
  42304. .join('\n')
  42305. } else {
  42306. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42307. }
  42308. };
  42309. }
  42310. /* */
  42311. var uid = 0;
  42312. /**
  42313. * A dep is an observable that can have multiple
  42314. * directives subscribing to it.
  42315. */
  42316. var Dep = function Dep () {
  42317. this.id = uid++;
  42318. this.subs = [];
  42319. };
  42320. Dep.prototype.addSub = function addSub (sub) {
  42321. this.subs.push(sub);
  42322. };
  42323. Dep.prototype.removeSub = function removeSub (sub) {
  42324. remove(this.subs, sub);
  42325. };
  42326. Dep.prototype.depend = function depend () {
  42327. if (Dep.target) {
  42328. Dep.target.addDep(this);
  42329. }
  42330. };
  42331. Dep.prototype.notify = function notify () {
  42332. // stabilize the subscriber list first
  42333. var subs = this.subs.slice();
  42334. if (!config.async) {
  42335. // subs aren't sorted in scheduler if not running async
  42336. // we need to sort them now to make sure they fire in correct
  42337. // order
  42338. subs.sort(function (a, b) { return a.id - b.id; });
  42339. }
  42340. for (var i = 0, l = subs.length; i < l; i++) {
  42341. subs[i].update();
  42342. }
  42343. };
  42344. // The current target watcher being evaluated.
  42345. // This is globally unique because only one watcher
  42346. // can be evaluated at a time.
  42347. Dep.target = null;
  42348. var targetStack = [];
  42349. function pushTarget (target) {
  42350. targetStack.push(target);
  42351. Dep.target = target;
  42352. }
  42353. function popTarget () {
  42354. targetStack.pop();
  42355. Dep.target = targetStack[targetStack.length - 1];
  42356. }
  42357. /* */
  42358. var VNode = function VNode (
  42359. tag,
  42360. data,
  42361. children,
  42362. text,
  42363. elm,
  42364. context,
  42365. componentOptions,
  42366. asyncFactory
  42367. ) {
  42368. this.tag = tag;
  42369. this.data = data;
  42370. this.children = children;
  42371. this.text = text;
  42372. this.elm = elm;
  42373. this.ns = undefined;
  42374. this.context = context;
  42375. this.fnContext = undefined;
  42376. this.fnOptions = undefined;
  42377. this.fnScopeId = undefined;
  42378. this.key = data && data.key;
  42379. this.componentOptions = componentOptions;
  42380. this.componentInstance = undefined;
  42381. this.parent = undefined;
  42382. this.raw = false;
  42383. this.isStatic = false;
  42384. this.isRootInsert = true;
  42385. this.isComment = false;
  42386. this.isCloned = false;
  42387. this.isOnce = false;
  42388. this.asyncFactory = asyncFactory;
  42389. this.asyncMeta = undefined;
  42390. this.isAsyncPlaceholder = false;
  42391. };
  42392. var prototypeAccessors = { child: { configurable: true } };
  42393. // DEPRECATED: alias for componentInstance for backwards compat.
  42394. /* istanbul ignore next */
  42395. prototypeAccessors.child.get = function () {
  42396. return this.componentInstance
  42397. };
  42398. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42399. var createEmptyVNode = function (text) {
  42400. if ( text === void 0 ) text = '';
  42401. var node = new VNode();
  42402. node.text = text;
  42403. node.isComment = true;
  42404. return node
  42405. };
  42406. function createTextVNode (val) {
  42407. return new VNode(undefined, undefined, undefined, String(val))
  42408. }
  42409. // optimized shallow clone
  42410. // used for static nodes and slot nodes because they may be reused across
  42411. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42412. // on their elm reference.
  42413. function cloneVNode (vnode) {
  42414. var cloned = new VNode(
  42415. vnode.tag,
  42416. vnode.data,
  42417. // #7975
  42418. // clone children array to avoid mutating original in case of cloning
  42419. // a child.
  42420. vnode.children && vnode.children.slice(),
  42421. vnode.text,
  42422. vnode.elm,
  42423. vnode.context,
  42424. vnode.componentOptions,
  42425. vnode.asyncFactory
  42426. );
  42427. cloned.ns = vnode.ns;
  42428. cloned.isStatic = vnode.isStatic;
  42429. cloned.key = vnode.key;
  42430. cloned.isComment = vnode.isComment;
  42431. cloned.fnContext = vnode.fnContext;
  42432. cloned.fnOptions = vnode.fnOptions;
  42433. cloned.fnScopeId = vnode.fnScopeId;
  42434. cloned.asyncMeta = vnode.asyncMeta;
  42435. cloned.isCloned = true;
  42436. return cloned
  42437. }
  42438. /*
  42439. * not type checking this file because flow doesn't play well with
  42440. * dynamically accessing methods on Array prototype
  42441. */
  42442. var arrayProto = Array.prototype;
  42443. var arrayMethods = Object.create(arrayProto);
  42444. var methodsToPatch = [
  42445. 'push',
  42446. 'pop',
  42447. 'shift',
  42448. 'unshift',
  42449. 'splice',
  42450. 'sort',
  42451. 'reverse'
  42452. ];
  42453. /**
  42454. * Intercept mutating methods and emit events
  42455. */
  42456. methodsToPatch.forEach(function (method) {
  42457. // cache original method
  42458. var original = arrayProto[method];
  42459. def(arrayMethods, method, function mutator () {
  42460. var args = [], len = arguments.length;
  42461. while ( len-- ) args[ len ] = arguments[ len ];
  42462. var result = original.apply(this, args);
  42463. var ob = this.__ob__;
  42464. var inserted;
  42465. switch (method) {
  42466. case 'push':
  42467. case 'unshift':
  42468. inserted = args;
  42469. break
  42470. case 'splice':
  42471. inserted = args.slice(2);
  42472. break
  42473. }
  42474. if (inserted) { ob.observeArray(inserted); }
  42475. // notify change
  42476. ob.dep.notify();
  42477. return result
  42478. });
  42479. });
  42480. /* */
  42481. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42482. /**
  42483. * In some cases we may want to disable observation inside a component's
  42484. * update computation.
  42485. */
  42486. var shouldObserve = true;
  42487. function toggleObserving (value) {
  42488. shouldObserve = value;
  42489. }
  42490. /**
  42491. * Observer class that is attached to each observed
  42492. * object. Once attached, the observer converts the target
  42493. * object's property keys into getter/setters that
  42494. * collect dependencies and dispatch updates.
  42495. */
  42496. var Observer = function Observer (value) {
  42497. this.value = value;
  42498. this.dep = new Dep();
  42499. this.vmCount = 0;
  42500. def(value, '__ob__', this);
  42501. if (Array.isArray(value)) {
  42502. if (hasProto) {
  42503. protoAugment(value, arrayMethods);
  42504. } else {
  42505. copyAugment(value, arrayMethods, arrayKeys);
  42506. }
  42507. this.observeArray(value);
  42508. } else {
  42509. this.walk(value);
  42510. }
  42511. };
  42512. /**
  42513. * Walk through all properties and convert them into
  42514. * getter/setters. This method should only be called when
  42515. * value type is Object.
  42516. */
  42517. Observer.prototype.walk = function walk (obj) {
  42518. var keys = Object.keys(obj);
  42519. for (var i = 0; i < keys.length; i++) {
  42520. defineReactive$$1(obj, keys[i]);
  42521. }
  42522. };
  42523. /**
  42524. * Observe a list of Array items.
  42525. */
  42526. Observer.prototype.observeArray = function observeArray (items) {
  42527. for (var i = 0, l = items.length; i < l; i++) {
  42528. observe(items[i]);
  42529. }
  42530. };
  42531. // helpers
  42532. /**
  42533. * Augment a target Object or Array by intercepting
  42534. * the prototype chain using __proto__
  42535. */
  42536. function protoAugment (target, src) {
  42537. /* eslint-disable no-proto */
  42538. target.__proto__ = src;
  42539. /* eslint-enable no-proto */
  42540. }
  42541. /**
  42542. * Augment a target Object or Array by defining
  42543. * hidden properties.
  42544. */
  42545. /* istanbul ignore next */
  42546. function copyAugment (target, src, keys) {
  42547. for (var i = 0, l = keys.length; i < l; i++) {
  42548. var key = keys[i];
  42549. def(target, key, src[key]);
  42550. }
  42551. }
  42552. /**
  42553. * Attempt to create an observer instance for a value,
  42554. * returns the new observer if successfully observed,
  42555. * or the existing observer if the value already has one.
  42556. */
  42557. function observe (value, asRootData) {
  42558. if (!isObject(value) || value instanceof VNode) {
  42559. return
  42560. }
  42561. var ob;
  42562. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42563. ob = value.__ob__;
  42564. } else if (
  42565. shouldObserve &&
  42566. !isServerRendering() &&
  42567. (Array.isArray(value) || isPlainObject(value)) &&
  42568. Object.isExtensible(value) &&
  42569. !value._isVue
  42570. ) {
  42571. ob = new Observer(value);
  42572. }
  42573. if (asRootData && ob) {
  42574. ob.vmCount++;
  42575. }
  42576. return ob
  42577. }
  42578. /**
  42579. * Define a reactive property on an Object.
  42580. */
  42581. function defineReactive$$1 (
  42582. obj,
  42583. key,
  42584. val,
  42585. customSetter,
  42586. shallow
  42587. ) {
  42588. var dep = new Dep();
  42589. var property = Object.getOwnPropertyDescriptor(obj, key);
  42590. if (property && property.configurable === false) {
  42591. return
  42592. }
  42593. // cater for pre-defined getter/setters
  42594. var getter = property && property.get;
  42595. var setter = property && property.set;
  42596. if ((!getter || setter) && arguments.length === 2) {
  42597. val = obj[key];
  42598. }
  42599. var childOb = !shallow && observe(val);
  42600. Object.defineProperty(obj, key, {
  42601. enumerable: true,
  42602. configurable: true,
  42603. get: function reactiveGetter () {
  42604. var value = getter ? getter.call(obj) : val;
  42605. if (Dep.target) {
  42606. dep.depend();
  42607. if (childOb) {
  42608. childOb.dep.depend();
  42609. if (Array.isArray(value)) {
  42610. dependArray(value);
  42611. }
  42612. }
  42613. }
  42614. return value
  42615. },
  42616. set: function reactiveSetter (newVal) {
  42617. var value = getter ? getter.call(obj) : val;
  42618. /* eslint-disable no-self-compare */
  42619. if (newVal === value || (newVal !== newVal && value !== value)) {
  42620. return
  42621. }
  42622. /* eslint-enable no-self-compare */
  42623. if (customSetter) {
  42624. customSetter();
  42625. }
  42626. // #7981: for accessor properties without setter
  42627. if (getter && !setter) { return }
  42628. if (setter) {
  42629. setter.call(obj, newVal);
  42630. } else {
  42631. val = newVal;
  42632. }
  42633. childOb = !shallow && observe(newVal);
  42634. dep.notify();
  42635. }
  42636. });
  42637. }
  42638. /**
  42639. * Set a property on an object. Adds the new property and
  42640. * triggers change notification if the property doesn't
  42641. * already exist.
  42642. */
  42643. function set (target, key, val) {
  42644. if (isUndef(target) || isPrimitive(target)
  42645. ) {
  42646. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42647. }
  42648. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42649. target.length = Math.max(target.length, key);
  42650. target.splice(key, 1, val);
  42651. return val
  42652. }
  42653. if (key in target && !(key in Object.prototype)) {
  42654. target[key] = val;
  42655. return val
  42656. }
  42657. var ob = (target).__ob__;
  42658. if (target._isVue || (ob && ob.vmCount)) {
  42659. warn(
  42660. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42661. 'at runtime - declare it upfront in the data option.'
  42662. );
  42663. return val
  42664. }
  42665. if (!ob) {
  42666. target[key] = val;
  42667. return val
  42668. }
  42669. defineReactive$$1(ob.value, key, val);
  42670. ob.dep.notify();
  42671. return val
  42672. }
  42673. /**
  42674. * Delete a property and trigger change if necessary.
  42675. */
  42676. function del (target, key) {
  42677. if (isUndef(target) || isPrimitive(target)
  42678. ) {
  42679. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42680. }
  42681. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42682. target.splice(key, 1);
  42683. return
  42684. }
  42685. var ob = (target).__ob__;
  42686. if (target._isVue || (ob && ob.vmCount)) {
  42687. warn(
  42688. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42689. '- just set it to null.'
  42690. );
  42691. return
  42692. }
  42693. if (!hasOwn(target, key)) {
  42694. return
  42695. }
  42696. delete target[key];
  42697. if (!ob) {
  42698. return
  42699. }
  42700. ob.dep.notify();
  42701. }
  42702. /**
  42703. * Collect dependencies on array elements when the array is touched, since
  42704. * we cannot intercept array element access like property getters.
  42705. */
  42706. function dependArray (value) {
  42707. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42708. e = value[i];
  42709. e && e.__ob__ && e.__ob__.dep.depend();
  42710. if (Array.isArray(e)) {
  42711. dependArray(e);
  42712. }
  42713. }
  42714. }
  42715. /* */
  42716. /**
  42717. * Option overwriting strategies are functions that handle
  42718. * how to merge a parent option value and a child option
  42719. * value into the final value.
  42720. */
  42721. var strats = config.optionMergeStrategies;
  42722. /**
  42723. * Options with restrictions
  42724. */
  42725. {
  42726. strats.el = strats.propsData = function (parent, child, vm, key) {
  42727. if (!vm) {
  42728. warn(
  42729. "option \"" + key + "\" can only be used during instance " +
  42730. 'creation with the `new` keyword.'
  42731. );
  42732. }
  42733. return defaultStrat(parent, child)
  42734. };
  42735. }
  42736. /**
  42737. * Helper that recursively merges two data objects together.
  42738. */
  42739. function mergeData (to, from) {
  42740. if (!from) { return to }
  42741. var key, toVal, fromVal;
  42742. var keys = hasSymbol
  42743. ? Reflect.ownKeys(from)
  42744. : Object.keys(from);
  42745. for (var i = 0; i < keys.length; i++) {
  42746. key = keys[i];
  42747. // in case the object is already observed...
  42748. if (key === '__ob__') { continue }
  42749. toVal = to[key];
  42750. fromVal = from[key];
  42751. if (!hasOwn(to, key)) {
  42752. set(to, key, fromVal);
  42753. } else if (
  42754. toVal !== fromVal &&
  42755. isPlainObject(toVal) &&
  42756. isPlainObject(fromVal)
  42757. ) {
  42758. mergeData(toVal, fromVal);
  42759. }
  42760. }
  42761. return to
  42762. }
  42763. /**
  42764. * Data
  42765. */
  42766. function mergeDataOrFn (
  42767. parentVal,
  42768. childVal,
  42769. vm
  42770. ) {
  42771. if (!vm) {
  42772. // in a Vue.extend merge, both should be functions
  42773. if (!childVal) {
  42774. return parentVal
  42775. }
  42776. if (!parentVal) {
  42777. return childVal
  42778. }
  42779. // when parentVal & childVal are both present,
  42780. // we need to return a function that returns the
  42781. // merged result of both functions... no need to
  42782. // check if parentVal is a function here because
  42783. // it has to be a function to pass previous merges.
  42784. return function mergedDataFn () {
  42785. return mergeData(
  42786. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42787. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42788. )
  42789. }
  42790. } else {
  42791. return function mergedInstanceDataFn () {
  42792. // instance merge
  42793. var instanceData = typeof childVal === 'function'
  42794. ? childVal.call(vm, vm)
  42795. : childVal;
  42796. var defaultData = typeof parentVal === 'function'
  42797. ? parentVal.call(vm, vm)
  42798. : parentVal;
  42799. if (instanceData) {
  42800. return mergeData(instanceData, defaultData)
  42801. } else {
  42802. return defaultData
  42803. }
  42804. }
  42805. }
  42806. }
  42807. strats.data = function (
  42808. parentVal,
  42809. childVal,
  42810. vm
  42811. ) {
  42812. if (!vm) {
  42813. if (childVal && typeof childVal !== 'function') {
  42814. warn(
  42815. 'The "data" option should be a function ' +
  42816. 'that returns a per-instance value in component ' +
  42817. 'definitions.',
  42818. vm
  42819. );
  42820. return parentVal
  42821. }
  42822. return mergeDataOrFn(parentVal, childVal)
  42823. }
  42824. return mergeDataOrFn(parentVal, childVal, vm)
  42825. };
  42826. /**
  42827. * Hooks and props are merged as arrays.
  42828. */
  42829. function mergeHook (
  42830. parentVal,
  42831. childVal
  42832. ) {
  42833. var res = childVal
  42834. ? parentVal
  42835. ? parentVal.concat(childVal)
  42836. : Array.isArray(childVal)
  42837. ? childVal
  42838. : [childVal]
  42839. : parentVal;
  42840. return res
  42841. ? dedupeHooks(res)
  42842. : res
  42843. }
  42844. function dedupeHooks (hooks) {
  42845. var res = [];
  42846. for (var i = 0; i < hooks.length; i++) {
  42847. if (res.indexOf(hooks[i]) === -1) {
  42848. res.push(hooks[i]);
  42849. }
  42850. }
  42851. return res
  42852. }
  42853. LIFECYCLE_HOOKS.forEach(function (hook) {
  42854. strats[hook] = mergeHook;
  42855. });
  42856. /**
  42857. * Assets
  42858. *
  42859. * When a vm is present (instance creation), we need to do
  42860. * a three-way merge between constructor options, instance
  42861. * options and parent options.
  42862. */
  42863. function mergeAssets (
  42864. parentVal,
  42865. childVal,
  42866. vm,
  42867. key
  42868. ) {
  42869. var res = Object.create(parentVal || null);
  42870. if (childVal) {
  42871. assertObjectType(key, childVal, vm);
  42872. return extend(res, childVal)
  42873. } else {
  42874. return res
  42875. }
  42876. }
  42877. ASSET_TYPES.forEach(function (type) {
  42878. strats[type + 's'] = mergeAssets;
  42879. });
  42880. /**
  42881. * Watchers.
  42882. *
  42883. * Watchers hashes should not overwrite one
  42884. * another, so we merge them as arrays.
  42885. */
  42886. strats.watch = function (
  42887. parentVal,
  42888. childVal,
  42889. vm,
  42890. key
  42891. ) {
  42892. // work around Firefox's Object.prototype.watch...
  42893. if (parentVal === nativeWatch) { parentVal = undefined; }
  42894. if (childVal === nativeWatch) { childVal = undefined; }
  42895. /* istanbul ignore if */
  42896. if (!childVal) { return Object.create(parentVal || null) }
  42897. {
  42898. assertObjectType(key, childVal, vm);
  42899. }
  42900. if (!parentVal) { return childVal }
  42901. var ret = {};
  42902. extend(ret, parentVal);
  42903. for (var key$1 in childVal) {
  42904. var parent = ret[key$1];
  42905. var child = childVal[key$1];
  42906. if (parent && !Array.isArray(parent)) {
  42907. parent = [parent];
  42908. }
  42909. ret[key$1] = parent
  42910. ? parent.concat(child)
  42911. : Array.isArray(child) ? child : [child];
  42912. }
  42913. return ret
  42914. };
  42915. /**
  42916. * Other object hashes.
  42917. */
  42918. strats.props =
  42919. strats.methods =
  42920. strats.inject =
  42921. strats.computed = function (
  42922. parentVal,
  42923. childVal,
  42924. vm,
  42925. key
  42926. ) {
  42927. if (childVal && "development" !== 'production') {
  42928. assertObjectType(key, childVal, vm);
  42929. }
  42930. if (!parentVal) { return childVal }
  42931. var ret = Object.create(null);
  42932. extend(ret, parentVal);
  42933. if (childVal) { extend(ret, childVal); }
  42934. return ret
  42935. };
  42936. strats.provide = mergeDataOrFn;
  42937. /**
  42938. * Default strategy.
  42939. */
  42940. var defaultStrat = function (parentVal, childVal) {
  42941. return childVal === undefined
  42942. ? parentVal
  42943. : childVal
  42944. };
  42945. /**
  42946. * Validate component names
  42947. */
  42948. function checkComponents (options) {
  42949. for (var key in options.components) {
  42950. validateComponentName(key);
  42951. }
  42952. }
  42953. function validateComponentName (name) {
  42954. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  42955. warn(
  42956. 'Invalid component name: "' + name + '". Component names ' +
  42957. 'should conform to valid custom element name in html5 specification.'
  42958. );
  42959. }
  42960. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  42961. warn(
  42962. 'Do not use built-in or reserved HTML elements as component ' +
  42963. 'id: ' + name
  42964. );
  42965. }
  42966. }
  42967. /**
  42968. * Ensure all props option syntax are normalized into the
  42969. * Object-based format.
  42970. */
  42971. function normalizeProps (options, vm) {
  42972. var props = options.props;
  42973. if (!props) { return }
  42974. var res = {};
  42975. var i, val, name;
  42976. if (Array.isArray(props)) {
  42977. i = props.length;
  42978. while (i--) {
  42979. val = props[i];
  42980. if (typeof val === 'string') {
  42981. name = camelize(val);
  42982. res[name] = { type: null };
  42983. } else {
  42984. warn('props must be strings when using array syntax.');
  42985. }
  42986. }
  42987. } else if (isPlainObject(props)) {
  42988. for (var key in props) {
  42989. val = props[key];
  42990. name = camelize(key);
  42991. res[name] = isPlainObject(val)
  42992. ? val
  42993. : { type: val };
  42994. }
  42995. } else {
  42996. warn(
  42997. "Invalid value for option \"props\": expected an Array or an Object, " +
  42998. "but got " + (toRawType(props)) + ".",
  42999. vm
  43000. );
  43001. }
  43002. options.props = res;
  43003. }
  43004. /**
  43005. * Normalize all injections into Object-based format
  43006. */
  43007. function normalizeInject (options, vm) {
  43008. var inject = options.inject;
  43009. if (!inject) { return }
  43010. var normalized = options.inject = {};
  43011. if (Array.isArray(inject)) {
  43012. for (var i = 0; i < inject.length; i++) {
  43013. normalized[inject[i]] = { from: inject[i] };
  43014. }
  43015. } else if (isPlainObject(inject)) {
  43016. for (var key in inject) {
  43017. var val = inject[key];
  43018. normalized[key] = isPlainObject(val)
  43019. ? extend({ from: key }, val)
  43020. : { from: val };
  43021. }
  43022. } else {
  43023. warn(
  43024. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43025. "but got " + (toRawType(inject)) + ".",
  43026. vm
  43027. );
  43028. }
  43029. }
  43030. /**
  43031. * Normalize raw function directives into object format.
  43032. */
  43033. function normalizeDirectives (options) {
  43034. var dirs = options.directives;
  43035. if (dirs) {
  43036. for (var key in dirs) {
  43037. var def$$1 = dirs[key];
  43038. if (typeof def$$1 === 'function') {
  43039. dirs[key] = { bind: def$$1, update: def$$1 };
  43040. }
  43041. }
  43042. }
  43043. }
  43044. function assertObjectType (name, value, vm) {
  43045. if (!isPlainObject(value)) {
  43046. warn(
  43047. "Invalid value for option \"" + name + "\": expected an Object, " +
  43048. "but got " + (toRawType(value)) + ".",
  43049. vm
  43050. );
  43051. }
  43052. }
  43053. /**
  43054. * Merge two option objects into a new one.
  43055. * Core utility used in both instantiation and inheritance.
  43056. */
  43057. function mergeOptions (
  43058. parent,
  43059. child,
  43060. vm
  43061. ) {
  43062. {
  43063. checkComponents(child);
  43064. }
  43065. if (typeof child === 'function') {
  43066. child = child.options;
  43067. }
  43068. normalizeProps(child, vm);
  43069. normalizeInject(child, vm);
  43070. normalizeDirectives(child);
  43071. // Apply extends and mixins on the child options,
  43072. // but only if it is a raw options object that isn't
  43073. // the result of another mergeOptions call.
  43074. // Only merged options has the _base property.
  43075. if (!child._base) {
  43076. if (child.extends) {
  43077. parent = mergeOptions(parent, child.extends, vm);
  43078. }
  43079. if (child.mixins) {
  43080. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43081. parent = mergeOptions(parent, child.mixins[i], vm);
  43082. }
  43083. }
  43084. }
  43085. var options = {};
  43086. var key;
  43087. for (key in parent) {
  43088. mergeField(key);
  43089. }
  43090. for (key in child) {
  43091. if (!hasOwn(parent, key)) {
  43092. mergeField(key);
  43093. }
  43094. }
  43095. function mergeField (key) {
  43096. var strat = strats[key] || defaultStrat;
  43097. options[key] = strat(parent[key], child[key], vm, key);
  43098. }
  43099. return options
  43100. }
  43101. /**
  43102. * Resolve an asset.
  43103. * This function is used because child instances need access
  43104. * to assets defined in its ancestor chain.
  43105. */
  43106. function resolveAsset (
  43107. options,
  43108. type,
  43109. id,
  43110. warnMissing
  43111. ) {
  43112. /* istanbul ignore if */
  43113. if (typeof id !== 'string') {
  43114. return
  43115. }
  43116. var assets = options[type];
  43117. // check local registration variations first
  43118. if (hasOwn(assets, id)) { return assets[id] }
  43119. var camelizedId = camelize(id);
  43120. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43121. var PascalCaseId = capitalize(camelizedId);
  43122. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43123. // fallback to prototype chain
  43124. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43125. if (warnMissing && !res) {
  43126. warn(
  43127. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43128. options
  43129. );
  43130. }
  43131. return res
  43132. }
  43133. /* */
  43134. function validateProp (
  43135. key,
  43136. propOptions,
  43137. propsData,
  43138. vm
  43139. ) {
  43140. var prop = propOptions[key];
  43141. var absent = !hasOwn(propsData, key);
  43142. var value = propsData[key];
  43143. // boolean casting
  43144. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43145. if (booleanIndex > -1) {
  43146. if (absent && !hasOwn(prop, 'default')) {
  43147. value = false;
  43148. } else if (value === '' || value === hyphenate(key)) {
  43149. // only cast empty string / same name to boolean if
  43150. // boolean has higher priority
  43151. var stringIndex = getTypeIndex(String, prop.type);
  43152. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43153. value = true;
  43154. }
  43155. }
  43156. }
  43157. // check default value
  43158. if (value === undefined) {
  43159. value = getPropDefaultValue(vm, prop, key);
  43160. // since the default value is a fresh copy,
  43161. // make sure to observe it.
  43162. var prevShouldObserve = shouldObserve;
  43163. toggleObserving(true);
  43164. observe(value);
  43165. toggleObserving(prevShouldObserve);
  43166. }
  43167. {
  43168. assertProp(prop, key, value, vm, absent);
  43169. }
  43170. return value
  43171. }
  43172. /**
  43173. * Get the default value of a prop.
  43174. */
  43175. function getPropDefaultValue (vm, prop, key) {
  43176. // no default, return undefined
  43177. if (!hasOwn(prop, 'default')) {
  43178. return undefined
  43179. }
  43180. var def = prop.default;
  43181. // warn against non-factory defaults for Object & Array
  43182. if (isObject(def)) {
  43183. warn(
  43184. 'Invalid default value for prop "' + key + '": ' +
  43185. 'Props with type Object/Array must use a factory function ' +
  43186. 'to return the default value.',
  43187. vm
  43188. );
  43189. }
  43190. // the raw prop value was also undefined from previous render,
  43191. // return previous default value to avoid unnecessary watcher trigger
  43192. if (vm && vm.$options.propsData &&
  43193. vm.$options.propsData[key] === undefined &&
  43194. vm._props[key] !== undefined
  43195. ) {
  43196. return vm._props[key]
  43197. }
  43198. // call factory function for non-Function types
  43199. // a value is Function if its prototype is function even across different execution context
  43200. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43201. ? def.call(vm)
  43202. : def
  43203. }
  43204. /**
  43205. * Assert whether a prop is valid.
  43206. */
  43207. function assertProp (
  43208. prop,
  43209. name,
  43210. value,
  43211. vm,
  43212. absent
  43213. ) {
  43214. if (prop.required && absent) {
  43215. warn(
  43216. 'Missing required prop: "' + name + '"',
  43217. vm
  43218. );
  43219. return
  43220. }
  43221. if (value == null && !prop.required) {
  43222. return
  43223. }
  43224. var type = prop.type;
  43225. var valid = !type || type === true;
  43226. var expectedTypes = [];
  43227. if (type) {
  43228. if (!Array.isArray(type)) {
  43229. type = [type];
  43230. }
  43231. for (var i = 0; i < type.length && !valid; i++) {
  43232. var assertedType = assertType(value, type[i]);
  43233. expectedTypes.push(assertedType.expectedType || '');
  43234. valid = assertedType.valid;
  43235. }
  43236. }
  43237. if (!valid) {
  43238. warn(
  43239. getInvalidTypeMessage(name, value, expectedTypes),
  43240. vm
  43241. );
  43242. return
  43243. }
  43244. var validator = prop.validator;
  43245. if (validator) {
  43246. if (!validator(value)) {
  43247. warn(
  43248. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43249. vm
  43250. );
  43251. }
  43252. }
  43253. }
  43254. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43255. function assertType (value, type) {
  43256. var valid;
  43257. var expectedType = getType(type);
  43258. if (simpleCheckRE.test(expectedType)) {
  43259. var t = typeof value;
  43260. valid = t === expectedType.toLowerCase();
  43261. // for primitive wrapper objects
  43262. if (!valid && t === 'object') {
  43263. valid = value instanceof type;
  43264. }
  43265. } else if (expectedType === 'Object') {
  43266. valid = isPlainObject(value);
  43267. } else if (expectedType === 'Array') {
  43268. valid = Array.isArray(value);
  43269. } else {
  43270. valid = value instanceof type;
  43271. }
  43272. return {
  43273. valid: valid,
  43274. expectedType: expectedType
  43275. }
  43276. }
  43277. /**
  43278. * Use function string name to check built-in types,
  43279. * because a simple equality check will fail when running
  43280. * across different vms / iframes.
  43281. */
  43282. function getType (fn) {
  43283. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43284. return match ? match[1] : ''
  43285. }
  43286. function isSameType (a, b) {
  43287. return getType(a) === getType(b)
  43288. }
  43289. function getTypeIndex (type, expectedTypes) {
  43290. if (!Array.isArray(expectedTypes)) {
  43291. return isSameType(expectedTypes, type) ? 0 : -1
  43292. }
  43293. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43294. if (isSameType(expectedTypes[i], type)) {
  43295. return i
  43296. }
  43297. }
  43298. return -1
  43299. }
  43300. function getInvalidTypeMessage (name, value, expectedTypes) {
  43301. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43302. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43303. var expectedType = expectedTypes[0];
  43304. var receivedType = toRawType(value);
  43305. var expectedValue = styleValue(value, expectedType);
  43306. var receivedValue = styleValue(value, receivedType);
  43307. // check if we need to specify expected value
  43308. if (expectedTypes.length === 1 &&
  43309. isExplicable(expectedType) &&
  43310. !isBoolean(expectedType, receivedType)) {
  43311. message += " with value " + expectedValue;
  43312. }
  43313. message += ", got " + receivedType + " ";
  43314. // check if we need to specify received value
  43315. if (isExplicable(receivedType)) {
  43316. message += "with value " + receivedValue + ".";
  43317. }
  43318. return message
  43319. }
  43320. function styleValue (value, type) {
  43321. if (type === 'String') {
  43322. return ("\"" + value + "\"")
  43323. } else if (type === 'Number') {
  43324. return ("" + (Number(value)))
  43325. } else {
  43326. return ("" + value)
  43327. }
  43328. }
  43329. function isExplicable (value) {
  43330. var explicitTypes = ['string', 'number', 'boolean'];
  43331. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43332. }
  43333. function isBoolean () {
  43334. var args = [], len = arguments.length;
  43335. while ( len-- ) args[ len ] = arguments[ len ];
  43336. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43337. }
  43338. /* */
  43339. function handleError (err, vm, info) {
  43340. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43341. // See: https://github.com/vuejs/vuex/issues/1505
  43342. pushTarget();
  43343. try {
  43344. if (vm) {
  43345. var cur = vm;
  43346. while ((cur = cur.$parent)) {
  43347. var hooks = cur.$options.errorCaptured;
  43348. if (hooks) {
  43349. for (var i = 0; i < hooks.length; i++) {
  43350. try {
  43351. var capture = hooks[i].call(cur, err, vm, info) === false;
  43352. if (capture) { return }
  43353. } catch (e) {
  43354. globalHandleError(e, cur, 'errorCaptured hook');
  43355. }
  43356. }
  43357. }
  43358. }
  43359. }
  43360. globalHandleError(err, vm, info);
  43361. } finally {
  43362. popTarget();
  43363. }
  43364. }
  43365. function invokeWithErrorHandling (
  43366. handler,
  43367. context,
  43368. args,
  43369. vm,
  43370. info
  43371. ) {
  43372. var res;
  43373. try {
  43374. res = args ? handler.apply(context, args) : handler.call(context);
  43375. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43376. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43377. // issue #9511
  43378. // avoid catch triggering multiple times when nested calls
  43379. res._handled = true;
  43380. }
  43381. } catch (e) {
  43382. handleError(e, vm, info);
  43383. }
  43384. return res
  43385. }
  43386. function globalHandleError (err, vm, info) {
  43387. if (config.errorHandler) {
  43388. try {
  43389. return config.errorHandler.call(null, err, vm, info)
  43390. } catch (e) {
  43391. // if the user intentionally throws the original error in the handler,
  43392. // do not log it twice
  43393. if (e !== err) {
  43394. logError(e, null, 'config.errorHandler');
  43395. }
  43396. }
  43397. }
  43398. logError(err, vm, info);
  43399. }
  43400. function logError (err, vm, info) {
  43401. {
  43402. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43403. }
  43404. /* istanbul ignore else */
  43405. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43406. console.error(err);
  43407. } else {
  43408. throw err
  43409. }
  43410. }
  43411. /* */
  43412. var isUsingMicroTask = false;
  43413. var callbacks = [];
  43414. var pending = false;
  43415. function flushCallbacks () {
  43416. pending = false;
  43417. var copies = callbacks.slice(0);
  43418. callbacks.length = 0;
  43419. for (var i = 0; i < copies.length; i++) {
  43420. copies[i]();
  43421. }
  43422. }
  43423. // Here we have async deferring wrappers using microtasks.
  43424. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43425. // However, it has subtle problems when state is changed right before repaint
  43426. // (e.g. #6813, out-in transitions).
  43427. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43428. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43429. // So we now use microtasks everywhere, again.
  43430. // A major drawback of this tradeoff is that there are some scenarios
  43431. // where microtasks have too high a priority and fire in between supposedly
  43432. // sequential events (e.g. #4521, #6690, which have workarounds)
  43433. // or even between bubbling of the same event (#6566).
  43434. var timerFunc;
  43435. // The nextTick behavior leverages the microtask queue, which can be accessed
  43436. // via either native Promise.then or MutationObserver.
  43437. // MutationObserver has wider support, however it is seriously bugged in
  43438. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43439. // completely stops working after triggering a few times... so, if native
  43440. // Promise is available, we will use it:
  43441. /* istanbul ignore next, $flow-disable-line */
  43442. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43443. var p = Promise.resolve();
  43444. timerFunc = function () {
  43445. p.then(flushCallbacks);
  43446. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43447. // it can get stuck in a weird state where callbacks are pushed into the
  43448. // microtask queue but the queue isn't being flushed, until the browser
  43449. // needs to do some other work, e.g. handle a timer. Therefore we can
  43450. // "force" the microtask queue to be flushed by adding an empty timer.
  43451. if (isIOS) { setTimeout(noop); }
  43452. };
  43453. isUsingMicroTask = true;
  43454. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43455. isNative(MutationObserver) ||
  43456. // PhantomJS and iOS 7.x
  43457. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43458. )) {
  43459. // Use MutationObserver where native Promise is not available,
  43460. // e.g. PhantomJS, iOS7, Android 4.4
  43461. // (#6466 MutationObserver is unreliable in IE11)
  43462. var counter = 1;
  43463. var observer = new MutationObserver(flushCallbacks);
  43464. var textNode = document.createTextNode(String(counter));
  43465. observer.observe(textNode, {
  43466. characterData: true
  43467. });
  43468. timerFunc = function () {
  43469. counter = (counter + 1) % 2;
  43470. textNode.data = String(counter);
  43471. };
  43472. isUsingMicroTask = true;
  43473. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43474. // Fallback to setImmediate.
  43475. // Technically it leverages the (macro) task queue,
  43476. // but it is still a better choice than setTimeout.
  43477. timerFunc = function () {
  43478. setImmediate(flushCallbacks);
  43479. };
  43480. } else {
  43481. // Fallback to setTimeout.
  43482. timerFunc = function () {
  43483. setTimeout(flushCallbacks, 0);
  43484. };
  43485. }
  43486. function nextTick (cb, ctx) {
  43487. var _resolve;
  43488. callbacks.push(function () {
  43489. if (cb) {
  43490. try {
  43491. cb.call(ctx);
  43492. } catch (e) {
  43493. handleError(e, ctx, 'nextTick');
  43494. }
  43495. } else if (_resolve) {
  43496. _resolve(ctx);
  43497. }
  43498. });
  43499. if (!pending) {
  43500. pending = true;
  43501. timerFunc();
  43502. }
  43503. // $flow-disable-line
  43504. if (!cb && typeof Promise !== 'undefined') {
  43505. return new Promise(function (resolve) {
  43506. _resolve = resolve;
  43507. })
  43508. }
  43509. }
  43510. /* */
  43511. var mark;
  43512. var measure;
  43513. {
  43514. var perf = inBrowser && window.performance;
  43515. /* istanbul ignore if */
  43516. if (
  43517. perf &&
  43518. perf.mark &&
  43519. perf.measure &&
  43520. perf.clearMarks &&
  43521. perf.clearMeasures
  43522. ) {
  43523. mark = function (tag) { return perf.mark(tag); };
  43524. measure = function (name, startTag, endTag) {
  43525. perf.measure(name, startTag, endTag);
  43526. perf.clearMarks(startTag);
  43527. perf.clearMarks(endTag);
  43528. // perf.clearMeasures(name)
  43529. };
  43530. }
  43531. }
  43532. /* not type checking this file because flow doesn't play well with Proxy */
  43533. var initProxy;
  43534. {
  43535. var allowedGlobals = makeMap(
  43536. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43537. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43538. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43539. 'require' // for Webpack/Browserify
  43540. );
  43541. var warnNonPresent = function (target, key) {
  43542. warn(
  43543. "Property or method \"" + key + "\" is not defined on the instance but " +
  43544. 'referenced during render. Make sure that this property is reactive, ' +
  43545. 'either in the data option, or for class-based components, by ' +
  43546. 'initializing the property. ' +
  43547. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43548. target
  43549. );
  43550. };
  43551. var warnReservedPrefix = function (target, key) {
  43552. warn(
  43553. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43554. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43555. 'prevent conflicts with Vue internals. ' +
  43556. 'See: https://vuejs.org/v2/api/#data',
  43557. target
  43558. );
  43559. };
  43560. var hasProxy =
  43561. typeof Proxy !== 'undefined' && isNative(Proxy);
  43562. if (hasProxy) {
  43563. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43564. config.keyCodes = new Proxy(config.keyCodes, {
  43565. set: function set (target, key, value) {
  43566. if (isBuiltInModifier(key)) {
  43567. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43568. return false
  43569. } else {
  43570. target[key] = value;
  43571. return true
  43572. }
  43573. }
  43574. });
  43575. }
  43576. var hasHandler = {
  43577. has: function has (target, key) {
  43578. var has = key in target;
  43579. var isAllowed = allowedGlobals(key) ||
  43580. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43581. if (!has && !isAllowed) {
  43582. if (key in target.$data) { warnReservedPrefix(target, key); }
  43583. else { warnNonPresent(target, key); }
  43584. }
  43585. return has || !isAllowed
  43586. }
  43587. };
  43588. var getHandler = {
  43589. get: function get (target, key) {
  43590. if (typeof key === 'string' && !(key in target)) {
  43591. if (key in target.$data) { warnReservedPrefix(target, key); }
  43592. else { warnNonPresent(target, key); }
  43593. }
  43594. return target[key]
  43595. }
  43596. };
  43597. initProxy = function initProxy (vm) {
  43598. if (hasProxy) {
  43599. // determine which proxy handler to use
  43600. var options = vm.$options;
  43601. var handlers = options.render && options.render._withStripped
  43602. ? getHandler
  43603. : hasHandler;
  43604. vm._renderProxy = new Proxy(vm, handlers);
  43605. } else {
  43606. vm._renderProxy = vm;
  43607. }
  43608. };
  43609. }
  43610. /* */
  43611. var seenObjects = new _Set();
  43612. /**
  43613. * Recursively traverse an object to evoke all converted
  43614. * getters, so that every nested property inside the object
  43615. * is collected as a "deep" dependency.
  43616. */
  43617. function traverse (val) {
  43618. _traverse(val, seenObjects);
  43619. seenObjects.clear();
  43620. }
  43621. function _traverse (val, seen) {
  43622. var i, keys;
  43623. var isA = Array.isArray(val);
  43624. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43625. return
  43626. }
  43627. if (val.__ob__) {
  43628. var depId = val.__ob__.dep.id;
  43629. if (seen.has(depId)) {
  43630. return
  43631. }
  43632. seen.add(depId);
  43633. }
  43634. if (isA) {
  43635. i = val.length;
  43636. while (i--) { _traverse(val[i], seen); }
  43637. } else {
  43638. keys = Object.keys(val);
  43639. i = keys.length;
  43640. while (i--) { _traverse(val[keys[i]], seen); }
  43641. }
  43642. }
  43643. /* */
  43644. var normalizeEvent = cached(function (name) {
  43645. var passive = name.charAt(0) === '&';
  43646. name = passive ? name.slice(1) : name;
  43647. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43648. name = once$$1 ? name.slice(1) : name;
  43649. var capture = name.charAt(0) === '!';
  43650. name = capture ? name.slice(1) : name;
  43651. return {
  43652. name: name,
  43653. once: once$$1,
  43654. capture: capture,
  43655. passive: passive
  43656. }
  43657. });
  43658. function createFnInvoker (fns, vm) {
  43659. function invoker () {
  43660. var arguments$1 = arguments;
  43661. var fns = invoker.fns;
  43662. if (Array.isArray(fns)) {
  43663. var cloned = fns.slice();
  43664. for (var i = 0; i < cloned.length; i++) {
  43665. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43666. }
  43667. } else {
  43668. // return handler return value for single handlers
  43669. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43670. }
  43671. }
  43672. invoker.fns = fns;
  43673. return invoker
  43674. }
  43675. function updateListeners (
  43676. on,
  43677. oldOn,
  43678. add,
  43679. remove$$1,
  43680. createOnceHandler,
  43681. vm
  43682. ) {
  43683. var name, def$$1, cur, old, event;
  43684. for (name in on) {
  43685. def$$1 = cur = on[name];
  43686. old = oldOn[name];
  43687. event = normalizeEvent(name);
  43688. if (isUndef(cur)) {
  43689. warn(
  43690. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43691. vm
  43692. );
  43693. } else if (isUndef(old)) {
  43694. if (isUndef(cur.fns)) {
  43695. cur = on[name] = createFnInvoker(cur, vm);
  43696. }
  43697. if (isTrue(event.once)) {
  43698. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43699. }
  43700. add(event.name, cur, event.capture, event.passive, event.params);
  43701. } else if (cur !== old) {
  43702. old.fns = cur;
  43703. on[name] = old;
  43704. }
  43705. }
  43706. for (name in oldOn) {
  43707. if (isUndef(on[name])) {
  43708. event = normalizeEvent(name);
  43709. remove$$1(event.name, oldOn[name], event.capture);
  43710. }
  43711. }
  43712. }
  43713. /* */
  43714. function mergeVNodeHook (def, hookKey, hook) {
  43715. if (def instanceof VNode) {
  43716. def = def.data.hook || (def.data.hook = {});
  43717. }
  43718. var invoker;
  43719. var oldHook = def[hookKey];
  43720. function wrappedHook () {
  43721. hook.apply(this, arguments);
  43722. // important: remove merged hook to ensure it's called only once
  43723. // and prevent memory leak
  43724. remove(invoker.fns, wrappedHook);
  43725. }
  43726. if (isUndef(oldHook)) {
  43727. // no existing hook
  43728. invoker = createFnInvoker([wrappedHook]);
  43729. } else {
  43730. /* istanbul ignore if */
  43731. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43732. // already a merged invoker
  43733. invoker = oldHook;
  43734. invoker.fns.push(wrappedHook);
  43735. } else {
  43736. // existing plain hook
  43737. invoker = createFnInvoker([oldHook, wrappedHook]);
  43738. }
  43739. }
  43740. invoker.merged = true;
  43741. def[hookKey] = invoker;
  43742. }
  43743. /* */
  43744. function extractPropsFromVNodeData (
  43745. data,
  43746. Ctor,
  43747. tag
  43748. ) {
  43749. // we are only extracting raw values here.
  43750. // validation and default values are handled in the child
  43751. // component itself.
  43752. var propOptions = Ctor.options.props;
  43753. if (isUndef(propOptions)) {
  43754. return
  43755. }
  43756. var res = {};
  43757. var attrs = data.attrs;
  43758. var props = data.props;
  43759. if (isDef(attrs) || isDef(props)) {
  43760. for (var key in propOptions) {
  43761. var altKey = hyphenate(key);
  43762. {
  43763. var keyInLowerCase = key.toLowerCase();
  43764. if (
  43765. key !== keyInLowerCase &&
  43766. attrs && hasOwn(attrs, keyInLowerCase)
  43767. ) {
  43768. tip(
  43769. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43770. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43771. " \"" + key + "\". " +
  43772. "Note that HTML attributes are case-insensitive and camelCased " +
  43773. "props need to use their kebab-case equivalents when using in-DOM " +
  43774. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43775. );
  43776. }
  43777. }
  43778. checkProp(res, props, key, altKey, true) ||
  43779. checkProp(res, attrs, key, altKey, false);
  43780. }
  43781. }
  43782. return res
  43783. }
  43784. function checkProp (
  43785. res,
  43786. hash,
  43787. key,
  43788. altKey,
  43789. preserve
  43790. ) {
  43791. if (isDef(hash)) {
  43792. if (hasOwn(hash, key)) {
  43793. res[key] = hash[key];
  43794. if (!preserve) {
  43795. delete hash[key];
  43796. }
  43797. return true
  43798. } else if (hasOwn(hash, altKey)) {
  43799. res[key] = hash[altKey];
  43800. if (!preserve) {
  43801. delete hash[altKey];
  43802. }
  43803. return true
  43804. }
  43805. }
  43806. return false
  43807. }
  43808. /* */
  43809. // The template compiler attempts to minimize the need for normalization by
  43810. // statically analyzing the template at compile time.
  43811. //
  43812. // For plain HTML markup, normalization can be completely skipped because the
  43813. // generated render function is guaranteed to return Array<VNode>. There are
  43814. // two cases where extra normalization is needed:
  43815. // 1. When the children contains components - because a functional component
  43816. // may return an Array instead of a single root. In this case, just a simple
  43817. // normalization is needed - if any child is an Array, we flatten the whole
  43818. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43819. // because functional components already normalize their own children.
  43820. function simpleNormalizeChildren (children) {
  43821. for (var i = 0; i < children.length; i++) {
  43822. if (Array.isArray(children[i])) {
  43823. return Array.prototype.concat.apply([], children)
  43824. }
  43825. }
  43826. return children
  43827. }
  43828. // 2. When the children contains constructs that always generated nested Arrays,
  43829. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43830. // with hand-written render functions / JSX. In such cases a full normalization
  43831. // is needed to cater to all possible types of children values.
  43832. function normalizeChildren (children) {
  43833. return isPrimitive(children)
  43834. ? [createTextVNode(children)]
  43835. : Array.isArray(children)
  43836. ? normalizeArrayChildren(children)
  43837. : undefined
  43838. }
  43839. function isTextNode (node) {
  43840. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43841. }
  43842. function normalizeArrayChildren (children, nestedIndex) {
  43843. var res = [];
  43844. var i, c, lastIndex, last;
  43845. for (i = 0; i < children.length; i++) {
  43846. c = children[i];
  43847. if (isUndef(c) || typeof c === 'boolean') { continue }
  43848. lastIndex = res.length - 1;
  43849. last = res[lastIndex];
  43850. // nested
  43851. if (Array.isArray(c)) {
  43852. if (c.length > 0) {
  43853. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43854. // merge adjacent text nodes
  43855. if (isTextNode(c[0]) && isTextNode(last)) {
  43856. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43857. c.shift();
  43858. }
  43859. res.push.apply(res, c);
  43860. }
  43861. } else if (isPrimitive(c)) {
  43862. if (isTextNode(last)) {
  43863. // merge adjacent text nodes
  43864. // this is necessary for SSR hydration because text nodes are
  43865. // essentially merged when rendered to HTML strings
  43866. res[lastIndex] = createTextVNode(last.text + c);
  43867. } else if (c !== '') {
  43868. // convert primitive to vnode
  43869. res.push(createTextVNode(c));
  43870. }
  43871. } else {
  43872. if (isTextNode(c) && isTextNode(last)) {
  43873. // merge adjacent text nodes
  43874. res[lastIndex] = createTextVNode(last.text + c.text);
  43875. } else {
  43876. // default key for nested array children (likely generated by v-for)
  43877. if (isTrue(children._isVList) &&
  43878. isDef(c.tag) &&
  43879. isUndef(c.key) &&
  43880. isDef(nestedIndex)) {
  43881. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  43882. }
  43883. res.push(c);
  43884. }
  43885. }
  43886. }
  43887. return res
  43888. }
  43889. /* */
  43890. function initProvide (vm) {
  43891. var provide = vm.$options.provide;
  43892. if (provide) {
  43893. vm._provided = typeof provide === 'function'
  43894. ? provide.call(vm)
  43895. : provide;
  43896. }
  43897. }
  43898. function initInjections (vm) {
  43899. var result = resolveInject(vm.$options.inject, vm);
  43900. if (result) {
  43901. toggleObserving(false);
  43902. Object.keys(result).forEach(function (key) {
  43903. /* istanbul ignore else */
  43904. {
  43905. defineReactive$$1(vm, key, result[key], function () {
  43906. warn(
  43907. "Avoid mutating an injected value directly since the changes will be " +
  43908. "overwritten whenever the provided component re-renders. " +
  43909. "injection being mutated: \"" + key + "\"",
  43910. vm
  43911. );
  43912. });
  43913. }
  43914. });
  43915. toggleObserving(true);
  43916. }
  43917. }
  43918. function resolveInject (inject, vm) {
  43919. if (inject) {
  43920. // inject is :any because flow is not smart enough to figure out cached
  43921. var result = Object.create(null);
  43922. var keys = hasSymbol
  43923. ? Reflect.ownKeys(inject)
  43924. : Object.keys(inject);
  43925. for (var i = 0; i < keys.length; i++) {
  43926. var key = keys[i];
  43927. // #6574 in case the inject object is observed...
  43928. if (key === '__ob__') { continue }
  43929. var provideKey = inject[key].from;
  43930. var source = vm;
  43931. while (source) {
  43932. if (source._provided && hasOwn(source._provided, provideKey)) {
  43933. result[key] = source._provided[provideKey];
  43934. break
  43935. }
  43936. source = source.$parent;
  43937. }
  43938. if (!source) {
  43939. if ('default' in inject[key]) {
  43940. var provideDefault = inject[key].default;
  43941. result[key] = typeof provideDefault === 'function'
  43942. ? provideDefault.call(vm)
  43943. : provideDefault;
  43944. } else {
  43945. warn(("Injection \"" + key + "\" not found"), vm);
  43946. }
  43947. }
  43948. }
  43949. return result
  43950. }
  43951. }
  43952. /* */
  43953. /**
  43954. * Runtime helper for resolving raw children VNodes into a slot object.
  43955. */
  43956. function resolveSlots (
  43957. children,
  43958. context
  43959. ) {
  43960. if (!children || !children.length) {
  43961. return {}
  43962. }
  43963. var slots = {};
  43964. for (var i = 0, l = children.length; i < l; i++) {
  43965. var child = children[i];
  43966. var data = child.data;
  43967. // remove slot attribute if the node is resolved as a Vue slot node
  43968. if (data && data.attrs && data.attrs.slot) {
  43969. delete data.attrs.slot;
  43970. }
  43971. // named slots should only be respected if the vnode was rendered in the
  43972. // same context.
  43973. if ((child.context === context || child.fnContext === context) &&
  43974. data && data.slot != null
  43975. ) {
  43976. var name = data.slot;
  43977. var slot = (slots[name] || (slots[name] = []));
  43978. if (child.tag === 'template') {
  43979. slot.push.apply(slot, child.children || []);
  43980. } else {
  43981. slot.push(child);
  43982. }
  43983. } else {
  43984. (slots.default || (slots.default = [])).push(child);
  43985. }
  43986. }
  43987. // ignore slots that contains only whitespace
  43988. for (var name$1 in slots) {
  43989. if (slots[name$1].every(isWhitespace)) {
  43990. delete slots[name$1];
  43991. }
  43992. }
  43993. return slots
  43994. }
  43995. function isWhitespace (node) {
  43996. return (node.isComment && !node.asyncFactory) || node.text === ' '
  43997. }
  43998. /* */
  43999. function normalizeScopedSlots (
  44000. slots,
  44001. normalSlots,
  44002. prevSlots
  44003. ) {
  44004. var res;
  44005. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44006. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44007. var key = slots && slots.$key;
  44008. if (!slots) {
  44009. res = {};
  44010. } else if (slots._normalized) {
  44011. // fast path 1: child component re-render only, parent did not change
  44012. return slots._normalized
  44013. } else if (
  44014. isStable &&
  44015. prevSlots &&
  44016. prevSlots !== emptyObject &&
  44017. key === prevSlots.$key &&
  44018. !hasNormalSlots &&
  44019. !prevSlots.$hasNormal
  44020. ) {
  44021. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44022. // only need to normalize once
  44023. return prevSlots
  44024. } else {
  44025. res = {};
  44026. for (var key$1 in slots) {
  44027. if (slots[key$1] && key$1[0] !== '$') {
  44028. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44029. }
  44030. }
  44031. }
  44032. // expose normal slots on scopedSlots
  44033. for (var key$2 in normalSlots) {
  44034. if (!(key$2 in res)) {
  44035. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44036. }
  44037. }
  44038. // avoriaz seems to mock a non-extensible $scopedSlots object
  44039. // and when that is passed down this would cause an error
  44040. if (slots && Object.isExtensible(slots)) {
  44041. (slots)._normalized = res;
  44042. }
  44043. def(res, '$stable', isStable);
  44044. def(res, '$key', key);
  44045. def(res, '$hasNormal', hasNormalSlots);
  44046. return res
  44047. }
  44048. function normalizeScopedSlot(normalSlots, key, fn) {
  44049. var normalized = function () {
  44050. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44051. res = res && typeof res === 'object' && !Array.isArray(res)
  44052. ? [res] // single vnode
  44053. : normalizeChildren(res);
  44054. return res && (
  44055. res.length === 0 ||
  44056. (res.length === 1 && res[0].isComment) // #9658
  44057. ) ? undefined
  44058. : res
  44059. };
  44060. // this is a slot using the new v-slot syntax without scope. although it is
  44061. // compiled as a scoped slot, render fn users would expect it to be present
  44062. // on this.$slots because the usage is semantically a normal slot.
  44063. if (fn.proxy) {
  44064. Object.defineProperty(normalSlots, key, {
  44065. get: normalized,
  44066. enumerable: true,
  44067. configurable: true
  44068. });
  44069. }
  44070. return normalized
  44071. }
  44072. function proxyNormalSlot(slots, key) {
  44073. return function () { return slots[key]; }
  44074. }
  44075. /* */
  44076. /**
  44077. * Runtime helper for rendering v-for lists.
  44078. */
  44079. function renderList (
  44080. val,
  44081. render
  44082. ) {
  44083. var ret, i, l, keys, key;
  44084. if (Array.isArray(val) || typeof val === 'string') {
  44085. ret = new Array(val.length);
  44086. for (i = 0, l = val.length; i < l; i++) {
  44087. ret[i] = render(val[i], i);
  44088. }
  44089. } else if (typeof val === 'number') {
  44090. ret = new Array(val);
  44091. for (i = 0; i < val; i++) {
  44092. ret[i] = render(i + 1, i);
  44093. }
  44094. } else if (isObject(val)) {
  44095. if (hasSymbol && val[Symbol.iterator]) {
  44096. ret = [];
  44097. var iterator = val[Symbol.iterator]();
  44098. var result = iterator.next();
  44099. while (!result.done) {
  44100. ret.push(render(result.value, ret.length));
  44101. result = iterator.next();
  44102. }
  44103. } else {
  44104. keys = Object.keys(val);
  44105. ret = new Array(keys.length);
  44106. for (i = 0, l = keys.length; i < l; i++) {
  44107. key = keys[i];
  44108. ret[i] = render(val[key], key, i);
  44109. }
  44110. }
  44111. }
  44112. if (!isDef(ret)) {
  44113. ret = [];
  44114. }
  44115. (ret)._isVList = true;
  44116. return ret
  44117. }
  44118. /* */
  44119. /**
  44120. * Runtime helper for rendering <slot>
  44121. */
  44122. function renderSlot (
  44123. name,
  44124. fallback,
  44125. props,
  44126. bindObject
  44127. ) {
  44128. var scopedSlotFn = this.$scopedSlots[name];
  44129. var nodes;
  44130. if (scopedSlotFn) { // scoped slot
  44131. props = props || {};
  44132. if (bindObject) {
  44133. if (!isObject(bindObject)) {
  44134. warn(
  44135. 'slot v-bind without argument expects an Object',
  44136. this
  44137. );
  44138. }
  44139. props = extend(extend({}, bindObject), props);
  44140. }
  44141. nodes = scopedSlotFn(props) || fallback;
  44142. } else {
  44143. nodes = this.$slots[name] || fallback;
  44144. }
  44145. var target = props && props.slot;
  44146. if (target) {
  44147. return this.$createElement('template', { slot: target }, nodes)
  44148. } else {
  44149. return nodes
  44150. }
  44151. }
  44152. /* */
  44153. /**
  44154. * Runtime helper for resolving filters
  44155. */
  44156. function resolveFilter (id) {
  44157. return resolveAsset(this.$options, 'filters', id, true) || identity
  44158. }
  44159. /* */
  44160. function isKeyNotMatch (expect, actual) {
  44161. if (Array.isArray(expect)) {
  44162. return expect.indexOf(actual) === -1
  44163. } else {
  44164. return expect !== actual
  44165. }
  44166. }
  44167. /**
  44168. * Runtime helper for checking keyCodes from config.
  44169. * exposed as Vue.prototype._k
  44170. * passing in eventKeyName as last argument separately for backwards compat
  44171. */
  44172. function checkKeyCodes (
  44173. eventKeyCode,
  44174. key,
  44175. builtInKeyCode,
  44176. eventKeyName,
  44177. builtInKeyName
  44178. ) {
  44179. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44180. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44181. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44182. } else if (mappedKeyCode) {
  44183. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44184. } else if (eventKeyName) {
  44185. return hyphenate(eventKeyName) !== key
  44186. }
  44187. }
  44188. /* */
  44189. /**
  44190. * Runtime helper for merging v-bind="object" into a VNode's data.
  44191. */
  44192. function bindObjectProps (
  44193. data,
  44194. tag,
  44195. value,
  44196. asProp,
  44197. isSync
  44198. ) {
  44199. if (value) {
  44200. if (!isObject(value)) {
  44201. warn(
  44202. 'v-bind without argument expects an Object or Array value',
  44203. this
  44204. );
  44205. } else {
  44206. if (Array.isArray(value)) {
  44207. value = toObject(value);
  44208. }
  44209. var hash;
  44210. var loop = function ( key ) {
  44211. if (
  44212. key === 'class' ||
  44213. key === 'style' ||
  44214. isReservedAttribute(key)
  44215. ) {
  44216. hash = data;
  44217. } else {
  44218. var type = data.attrs && data.attrs.type;
  44219. hash = asProp || config.mustUseProp(tag, type, key)
  44220. ? data.domProps || (data.domProps = {})
  44221. : data.attrs || (data.attrs = {});
  44222. }
  44223. var camelizedKey = camelize(key);
  44224. var hyphenatedKey = hyphenate(key);
  44225. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44226. hash[key] = value[key];
  44227. if (isSync) {
  44228. var on = data.on || (data.on = {});
  44229. on[("update:" + key)] = function ($event) {
  44230. value[key] = $event;
  44231. };
  44232. }
  44233. }
  44234. };
  44235. for (var key in value) loop( key );
  44236. }
  44237. }
  44238. return data
  44239. }
  44240. /* */
  44241. /**
  44242. * Runtime helper for rendering static trees.
  44243. */
  44244. function renderStatic (
  44245. index,
  44246. isInFor
  44247. ) {
  44248. var cached = this._staticTrees || (this._staticTrees = []);
  44249. var tree = cached[index];
  44250. // if has already-rendered static tree and not inside v-for,
  44251. // we can reuse the same tree.
  44252. if (tree && !isInFor) {
  44253. return tree
  44254. }
  44255. // otherwise, render a fresh tree.
  44256. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44257. this._renderProxy,
  44258. null,
  44259. this // for render fns generated for functional component templates
  44260. );
  44261. markStatic(tree, ("__static__" + index), false);
  44262. return tree
  44263. }
  44264. /**
  44265. * Runtime helper for v-once.
  44266. * Effectively it means marking the node as static with a unique key.
  44267. */
  44268. function markOnce (
  44269. tree,
  44270. index,
  44271. key
  44272. ) {
  44273. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44274. return tree
  44275. }
  44276. function markStatic (
  44277. tree,
  44278. key,
  44279. isOnce
  44280. ) {
  44281. if (Array.isArray(tree)) {
  44282. for (var i = 0; i < tree.length; i++) {
  44283. if (tree[i] && typeof tree[i] !== 'string') {
  44284. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44285. }
  44286. }
  44287. } else {
  44288. markStaticNode(tree, key, isOnce);
  44289. }
  44290. }
  44291. function markStaticNode (node, key, isOnce) {
  44292. node.isStatic = true;
  44293. node.key = key;
  44294. node.isOnce = isOnce;
  44295. }
  44296. /* */
  44297. function bindObjectListeners (data, value) {
  44298. if (value) {
  44299. if (!isPlainObject(value)) {
  44300. warn(
  44301. 'v-on without argument expects an Object value',
  44302. this
  44303. );
  44304. } else {
  44305. var on = data.on = data.on ? extend({}, data.on) : {};
  44306. for (var key in value) {
  44307. var existing = on[key];
  44308. var ours = value[key];
  44309. on[key] = existing ? [].concat(existing, ours) : ours;
  44310. }
  44311. }
  44312. }
  44313. return data
  44314. }
  44315. /* */
  44316. function resolveScopedSlots (
  44317. fns, // see flow/vnode
  44318. res,
  44319. // the following are added in 2.6
  44320. hasDynamicKeys,
  44321. contentHashKey
  44322. ) {
  44323. res = res || { $stable: !hasDynamicKeys };
  44324. for (var i = 0; i < fns.length; i++) {
  44325. var slot = fns[i];
  44326. if (Array.isArray(slot)) {
  44327. resolveScopedSlots(slot, res, hasDynamicKeys);
  44328. } else if (slot) {
  44329. // marker for reverse proxying v-slot without scope on this.$slots
  44330. if (slot.proxy) {
  44331. slot.fn.proxy = true;
  44332. }
  44333. res[slot.key] = slot.fn;
  44334. }
  44335. }
  44336. if (contentHashKey) {
  44337. (res).$key = contentHashKey;
  44338. }
  44339. return res
  44340. }
  44341. /* */
  44342. function bindDynamicKeys (baseObj, values) {
  44343. for (var i = 0; i < values.length; i += 2) {
  44344. var key = values[i];
  44345. if (typeof key === 'string' && key) {
  44346. baseObj[values[i]] = values[i + 1];
  44347. } else if (key !== '' && key !== null) {
  44348. // null is a special value for explicitly removing a binding
  44349. warn(
  44350. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44351. this
  44352. );
  44353. }
  44354. }
  44355. return baseObj
  44356. }
  44357. // helper to dynamically append modifier runtime markers to event names.
  44358. // ensure only append when value is already string, otherwise it will be cast
  44359. // to string and cause the type check to miss.
  44360. function prependModifier (value, symbol) {
  44361. return typeof value === 'string' ? symbol + value : value
  44362. }
  44363. /* */
  44364. function installRenderHelpers (target) {
  44365. target._o = markOnce;
  44366. target._n = toNumber;
  44367. target._s = toString;
  44368. target._l = renderList;
  44369. target._t = renderSlot;
  44370. target._q = looseEqual;
  44371. target._i = looseIndexOf;
  44372. target._m = renderStatic;
  44373. target._f = resolveFilter;
  44374. target._k = checkKeyCodes;
  44375. target._b = bindObjectProps;
  44376. target._v = createTextVNode;
  44377. target._e = createEmptyVNode;
  44378. target._u = resolveScopedSlots;
  44379. target._g = bindObjectListeners;
  44380. target._d = bindDynamicKeys;
  44381. target._p = prependModifier;
  44382. }
  44383. /* */
  44384. function FunctionalRenderContext (
  44385. data,
  44386. props,
  44387. children,
  44388. parent,
  44389. Ctor
  44390. ) {
  44391. var this$1 = this;
  44392. var options = Ctor.options;
  44393. // ensure the createElement function in functional components
  44394. // gets a unique context - this is necessary for correct named slot check
  44395. var contextVm;
  44396. if (hasOwn(parent, '_uid')) {
  44397. contextVm = Object.create(parent);
  44398. // $flow-disable-line
  44399. contextVm._original = parent;
  44400. } else {
  44401. // the context vm passed in is a functional context as well.
  44402. // in this case we want to make sure we are able to get a hold to the
  44403. // real context instance.
  44404. contextVm = parent;
  44405. // $flow-disable-line
  44406. parent = parent._original;
  44407. }
  44408. var isCompiled = isTrue(options._compiled);
  44409. var needNormalization = !isCompiled;
  44410. this.data = data;
  44411. this.props = props;
  44412. this.children = children;
  44413. this.parent = parent;
  44414. this.listeners = data.on || emptyObject;
  44415. this.injections = resolveInject(options.inject, parent);
  44416. this.slots = function () {
  44417. if (!this$1.$slots) {
  44418. normalizeScopedSlots(
  44419. data.scopedSlots,
  44420. this$1.$slots = resolveSlots(children, parent)
  44421. );
  44422. }
  44423. return this$1.$slots
  44424. };
  44425. Object.defineProperty(this, 'scopedSlots', ({
  44426. enumerable: true,
  44427. get: function get () {
  44428. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44429. }
  44430. }));
  44431. // support for compiled functional template
  44432. if (isCompiled) {
  44433. // exposing $options for renderStatic()
  44434. this.$options = options;
  44435. // pre-resolve slots for renderSlot()
  44436. this.$slots = this.slots();
  44437. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44438. }
  44439. if (options._scopeId) {
  44440. this._c = function (a, b, c, d) {
  44441. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44442. if (vnode && !Array.isArray(vnode)) {
  44443. vnode.fnScopeId = options._scopeId;
  44444. vnode.fnContext = parent;
  44445. }
  44446. return vnode
  44447. };
  44448. } else {
  44449. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44450. }
  44451. }
  44452. installRenderHelpers(FunctionalRenderContext.prototype);
  44453. function createFunctionalComponent (
  44454. Ctor,
  44455. propsData,
  44456. data,
  44457. contextVm,
  44458. children
  44459. ) {
  44460. var options = Ctor.options;
  44461. var props = {};
  44462. var propOptions = options.props;
  44463. if (isDef(propOptions)) {
  44464. for (var key in propOptions) {
  44465. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44466. }
  44467. } else {
  44468. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44469. if (isDef(data.props)) { mergeProps(props, data.props); }
  44470. }
  44471. var renderContext = new FunctionalRenderContext(
  44472. data,
  44473. props,
  44474. children,
  44475. contextVm,
  44476. Ctor
  44477. );
  44478. var vnode = options.render.call(null, renderContext._c, renderContext);
  44479. if (vnode instanceof VNode) {
  44480. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44481. } else if (Array.isArray(vnode)) {
  44482. var vnodes = normalizeChildren(vnode) || [];
  44483. var res = new Array(vnodes.length);
  44484. for (var i = 0; i < vnodes.length; i++) {
  44485. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44486. }
  44487. return res
  44488. }
  44489. }
  44490. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44491. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44492. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44493. // that should not be matched to match.
  44494. var clone = cloneVNode(vnode);
  44495. clone.fnContext = contextVm;
  44496. clone.fnOptions = options;
  44497. {
  44498. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44499. }
  44500. if (data.slot) {
  44501. (clone.data || (clone.data = {})).slot = data.slot;
  44502. }
  44503. return clone
  44504. }
  44505. function mergeProps (to, from) {
  44506. for (var key in from) {
  44507. to[camelize(key)] = from[key];
  44508. }
  44509. }
  44510. /* */
  44511. /* */
  44512. /* */
  44513. /* */
  44514. // inline hooks to be invoked on component VNodes during patch
  44515. var componentVNodeHooks = {
  44516. init: function init (vnode, hydrating) {
  44517. if (
  44518. vnode.componentInstance &&
  44519. !vnode.componentInstance._isDestroyed &&
  44520. vnode.data.keepAlive
  44521. ) {
  44522. // kept-alive components, treat as a patch
  44523. var mountedNode = vnode; // work around flow
  44524. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44525. } else {
  44526. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44527. vnode,
  44528. activeInstance
  44529. );
  44530. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44531. }
  44532. },
  44533. prepatch: function prepatch (oldVnode, vnode) {
  44534. var options = vnode.componentOptions;
  44535. var child = vnode.componentInstance = oldVnode.componentInstance;
  44536. updateChildComponent(
  44537. child,
  44538. options.propsData, // updated props
  44539. options.listeners, // updated listeners
  44540. vnode, // new parent vnode
  44541. options.children // new children
  44542. );
  44543. },
  44544. insert: function insert (vnode) {
  44545. var context = vnode.context;
  44546. var componentInstance = vnode.componentInstance;
  44547. if (!componentInstance._isMounted) {
  44548. componentInstance._isMounted = true;
  44549. callHook(componentInstance, 'mounted');
  44550. }
  44551. if (vnode.data.keepAlive) {
  44552. if (context._isMounted) {
  44553. // vue-router#1212
  44554. // During updates, a kept-alive component's child components may
  44555. // change, so directly walking the tree here may call activated hooks
  44556. // on incorrect children. Instead we push them into a queue which will
  44557. // be processed after the whole patch process ended.
  44558. queueActivatedComponent(componentInstance);
  44559. } else {
  44560. activateChildComponent(componentInstance, true /* direct */);
  44561. }
  44562. }
  44563. },
  44564. destroy: function destroy (vnode) {
  44565. var componentInstance = vnode.componentInstance;
  44566. if (!componentInstance._isDestroyed) {
  44567. if (!vnode.data.keepAlive) {
  44568. componentInstance.$destroy();
  44569. } else {
  44570. deactivateChildComponent(componentInstance, true /* direct */);
  44571. }
  44572. }
  44573. }
  44574. };
  44575. var hooksToMerge = Object.keys(componentVNodeHooks);
  44576. function createComponent (
  44577. Ctor,
  44578. data,
  44579. context,
  44580. children,
  44581. tag
  44582. ) {
  44583. if (isUndef(Ctor)) {
  44584. return
  44585. }
  44586. var baseCtor = context.$options._base;
  44587. // plain options object: turn it into a constructor
  44588. if (isObject(Ctor)) {
  44589. Ctor = baseCtor.extend(Ctor);
  44590. }
  44591. // if at this stage it's not a constructor or an async component factory,
  44592. // reject.
  44593. if (typeof Ctor !== 'function') {
  44594. {
  44595. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44596. }
  44597. return
  44598. }
  44599. // async component
  44600. var asyncFactory;
  44601. if (isUndef(Ctor.cid)) {
  44602. asyncFactory = Ctor;
  44603. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44604. if (Ctor === undefined) {
  44605. // return a placeholder node for async component, which is rendered
  44606. // as a comment node but preserves all the raw information for the node.
  44607. // the information will be used for async server-rendering and hydration.
  44608. return createAsyncPlaceholder(
  44609. asyncFactory,
  44610. data,
  44611. context,
  44612. children,
  44613. tag
  44614. )
  44615. }
  44616. }
  44617. data = data || {};
  44618. // resolve constructor options in case global mixins are applied after
  44619. // component constructor creation
  44620. resolveConstructorOptions(Ctor);
  44621. // transform component v-model data into props & events
  44622. if (isDef(data.model)) {
  44623. transformModel(Ctor.options, data);
  44624. }
  44625. // extract props
  44626. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44627. // functional component
  44628. if (isTrue(Ctor.options.functional)) {
  44629. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44630. }
  44631. // extract listeners, since these needs to be treated as
  44632. // child component listeners instead of DOM listeners
  44633. var listeners = data.on;
  44634. // replace with listeners with .native modifier
  44635. // so it gets processed during parent component patch.
  44636. data.on = data.nativeOn;
  44637. if (isTrue(Ctor.options.abstract)) {
  44638. // abstract components do not keep anything
  44639. // other than props & listeners & slot
  44640. // work around flow
  44641. var slot = data.slot;
  44642. data = {};
  44643. if (slot) {
  44644. data.slot = slot;
  44645. }
  44646. }
  44647. // install component management hooks onto the placeholder node
  44648. installComponentHooks(data);
  44649. // return a placeholder vnode
  44650. var name = Ctor.options.name || tag;
  44651. var vnode = new VNode(
  44652. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44653. data, undefined, undefined, undefined, context,
  44654. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44655. asyncFactory
  44656. );
  44657. return vnode
  44658. }
  44659. function createComponentInstanceForVnode (
  44660. vnode, // we know it's MountedComponentVNode but flow doesn't
  44661. parent // activeInstance in lifecycle state
  44662. ) {
  44663. var options = {
  44664. _isComponent: true,
  44665. _parentVnode: vnode,
  44666. parent: parent
  44667. };
  44668. // check inline-template render functions
  44669. var inlineTemplate = vnode.data.inlineTemplate;
  44670. if (isDef(inlineTemplate)) {
  44671. options.render = inlineTemplate.render;
  44672. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44673. }
  44674. return new vnode.componentOptions.Ctor(options)
  44675. }
  44676. function installComponentHooks (data) {
  44677. var hooks = data.hook || (data.hook = {});
  44678. for (var i = 0; i < hooksToMerge.length; i++) {
  44679. var key = hooksToMerge[i];
  44680. var existing = hooks[key];
  44681. var toMerge = componentVNodeHooks[key];
  44682. if (existing !== toMerge && !(existing && existing._merged)) {
  44683. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44684. }
  44685. }
  44686. }
  44687. function mergeHook$1 (f1, f2) {
  44688. var merged = function (a, b) {
  44689. // flow complains about extra args which is why we use any
  44690. f1(a, b);
  44691. f2(a, b);
  44692. };
  44693. merged._merged = true;
  44694. return merged
  44695. }
  44696. // transform component v-model info (value and callback) into
  44697. // prop and event handler respectively.
  44698. function transformModel (options, data) {
  44699. var prop = (options.model && options.model.prop) || 'value';
  44700. var event = (options.model && options.model.event) || 'input'
  44701. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44702. var on = data.on || (data.on = {});
  44703. var existing = on[event];
  44704. var callback = data.model.callback;
  44705. if (isDef(existing)) {
  44706. if (
  44707. Array.isArray(existing)
  44708. ? existing.indexOf(callback) === -1
  44709. : existing !== callback
  44710. ) {
  44711. on[event] = [callback].concat(existing);
  44712. }
  44713. } else {
  44714. on[event] = callback;
  44715. }
  44716. }
  44717. /* */
  44718. var SIMPLE_NORMALIZE = 1;
  44719. var ALWAYS_NORMALIZE = 2;
  44720. // wrapper function for providing a more flexible interface
  44721. // without getting yelled at by flow
  44722. function createElement (
  44723. context,
  44724. tag,
  44725. data,
  44726. children,
  44727. normalizationType,
  44728. alwaysNormalize
  44729. ) {
  44730. if (Array.isArray(data) || isPrimitive(data)) {
  44731. normalizationType = children;
  44732. children = data;
  44733. data = undefined;
  44734. }
  44735. if (isTrue(alwaysNormalize)) {
  44736. normalizationType = ALWAYS_NORMALIZE;
  44737. }
  44738. return _createElement(context, tag, data, children, normalizationType)
  44739. }
  44740. function _createElement (
  44741. context,
  44742. tag,
  44743. data,
  44744. children,
  44745. normalizationType
  44746. ) {
  44747. if (isDef(data) && isDef((data).__ob__)) {
  44748. warn(
  44749. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44750. 'Always create fresh vnode data objects in each render!',
  44751. context
  44752. );
  44753. return createEmptyVNode()
  44754. }
  44755. // object syntax in v-bind
  44756. if (isDef(data) && isDef(data.is)) {
  44757. tag = data.is;
  44758. }
  44759. if (!tag) {
  44760. // in case of component :is set to falsy value
  44761. return createEmptyVNode()
  44762. }
  44763. // warn against non-primitive key
  44764. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44765. ) {
  44766. {
  44767. warn(
  44768. 'Avoid using non-primitive value as key, ' +
  44769. 'use string/number value instead.',
  44770. context
  44771. );
  44772. }
  44773. }
  44774. // support single function children as default scoped slot
  44775. if (Array.isArray(children) &&
  44776. typeof children[0] === 'function'
  44777. ) {
  44778. data = data || {};
  44779. data.scopedSlots = { default: children[0] };
  44780. children.length = 0;
  44781. }
  44782. if (normalizationType === ALWAYS_NORMALIZE) {
  44783. children = normalizeChildren(children);
  44784. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44785. children = simpleNormalizeChildren(children);
  44786. }
  44787. var vnode, ns;
  44788. if (typeof tag === 'string') {
  44789. var Ctor;
  44790. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44791. if (config.isReservedTag(tag)) {
  44792. // platform built-in elements
  44793. if (isDef(data) && isDef(data.nativeOn)) {
  44794. warn(
  44795. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44796. context
  44797. );
  44798. }
  44799. vnode = new VNode(
  44800. config.parsePlatformTagName(tag), data, children,
  44801. undefined, undefined, context
  44802. );
  44803. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44804. // component
  44805. vnode = createComponent(Ctor, data, context, children, tag);
  44806. } else {
  44807. // unknown or unlisted namespaced elements
  44808. // check at runtime because it may get assigned a namespace when its
  44809. // parent normalizes children
  44810. vnode = new VNode(
  44811. tag, data, children,
  44812. undefined, undefined, context
  44813. );
  44814. }
  44815. } else {
  44816. // direct component options / constructor
  44817. vnode = createComponent(tag, data, context, children);
  44818. }
  44819. if (Array.isArray(vnode)) {
  44820. return vnode
  44821. } else if (isDef(vnode)) {
  44822. if (isDef(ns)) { applyNS(vnode, ns); }
  44823. if (isDef(data)) { registerDeepBindings(data); }
  44824. return vnode
  44825. } else {
  44826. return createEmptyVNode()
  44827. }
  44828. }
  44829. function applyNS (vnode, ns, force) {
  44830. vnode.ns = ns;
  44831. if (vnode.tag === 'foreignObject') {
  44832. // use default namespace inside foreignObject
  44833. ns = undefined;
  44834. force = true;
  44835. }
  44836. if (isDef(vnode.children)) {
  44837. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44838. var child = vnode.children[i];
  44839. if (isDef(child.tag) && (
  44840. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44841. applyNS(child, ns, force);
  44842. }
  44843. }
  44844. }
  44845. }
  44846. // ref #5318
  44847. // necessary to ensure parent re-render when deep bindings like :style and
  44848. // :class are used on slot nodes
  44849. function registerDeepBindings (data) {
  44850. if (isObject(data.style)) {
  44851. traverse(data.style);
  44852. }
  44853. if (isObject(data.class)) {
  44854. traverse(data.class);
  44855. }
  44856. }
  44857. /* */
  44858. function initRender (vm) {
  44859. vm._vnode = null; // the root of the child tree
  44860. vm._staticTrees = null; // v-once cached trees
  44861. var options = vm.$options;
  44862. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  44863. var renderContext = parentVnode && parentVnode.context;
  44864. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  44865. vm.$scopedSlots = emptyObject;
  44866. // bind the createElement fn to this instance
  44867. // so that we get proper render context inside it.
  44868. // args order: tag, data, children, normalizationType, alwaysNormalize
  44869. // internal version is used by render functions compiled from templates
  44870. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  44871. // normalization is always applied for the public version, used in
  44872. // user-written render functions.
  44873. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  44874. // $attrs & $listeners are exposed for easier HOC creation.
  44875. // they need to be reactive so that HOCs using them are always updated
  44876. var parentData = parentVnode && parentVnode.data;
  44877. /* istanbul ignore else */
  44878. {
  44879. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  44880. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  44881. }, true);
  44882. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  44883. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  44884. }, true);
  44885. }
  44886. }
  44887. var currentRenderingInstance = null;
  44888. function renderMixin (Vue) {
  44889. // install runtime convenience helpers
  44890. installRenderHelpers(Vue.prototype);
  44891. Vue.prototype.$nextTick = function (fn) {
  44892. return nextTick(fn, this)
  44893. };
  44894. Vue.prototype._render = function () {
  44895. var vm = this;
  44896. var ref = vm.$options;
  44897. var render = ref.render;
  44898. var _parentVnode = ref._parentVnode;
  44899. if (_parentVnode) {
  44900. vm.$scopedSlots = normalizeScopedSlots(
  44901. _parentVnode.data.scopedSlots,
  44902. vm.$slots,
  44903. vm.$scopedSlots
  44904. );
  44905. }
  44906. // set parent vnode. this allows render functions to have access
  44907. // to the data on the placeholder node.
  44908. vm.$vnode = _parentVnode;
  44909. // render self
  44910. var vnode;
  44911. try {
  44912. // There's no need to maintain a stack because all render fns are called
  44913. // separately from one another. Nested component's render fns are called
  44914. // when parent component is patched.
  44915. currentRenderingInstance = vm;
  44916. vnode = render.call(vm._renderProxy, vm.$createElement);
  44917. } catch (e) {
  44918. handleError(e, vm, "render");
  44919. // return error render result,
  44920. // or previous vnode to prevent render error causing blank component
  44921. /* istanbul ignore else */
  44922. if (vm.$options.renderError) {
  44923. try {
  44924. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  44925. } catch (e) {
  44926. handleError(e, vm, "renderError");
  44927. vnode = vm._vnode;
  44928. }
  44929. } else {
  44930. vnode = vm._vnode;
  44931. }
  44932. } finally {
  44933. currentRenderingInstance = null;
  44934. }
  44935. // if the returned array contains only a single node, allow it
  44936. if (Array.isArray(vnode) && vnode.length === 1) {
  44937. vnode = vnode[0];
  44938. }
  44939. // return empty vnode in case the render function errored out
  44940. if (!(vnode instanceof VNode)) {
  44941. if (Array.isArray(vnode)) {
  44942. warn(
  44943. 'Multiple root nodes returned from render function. Render function ' +
  44944. 'should return a single root node.',
  44945. vm
  44946. );
  44947. }
  44948. vnode = createEmptyVNode();
  44949. }
  44950. // set parent
  44951. vnode.parent = _parentVnode;
  44952. return vnode
  44953. };
  44954. }
  44955. /* */
  44956. function ensureCtor (comp, base) {
  44957. if (
  44958. comp.__esModule ||
  44959. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  44960. ) {
  44961. comp = comp.default;
  44962. }
  44963. return isObject(comp)
  44964. ? base.extend(comp)
  44965. : comp
  44966. }
  44967. function createAsyncPlaceholder (
  44968. factory,
  44969. data,
  44970. context,
  44971. children,
  44972. tag
  44973. ) {
  44974. var node = createEmptyVNode();
  44975. node.asyncFactory = factory;
  44976. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  44977. return node
  44978. }
  44979. function resolveAsyncComponent (
  44980. factory,
  44981. baseCtor
  44982. ) {
  44983. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  44984. return factory.errorComp
  44985. }
  44986. if (isDef(factory.resolved)) {
  44987. return factory.resolved
  44988. }
  44989. var owner = currentRenderingInstance;
  44990. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  44991. // already pending
  44992. factory.owners.push(owner);
  44993. }
  44994. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  44995. return factory.loadingComp
  44996. }
  44997. if (owner && !isDef(factory.owners)) {
  44998. var owners = factory.owners = [owner];
  44999. var sync = true;
  45000. var timerLoading = null;
  45001. var timerTimeout = null
  45002. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  45003. var forceRender = function (renderCompleted) {
  45004. for (var i = 0, l = owners.length; i < l; i++) {
  45005. (owners[i]).$forceUpdate();
  45006. }
  45007. if (renderCompleted) {
  45008. owners.length = 0;
  45009. if (timerLoading !== null) {
  45010. clearTimeout(timerLoading);
  45011. timerLoading = null;
  45012. }
  45013. if (timerTimeout !== null) {
  45014. clearTimeout(timerTimeout);
  45015. timerTimeout = null;
  45016. }
  45017. }
  45018. };
  45019. var resolve = once(function (res) {
  45020. // cache resolved
  45021. factory.resolved = ensureCtor(res, baseCtor);
  45022. // invoke callbacks only if this is not a synchronous resolve
  45023. // (async resolves are shimmed as synchronous during SSR)
  45024. if (!sync) {
  45025. forceRender(true);
  45026. } else {
  45027. owners.length = 0;
  45028. }
  45029. });
  45030. var reject = once(function (reason) {
  45031. warn(
  45032. "Failed to resolve async component: " + (String(factory)) +
  45033. (reason ? ("\nReason: " + reason) : '')
  45034. );
  45035. if (isDef(factory.errorComp)) {
  45036. factory.error = true;
  45037. forceRender(true);
  45038. }
  45039. });
  45040. var res = factory(resolve, reject);
  45041. if (isObject(res)) {
  45042. if (isPromise(res)) {
  45043. // () => Promise
  45044. if (isUndef(factory.resolved)) {
  45045. res.then(resolve, reject);
  45046. }
  45047. } else if (isPromise(res.component)) {
  45048. res.component.then(resolve, reject);
  45049. if (isDef(res.error)) {
  45050. factory.errorComp = ensureCtor(res.error, baseCtor);
  45051. }
  45052. if (isDef(res.loading)) {
  45053. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45054. if (res.delay === 0) {
  45055. factory.loading = true;
  45056. } else {
  45057. timerLoading = setTimeout(function () {
  45058. timerLoading = null;
  45059. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45060. factory.loading = true;
  45061. forceRender(false);
  45062. }
  45063. }, res.delay || 200);
  45064. }
  45065. }
  45066. if (isDef(res.timeout)) {
  45067. timerTimeout = setTimeout(function () {
  45068. timerTimeout = null;
  45069. if (isUndef(factory.resolved)) {
  45070. reject(
  45071. "timeout (" + (res.timeout) + "ms)"
  45072. );
  45073. }
  45074. }, res.timeout);
  45075. }
  45076. }
  45077. }
  45078. sync = false;
  45079. // return in case resolved synchronously
  45080. return factory.loading
  45081. ? factory.loadingComp
  45082. : factory.resolved
  45083. }
  45084. }
  45085. /* */
  45086. function isAsyncPlaceholder (node) {
  45087. return node.isComment && node.asyncFactory
  45088. }
  45089. /* */
  45090. function getFirstComponentChild (children) {
  45091. if (Array.isArray(children)) {
  45092. for (var i = 0; i < children.length; i++) {
  45093. var c = children[i];
  45094. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45095. return c
  45096. }
  45097. }
  45098. }
  45099. }
  45100. /* */
  45101. /* */
  45102. function initEvents (vm) {
  45103. vm._events = Object.create(null);
  45104. vm._hasHookEvent = false;
  45105. // init parent attached events
  45106. var listeners = vm.$options._parentListeners;
  45107. if (listeners) {
  45108. updateComponentListeners(vm, listeners);
  45109. }
  45110. }
  45111. var target;
  45112. function add (event, fn) {
  45113. target.$on(event, fn);
  45114. }
  45115. function remove$1 (event, fn) {
  45116. target.$off(event, fn);
  45117. }
  45118. function createOnceHandler (event, fn) {
  45119. var _target = target;
  45120. return function onceHandler () {
  45121. var res = fn.apply(null, arguments);
  45122. if (res !== null) {
  45123. _target.$off(event, onceHandler);
  45124. }
  45125. }
  45126. }
  45127. function updateComponentListeners (
  45128. vm,
  45129. listeners,
  45130. oldListeners
  45131. ) {
  45132. target = vm;
  45133. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45134. target = undefined;
  45135. }
  45136. function eventsMixin (Vue) {
  45137. var hookRE = /^hook:/;
  45138. Vue.prototype.$on = function (event, fn) {
  45139. var vm = this;
  45140. if (Array.isArray(event)) {
  45141. for (var i = 0, l = event.length; i < l; i++) {
  45142. vm.$on(event[i], fn);
  45143. }
  45144. } else {
  45145. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45146. // optimize hook:event cost by using a boolean flag marked at registration
  45147. // instead of a hash lookup
  45148. if (hookRE.test(event)) {
  45149. vm._hasHookEvent = true;
  45150. }
  45151. }
  45152. return vm
  45153. };
  45154. Vue.prototype.$once = function (event, fn) {
  45155. var vm = this;
  45156. function on () {
  45157. vm.$off(event, on);
  45158. fn.apply(vm, arguments);
  45159. }
  45160. on.fn = fn;
  45161. vm.$on(event, on);
  45162. return vm
  45163. };
  45164. Vue.prototype.$off = function (event, fn) {
  45165. var vm = this;
  45166. // all
  45167. if (!arguments.length) {
  45168. vm._events = Object.create(null);
  45169. return vm
  45170. }
  45171. // array of events
  45172. if (Array.isArray(event)) {
  45173. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45174. vm.$off(event[i$1], fn);
  45175. }
  45176. return vm
  45177. }
  45178. // specific event
  45179. var cbs = vm._events[event];
  45180. if (!cbs) {
  45181. return vm
  45182. }
  45183. if (!fn) {
  45184. vm._events[event] = null;
  45185. return vm
  45186. }
  45187. // specific handler
  45188. var cb;
  45189. var i = cbs.length;
  45190. while (i--) {
  45191. cb = cbs[i];
  45192. if (cb === fn || cb.fn === fn) {
  45193. cbs.splice(i, 1);
  45194. break
  45195. }
  45196. }
  45197. return vm
  45198. };
  45199. Vue.prototype.$emit = function (event) {
  45200. var vm = this;
  45201. {
  45202. var lowerCaseEvent = event.toLowerCase();
  45203. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45204. tip(
  45205. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45206. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45207. "Note that HTML attributes are case-insensitive and you cannot use " +
  45208. "v-on to listen to camelCase events when using in-DOM templates. " +
  45209. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45210. );
  45211. }
  45212. }
  45213. var cbs = vm._events[event];
  45214. if (cbs) {
  45215. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45216. var args = toArray(arguments, 1);
  45217. var info = "event handler for \"" + event + "\"";
  45218. for (var i = 0, l = cbs.length; i < l; i++) {
  45219. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45220. }
  45221. }
  45222. return vm
  45223. };
  45224. }
  45225. /* */
  45226. var activeInstance = null;
  45227. var isUpdatingChildComponent = false;
  45228. function setActiveInstance(vm) {
  45229. var prevActiveInstance = activeInstance;
  45230. activeInstance = vm;
  45231. return function () {
  45232. activeInstance = prevActiveInstance;
  45233. }
  45234. }
  45235. function initLifecycle (vm) {
  45236. var options = vm.$options;
  45237. // locate first non-abstract parent
  45238. var parent = options.parent;
  45239. if (parent && !options.abstract) {
  45240. while (parent.$options.abstract && parent.$parent) {
  45241. parent = parent.$parent;
  45242. }
  45243. parent.$children.push(vm);
  45244. }
  45245. vm.$parent = parent;
  45246. vm.$root = parent ? parent.$root : vm;
  45247. vm.$children = [];
  45248. vm.$refs = {};
  45249. vm._watcher = null;
  45250. vm._inactive = null;
  45251. vm._directInactive = false;
  45252. vm._isMounted = false;
  45253. vm._isDestroyed = false;
  45254. vm._isBeingDestroyed = false;
  45255. }
  45256. function lifecycleMixin (Vue) {
  45257. Vue.prototype._update = function (vnode, hydrating) {
  45258. var vm = this;
  45259. var prevEl = vm.$el;
  45260. var prevVnode = vm._vnode;
  45261. var restoreActiveInstance = setActiveInstance(vm);
  45262. vm._vnode = vnode;
  45263. // Vue.prototype.__patch__ is injected in entry points
  45264. // based on the rendering backend used.
  45265. if (!prevVnode) {
  45266. // initial render
  45267. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45268. } else {
  45269. // updates
  45270. vm.$el = vm.__patch__(prevVnode, vnode);
  45271. }
  45272. restoreActiveInstance();
  45273. // update __vue__ reference
  45274. if (prevEl) {
  45275. prevEl.__vue__ = null;
  45276. }
  45277. if (vm.$el) {
  45278. vm.$el.__vue__ = vm;
  45279. }
  45280. // if parent is an HOC, update its $el as well
  45281. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45282. vm.$parent.$el = vm.$el;
  45283. }
  45284. // updated hook is called by the scheduler to ensure that children are
  45285. // updated in a parent's updated hook.
  45286. };
  45287. Vue.prototype.$forceUpdate = function () {
  45288. var vm = this;
  45289. if (vm._watcher) {
  45290. vm._watcher.update();
  45291. }
  45292. };
  45293. Vue.prototype.$destroy = function () {
  45294. var vm = this;
  45295. if (vm._isBeingDestroyed) {
  45296. return
  45297. }
  45298. callHook(vm, 'beforeDestroy');
  45299. vm._isBeingDestroyed = true;
  45300. // remove self from parent
  45301. var parent = vm.$parent;
  45302. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45303. remove(parent.$children, vm);
  45304. }
  45305. // teardown watchers
  45306. if (vm._watcher) {
  45307. vm._watcher.teardown();
  45308. }
  45309. var i = vm._watchers.length;
  45310. while (i--) {
  45311. vm._watchers[i].teardown();
  45312. }
  45313. // remove reference from data ob
  45314. // frozen object may not have observer.
  45315. if (vm._data.__ob__) {
  45316. vm._data.__ob__.vmCount--;
  45317. }
  45318. // call the last hook...
  45319. vm._isDestroyed = true;
  45320. // invoke destroy hooks on current rendered tree
  45321. vm.__patch__(vm._vnode, null);
  45322. // fire destroyed hook
  45323. callHook(vm, 'destroyed');
  45324. // turn off all instance listeners.
  45325. vm.$off();
  45326. // remove __vue__ reference
  45327. if (vm.$el) {
  45328. vm.$el.__vue__ = null;
  45329. }
  45330. // release circular reference (#6759)
  45331. if (vm.$vnode) {
  45332. vm.$vnode.parent = null;
  45333. }
  45334. };
  45335. }
  45336. function mountComponent (
  45337. vm,
  45338. el,
  45339. hydrating
  45340. ) {
  45341. vm.$el = el;
  45342. if (!vm.$options.render) {
  45343. vm.$options.render = createEmptyVNode;
  45344. {
  45345. /* istanbul ignore if */
  45346. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45347. vm.$options.el || el) {
  45348. warn(
  45349. 'You are using the runtime-only build of Vue where the template ' +
  45350. 'compiler is not available. Either pre-compile the templates into ' +
  45351. 'render functions, or use the compiler-included build.',
  45352. vm
  45353. );
  45354. } else {
  45355. warn(
  45356. 'Failed to mount component: template or render function not defined.',
  45357. vm
  45358. );
  45359. }
  45360. }
  45361. }
  45362. callHook(vm, 'beforeMount');
  45363. var updateComponent;
  45364. /* istanbul ignore if */
  45365. if (config.performance && mark) {
  45366. updateComponent = function () {
  45367. var name = vm._name;
  45368. var id = vm._uid;
  45369. var startTag = "vue-perf-start:" + id;
  45370. var endTag = "vue-perf-end:" + id;
  45371. mark(startTag);
  45372. var vnode = vm._render();
  45373. mark(endTag);
  45374. measure(("vue " + name + " render"), startTag, endTag);
  45375. mark(startTag);
  45376. vm._update(vnode, hydrating);
  45377. mark(endTag);
  45378. measure(("vue " + name + " patch"), startTag, endTag);
  45379. };
  45380. } else {
  45381. updateComponent = function () {
  45382. vm._update(vm._render(), hydrating);
  45383. };
  45384. }
  45385. // we set this to vm._watcher inside the watcher's constructor
  45386. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45387. // component's mounted hook), which relies on vm._watcher being already defined
  45388. new Watcher(vm, updateComponent, noop, {
  45389. before: function before () {
  45390. if (vm._isMounted && !vm._isDestroyed) {
  45391. callHook(vm, 'beforeUpdate');
  45392. }
  45393. }
  45394. }, true /* isRenderWatcher */);
  45395. hydrating = false;
  45396. // manually mounted instance, call mounted on self
  45397. // mounted is called for render-created child components in its inserted hook
  45398. if (vm.$vnode == null) {
  45399. vm._isMounted = true;
  45400. callHook(vm, 'mounted');
  45401. }
  45402. return vm
  45403. }
  45404. function updateChildComponent (
  45405. vm,
  45406. propsData,
  45407. listeners,
  45408. parentVnode,
  45409. renderChildren
  45410. ) {
  45411. {
  45412. isUpdatingChildComponent = true;
  45413. }
  45414. // determine whether component has slot children
  45415. // we need to do this before overwriting $options._renderChildren.
  45416. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45417. // dynamic slot names). Static scoped slots compiled from template has the
  45418. // "$stable" marker.
  45419. var newScopedSlots = parentVnode.data.scopedSlots;
  45420. var oldScopedSlots = vm.$scopedSlots;
  45421. var hasDynamicScopedSlot = !!(
  45422. (newScopedSlots && !newScopedSlots.$stable) ||
  45423. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45424. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45425. );
  45426. // Any static slot children from the parent may have changed during parent's
  45427. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45428. // update is necessary to ensure correctness.
  45429. var needsForceUpdate = !!(
  45430. renderChildren || // has new static slots
  45431. vm.$options._renderChildren || // has old static slots
  45432. hasDynamicScopedSlot
  45433. );
  45434. vm.$options._parentVnode = parentVnode;
  45435. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45436. if (vm._vnode) { // update child tree's parent
  45437. vm._vnode.parent = parentVnode;
  45438. }
  45439. vm.$options._renderChildren = renderChildren;
  45440. // update $attrs and $listeners hash
  45441. // these are also reactive so they may trigger child update if the child
  45442. // used them during render
  45443. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45444. vm.$listeners = listeners || emptyObject;
  45445. // update props
  45446. if (propsData && vm.$options.props) {
  45447. toggleObserving(false);
  45448. var props = vm._props;
  45449. var propKeys = vm.$options._propKeys || [];
  45450. for (var i = 0; i < propKeys.length; i++) {
  45451. var key = propKeys[i];
  45452. var propOptions = vm.$options.props; // wtf flow?
  45453. props[key] = validateProp(key, propOptions, propsData, vm);
  45454. }
  45455. toggleObserving(true);
  45456. // keep a copy of raw propsData
  45457. vm.$options.propsData = propsData;
  45458. }
  45459. // update listeners
  45460. listeners = listeners || emptyObject;
  45461. var oldListeners = vm.$options._parentListeners;
  45462. vm.$options._parentListeners = listeners;
  45463. updateComponentListeners(vm, listeners, oldListeners);
  45464. // resolve slots + force update if has children
  45465. if (needsForceUpdate) {
  45466. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45467. vm.$forceUpdate();
  45468. }
  45469. {
  45470. isUpdatingChildComponent = false;
  45471. }
  45472. }
  45473. function isInInactiveTree (vm) {
  45474. while (vm && (vm = vm.$parent)) {
  45475. if (vm._inactive) { return true }
  45476. }
  45477. return false
  45478. }
  45479. function activateChildComponent (vm, direct) {
  45480. if (direct) {
  45481. vm._directInactive = false;
  45482. if (isInInactiveTree(vm)) {
  45483. return
  45484. }
  45485. } else if (vm._directInactive) {
  45486. return
  45487. }
  45488. if (vm._inactive || vm._inactive === null) {
  45489. vm._inactive = false;
  45490. for (var i = 0; i < vm.$children.length; i++) {
  45491. activateChildComponent(vm.$children[i]);
  45492. }
  45493. callHook(vm, 'activated');
  45494. }
  45495. }
  45496. function deactivateChildComponent (vm, direct) {
  45497. if (direct) {
  45498. vm._directInactive = true;
  45499. if (isInInactiveTree(vm)) {
  45500. return
  45501. }
  45502. }
  45503. if (!vm._inactive) {
  45504. vm._inactive = true;
  45505. for (var i = 0; i < vm.$children.length; i++) {
  45506. deactivateChildComponent(vm.$children[i]);
  45507. }
  45508. callHook(vm, 'deactivated');
  45509. }
  45510. }
  45511. function callHook (vm, hook) {
  45512. // #7573 disable dep collection when invoking lifecycle hooks
  45513. pushTarget();
  45514. var handlers = vm.$options[hook];
  45515. var info = hook + " hook";
  45516. if (handlers) {
  45517. for (var i = 0, j = handlers.length; i < j; i++) {
  45518. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45519. }
  45520. }
  45521. if (vm._hasHookEvent) {
  45522. vm.$emit('hook:' + hook);
  45523. }
  45524. popTarget();
  45525. }
  45526. /* */
  45527. var MAX_UPDATE_COUNT = 100;
  45528. var queue = [];
  45529. var activatedChildren = [];
  45530. var has = {};
  45531. var circular = {};
  45532. var waiting = false;
  45533. var flushing = false;
  45534. var index = 0;
  45535. /**
  45536. * Reset the scheduler's state.
  45537. */
  45538. function resetSchedulerState () {
  45539. index = queue.length = activatedChildren.length = 0;
  45540. has = {};
  45541. {
  45542. circular = {};
  45543. }
  45544. waiting = flushing = false;
  45545. }
  45546. // Async edge case #6566 requires saving the timestamp when event listeners are
  45547. // attached. However, calling performance.now() has a perf overhead especially
  45548. // if the page has thousands of event listeners. Instead, we take a timestamp
  45549. // every time the scheduler flushes and use that for all event listeners
  45550. // attached during that flush.
  45551. var currentFlushTimestamp = 0;
  45552. // Async edge case fix requires storing an event listener's attach timestamp.
  45553. var getNow = Date.now;
  45554. // Determine what event timestamp the browser is using. Annoyingly, the
  45555. // timestamp can either be hi-res (relative to page load) or low-res
  45556. // (relative to UNIX epoch), so in order to compare time we have to use the
  45557. // same timestamp type when saving the flush timestamp.
  45558. // All IE versions use low-res event timestamps, and have problematic clock
  45559. // implementations (#9632)
  45560. if (inBrowser && !isIE) {
  45561. var performance = window.performance;
  45562. if (
  45563. performance &&
  45564. typeof performance.now === 'function' &&
  45565. getNow() > document.createEvent('Event').timeStamp
  45566. ) {
  45567. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45568. // smaller than it, it means the event is using a hi-res timestamp,
  45569. // and we need to use the hi-res version for event listener timestamps as
  45570. // well.
  45571. getNow = function () { return performance.now(); };
  45572. }
  45573. }
  45574. /**
  45575. * Flush both queues and run the watchers.
  45576. */
  45577. function flushSchedulerQueue () {
  45578. currentFlushTimestamp = getNow();
  45579. flushing = true;
  45580. var watcher, id;
  45581. // Sort queue before flush.
  45582. // This ensures that:
  45583. // 1. Components are updated from parent to child. (because parent is always
  45584. // created before the child)
  45585. // 2. A component's user watchers are run before its render watcher (because
  45586. // user watchers are created before the render watcher)
  45587. // 3. If a component is destroyed during a parent component's watcher run,
  45588. // its watchers can be skipped.
  45589. queue.sort(function (a, b) { return a.id - b.id; });
  45590. // do not cache length because more watchers might be pushed
  45591. // as we run existing watchers
  45592. for (index = 0; index < queue.length; index++) {
  45593. watcher = queue[index];
  45594. if (watcher.before) {
  45595. watcher.before();
  45596. }
  45597. id = watcher.id;
  45598. has[id] = null;
  45599. watcher.run();
  45600. // in dev build, check and stop circular updates.
  45601. if (has[id] != null) {
  45602. circular[id] = (circular[id] || 0) + 1;
  45603. if (circular[id] > MAX_UPDATE_COUNT) {
  45604. warn(
  45605. 'You may have an infinite update loop ' + (
  45606. watcher.user
  45607. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45608. : "in a component render function."
  45609. ),
  45610. watcher.vm
  45611. );
  45612. break
  45613. }
  45614. }
  45615. }
  45616. // keep copies of post queues before resetting state
  45617. var activatedQueue = activatedChildren.slice();
  45618. var updatedQueue = queue.slice();
  45619. resetSchedulerState();
  45620. // call component updated and activated hooks
  45621. callActivatedHooks(activatedQueue);
  45622. callUpdatedHooks(updatedQueue);
  45623. // devtool hook
  45624. /* istanbul ignore if */
  45625. if (devtools && config.devtools) {
  45626. devtools.emit('flush');
  45627. }
  45628. }
  45629. function callUpdatedHooks (queue) {
  45630. var i = queue.length;
  45631. while (i--) {
  45632. var watcher = queue[i];
  45633. var vm = watcher.vm;
  45634. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45635. callHook(vm, 'updated');
  45636. }
  45637. }
  45638. }
  45639. /**
  45640. * Queue a kept-alive component that was activated during patch.
  45641. * The queue will be processed after the entire tree has been patched.
  45642. */
  45643. function queueActivatedComponent (vm) {
  45644. // setting _inactive to false here so that a render function can
  45645. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45646. vm._inactive = false;
  45647. activatedChildren.push(vm);
  45648. }
  45649. function callActivatedHooks (queue) {
  45650. for (var i = 0; i < queue.length; i++) {
  45651. queue[i]._inactive = true;
  45652. activateChildComponent(queue[i], true /* true */);
  45653. }
  45654. }
  45655. /**
  45656. * Push a watcher into the watcher queue.
  45657. * Jobs with duplicate IDs will be skipped unless it's
  45658. * pushed when the queue is being flushed.
  45659. */
  45660. function queueWatcher (watcher) {
  45661. var id = watcher.id;
  45662. if (has[id] == null) {
  45663. has[id] = true;
  45664. if (!flushing) {
  45665. queue.push(watcher);
  45666. } else {
  45667. // if already flushing, splice the watcher based on its id
  45668. // if already past its id, it will be run next immediately.
  45669. var i = queue.length - 1;
  45670. while (i > index && queue[i].id > watcher.id) {
  45671. i--;
  45672. }
  45673. queue.splice(i + 1, 0, watcher);
  45674. }
  45675. // queue the flush
  45676. if (!waiting) {
  45677. waiting = true;
  45678. if (!config.async) {
  45679. flushSchedulerQueue();
  45680. return
  45681. }
  45682. nextTick(flushSchedulerQueue);
  45683. }
  45684. }
  45685. }
  45686. /* */
  45687. var uid$2 = 0;
  45688. /**
  45689. * A watcher parses an expression, collects dependencies,
  45690. * and fires callback when the expression value changes.
  45691. * This is used for both the $watch() api and directives.
  45692. */
  45693. var Watcher = function Watcher (
  45694. vm,
  45695. expOrFn,
  45696. cb,
  45697. options,
  45698. isRenderWatcher
  45699. ) {
  45700. this.vm = vm;
  45701. if (isRenderWatcher) {
  45702. vm._watcher = this;
  45703. }
  45704. vm._watchers.push(this);
  45705. // options
  45706. if (options) {
  45707. this.deep = !!options.deep;
  45708. this.user = !!options.user;
  45709. this.lazy = !!options.lazy;
  45710. this.sync = !!options.sync;
  45711. this.before = options.before;
  45712. } else {
  45713. this.deep = this.user = this.lazy = this.sync = false;
  45714. }
  45715. this.cb = cb;
  45716. this.id = ++uid$2; // uid for batching
  45717. this.active = true;
  45718. this.dirty = this.lazy; // for lazy watchers
  45719. this.deps = [];
  45720. this.newDeps = [];
  45721. this.depIds = new _Set();
  45722. this.newDepIds = new _Set();
  45723. this.expression = expOrFn.toString();
  45724. // parse expression for getter
  45725. if (typeof expOrFn === 'function') {
  45726. this.getter = expOrFn;
  45727. } else {
  45728. this.getter = parsePath(expOrFn);
  45729. if (!this.getter) {
  45730. this.getter = noop;
  45731. warn(
  45732. "Failed watching path: \"" + expOrFn + "\" " +
  45733. 'Watcher only accepts simple dot-delimited paths. ' +
  45734. 'For full control, use a function instead.',
  45735. vm
  45736. );
  45737. }
  45738. }
  45739. this.value = this.lazy
  45740. ? undefined
  45741. : this.get();
  45742. };
  45743. /**
  45744. * Evaluate the getter, and re-collect dependencies.
  45745. */
  45746. Watcher.prototype.get = function get () {
  45747. pushTarget(this);
  45748. var value;
  45749. var vm = this.vm;
  45750. try {
  45751. value = this.getter.call(vm, vm);
  45752. } catch (e) {
  45753. if (this.user) {
  45754. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45755. } else {
  45756. throw e
  45757. }
  45758. } finally {
  45759. // "touch" every property so they are all tracked as
  45760. // dependencies for deep watching
  45761. if (this.deep) {
  45762. traverse(value);
  45763. }
  45764. popTarget();
  45765. this.cleanupDeps();
  45766. }
  45767. return value
  45768. };
  45769. /**
  45770. * Add a dependency to this directive.
  45771. */
  45772. Watcher.prototype.addDep = function addDep (dep) {
  45773. var id = dep.id;
  45774. if (!this.newDepIds.has(id)) {
  45775. this.newDepIds.add(id);
  45776. this.newDeps.push(dep);
  45777. if (!this.depIds.has(id)) {
  45778. dep.addSub(this);
  45779. }
  45780. }
  45781. };
  45782. /**
  45783. * Clean up for dependency collection.
  45784. */
  45785. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45786. var i = this.deps.length;
  45787. while (i--) {
  45788. var dep = this.deps[i];
  45789. if (!this.newDepIds.has(dep.id)) {
  45790. dep.removeSub(this);
  45791. }
  45792. }
  45793. var tmp = this.depIds;
  45794. this.depIds = this.newDepIds;
  45795. this.newDepIds = tmp;
  45796. this.newDepIds.clear();
  45797. tmp = this.deps;
  45798. this.deps = this.newDeps;
  45799. this.newDeps = tmp;
  45800. this.newDeps.length = 0;
  45801. };
  45802. /**
  45803. * Subscriber interface.
  45804. * Will be called when a dependency changes.
  45805. */
  45806. Watcher.prototype.update = function update () {
  45807. /* istanbul ignore else */
  45808. if (this.lazy) {
  45809. this.dirty = true;
  45810. } else if (this.sync) {
  45811. this.run();
  45812. } else {
  45813. queueWatcher(this);
  45814. }
  45815. };
  45816. /**
  45817. * Scheduler job interface.
  45818. * Will be called by the scheduler.
  45819. */
  45820. Watcher.prototype.run = function run () {
  45821. if (this.active) {
  45822. var value = this.get();
  45823. if (
  45824. value !== this.value ||
  45825. // Deep watchers and watchers on Object/Arrays should fire even
  45826. // when the value is the same, because the value may
  45827. // have mutated.
  45828. isObject(value) ||
  45829. this.deep
  45830. ) {
  45831. // set new value
  45832. var oldValue = this.value;
  45833. this.value = value;
  45834. if (this.user) {
  45835. try {
  45836. this.cb.call(this.vm, value, oldValue);
  45837. } catch (e) {
  45838. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45839. }
  45840. } else {
  45841. this.cb.call(this.vm, value, oldValue);
  45842. }
  45843. }
  45844. }
  45845. };
  45846. /**
  45847. * Evaluate the value of the watcher.
  45848. * This only gets called for lazy watchers.
  45849. */
  45850. Watcher.prototype.evaluate = function evaluate () {
  45851. this.value = this.get();
  45852. this.dirty = false;
  45853. };
  45854. /**
  45855. * Depend on all deps collected by this watcher.
  45856. */
  45857. Watcher.prototype.depend = function depend () {
  45858. var i = this.deps.length;
  45859. while (i--) {
  45860. this.deps[i].depend();
  45861. }
  45862. };
  45863. /**
  45864. * Remove self from all dependencies' subscriber list.
  45865. */
  45866. Watcher.prototype.teardown = function teardown () {
  45867. if (this.active) {
  45868. // remove self from vm's watcher list
  45869. // this is a somewhat expensive operation so we skip it
  45870. // if the vm is being destroyed.
  45871. if (!this.vm._isBeingDestroyed) {
  45872. remove(this.vm._watchers, this);
  45873. }
  45874. var i = this.deps.length;
  45875. while (i--) {
  45876. this.deps[i].removeSub(this);
  45877. }
  45878. this.active = false;
  45879. }
  45880. };
  45881. /* */
  45882. var sharedPropertyDefinition = {
  45883. enumerable: true,
  45884. configurable: true,
  45885. get: noop,
  45886. set: noop
  45887. };
  45888. function proxy (target, sourceKey, key) {
  45889. sharedPropertyDefinition.get = function proxyGetter () {
  45890. return this[sourceKey][key]
  45891. };
  45892. sharedPropertyDefinition.set = function proxySetter (val) {
  45893. this[sourceKey][key] = val;
  45894. };
  45895. Object.defineProperty(target, key, sharedPropertyDefinition);
  45896. }
  45897. function initState (vm) {
  45898. vm._watchers = [];
  45899. var opts = vm.$options;
  45900. if (opts.props) { initProps(vm, opts.props); }
  45901. if (opts.methods) { initMethods(vm, opts.methods); }
  45902. if (opts.data) {
  45903. initData(vm);
  45904. } else {
  45905. observe(vm._data = {}, true /* asRootData */);
  45906. }
  45907. if (opts.computed) { initComputed(vm, opts.computed); }
  45908. if (opts.watch && opts.watch !== nativeWatch) {
  45909. initWatch(vm, opts.watch);
  45910. }
  45911. }
  45912. function initProps (vm, propsOptions) {
  45913. var propsData = vm.$options.propsData || {};
  45914. var props = vm._props = {};
  45915. // cache prop keys so that future props updates can iterate using Array
  45916. // instead of dynamic object key enumeration.
  45917. var keys = vm.$options._propKeys = [];
  45918. var isRoot = !vm.$parent;
  45919. // root instance props should be converted
  45920. if (!isRoot) {
  45921. toggleObserving(false);
  45922. }
  45923. var loop = function ( key ) {
  45924. keys.push(key);
  45925. var value = validateProp(key, propsOptions, propsData, vm);
  45926. /* istanbul ignore else */
  45927. {
  45928. var hyphenatedKey = hyphenate(key);
  45929. if (isReservedAttribute(hyphenatedKey) ||
  45930. config.isReservedAttr(hyphenatedKey)) {
  45931. warn(
  45932. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  45933. vm
  45934. );
  45935. }
  45936. defineReactive$$1(props, key, value, function () {
  45937. if (!isRoot && !isUpdatingChildComponent) {
  45938. warn(
  45939. "Avoid mutating a prop directly since the value will be " +
  45940. "overwritten whenever the parent component re-renders. " +
  45941. "Instead, use a data or computed property based on the prop's " +
  45942. "value. Prop being mutated: \"" + key + "\"",
  45943. vm
  45944. );
  45945. }
  45946. });
  45947. }
  45948. // static props are already proxied on the component's prototype
  45949. // during Vue.extend(). We only need to proxy props defined at
  45950. // instantiation here.
  45951. if (!(key in vm)) {
  45952. proxy(vm, "_props", key);
  45953. }
  45954. };
  45955. for (var key in propsOptions) loop( key );
  45956. toggleObserving(true);
  45957. }
  45958. function initData (vm) {
  45959. var data = vm.$options.data;
  45960. data = vm._data = typeof data === 'function'
  45961. ? getData(data, vm)
  45962. : data || {};
  45963. if (!isPlainObject(data)) {
  45964. data = {};
  45965. warn(
  45966. 'data functions should return an object:\n' +
  45967. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  45968. vm
  45969. );
  45970. }
  45971. // proxy data on instance
  45972. var keys = Object.keys(data);
  45973. var props = vm.$options.props;
  45974. var methods = vm.$options.methods;
  45975. var i = keys.length;
  45976. while (i--) {
  45977. var key = keys[i];
  45978. {
  45979. if (methods && hasOwn(methods, key)) {
  45980. warn(
  45981. ("Method \"" + key + "\" has already been defined as a data property."),
  45982. vm
  45983. );
  45984. }
  45985. }
  45986. if (props && hasOwn(props, key)) {
  45987. warn(
  45988. "The data property \"" + key + "\" is already declared as a prop. " +
  45989. "Use prop default value instead.",
  45990. vm
  45991. );
  45992. } else if (!isReserved(key)) {
  45993. proxy(vm, "_data", key);
  45994. }
  45995. }
  45996. // observe data
  45997. observe(data, true /* asRootData */);
  45998. }
  45999. function getData (data, vm) {
  46000. // #7573 disable dep collection when invoking data getters
  46001. pushTarget();
  46002. try {
  46003. return data.call(vm, vm)
  46004. } catch (e) {
  46005. handleError(e, vm, "data()");
  46006. return {}
  46007. } finally {
  46008. popTarget();
  46009. }
  46010. }
  46011. var computedWatcherOptions = { lazy: true };
  46012. function initComputed (vm, computed) {
  46013. // $flow-disable-line
  46014. var watchers = vm._computedWatchers = Object.create(null);
  46015. // computed properties are just getters during SSR
  46016. var isSSR = isServerRendering();
  46017. for (var key in computed) {
  46018. var userDef = computed[key];
  46019. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46020. if (getter == null) {
  46021. warn(
  46022. ("Getter is missing for computed property \"" + key + "\"."),
  46023. vm
  46024. );
  46025. }
  46026. if (!isSSR) {
  46027. // create internal watcher for the computed property.
  46028. watchers[key] = new Watcher(
  46029. vm,
  46030. getter || noop,
  46031. noop,
  46032. computedWatcherOptions
  46033. );
  46034. }
  46035. // component-defined computed properties are already defined on the
  46036. // component prototype. We only need to define computed properties defined
  46037. // at instantiation here.
  46038. if (!(key in vm)) {
  46039. defineComputed(vm, key, userDef);
  46040. } else {
  46041. if (key in vm.$data) {
  46042. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46043. } else if (vm.$options.props && key in vm.$options.props) {
  46044. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46045. }
  46046. }
  46047. }
  46048. }
  46049. function defineComputed (
  46050. target,
  46051. key,
  46052. userDef
  46053. ) {
  46054. var shouldCache = !isServerRendering();
  46055. if (typeof userDef === 'function') {
  46056. sharedPropertyDefinition.get = shouldCache
  46057. ? createComputedGetter(key)
  46058. : createGetterInvoker(userDef);
  46059. sharedPropertyDefinition.set = noop;
  46060. } else {
  46061. sharedPropertyDefinition.get = userDef.get
  46062. ? shouldCache && userDef.cache !== false
  46063. ? createComputedGetter(key)
  46064. : createGetterInvoker(userDef.get)
  46065. : noop;
  46066. sharedPropertyDefinition.set = userDef.set || noop;
  46067. }
  46068. if (sharedPropertyDefinition.set === noop) {
  46069. sharedPropertyDefinition.set = function () {
  46070. warn(
  46071. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46072. this
  46073. );
  46074. };
  46075. }
  46076. Object.defineProperty(target, key, sharedPropertyDefinition);
  46077. }
  46078. function createComputedGetter (key) {
  46079. return function computedGetter () {
  46080. var watcher = this._computedWatchers && this._computedWatchers[key];
  46081. if (watcher) {
  46082. if (watcher.dirty) {
  46083. watcher.evaluate();
  46084. }
  46085. if (Dep.target) {
  46086. watcher.depend();
  46087. }
  46088. return watcher.value
  46089. }
  46090. }
  46091. }
  46092. function createGetterInvoker(fn) {
  46093. return function computedGetter () {
  46094. return fn.call(this, this)
  46095. }
  46096. }
  46097. function initMethods (vm, methods) {
  46098. var props = vm.$options.props;
  46099. for (var key in methods) {
  46100. {
  46101. if (typeof methods[key] !== 'function') {
  46102. warn(
  46103. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46104. "Did you reference the function correctly?",
  46105. vm
  46106. );
  46107. }
  46108. if (props && hasOwn(props, key)) {
  46109. warn(
  46110. ("Method \"" + key + "\" has already been defined as a prop."),
  46111. vm
  46112. );
  46113. }
  46114. if ((key in vm) && isReserved(key)) {
  46115. warn(
  46116. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46117. "Avoid defining component methods that start with _ or $."
  46118. );
  46119. }
  46120. }
  46121. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46122. }
  46123. }
  46124. function initWatch (vm, watch) {
  46125. for (var key in watch) {
  46126. var handler = watch[key];
  46127. if (Array.isArray(handler)) {
  46128. for (var i = 0; i < handler.length; i++) {
  46129. createWatcher(vm, key, handler[i]);
  46130. }
  46131. } else {
  46132. createWatcher(vm, key, handler);
  46133. }
  46134. }
  46135. }
  46136. function createWatcher (
  46137. vm,
  46138. expOrFn,
  46139. handler,
  46140. options
  46141. ) {
  46142. if (isPlainObject(handler)) {
  46143. options = handler;
  46144. handler = handler.handler;
  46145. }
  46146. if (typeof handler === 'string') {
  46147. handler = vm[handler];
  46148. }
  46149. return vm.$watch(expOrFn, handler, options)
  46150. }
  46151. function stateMixin (Vue) {
  46152. // flow somehow has problems with directly declared definition object
  46153. // when using Object.defineProperty, so we have to procedurally build up
  46154. // the object here.
  46155. var dataDef = {};
  46156. dataDef.get = function () { return this._data };
  46157. var propsDef = {};
  46158. propsDef.get = function () { return this._props };
  46159. {
  46160. dataDef.set = function () {
  46161. warn(
  46162. 'Avoid replacing instance root $data. ' +
  46163. 'Use nested data properties instead.',
  46164. this
  46165. );
  46166. };
  46167. propsDef.set = function () {
  46168. warn("$props is readonly.", this);
  46169. };
  46170. }
  46171. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46172. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46173. Vue.prototype.$set = set;
  46174. Vue.prototype.$delete = del;
  46175. Vue.prototype.$watch = function (
  46176. expOrFn,
  46177. cb,
  46178. options
  46179. ) {
  46180. var vm = this;
  46181. if (isPlainObject(cb)) {
  46182. return createWatcher(vm, expOrFn, cb, options)
  46183. }
  46184. options = options || {};
  46185. options.user = true;
  46186. var watcher = new Watcher(vm, expOrFn, cb, options);
  46187. if (options.immediate) {
  46188. try {
  46189. cb.call(vm, watcher.value);
  46190. } catch (error) {
  46191. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46192. }
  46193. }
  46194. return function unwatchFn () {
  46195. watcher.teardown();
  46196. }
  46197. };
  46198. }
  46199. /* */
  46200. var uid$3 = 0;
  46201. function initMixin (Vue) {
  46202. Vue.prototype._init = function (options) {
  46203. var vm = this;
  46204. // a uid
  46205. vm._uid = uid$3++;
  46206. var startTag, endTag;
  46207. /* istanbul ignore if */
  46208. if (config.performance && mark) {
  46209. startTag = "vue-perf-start:" + (vm._uid);
  46210. endTag = "vue-perf-end:" + (vm._uid);
  46211. mark(startTag);
  46212. }
  46213. // a flag to avoid this being observed
  46214. vm._isVue = true;
  46215. // merge options
  46216. if (options && options._isComponent) {
  46217. // optimize internal component instantiation
  46218. // since dynamic options merging is pretty slow, and none of the
  46219. // internal component options needs special treatment.
  46220. initInternalComponent(vm, options);
  46221. } else {
  46222. vm.$options = mergeOptions(
  46223. resolveConstructorOptions(vm.constructor),
  46224. options || {},
  46225. vm
  46226. );
  46227. }
  46228. /* istanbul ignore else */
  46229. {
  46230. initProxy(vm);
  46231. }
  46232. // expose real self
  46233. vm._self = vm;
  46234. initLifecycle(vm);
  46235. initEvents(vm);
  46236. initRender(vm);
  46237. callHook(vm, 'beforeCreate');
  46238. initInjections(vm); // resolve injections before data/props
  46239. initState(vm);
  46240. initProvide(vm); // resolve provide after data/props
  46241. callHook(vm, 'created');
  46242. /* istanbul ignore if */
  46243. if (config.performance && mark) {
  46244. vm._name = formatComponentName(vm, false);
  46245. mark(endTag);
  46246. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46247. }
  46248. if (vm.$options.el) {
  46249. vm.$mount(vm.$options.el);
  46250. }
  46251. };
  46252. }
  46253. function initInternalComponent (vm, options) {
  46254. var opts = vm.$options = Object.create(vm.constructor.options);
  46255. // doing this because it's faster than dynamic enumeration.
  46256. var parentVnode = options._parentVnode;
  46257. opts.parent = options.parent;
  46258. opts._parentVnode = parentVnode;
  46259. var vnodeComponentOptions = parentVnode.componentOptions;
  46260. opts.propsData = vnodeComponentOptions.propsData;
  46261. opts._parentListeners = vnodeComponentOptions.listeners;
  46262. opts._renderChildren = vnodeComponentOptions.children;
  46263. opts._componentTag = vnodeComponentOptions.tag;
  46264. if (options.render) {
  46265. opts.render = options.render;
  46266. opts.staticRenderFns = options.staticRenderFns;
  46267. }
  46268. }
  46269. function resolveConstructorOptions (Ctor) {
  46270. var options = Ctor.options;
  46271. if (Ctor.super) {
  46272. var superOptions = resolveConstructorOptions(Ctor.super);
  46273. var cachedSuperOptions = Ctor.superOptions;
  46274. if (superOptions !== cachedSuperOptions) {
  46275. // super option changed,
  46276. // need to resolve new options.
  46277. Ctor.superOptions = superOptions;
  46278. // check if there are any late-modified/attached options (#4976)
  46279. var modifiedOptions = resolveModifiedOptions(Ctor);
  46280. // update base extend options
  46281. if (modifiedOptions) {
  46282. extend(Ctor.extendOptions, modifiedOptions);
  46283. }
  46284. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46285. if (options.name) {
  46286. options.components[options.name] = Ctor;
  46287. }
  46288. }
  46289. }
  46290. return options
  46291. }
  46292. function resolveModifiedOptions (Ctor) {
  46293. var modified;
  46294. var latest = Ctor.options;
  46295. var sealed = Ctor.sealedOptions;
  46296. for (var key in latest) {
  46297. if (latest[key] !== sealed[key]) {
  46298. if (!modified) { modified = {}; }
  46299. modified[key] = latest[key];
  46300. }
  46301. }
  46302. return modified
  46303. }
  46304. function Vue (options) {
  46305. if (!(this instanceof Vue)
  46306. ) {
  46307. warn('Vue is a constructor and should be called with the `new` keyword');
  46308. }
  46309. this._init(options);
  46310. }
  46311. initMixin(Vue);
  46312. stateMixin(Vue);
  46313. eventsMixin(Vue);
  46314. lifecycleMixin(Vue);
  46315. renderMixin(Vue);
  46316. /* */
  46317. function initUse (Vue) {
  46318. Vue.use = function (plugin) {
  46319. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46320. if (installedPlugins.indexOf(plugin) > -1) {
  46321. return this
  46322. }
  46323. // additional parameters
  46324. var args = toArray(arguments, 1);
  46325. args.unshift(this);
  46326. if (typeof plugin.install === 'function') {
  46327. plugin.install.apply(plugin, args);
  46328. } else if (typeof plugin === 'function') {
  46329. plugin.apply(null, args);
  46330. }
  46331. installedPlugins.push(plugin);
  46332. return this
  46333. };
  46334. }
  46335. /* */
  46336. function initMixin$1 (Vue) {
  46337. Vue.mixin = function (mixin) {
  46338. this.options = mergeOptions(this.options, mixin);
  46339. return this
  46340. };
  46341. }
  46342. /* */
  46343. function initExtend (Vue) {
  46344. /**
  46345. * Each instance constructor, including Vue, has a unique
  46346. * cid. This enables us to create wrapped "child
  46347. * constructors" for prototypal inheritance and cache them.
  46348. */
  46349. Vue.cid = 0;
  46350. var cid = 1;
  46351. /**
  46352. * Class inheritance
  46353. */
  46354. Vue.extend = function (extendOptions) {
  46355. extendOptions = extendOptions || {};
  46356. var Super = this;
  46357. var SuperId = Super.cid;
  46358. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46359. if (cachedCtors[SuperId]) {
  46360. return cachedCtors[SuperId]
  46361. }
  46362. var name = extendOptions.name || Super.options.name;
  46363. if (name) {
  46364. validateComponentName(name);
  46365. }
  46366. var Sub = function VueComponent (options) {
  46367. this._init(options);
  46368. };
  46369. Sub.prototype = Object.create(Super.prototype);
  46370. Sub.prototype.constructor = Sub;
  46371. Sub.cid = cid++;
  46372. Sub.options = mergeOptions(
  46373. Super.options,
  46374. extendOptions
  46375. );
  46376. Sub['super'] = Super;
  46377. // For props and computed properties, we define the proxy getters on
  46378. // the Vue instances at extension time, on the extended prototype. This
  46379. // avoids Object.defineProperty calls for each instance created.
  46380. if (Sub.options.props) {
  46381. initProps$1(Sub);
  46382. }
  46383. if (Sub.options.computed) {
  46384. initComputed$1(Sub);
  46385. }
  46386. // allow further extension/mixin/plugin usage
  46387. Sub.extend = Super.extend;
  46388. Sub.mixin = Super.mixin;
  46389. Sub.use = Super.use;
  46390. // create asset registers, so extended classes
  46391. // can have their private assets too.
  46392. ASSET_TYPES.forEach(function (type) {
  46393. Sub[type] = Super[type];
  46394. });
  46395. // enable recursive self-lookup
  46396. if (name) {
  46397. Sub.options.components[name] = Sub;
  46398. }
  46399. // keep a reference to the super options at extension time.
  46400. // later at instantiation we can check if Super's options have
  46401. // been updated.
  46402. Sub.superOptions = Super.options;
  46403. Sub.extendOptions = extendOptions;
  46404. Sub.sealedOptions = extend({}, Sub.options);
  46405. // cache constructor
  46406. cachedCtors[SuperId] = Sub;
  46407. return Sub
  46408. };
  46409. }
  46410. function initProps$1 (Comp) {
  46411. var props = Comp.options.props;
  46412. for (var key in props) {
  46413. proxy(Comp.prototype, "_props", key);
  46414. }
  46415. }
  46416. function initComputed$1 (Comp) {
  46417. var computed = Comp.options.computed;
  46418. for (var key in computed) {
  46419. defineComputed(Comp.prototype, key, computed[key]);
  46420. }
  46421. }
  46422. /* */
  46423. function initAssetRegisters (Vue) {
  46424. /**
  46425. * Create asset registration methods.
  46426. */
  46427. ASSET_TYPES.forEach(function (type) {
  46428. Vue[type] = function (
  46429. id,
  46430. definition
  46431. ) {
  46432. if (!definition) {
  46433. return this.options[type + 's'][id]
  46434. } else {
  46435. /* istanbul ignore if */
  46436. if (type === 'component') {
  46437. validateComponentName(id);
  46438. }
  46439. if (type === 'component' && isPlainObject(definition)) {
  46440. definition.name = definition.name || id;
  46441. definition = this.options._base.extend(definition);
  46442. }
  46443. if (type === 'directive' && typeof definition === 'function') {
  46444. definition = { bind: definition, update: definition };
  46445. }
  46446. this.options[type + 's'][id] = definition;
  46447. return definition
  46448. }
  46449. };
  46450. });
  46451. }
  46452. /* */
  46453. function getComponentName (opts) {
  46454. return opts && (opts.Ctor.options.name || opts.tag)
  46455. }
  46456. function matches (pattern, name) {
  46457. if (Array.isArray(pattern)) {
  46458. return pattern.indexOf(name) > -1
  46459. } else if (typeof pattern === 'string') {
  46460. return pattern.split(',').indexOf(name) > -1
  46461. } else if (isRegExp(pattern)) {
  46462. return pattern.test(name)
  46463. }
  46464. /* istanbul ignore next */
  46465. return false
  46466. }
  46467. function pruneCache (keepAliveInstance, filter) {
  46468. var cache = keepAliveInstance.cache;
  46469. var keys = keepAliveInstance.keys;
  46470. var _vnode = keepAliveInstance._vnode;
  46471. for (var key in cache) {
  46472. var cachedNode = cache[key];
  46473. if (cachedNode) {
  46474. var name = getComponentName(cachedNode.componentOptions);
  46475. if (name && !filter(name)) {
  46476. pruneCacheEntry(cache, key, keys, _vnode);
  46477. }
  46478. }
  46479. }
  46480. }
  46481. function pruneCacheEntry (
  46482. cache,
  46483. key,
  46484. keys,
  46485. current
  46486. ) {
  46487. var cached$$1 = cache[key];
  46488. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46489. cached$$1.componentInstance.$destroy();
  46490. }
  46491. cache[key] = null;
  46492. remove(keys, key);
  46493. }
  46494. var patternTypes = [String, RegExp, Array];
  46495. var KeepAlive = {
  46496. name: 'keep-alive',
  46497. abstract: true,
  46498. props: {
  46499. include: patternTypes,
  46500. exclude: patternTypes,
  46501. max: [String, Number]
  46502. },
  46503. created: function created () {
  46504. this.cache = Object.create(null);
  46505. this.keys = [];
  46506. },
  46507. destroyed: function destroyed () {
  46508. for (var key in this.cache) {
  46509. pruneCacheEntry(this.cache, key, this.keys);
  46510. }
  46511. },
  46512. mounted: function mounted () {
  46513. var this$1 = this;
  46514. this.$watch('include', function (val) {
  46515. pruneCache(this$1, function (name) { return matches(val, name); });
  46516. });
  46517. this.$watch('exclude', function (val) {
  46518. pruneCache(this$1, function (name) { return !matches(val, name); });
  46519. });
  46520. },
  46521. render: function render () {
  46522. var slot = this.$slots.default;
  46523. var vnode = getFirstComponentChild(slot);
  46524. var componentOptions = vnode && vnode.componentOptions;
  46525. if (componentOptions) {
  46526. // check pattern
  46527. var name = getComponentName(componentOptions);
  46528. var ref = this;
  46529. var include = ref.include;
  46530. var exclude = ref.exclude;
  46531. if (
  46532. // not included
  46533. (include && (!name || !matches(include, name))) ||
  46534. // excluded
  46535. (exclude && name && matches(exclude, name))
  46536. ) {
  46537. return vnode
  46538. }
  46539. var ref$1 = this;
  46540. var cache = ref$1.cache;
  46541. var keys = ref$1.keys;
  46542. var key = vnode.key == null
  46543. // same constructor may get registered as different local components
  46544. // so cid alone is not enough (#3269)
  46545. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46546. : vnode.key;
  46547. if (cache[key]) {
  46548. vnode.componentInstance = cache[key].componentInstance;
  46549. // make current key freshest
  46550. remove(keys, key);
  46551. keys.push(key);
  46552. } else {
  46553. cache[key] = vnode;
  46554. keys.push(key);
  46555. // prune oldest entry
  46556. if (this.max && keys.length > parseInt(this.max)) {
  46557. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46558. }
  46559. }
  46560. vnode.data.keepAlive = true;
  46561. }
  46562. return vnode || (slot && slot[0])
  46563. }
  46564. };
  46565. var builtInComponents = {
  46566. KeepAlive: KeepAlive
  46567. };
  46568. /* */
  46569. function initGlobalAPI (Vue) {
  46570. // config
  46571. var configDef = {};
  46572. configDef.get = function () { return config; };
  46573. {
  46574. configDef.set = function () {
  46575. warn(
  46576. 'Do not replace the Vue.config object, set individual fields instead.'
  46577. );
  46578. };
  46579. }
  46580. Object.defineProperty(Vue, 'config', configDef);
  46581. // exposed util methods.
  46582. // NOTE: these are not considered part of the public API - avoid relying on
  46583. // them unless you are aware of the risk.
  46584. Vue.util = {
  46585. warn: warn,
  46586. extend: extend,
  46587. mergeOptions: mergeOptions,
  46588. defineReactive: defineReactive$$1
  46589. };
  46590. Vue.set = set;
  46591. Vue.delete = del;
  46592. Vue.nextTick = nextTick;
  46593. // 2.6 explicit observable API
  46594. Vue.observable = function (obj) {
  46595. observe(obj);
  46596. return obj
  46597. };
  46598. Vue.options = Object.create(null);
  46599. ASSET_TYPES.forEach(function (type) {
  46600. Vue.options[type + 's'] = Object.create(null);
  46601. });
  46602. // this is used to identify the "base" constructor to extend all plain-object
  46603. // components with in Weex's multi-instance scenarios.
  46604. Vue.options._base = Vue;
  46605. extend(Vue.options.components, builtInComponents);
  46606. initUse(Vue);
  46607. initMixin$1(Vue);
  46608. initExtend(Vue);
  46609. initAssetRegisters(Vue);
  46610. }
  46611. initGlobalAPI(Vue);
  46612. Object.defineProperty(Vue.prototype, '$isServer', {
  46613. get: isServerRendering
  46614. });
  46615. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46616. get: function get () {
  46617. /* istanbul ignore next */
  46618. return this.$vnode && this.$vnode.ssrContext
  46619. }
  46620. });
  46621. // expose FunctionalRenderContext for ssr runtime helper installation
  46622. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46623. value: FunctionalRenderContext
  46624. });
  46625. Vue.version = '2.6.11';
  46626. /* */
  46627. // these are reserved for web because they are directly compiled away
  46628. // during template compilation
  46629. var isReservedAttr = makeMap('style,class');
  46630. // attributes that should be using props for binding
  46631. var acceptValue = makeMap('input,textarea,option,select,progress');
  46632. var mustUseProp = function (tag, type, attr) {
  46633. return (
  46634. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46635. (attr === 'selected' && tag === 'option') ||
  46636. (attr === 'checked' && tag === 'input') ||
  46637. (attr === 'muted' && tag === 'video')
  46638. )
  46639. };
  46640. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46641. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46642. var convertEnumeratedValue = function (key, value) {
  46643. return isFalsyAttrValue(value) || value === 'false'
  46644. ? 'false'
  46645. // allow arbitrary string value for contenteditable
  46646. : key === 'contenteditable' && isValidContentEditableValue(value)
  46647. ? value
  46648. : 'true'
  46649. };
  46650. var isBooleanAttr = makeMap(
  46651. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46652. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46653. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46654. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46655. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46656. 'truespeed,typemustmatch,visible'
  46657. );
  46658. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46659. var isXlink = function (name) {
  46660. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46661. };
  46662. var getXlinkProp = function (name) {
  46663. return isXlink(name) ? name.slice(6, name.length) : ''
  46664. };
  46665. var isFalsyAttrValue = function (val) {
  46666. return val == null || val === false
  46667. };
  46668. /* */
  46669. function genClassForVnode (vnode) {
  46670. var data = vnode.data;
  46671. var parentNode = vnode;
  46672. var childNode = vnode;
  46673. while (isDef(childNode.componentInstance)) {
  46674. childNode = childNode.componentInstance._vnode;
  46675. if (childNode && childNode.data) {
  46676. data = mergeClassData(childNode.data, data);
  46677. }
  46678. }
  46679. while (isDef(parentNode = parentNode.parent)) {
  46680. if (parentNode && parentNode.data) {
  46681. data = mergeClassData(data, parentNode.data);
  46682. }
  46683. }
  46684. return renderClass(data.staticClass, data.class)
  46685. }
  46686. function mergeClassData (child, parent) {
  46687. return {
  46688. staticClass: concat(child.staticClass, parent.staticClass),
  46689. class: isDef(child.class)
  46690. ? [child.class, parent.class]
  46691. : parent.class
  46692. }
  46693. }
  46694. function renderClass (
  46695. staticClass,
  46696. dynamicClass
  46697. ) {
  46698. if (isDef(staticClass) || isDef(dynamicClass)) {
  46699. return concat(staticClass, stringifyClass(dynamicClass))
  46700. }
  46701. /* istanbul ignore next */
  46702. return ''
  46703. }
  46704. function concat (a, b) {
  46705. return a ? b ? (a + ' ' + b) : a : (b || '')
  46706. }
  46707. function stringifyClass (value) {
  46708. if (Array.isArray(value)) {
  46709. return stringifyArray(value)
  46710. }
  46711. if (isObject(value)) {
  46712. return stringifyObject(value)
  46713. }
  46714. if (typeof value === 'string') {
  46715. return value
  46716. }
  46717. /* istanbul ignore next */
  46718. return ''
  46719. }
  46720. function stringifyArray (value) {
  46721. var res = '';
  46722. var stringified;
  46723. for (var i = 0, l = value.length; i < l; i++) {
  46724. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46725. if (res) { res += ' '; }
  46726. res += stringified;
  46727. }
  46728. }
  46729. return res
  46730. }
  46731. function stringifyObject (value) {
  46732. var res = '';
  46733. for (var key in value) {
  46734. if (value[key]) {
  46735. if (res) { res += ' '; }
  46736. res += key;
  46737. }
  46738. }
  46739. return res
  46740. }
  46741. /* */
  46742. var namespaceMap = {
  46743. svg: 'http://www.w3.org/2000/svg',
  46744. math: 'http://www.w3.org/1998/Math/MathML'
  46745. };
  46746. var isHTMLTag = makeMap(
  46747. 'html,body,base,head,link,meta,style,title,' +
  46748. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46749. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46750. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46751. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46752. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46753. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46754. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46755. 'output,progress,select,textarea,' +
  46756. 'details,dialog,menu,menuitem,summary,' +
  46757. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46758. );
  46759. // this map is intentionally selective, only covering SVG elements that may
  46760. // contain child elements.
  46761. var isSVG = makeMap(
  46762. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46763. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46764. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46765. true
  46766. );
  46767. var isPreTag = function (tag) { return tag === 'pre'; };
  46768. var isReservedTag = function (tag) {
  46769. return isHTMLTag(tag) || isSVG(tag)
  46770. };
  46771. function getTagNamespace (tag) {
  46772. if (isSVG(tag)) {
  46773. return 'svg'
  46774. }
  46775. // basic support for MathML
  46776. // note it doesn't support other MathML elements being component roots
  46777. if (tag === 'math') {
  46778. return 'math'
  46779. }
  46780. }
  46781. var unknownElementCache = Object.create(null);
  46782. function isUnknownElement (tag) {
  46783. /* istanbul ignore if */
  46784. if (!inBrowser) {
  46785. return true
  46786. }
  46787. if (isReservedTag(tag)) {
  46788. return false
  46789. }
  46790. tag = tag.toLowerCase();
  46791. /* istanbul ignore if */
  46792. if (unknownElementCache[tag] != null) {
  46793. return unknownElementCache[tag]
  46794. }
  46795. var el = document.createElement(tag);
  46796. if (tag.indexOf('-') > -1) {
  46797. // http://stackoverflow.com/a/28210364/1070244
  46798. return (unknownElementCache[tag] = (
  46799. el.constructor === window.HTMLUnknownElement ||
  46800. el.constructor === window.HTMLElement
  46801. ))
  46802. } else {
  46803. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46804. }
  46805. }
  46806. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46807. /* */
  46808. /**
  46809. * Query an element selector if it's not an element already.
  46810. */
  46811. function query (el) {
  46812. if (typeof el === 'string') {
  46813. var selected = document.querySelector(el);
  46814. if (!selected) {
  46815. warn(
  46816. 'Cannot find element: ' + el
  46817. );
  46818. return document.createElement('div')
  46819. }
  46820. return selected
  46821. } else {
  46822. return el
  46823. }
  46824. }
  46825. /* */
  46826. function createElement$1 (tagName, vnode) {
  46827. var elm = document.createElement(tagName);
  46828. if (tagName !== 'select') {
  46829. return elm
  46830. }
  46831. // false or null will remove the attribute but undefined will not
  46832. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46833. elm.setAttribute('multiple', 'multiple');
  46834. }
  46835. return elm
  46836. }
  46837. function createElementNS (namespace, tagName) {
  46838. return document.createElementNS(namespaceMap[namespace], tagName)
  46839. }
  46840. function createTextNode (text) {
  46841. return document.createTextNode(text)
  46842. }
  46843. function createComment (text) {
  46844. return document.createComment(text)
  46845. }
  46846. function insertBefore (parentNode, newNode, referenceNode) {
  46847. parentNode.insertBefore(newNode, referenceNode);
  46848. }
  46849. function removeChild (node, child) {
  46850. node.removeChild(child);
  46851. }
  46852. function appendChild (node, child) {
  46853. node.appendChild(child);
  46854. }
  46855. function parentNode (node) {
  46856. return node.parentNode
  46857. }
  46858. function nextSibling (node) {
  46859. return node.nextSibling
  46860. }
  46861. function tagName (node) {
  46862. return node.tagName
  46863. }
  46864. function setTextContent (node, text) {
  46865. node.textContent = text;
  46866. }
  46867. function setStyleScope (node, scopeId) {
  46868. node.setAttribute(scopeId, '');
  46869. }
  46870. var nodeOps = /*#__PURE__*/Object.freeze({
  46871. createElement: createElement$1,
  46872. createElementNS: createElementNS,
  46873. createTextNode: createTextNode,
  46874. createComment: createComment,
  46875. insertBefore: insertBefore,
  46876. removeChild: removeChild,
  46877. appendChild: appendChild,
  46878. parentNode: parentNode,
  46879. nextSibling: nextSibling,
  46880. tagName: tagName,
  46881. setTextContent: setTextContent,
  46882. setStyleScope: setStyleScope
  46883. });
  46884. /* */
  46885. var ref = {
  46886. create: function create (_, vnode) {
  46887. registerRef(vnode);
  46888. },
  46889. update: function update (oldVnode, vnode) {
  46890. if (oldVnode.data.ref !== vnode.data.ref) {
  46891. registerRef(oldVnode, true);
  46892. registerRef(vnode);
  46893. }
  46894. },
  46895. destroy: function destroy (vnode) {
  46896. registerRef(vnode, true);
  46897. }
  46898. };
  46899. function registerRef (vnode, isRemoval) {
  46900. var key = vnode.data.ref;
  46901. if (!isDef(key)) { return }
  46902. var vm = vnode.context;
  46903. var ref = vnode.componentInstance || vnode.elm;
  46904. var refs = vm.$refs;
  46905. if (isRemoval) {
  46906. if (Array.isArray(refs[key])) {
  46907. remove(refs[key], ref);
  46908. } else if (refs[key] === ref) {
  46909. refs[key] = undefined;
  46910. }
  46911. } else {
  46912. if (vnode.data.refInFor) {
  46913. if (!Array.isArray(refs[key])) {
  46914. refs[key] = [ref];
  46915. } else if (refs[key].indexOf(ref) < 0) {
  46916. // $flow-disable-line
  46917. refs[key].push(ref);
  46918. }
  46919. } else {
  46920. refs[key] = ref;
  46921. }
  46922. }
  46923. }
  46924. /**
  46925. * Virtual DOM patching algorithm based on Snabbdom by
  46926. * Simon Friis Vindum (@paldepind)
  46927. * Licensed under the MIT License
  46928. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  46929. *
  46930. * modified by Evan You (@yyx990803)
  46931. *
  46932. * Not type-checking this because this file is perf-critical and the cost
  46933. * of making flow understand it is not worth it.
  46934. */
  46935. var emptyNode = new VNode('', {}, []);
  46936. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  46937. function sameVnode (a, b) {
  46938. return (
  46939. a.key === b.key && (
  46940. (
  46941. a.tag === b.tag &&
  46942. a.isComment === b.isComment &&
  46943. isDef(a.data) === isDef(b.data) &&
  46944. sameInputType(a, b)
  46945. ) || (
  46946. isTrue(a.isAsyncPlaceholder) &&
  46947. a.asyncFactory === b.asyncFactory &&
  46948. isUndef(b.asyncFactory.error)
  46949. )
  46950. )
  46951. )
  46952. }
  46953. function sameInputType (a, b) {
  46954. if (a.tag !== 'input') { return true }
  46955. var i;
  46956. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  46957. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  46958. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  46959. }
  46960. function createKeyToOldIdx (children, beginIdx, endIdx) {
  46961. var i, key;
  46962. var map = {};
  46963. for (i = beginIdx; i <= endIdx; ++i) {
  46964. key = children[i].key;
  46965. if (isDef(key)) { map[key] = i; }
  46966. }
  46967. return map
  46968. }
  46969. function createPatchFunction (backend) {
  46970. var i, j;
  46971. var cbs = {};
  46972. var modules = backend.modules;
  46973. var nodeOps = backend.nodeOps;
  46974. for (i = 0; i < hooks.length; ++i) {
  46975. cbs[hooks[i]] = [];
  46976. for (j = 0; j < modules.length; ++j) {
  46977. if (isDef(modules[j][hooks[i]])) {
  46978. cbs[hooks[i]].push(modules[j][hooks[i]]);
  46979. }
  46980. }
  46981. }
  46982. function emptyNodeAt (elm) {
  46983. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  46984. }
  46985. function createRmCb (childElm, listeners) {
  46986. function remove$$1 () {
  46987. if (--remove$$1.listeners === 0) {
  46988. removeNode(childElm);
  46989. }
  46990. }
  46991. remove$$1.listeners = listeners;
  46992. return remove$$1
  46993. }
  46994. function removeNode (el) {
  46995. var parent = nodeOps.parentNode(el);
  46996. // element may have already been removed due to v-html / v-text
  46997. if (isDef(parent)) {
  46998. nodeOps.removeChild(parent, el);
  46999. }
  47000. }
  47001. function isUnknownElement$$1 (vnode, inVPre) {
  47002. return (
  47003. !inVPre &&
  47004. !vnode.ns &&
  47005. !(
  47006. config.ignoredElements.length &&
  47007. config.ignoredElements.some(function (ignore) {
  47008. return isRegExp(ignore)
  47009. ? ignore.test(vnode.tag)
  47010. : ignore === vnode.tag
  47011. })
  47012. ) &&
  47013. config.isUnknownElement(vnode.tag)
  47014. )
  47015. }
  47016. var creatingElmInVPre = 0;
  47017. function createElm (
  47018. vnode,
  47019. insertedVnodeQueue,
  47020. parentElm,
  47021. refElm,
  47022. nested,
  47023. ownerArray,
  47024. index
  47025. ) {
  47026. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47027. // This vnode was used in a previous render!
  47028. // now it's used as a new node, overwriting its elm would cause
  47029. // potential patch errors down the road when it's used as an insertion
  47030. // reference node. Instead, we clone the node on-demand before creating
  47031. // associated DOM element for it.
  47032. vnode = ownerArray[index] = cloneVNode(vnode);
  47033. }
  47034. vnode.isRootInsert = !nested; // for transition enter check
  47035. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47036. return
  47037. }
  47038. var data = vnode.data;
  47039. var children = vnode.children;
  47040. var tag = vnode.tag;
  47041. if (isDef(tag)) {
  47042. {
  47043. if (data && data.pre) {
  47044. creatingElmInVPre++;
  47045. }
  47046. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47047. warn(
  47048. 'Unknown custom element: <' + tag + '> - did you ' +
  47049. 'register the component correctly? For recursive components, ' +
  47050. 'make sure to provide the "name" option.',
  47051. vnode.context
  47052. );
  47053. }
  47054. }
  47055. vnode.elm = vnode.ns
  47056. ? nodeOps.createElementNS(vnode.ns, tag)
  47057. : nodeOps.createElement(tag, vnode);
  47058. setScope(vnode);
  47059. /* istanbul ignore if */
  47060. {
  47061. createChildren(vnode, children, insertedVnodeQueue);
  47062. if (isDef(data)) {
  47063. invokeCreateHooks(vnode, insertedVnodeQueue);
  47064. }
  47065. insert(parentElm, vnode.elm, refElm);
  47066. }
  47067. if (data && data.pre) {
  47068. creatingElmInVPre--;
  47069. }
  47070. } else if (isTrue(vnode.isComment)) {
  47071. vnode.elm = nodeOps.createComment(vnode.text);
  47072. insert(parentElm, vnode.elm, refElm);
  47073. } else {
  47074. vnode.elm = nodeOps.createTextNode(vnode.text);
  47075. insert(parentElm, vnode.elm, refElm);
  47076. }
  47077. }
  47078. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47079. var i = vnode.data;
  47080. if (isDef(i)) {
  47081. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47082. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47083. i(vnode, false /* hydrating */);
  47084. }
  47085. // after calling the init hook, if the vnode is a child component
  47086. // it should've created a child instance and mounted it. the child
  47087. // component also has set the placeholder vnode's elm.
  47088. // in that case we can just return the element and be done.
  47089. if (isDef(vnode.componentInstance)) {
  47090. initComponent(vnode, insertedVnodeQueue);
  47091. insert(parentElm, vnode.elm, refElm);
  47092. if (isTrue(isReactivated)) {
  47093. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47094. }
  47095. return true
  47096. }
  47097. }
  47098. }
  47099. function initComponent (vnode, insertedVnodeQueue) {
  47100. if (isDef(vnode.data.pendingInsert)) {
  47101. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47102. vnode.data.pendingInsert = null;
  47103. }
  47104. vnode.elm = vnode.componentInstance.$el;
  47105. if (isPatchable(vnode)) {
  47106. invokeCreateHooks(vnode, insertedVnodeQueue);
  47107. setScope(vnode);
  47108. } else {
  47109. // empty component root.
  47110. // skip all element-related modules except for ref (#3455)
  47111. registerRef(vnode);
  47112. // make sure to invoke the insert hook
  47113. insertedVnodeQueue.push(vnode);
  47114. }
  47115. }
  47116. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47117. var i;
  47118. // hack for #4339: a reactivated component with inner transition
  47119. // does not trigger because the inner node's created hooks are not called
  47120. // again. It's not ideal to involve module-specific logic in here but
  47121. // there doesn't seem to be a better way to do it.
  47122. var innerNode = vnode;
  47123. while (innerNode.componentInstance) {
  47124. innerNode = innerNode.componentInstance._vnode;
  47125. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47126. for (i = 0; i < cbs.activate.length; ++i) {
  47127. cbs.activate[i](emptyNode, innerNode);
  47128. }
  47129. insertedVnodeQueue.push(innerNode);
  47130. break
  47131. }
  47132. }
  47133. // unlike a newly created component,
  47134. // a reactivated keep-alive component doesn't insert itself
  47135. insert(parentElm, vnode.elm, refElm);
  47136. }
  47137. function insert (parent, elm, ref$$1) {
  47138. if (isDef(parent)) {
  47139. if (isDef(ref$$1)) {
  47140. if (nodeOps.parentNode(ref$$1) === parent) {
  47141. nodeOps.insertBefore(parent, elm, ref$$1);
  47142. }
  47143. } else {
  47144. nodeOps.appendChild(parent, elm);
  47145. }
  47146. }
  47147. }
  47148. function createChildren (vnode, children, insertedVnodeQueue) {
  47149. if (Array.isArray(children)) {
  47150. {
  47151. checkDuplicateKeys(children);
  47152. }
  47153. for (var i = 0; i < children.length; ++i) {
  47154. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47155. }
  47156. } else if (isPrimitive(vnode.text)) {
  47157. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47158. }
  47159. }
  47160. function isPatchable (vnode) {
  47161. while (vnode.componentInstance) {
  47162. vnode = vnode.componentInstance._vnode;
  47163. }
  47164. return isDef(vnode.tag)
  47165. }
  47166. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47167. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47168. cbs.create[i$1](emptyNode, vnode);
  47169. }
  47170. i = vnode.data.hook; // Reuse variable
  47171. if (isDef(i)) {
  47172. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47173. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47174. }
  47175. }
  47176. // set scope id attribute for scoped CSS.
  47177. // this is implemented as a special case to avoid the overhead
  47178. // of going through the normal attribute patching process.
  47179. function setScope (vnode) {
  47180. var i;
  47181. if (isDef(i = vnode.fnScopeId)) {
  47182. nodeOps.setStyleScope(vnode.elm, i);
  47183. } else {
  47184. var ancestor = vnode;
  47185. while (ancestor) {
  47186. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47187. nodeOps.setStyleScope(vnode.elm, i);
  47188. }
  47189. ancestor = ancestor.parent;
  47190. }
  47191. }
  47192. // for slot content they should also get the scopeId from the host instance.
  47193. if (isDef(i = activeInstance) &&
  47194. i !== vnode.context &&
  47195. i !== vnode.fnContext &&
  47196. isDef(i = i.$options._scopeId)
  47197. ) {
  47198. nodeOps.setStyleScope(vnode.elm, i);
  47199. }
  47200. }
  47201. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47202. for (; startIdx <= endIdx; ++startIdx) {
  47203. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47204. }
  47205. }
  47206. function invokeDestroyHook (vnode) {
  47207. var i, j;
  47208. var data = vnode.data;
  47209. if (isDef(data)) {
  47210. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47211. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47212. }
  47213. if (isDef(i = vnode.children)) {
  47214. for (j = 0; j < vnode.children.length; ++j) {
  47215. invokeDestroyHook(vnode.children[j]);
  47216. }
  47217. }
  47218. }
  47219. function removeVnodes (vnodes, startIdx, endIdx) {
  47220. for (; startIdx <= endIdx; ++startIdx) {
  47221. var ch = vnodes[startIdx];
  47222. if (isDef(ch)) {
  47223. if (isDef(ch.tag)) {
  47224. removeAndInvokeRemoveHook(ch);
  47225. invokeDestroyHook(ch);
  47226. } else { // Text node
  47227. removeNode(ch.elm);
  47228. }
  47229. }
  47230. }
  47231. }
  47232. function removeAndInvokeRemoveHook (vnode, rm) {
  47233. if (isDef(rm) || isDef(vnode.data)) {
  47234. var i;
  47235. var listeners = cbs.remove.length + 1;
  47236. if (isDef(rm)) {
  47237. // we have a recursively passed down rm callback
  47238. // increase the listeners count
  47239. rm.listeners += listeners;
  47240. } else {
  47241. // directly removing
  47242. rm = createRmCb(vnode.elm, listeners);
  47243. }
  47244. // recursively invoke hooks on child component root node
  47245. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47246. removeAndInvokeRemoveHook(i, rm);
  47247. }
  47248. for (i = 0; i < cbs.remove.length; ++i) {
  47249. cbs.remove[i](vnode, rm);
  47250. }
  47251. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47252. i(vnode, rm);
  47253. } else {
  47254. rm();
  47255. }
  47256. } else {
  47257. removeNode(vnode.elm);
  47258. }
  47259. }
  47260. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47261. var oldStartIdx = 0;
  47262. var newStartIdx = 0;
  47263. var oldEndIdx = oldCh.length - 1;
  47264. var oldStartVnode = oldCh[0];
  47265. var oldEndVnode = oldCh[oldEndIdx];
  47266. var newEndIdx = newCh.length - 1;
  47267. var newStartVnode = newCh[0];
  47268. var newEndVnode = newCh[newEndIdx];
  47269. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47270. // removeOnly is a special flag used only by <transition-group>
  47271. // to ensure removed elements stay in correct relative positions
  47272. // during leaving transitions
  47273. var canMove = !removeOnly;
  47274. {
  47275. checkDuplicateKeys(newCh);
  47276. }
  47277. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47278. if (isUndef(oldStartVnode)) {
  47279. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47280. } else if (isUndef(oldEndVnode)) {
  47281. oldEndVnode = oldCh[--oldEndIdx];
  47282. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47283. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47284. oldStartVnode = oldCh[++oldStartIdx];
  47285. newStartVnode = newCh[++newStartIdx];
  47286. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47287. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47288. oldEndVnode = oldCh[--oldEndIdx];
  47289. newEndVnode = newCh[--newEndIdx];
  47290. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47291. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47292. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47293. oldStartVnode = oldCh[++oldStartIdx];
  47294. newEndVnode = newCh[--newEndIdx];
  47295. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47296. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47297. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47298. oldEndVnode = oldCh[--oldEndIdx];
  47299. newStartVnode = newCh[++newStartIdx];
  47300. } else {
  47301. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47302. idxInOld = isDef(newStartVnode.key)
  47303. ? oldKeyToIdx[newStartVnode.key]
  47304. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47305. if (isUndef(idxInOld)) { // New element
  47306. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47307. } else {
  47308. vnodeToMove = oldCh[idxInOld];
  47309. if (sameVnode(vnodeToMove, newStartVnode)) {
  47310. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47311. oldCh[idxInOld] = undefined;
  47312. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47313. } else {
  47314. // same key but different element. treat as new element
  47315. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47316. }
  47317. }
  47318. newStartVnode = newCh[++newStartIdx];
  47319. }
  47320. }
  47321. if (oldStartIdx > oldEndIdx) {
  47322. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47323. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47324. } else if (newStartIdx > newEndIdx) {
  47325. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47326. }
  47327. }
  47328. function checkDuplicateKeys (children) {
  47329. var seenKeys = {};
  47330. for (var i = 0; i < children.length; i++) {
  47331. var vnode = children[i];
  47332. var key = vnode.key;
  47333. if (isDef(key)) {
  47334. if (seenKeys[key]) {
  47335. warn(
  47336. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47337. vnode.context
  47338. );
  47339. } else {
  47340. seenKeys[key] = true;
  47341. }
  47342. }
  47343. }
  47344. }
  47345. function findIdxInOld (node, oldCh, start, end) {
  47346. for (var i = start; i < end; i++) {
  47347. var c = oldCh[i];
  47348. if (isDef(c) && sameVnode(node, c)) { return i }
  47349. }
  47350. }
  47351. function patchVnode (
  47352. oldVnode,
  47353. vnode,
  47354. insertedVnodeQueue,
  47355. ownerArray,
  47356. index,
  47357. removeOnly
  47358. ) {
  47359. if (oldVnode === vnode) {
  47360. return
  47361. }
  47362. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47363. // clone reused vnode
  47364. vnode = ownerArray[index] = cloneVNode(vnode);
  47365. }
  47366. var elm = vnode.elm = oldVnode.elm;
  47367. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47368. if (isDef(vnode.asyncFactory.resolved)) {
  47369. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47370. } else {
  47371. vnode.isAsyncPlaceholder = true;
  47372. }
  47373. return
  47374. }
  47375. // reuse element for static trees.
  47376. // note we only do this if the vnode is cloned -
  47377. // if the new node is not cloned it means the render functions have been
  47378. // reset by the hot-reload-api and we need to do a proper re-render.
  47379. if (isTrue(vnode.isStatic) &&
  47380. isTrue(oldVnode.isStatic) &&
  47381. vnode.key === oldVnode.key &&
  47382. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47383. ) {
  47384. vnode.componentInstance = oldVnode.componentInstance;
  47385. return
  47386. }
  47387. var i;
  47388. var data = vnode.data;
  47389. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47390. i(oldVnode, vnode);
  47391. }
  47392. var oldCh = oldVnode.children;
  47393. var ch = vnode.children;
  47394. if (isDef(data) && isPatchable(vnode)) {
  47395. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47396. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47397. }
  47398. if (isUndef(vnode.text)) {
  47399. if (isDef(oldCh) && isDef(ch)) {
  47400. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47401. } else if (isDef(ch)) {
  47402. {
  47403. checkDuplicateKeys(ch);
  47404. }
  47405. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47406. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47407. } else if (isDef(oldCh)) {
  47408. removeVnodes(oldCh, 0, oldCh.length - 1);
  47409. } else if (isDef(oldVnode.text)) {
  47410. nodeOps.setTextContent(elm, '');
  47411. }
  47412. } else if (oldVnode.text !== vnode.text) {
  47413. nodeOps.setTextContent(elm, vnode.text);
  47414. }
  47415. if (isDef(data)) {
  47416. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47417. }
  47418. }
  47419. function invokeInsertHook (vnode, queue, initial) {
  47420. // delay insert hooks for component root nodes, invoke them after the
  47421. // element is really inserted
  47422. if (isTrue(initial) && isDef(vnode.parent)) {
  47423. vnode.parent.data.pendingInsert = queue;
  47424. } else {
  47425. for (var i = 0; i < queue.length; ++i) {
  47426. queue[i].data.hook.insert(queue[i]);
  47427. }
  47428. }
  47429. }
  47430. var hydrationBailed = false;
  47431. // list of modules that can skip create hook during hydration because they
  47432. // are already rendered on the client or has no need for initialization
  47433. // Note: style is excluded because it relies on initial clone for future
  47434. // deep updates (#7063).
  47435. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47436. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47437. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47438. var i;
  47439. var tag = vnode.tag;
  47440. var data = vnode.data;
  47441. var children = vnode.children;
  47442. inVPre = inVPre || (data && data.pre);
  47443. vnode.elm = elm;
  47444. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47445. vnode.isAsyncPlaceholder = true;
  47446. return true
  47447. }
  47448. // assert node match
  47449. {
  47450. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47451. return false
  47452. }
  47453. }
  47454. if (isDef(data)) {
  47455. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47456. if (isDef(i = vnode.componentInstance)) {
  47457. // child component. it should have hydrated its own tree.
  47458. initComponent(vnode, insertedVnodeQueue);
  47459. return true
  47460. }
  47461. }
  47462. if (isDef(tag)) {
  47463. if (isDef(children)) {
  47464. // empty element, allow client to pick up and populate children
  47465. if (!elm.hasChildNodes()) {
  47466. createChildren(vnode, children, insertedVnodeQueue);
  47467. } else {
  47468. // v-html and domProps: innerHTML
  47469. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47470. if (i !== elm.innerHTML) {
  47471. /* istanbul ignore if */
  47472. if (typeof console !== 'undefined' &&
  47473. !hydrationBailed
  47474. ) {
  47475. hydrationBailed = true;
  47476. console.warn('Parent: ', elm);
  47477. console.warn('server innerHTML: ', i);
  47478. console.warn('client innerHTML: ', elm.innerHTML);
  47479. }
  47480. return false
  47481. }
  47482. } else {
  47483. // iterate and compare children lists
  47484. var childrenMatch = true;
  47485. var childNode = elm.firstChild;
  47486. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47487. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47488. childrenMatch = false;
  47489. break
  47490. }
  47491. childNode = childNode.nextSibling;
  47492. }
  47493. // if childNode is not null, it means the actual childNodes list is
  47494. // longer than the virtual children list.
  47495. if (!childrenMatch || childNode) {
  47496. /* istanbul ignore if */
  47497. if (typeof console !== 'undefined' &&
  47498. !hydrationBailed
  47499. ) {
  47500. hydrationBailed = true;
  47501. console.warn('Parent: ', elm);
  47502. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47503. }
  47504. return false
  47505. }
  47506. }
  47507. }
  47508. }
  47509. if (isDef(data)) {
  47510. var fullInvoke = false;
  47511. for (var key in data) {
  47512. if (!isRenderedModule(key)) {
  47513. fullInvoke = true;
  47514. invokeCreateHooks(vnode, insertedVnodeQueue);
  47515. break
  47516. }
  47517. }
  47518. if (!fullInvoke && data['class']) {
  47519. // ensure collecting deps for deep class bindings for future updates
  47520. traverse(data['class']);
  47521. }
  47522. }
  47523. } else if (elm.data !== vnode.text) {
  47524. elm.data = vnode.text;
  47525. }
  47526. return true
  47527. }
  47528. function assertNodeMatch (node, vnode, inVPre) {
  47529. if (isDef(vnode.tag)) {
  47530. return vnode.tag.indexOf('vue-component') === 0 || (
  47531. !isUnknownElement$$1(vnode, inVPre) &&
  47532. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47533. )
  47534. } else {
  47535. return node.nodeType === (vnode.isComment ? 8 : 3)
  47536. }
  47537. }
  47538. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47539. if (isUndef(vnode)) {
  47540. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47541. return
  47542. }
  47543. var isInitialPatch = false;
  47544. var insertedVnodeQueue = [];
  47545. if (isUndef(oldVnode)) {
  47546. // empty mount (likely as component), create new root element
  47547. isInitialPatch = true;
  47548. createElm(vnode, insertedVnodeQueue);
  47549. } else {
  47550. var isRealElement = isDef(oldVnode.nodeType);
  47551. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47552. // patch existing root node
  47553. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47554. } else {
  47555. if (isRealElement) {
  47556. // mounting to a real element
  47557. // check if this is server-rendered content and if we can perform
  47558. // a successful hydration.
  47559. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47560. oldVnode.removeAttribute(SSR_ATTR);
  47561. hydrating = true;
  47562. }
  47563. if (isTrue(hydrating)) {
  47564. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47565. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47566. return oldVnode
  47567. } else {
  47568. warn(
  47569. 'The client-side rendered virtual DOM tree is not matching ' +
  47570. 'server-rendered content. This is likely caused by incorrect ' +
  47571. 'HTML markup, for example nesting block-level elements inside ' +
  47572. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47573. 'full client-side render.'
  47574. );
  47575. }
  47576. }
  47577. // either not server-rendered, or hydration failed.
  47578. // create an empty node and replace it
  47579. oldVnode = emptyNodeAt(oldVnode);
  47580. }
  47581. // replacing existing element
  47582. var oldElm = oldVnode.elm;
  47583. var parentElm = nodeOps.parentNode(oldElm);
  47584. // create new node
  47585. createElm(
  47586. vnode,
  47587. insertedVnodeQueue,
  47588. // extremely rare edge case: do not insert if old element is in a
  47589. // leaving transition. Only happens when combining transition +
  47590. // keep-alive + HOCs. (#4590)
  47591. oldElm._leaveCb ? null : parentElm,
  47592. nodeOps.nextSibling(oldElm)
  47593. );
  47594. // update parent placeholder node element, recursively
  47595. if (isDef(vnode.parent)) {
  47596. var ancestor = vnode.parent;
  47597. var patchable = isPatchable(vnode);
  47598. while (ancestor) {
  47599. for (var i = 0; i < cbs.destroy.length; ++i) {
  47600. cbs.destroy[i](ancestor);
  47601. }
  47602. ancestor.elm = vnode.elm;
  47603. if (patchable) {
  47604. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47605. cbs.create[i$1](emptyNode, ancestor);
  47606. }
  47607. // #6513
  47608. // invoke insert hooks that may have been merged by create hooks.
  47609. // e.g. for directives that uses the "inserted" hook.
  47610. var insert = ancestor.data.hook.insert;
  47611. if (insert.merged) {
  47612. // start at index 1 to avoid re-invoking component mounted hook
  47613. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47614. insert.fns[i$2]();
  47615. }
  47616. }
  47617. } else {
  47618. registerRef(ancestor);
  47619. }
  47620. ancestor = ancestor.parent;
  47621. }
  47622. }
  47623. // destroy old node
  47624. if (isDef(parentElm)) {
  47625. removeVnodes([oldVnode], 0, 0);
  47626. } else if (isDef(oldVnode.tag)) {
  47627. invokeDestroyHook(oldVnode);
  47628. }
  47629. }
  47630. }
  47631. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47632. return vnode.elm
  47633. }
  47634. }
  47635. /* */
  47636. var directives = {
  47637. create: updateDirectives,
  47638. update: updateDirectives,
  47639. destroy: function unbindDirectives (vnode) {
  47640. updateDirectives(vnode, emptyNode);
  47641. }
  47642. };
  47643. function updateDirectives (oldVnode, vnode) {
  47644. if (oldVnode.data.directives || vnode.data.directives) {
  47645. _update(oldVnode, vnode);
  47646. }
  47647. }
  47648. function _update (oldVnode, vnode) {
  47649. var isCreate = oldVnode === emptyNode;
  47650. var isDestroy = vnode === emptyNode;
  47651. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47652. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47653. var dirsWithInsert = [];
  47654. var dirsWithPostpatch = [];
  47655. var key, oldDir, dir;
  47656. for (key in newDirs) {
  47657. oldDir = oldDirs[key];
  47658. dir = newDirs[key];
  47659. if (!oldDir) {
  47660. // new directive, bind
  47661. callHook$1(dir, 'bind', vnode, oldVnode);
  47662. if (dir.def && dir.def.inserted) {
  47663. dirsWithInsert.push(dir);
  47664. }
  47665. } else {
  47666. // existing directive, update
  47667. dir.oldValue = oldDir.value;
  47668. dir.oldArg = oldDir.arg;
  47669. callHook$1(dir, 'update', vnode, oldVnode);
  47670. if (dir.def && dir.def.componentUpdated) {
  47671. dirsWithPostpatch.push(dir);
  47672. }
  47673. }
  47674. }
  47675. if (dirsWithInsert.length) {
  47676. var callInsert = function () {
  47677. for (var i = 0; i < dirsWithInsert.length; i++) {
  47678. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47679. }
  47680. };
  47681. if (isCreate) {
  47682. mergeVNodeHook(vnode, 'insert', callInsert);
  47683. } else {
  47684. callInsert();
  47685. }
  47686. }
  47687. if (dirsWithPostpatch.length) {
  47688. mergeVNodeHook(vnode, 'postpatch', function () {
  47689. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47690. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47691. }
  47692. });
  47693. }
  47694. if (!isCreate) {
  47695. for (key in oldDirs) {
  47696. if (!newDirs[key]) {
  47697. // no longer present, unbind
  47698. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47699. }
  47700. }
  47701. }
  47702. }
  47703. var emptyModifiers = Object.create(null);
  47704. function normalizeDirectives$1 (
  47705. dirs,
  47706. vm
  47707. ) {
  47708. var res = Object.create(null);
  47709. if (!dirs) {
  47710. // $flow-disable-line
  47711. return res
  47712. }
  47713. var i, dir;
  47714. for (i = 0; i < dirs.length; i++) {
  47715. dir = dirs[i];
  47716. if (!dir.modifiers) {
  47717. // $flow-disable-line
  47718. dir.modifiers = emptyModifiers;
  47719. }
  47720. res[getRawDirName(dir)] = dir;
  47721. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47722. }
  47723. // $flow-disable-line
  47724. return res
  47725. }
  47726. function getRawDirName (dir) {
  47727. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47728. }
  47729. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47730. var fn = dir.def && dir.def[hook];
  47731. if (fn) {
  47732. try {
  47733. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47734. } catch (e) {
  47735. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47736. }
  47737. }
  47738. }
  47739. var baseModules = [
  47740. ref,
  47741. directives
  47742. ];
  47743. /* */
  47744. function updateAttrs (oldVnode, vnode) {
  47745. var opts = vnode.componentOptions;
  47746. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47747. return
  47748. }
  47749. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47750. return
  47751. }
  47752. var key, cur, old;
  47753. var elm = vnode.elm;
  47754. var oldAttrs = oldVnode.data.attrs || {};
  47755. var attrs = vnode.data.attrs || {};
  47756. // clone observed objects, as the user probably wants to mutate it
  47757. if (isDef(attrs.__ob__)) {
  47758. attrs = vnode.data.attrs = extend({}, attrs);
  47759. }
  47760. for (key in attrs) {
  47761. cur = attrs[key];
  47762. old = oldAttrs[key];
  47763. if (old !== cur) {
  47764. setAttr(elm, key, cur);
  47765. }
  47766. }
  47767. // #4391: in IE9, setting type can reset value for input[type=radio]
  47768. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47769. /* istanbul ignore if */
  47770. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47771. setAttr(elm, 'value', attrs.value);
  47772. }
  47773. for (key in oldAttrs) {
  47774. if (isUndef(attrs[key])) {
  47775. if (isXlink(key)) {
  47776. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47777. } else if (!isEnumeratedAttr(key)) {
  47778. elm.removeAttribute(key);
  47779. }
  47780. }
  47781. }
  47782. }
  47783. function setAttr (el, key, value) {
  47784. if (el.tagName.indexOf('-') > -1) {
  47785. baseSetAttr(el, key, value);
  47786. } else if (isBooleanAttr(key)) {
  47787. // set attribute for blank value
  47788. // e.g. <option disabled>Select one</option>
  47789. if (isFalsyAttrValue(value)) {
  47790. el.removeAttribute(key);
  47791. } else {
  47792. // technically allowfullscreen is a boolean attribute for <iframe>,
  47793. // but Flash expects a value of "true" when used on <embed> tag
  47794. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47795. ? 'true'
  47796. : key;
  47797. el.setAttribute(key, value);
  47798. }
  47799. } else if (isEnumeratedAttr(key)) {
  47800. el.setAttribute(key, convertEnumeratedValue(key, value));
  47801. } else if (isXlink(key)) {
  47802. if (isFalsyAttrValue(value)) {
  47803. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47804. } else {
  47805. el.setAttributeNS(xlinkNS, key, value);
  47806. }
  47807. } else {
  47808. baseSetAttr(el, key, value);
  47809. }
  47810. }
  47811. function baseSetAttr (el, key, value) {
  47812. if (isFalsyAttrValue(value)) {
  47813. el.removeAttribute(key);
  47814. } else {
  47815. // #7138: IE10 & 11 fires input event when setting placeholder on
  47816. // <textarea>... block the first input event and remove the blocker
  47817. // immediately.
  47818. /* istanbul ignore if */
  47819. if (
  47820. isIE && !isIE9 &&
  47821. el.tagName === 'TEXTAREA' &&
  47822. key === 'placeholder' && value !== '' && !el.__ieph
  47823. ) {
  47824. var blocker = function (e) {
  47825. e.stopImmediatePropagation();
  47826. el.removeEventListener('input', blocker);
  47827. };
  47828. el.addEventListener('input', blocker);
  47829. // $flow-disable-line
  47830. el.__ieph = true; /* IE placeholder patched */
  47831. }
  47832. el.setAttribute(key, value);
  47833. }
  47834. }
  47835. var attrs = {
  47836. create: updateAttrs,
  47837. update: updateAttrs
  47838. };
  47839. /* */
  47840. function updateClass (oldVnode, vnode) {
  47841. var el = vnode.elm;
  47842. var data = vnode.data;
  47843. var oldData = oldVnode.data;
  47844. if (
  47845. isUndef(data.staticClass) &&
  47846. isUndef(data.class) && (
  47847. isUndef(oldData) || (
  47848. isUndef(oldData.staticClass) &&
  47849. isUndef(oldData.class)
  47850. )
  47851. )
  47852. ) {
  47853. return
  47854. }
  47855. var cls = genClassForVnode(vnode);
  47856. // handle transition classes
  47857. var transitionClass = el._transitionClasses;
  47858. if (isDef(transitionClass)) {
  47859. cls = concat(cls, stringifyClass(transitionClass));
  47860. }
  47861. // set the class
  47862. if (cls !== el._prevClass) {
  47863. el.setAttribute('class', cls);
  47864. el._prevClass = cls;
  47865. }
  47866. }
  47867. var klass = {
  47868. create: updateClass,
  47869. update: updateClass
  47870. };
  47871. /* */
  47872. var validDivisionCharRE = /[\w).+\-_$\]]/;
  47873. function parseFilters (exp) {
  47874. var inSingle = false;
  47875. var inDouble = false;
  47876. var inTemplateString = false;
  47877. var inRegex = false;
  47878. var curly = 0;
  47879. var square = 0;
  47880. var paren = 0;
  47881. var lastFilterIndex = 0;
  47882. var c, prev, i, expression, filters;
  47883. for (i = 0; i < exp.length; i++) {
  47884. prev = c;
  47885. c = exp.charCodeAt(i);
  47886. if (inSingle) {
  47887. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  47888. } else if (inDouble) {
  47889. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  47890. } else if (inTemplateString) {
  47891. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  47892. } else if (inRegex) {
  47893. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  47894. } else if (
  47895. c === 0x7C && // pipe
  47896. exp.charCodeAt(i + 1) !== 0x7C &&
  47897. exp.charCodeAt(i - 1) !== 0x7C &&
  47898. !curly && !square && !paren
  47899. ) {
  47900. if (expression === undefined) {
  47901. // first filter, end of expression
  47902. lastFilterIndex = i + 1;
  47903. expression = exp.slice(0, i).trim();
  47904. } else {
  47905. pushFilter();
  47906. }
  47907. } else {
  47908. switch (c) {
  47909. case 0x22: inDouble = true; break // "
  47910. case 0x27: inSingle = true; break // '
  47911. case 0x60: inTemplateString = true; break // `
  47912. case 0x28: paren++; break // (
  47913. case 0x29: paren--; break // )
  47914. case 0x5B: square++; break // [
  47915. case 0x5D: square--; break // ]
  47916. case 0x7B: curly++; break // {
  47917. case 0x7D: curly--; break // }
  47918. }
  47919. if (c === 0x2f) { // /
  47920. var j = i - 1;
  47921. var p = (void 0);
  47922. // find first non-whitespace prev char
  47923. for (; j >= 0; j--) {
  47924. p = exp.charAt(j);
  47925. if (p !== ' ') { break }
  47926. }
  47927. if (!p || !validDivisionCharRE.test(p)) {
  47928. inRegex = true;
  47929. }
  47930. }
  47931. }
  47932. }
  47933. if (expression === undefined) {
  47934. expression = exp.slice(0, i).trim();
  47935. } else if (lastFilterIndex !== 0) {
  47936. pushFilter();
  47937. }
  47938. function pushFilter () {
  47939. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  47940. lastFilterIndex = i + 1;
  47941. }
  47942. if (filters) {
  47943. for (i = 0; i < filters.length; i++) {
  47944. expression = wrapFilter(expression, filters[i]);
  47945. }
  47946. }
  47947. return expression
  47948. }
  47949. function wrapFilter (exp, filter) {
  47950. var i = filter.indexOf('(');
  47951. if (i < 0) {
  47952. // _f: resolveFilter
  47953. return ("_f(\"" + filter + "\")(" + exp + ")")
  47954. } else {
  47955. var name = filter.slice(0, i);
  47956. var args = filter.slice(i + 1);
  47957. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  47958. }
  47959. }
  47960. /* */
  47961. /* eslint-disable no-unused-vars */
  47962. function baseWarn (msg, range) {
  47963. console.error(("[Vue compiler]: " + msg));
  47964. }
  47965. /* eslint-enable no-unused-vars */
  47966. function pluckModuleFunction (
  47967. modules,
  47968. key
  47969. ) {
  47970. return modules
  47971. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  47972. : []
  47973. }
  47974. function addProp (el, name, value, range, dynamic) {
  47975. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  47976. el.plain = false;
  47977. }
  47978. function addAttr (el, name, value, range, dynamic) {
  47979. var attrs = dynamic
  47980. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  47981. : (el.attrs || (el.attrs = []));
  47982. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  47983. el.plain = false;
  47984. }
  47985. // add a raw attr (use this in preTransforms)
  47986. function addRawAttr (el, name, value, range) {
  47987. el.attrsMap[name] = value;
  47988. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  47989. }
  47990. function addDirective (
  47991. el,
  47992. name,
  47993. rawName,
  47994. value,
  47995. arg,
  47996. isDynamicArg,
  47997. modifiers,
  47998. range
  47999. ) {
  48000. (el.directives || (el.directives = [])).push(rangeSetItem({
  48001. name: name,
  48002. rawName: rawName,
  48003. value: value,
  48004. arg: arg,
  48005. isDynamicArg: isDynamicArg,
  48006. modifiers: modifiers
  48007. }, range));
  48008. el.plain = false;
  48009. }
  48010. function prependModifierMarker (symbol, name, dynamic) {
  48011. return dynamic
  48012. ? ("_p(" + name + ",\"" + symbol + "\")")
  48013. : symbol + name // mark the event as captured
  48014. }
  48015. function addHandler (
  48016. el,
  48017. name,
  48018. value,
  48019. modifiers,
  48020. important,
  48021. warn,
  48022. range,
  48023. dynamic
  48024. ) {
  48025. modifiers = modifiers || emptyObject;
  48026. // warn prevent and passive modifier
  48027. /* istanbul ignore if */
  48028. if (
  48029. warn &&
  48030. modifiers.prevent && modifiers.passive
  48031. ) {
  48032. warn(
  48033. 'passive and prevent can\'t be used together. ' +
  48034. 'Passive handler can\'t prevent default event.',
  48035. range
  48036. );
  48037. }
  48038. // normalize click.right and click.middle since they don't actually fire
  48039. // this is technically browser-specific, but at least for now browsers are
  48040. // the only target envs that have right/middle clicks.
  48041. if (modifiers.right) {
  48042. if (dynamic) {
  48043. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48044. } else if (name === 'click') {
  48045. name = 'contextmenu';
  48046. delete modifiers.right;
  48047. }
  48048. } else if (modifiers.middle) {
  48049. if (dynamic) {
  48050. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48051. } else if (name === 'click') {
  48052. name = 'mouseup';
  48053. }
  48054. }
  48055. // check capture modifier
  48056. if (modifiers.capture) {
  48057. delete modifiers.capture;
  48058. name = prependModifierMarker('!', name, dynamic);
  48059. }
  48060. if (modifiers.once) {
  48061. delete modifiers.once;
  48062. name = prependModifierMarker('~', name, dynamic);
  48063. }
  48064. /* istanbul ignore if */
  48065. if (modifiers.passive) {
  48066. delete modifiers.passive;
  48067. name = prependModifierMarker('&', name, dynamic);
  48068. }
  48069. var events;
  48070. if (modifiers.native) {
  48071. delete modifiers.native;
  48072. events = el.nativeEvents || (el.nativeEvents = {});
  48073. } else {
  48074. events = el.events || (el.events = {});
  48075. }
  48076. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48077. if (modifiers !== emptyObject) {
  48078. newHandler.modifiers = modifiers;
  48079. }
  48080. var handlers = events[name];
  48081. /* istanbul ignore if */
  48082. if (Array.isArray(handlers)) {
  48083. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48084. } else if (handlers) {
  48085. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48086. } else {
  48087. events[name] = newHandler;
  48088. }
  48089. el.plain = false;
  48090. }
  48091. function getRawBindingAttr (
  48092. el,
  48093. name
  48094. ) {
  48095. return el.rawAttrsMap[':' + name] ||
  48096. el.rawAttrsMap['v-bind:' + name] ||
  48097. el.rawAttrsMap[name]
  48098. }
  48099. function getBindingAttr (
  48100. el,
  48101. name,
  48102. getStatic
  48103. ) {
  48104. var dynamicValue =
  48105. getAndRemoveAttr(el, ':' + name) ||
  48106. getAndRemoveAttr(el, 'v-bind:' + name);
  48107. if (dynamicValue != null) {
  48108. return parseFilters(dynamicValue)
  48109. } else if (getStatic !== false) {
  48110. var staticValue = getAndRemoveAttr(el, name);
  48111. if (staticValue != null) {
  48112. return JSON.stringify(staticValue)
  48113. }
  48114. }
  48115. }
  48116. // note: this only removes the attr from the Array (attrsList) so that it
  48117. // doesn't get processed by processAttrs.
  48118. // By default it does NOT remove it from the map (attrsMap) because the map is
  48119. // needed during codegen.
  48120. function getAndRemoveAttr (
  48121. el,
  48122. name,
  48123. removeFromMap
  48124. ) {
  48125. var val;
  48126. if ((val = el.attrsMap[name]) != null) {
  48127. var list = el.attrsList;
  48128. for (var i = 0, l = list.length; i < l; i++) {
  48129. if (list[i].name === name) {
  48130. list.splice(i, 1);
  48131. break
  48132. }
  48133. }
  48134. }
  48135. if (removeFromMap) {
  48136. delete el.attrsMap[name];
  48137. }
  48138. return val
  48139. }
  48140. function getAndRemoveAttrByRegex (
  48141. el,
  48142. name
  48143. ) {
  48144. var list = el.attrsList;
  48145. for (var i = 0, l = list.length; i < l; i++) {
  48146. var attr = list[i];
  48147. if (name.test(attr.name)) {
  48148. list.splice(i, 1);
  48149. return attr
  48150. }
  48151. }
  48152. }
  48153. function rangeSetItem (
  48154. item,
  48155. range
  48156. ) {
  48157. if (range) {
  48158. if (range.start != null) {
  48159. item.start = range.start;
  48160. }
  48161. if (range.end != null) {
  48162. item.end = range.end;
  48163. }
  48164. }
  48165. return item
  48166. }
  48167. /* */
  48168. /**
  48169. * Cross-platform code generation for component v-model
  48170. */
  48171. function genComponentModel (
  48172. el,
  48173. value,
  48174. modifiers
  48175. ) {
  48176. var ref = modifiers || {};
  48177. var number = ref.number;
  48178. var trim = ref.trim;
  48179. var baseValueExpression = '$$v';
  48180. var valueExpression = baseValueExpression;
  48181. if (trim) {
  48182. valueExpression =
  48183. "(typeof " + baseValueExpression + " === 'string'" +
  48184. "? " + baseValueExpression + ".trim()" +
  48185. ": " + baseValueExpression + ")";
  48186. }
  48187. if (number) {
  48188. valueExpression = "_n(" + valueExpression + ")";
  48189. }
  48190. var assignment = genAssignmentCode(value, valueExpression);
  48191. el.model = {
  48192. value: ("(" + value + ")"),
  48193. expression: JSON.stringify(value),
  48194. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48195. };
  48196. }
  48197. /**
  48198. * Cross-platform codegen helper for generating v-model value assignment code.
  48199. */
  48200. function genAssignmentCode (
  48201. value,
  48202. assignment
  48203. ) {
  48204. var res = parseModel(value);
  48205. if (res.key === null) {
  48206. return (value + "=" + assignment)
  48207. } else {
  48208. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48209. }
  48210. }
  48211. /**
  48212. * Parse a v-model expression into a base path and a final key segment.
  48213. * Handles both dot-path and possible square brackets.
  48214. *
  48215. * Possible cases:
  48216. *
  48217. * - test
  48218. * - test[key]
  48219. * - test[test1[key]]
  48220. * - test["a"][key]
  48221. * - xxx.test[a[a].test1[key]]
  48222. * - test.xxx.a["asa"][test1[key]]
  48223. *
  48224. */
  48225. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48226. function parseModel (val) {
  48227. // Fix https://github.com/vuejs/vue/pull/7730
  48228. // allow v-model="obj.val " (trailing whitespace)
  48229. val = val.trim();
  48230. len = val.length;
  48231. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48232. index$1 = val.lastIndexOf('.');
  48233. if (index$1 > -1) {
  48234. return {
  48235. exp: val.slice(0, index$1),
  48236. key: '"' + val.slice(index$1 + 1) + '"'
  48237. }
  48238. } else {
  48239. return {
  48240. exp: val,
  48241. key: null
  48242. }
  48243. }
  48244. }
  48245. str = val;
  48246. index$1 = expressionPos = expressionEndPos = 0;
  48247. while (!eof()) {
  48248. chr = next();
  48249. /* istanbul ignore if */
  48250. if (isStringStart(chr)) {
  48251. parseString(chr);
  48252. } else if (chr === 0x5B) {
  48253. parseBracket(chr);
  48254. }
  48255. }
  48256. return {
  48257. exp: val.slice(0, expressionPos),
  48258. key: val.slice(expressionPos + 1, expressionEndPos)
  48259. }
  48260. }
  48261. function next () {
  48262. return str.charCodeAt(++index$1)
  48263. }
  48264. function eof () {
  48265. return index$1 >= len
  48266. }
  48267. function isStringStart (chr) {
  48268. return chr === 0x22 || chr === 0x27
  48269. }
  48270. function parseBracket (chr) {
  48271. var inBracket = 1;
  48272. expressionPos = index$1;
  48273. while (!eof()) {
  48274. chr = next();
  48275. if (isStringStart(chr)) {
  48276. parseString(chr);
  48277. continue
  48278. }
  48279. if (chr === 0x5B) { inBracket++; }
  48280. if (chr === 0x5D) { inBracket--; }
  48281. if (inBracket === 0) {
  48282. expressionEndPos = index$1;
  48283. break
  48284. }
  48285. }
  48286. }
  48287. function parseString (chr) {
  48288. var stringQuote = chr;
  48289. while (!eof()) {
  48290. chr = next();
  48291. if (chr === stringQuote) {
  48292. break
  48293. }
  48294. }
  48295. }
  48296. /* */
  48297. var warn$1;
  48298. // in some cases, the event used has to be determined at runtime
  48299. // so we used some reserved tokens during compile.
  48300. var RANGE_TOKEN = '__r';
  48301. var CHECKBOX_RADIO_TOKEN = '__c';
  48302. function model (
  48303. el,
  48304. dir,
  48305. _warn
  48306. ) {
  48307. warn$1 = _warn;
  48308. var value = dir.value;
  48309. var modifiers = dir.modifiers;
  48310. var tag = el.tag;
  48311. var type = el.attrsMap.type;
  48312. {
  48313. // inputs with type="file" are read only and setting the input's
  48314. // value will throw an error.
  48315. if (tag === 'input' && type === 'file') {
  48316. warn$1(
  48317. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48318. "File inputs are read only. Use a v-on:change listener instead.",
  48319. el.rawAttrsMap['v-model']
  48320. );
  48321. }
  48322. }
  48323. if (el.component) {
  48324. genComponentModel(el, value, modifiers);
  48325. // component v-model doesn't need extra runtime
  48326. return false
  48327. } else if (tag === 'select') {
  48328. genSelect(el, value, modifiers);
  48329. } else if (tag === 'input' && type === 'checkbox') {
  48330. genCheckboxModel(el, value, modifiers);
  48331. } else if (tag === 'input' && type === 'radio') {
  48332. genRadioModel(el, value, modifiers);
  48333. } else if (tag === 'input' || tag === 'textarea') {
  48334. genDefaultModel(el, value, modifiers);
  48335. } else if (!config.isReservedTag(tag)) {
  48336. genComponentModel(el, value, modifiers);
  48337. // component v-model doesn't need extra runtime
  48338. return false
  48339. } else {
  48340. warn$1(
  48341. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48342. "v-model is not supported on this element type. " +
  48343. 'If you are working with contenteditable, it\'s recommended to ' +
  48344. 'wrap a library dedicated for that purpose inside a custom component.',
  48345. el.rawAttrsMap['v-model']
  48346. );
  48347. }
  48348. // ensure runtime directive metadata
  48349. return true
  48350. }
  48351. function genCheckboxModel (
  48352. el,
  48353. value,
  48354. modifiers
  48355. ) {
  48356. var number = modifiers && modifiers.number;
  48357. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48358. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48359. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48360. addProp(el, 'checked',
  48361. "Array.isArray(" + value + ")" +
  48362. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48363. trueValueBinding === 'true'
  48364. ? (":(" + value + ")")
  48365. : (":_q(" + value + "," + trueValueBinding + ")")
  48366. )
  48367. );
  48368. addHandler(el, 'change',
  48369. "var $$a=" + value + "," +
  48370. '$$el=$event.target,' +
  48371. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48372. 'if(Array.isArray($$a)){' +
  48373. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48374. '$$i=_i($$a,$$v);' +
  48375. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48376. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48377. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48378. null, true
  48379. );
  48380. }
  48381. function genRadioModel (
  48382. el,
  48383. value,
  48384. modifiers
  48385. ) {
  48386. var number = modifiers && modifiers.number;
  48387. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48388. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48389. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48390. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48391. }
  48392. function genSelect (
  48393. el,
  48394. value,
  48395. modifiers
  48396. ) {
  48397. var number = modifiers && modifiers.number;
  48398. var selectedVal = "Array.prototype.filter" +
  48399. ".call($event.target.options,function(o){return o.selected})" +
  48400. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48401. "return " + (number ? '_n(val)' : 'val') + "})";
  48402. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48403. var code = "var $$selectedVal = " + selectedVal + ";";
  48404. code = code + " " + (genAssignmentCode(value, assignment));
  48405. addHandler(el, 'change', code, null, true);
  48406. }
  48407. function genDefaultModel (
  48408. el,
  48409. value,
  48410. modifiers
  48411. ) {
  48412. var type = el.attrsMap.type;
  48413. // warn if v-bind:value conflicts with v-model
  48414. // except for inputs with v-bind:type
  48415. {
  48416. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48417. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48418. if (value$1 && !typeBinding) {
  48419. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48420. warn$1(
  48421. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48422. 'because the latter already expands to a value binding internally',
  48423. el.rawAttrsMap[binding]
  48424. );
  48425. }
  48426. }
  48427. var ref = modifiers || {};
  48428. var lazy = ref.lazy;
  48429. var number = ref.number;
  48430. var trim = ref.trim;
  48431. var needCompositionGuard = !lazy && type !== 'range';
  48432. var event = lazy
  48433. ? 'change'
  48434. : type === 'range'
  48435. ? RANGE_TOKEN
  48436. : 'input';
  48437. var valueExpression = '$event.target.value';
  48438. if (trim) {
  48439. valueExpression = "$event.target.value.trim()";
  48440. }
  48441. if (number) {
  48442. valueExpression = "_n(" + valueExpression + ")";
  48443. }
  48444. var code = genAssignmentCode(value, valueExpression);
  48445. if (needCompositionGuard) {
  48446. code = "if($event.target.composing)return;" + code;
  48447. }
  48448. addProp(el, 'value', ("(" + value + ")"));
  48449. addHandler(el, event, code, null, true);
  48450. if (trim || number) {
  48451. addHandler(el, 'blur', '$forceUpdate()');
  48452. }
  48453. }
  48454. /* */
  48455. // normalize v-model event tokens that can only be determined at runtime.
  48456. // it's important to place the event as the first in the array because
  48457. // the whole point is ensuring the v-model callback gets called before
  48458. // user-attached handlers.
  48459. function normalizeEvents (on) {
  48460. /* istanbul ignore if */
  48461. if (isDef(on[RANGE_TOKEN])) {
  48462. // IE input[type=range] only supports `change` event
  48463. var event = isIE ? 'change' : 'input';
  48464. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48465. delete on[RANGE_TOKEN];
  48466. }
  48467. // This was originally intended to fix #4521 but no longer necessary
  48468. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48469. /* istanbul ignore if */
  48470. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48471. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48472. delete on[CHECKBOX_RADIO_TOKEN];
  48473. }
  48474. }
  48475. var target$1;
  48476. function createOnceHandler$1 (event, handler, capture) {
  48477. var _target = target$1; // save current target element in closure
  48478. return function onceHandler () {
  48479. var res = handler.apply(null, arguments);
  48480. if (res !== null) {
  48481. remove$2(event, onceHandler, capture, _target);
  48482. }
  48483. }
  48484. }
  48485. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48486. // implementation and does not fire microtasks in between event propagation, so
  48487. // safe to exclude.
  48488. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48489. function add$1 (
  48490. name,
  48491. handler,
  48492. capture,
  48493. passive
  48494. ) {
  48495. // async edge case #6566: inner click event triggers patch, event handler
  48496. // attached to outer element during patch, and triggered again. This
  48497. // happens because browsers fire microtask ticks between event propagation.
  48498. // the solution is simple: we save the timestamp when a handler is attached,
  48499. // and the handler would only fire if the event passed to it was fired
  48500. // AFTER it was attached.
  48501. if (useMicrotaskFix) {
  48502. var attachedTimestamp = currentFlushTimestamp;
  48503. var original = handler;
  48504. handler = original._wrapper = function (e) {
  48505. if (
  48506. // no bubbling, should always fire.
  48507. // this is just a safety net in case event.timeStamp is unreliable in
  48508. // certain weird environments...
  48509. e.target === e.currentTarget ||
  48510. // event is fired after handler attachment
  48511. e.timeStamp >= attachedTimestamp ||
  48512. // bail for environments that have buggy event.timeStamp implementations
  48513. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48514. // #9681 QtWebEngine event.timeStamp is negative value
  48515. e.timeStamp <= 0 ||
  48516. // #9448 bail if event is fired in another document in a multi-page
  48517. // electron/nw.js app, since event.timeStamp will be using a different
  48518. // starting reference
  48519. e.target.ownerDocument !== document
  48520. ) {
  48521. return original.apply(this, arguments)
  48522. }
  48523. };
  48524. }
  48525. target$1.addEventListener(
  48526. name,
  48527. handler,
  48528. supportsPassive
  48529. ? { capture: capture, passive: passive }
  48530. : capture
  48531. );
  48532. }
  48533. function remove$2 (
  48534. name,
  48535. handler,
  48536. capture,
  48537. _target
  48538. ) {
  48539. (_target || target$1).removeEventListener(
  48540. name,
  48541. handler._wrapper || handler,
  48542. capture
  48543. );
  48544. }
  48545. function updateDOMListeners (oldVnode, vnode) {
  48546. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48547. return
  48548. }
  48549. var on = vnode.data.on || {};
  48550. var oldOn = oldVnode.data.on || {};
  48551. target$1 = vnode.elm;
  48552. normalizeEvents(on);
  48553. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48554. target$1 = undefined;
  48555. }
  48556. var events = {
  48557. create: updateDOMListeners,
  48558. update: updateDOMListeners
  48559. };
  48560. /* */
  48561. var svgContainer;
  48562. function updateDOMProps (oldVnode, vnode) {
  48563. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48564. return
  48565. }
  48566. var key, cur;
  48567. var elm = vnode.elm;
  48568. var oldProps = oldVnode.data.domProps || {};
  48569. var props = vnode.data.domProps || {};
  48570. // clone observed objects, as the user probably wants to mutate it
  48571. if (isDef(props.__ob__)) {
  48572. props = vnode.data.domProps = extend({}, props);
  48573. }
  48574. for (key in oldProps) {
  48575. if (!(key in props)) {
  48576. elm[key] = '';
  48577. }
  48578. }
  48579. for (key in props) {
  48580. cur = props[key];
  48581. // ignore children if the node has textContent or innerHTML,
  48582. // as these will throw away existing DOM nodes and cause removal errors
  48583. // on subsequent patches (#3360)
  48584. if (key === 'textContent' || key === 'innerHTML') {
  48585. if (vnode.children) { vnode.children.length = 0; }
  48586. if (cur === oldProps[key]) { continue }
  48587. // #6601 work around Chrome version <= 55 bug where single textNode
  48588. // replaced by innerHTML/textContent retains its parentNode property
  48589. if (elm.childNodes.length === 1) {
  48590. elm.removeChild(elm.childNodes[0]);
  48591. }
  48592. }
  48593. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48594. // store value as _value as well since
  48595. // non-string values will be stringified
  48596. elm._value = cur;
  48597. // avoid resetting cursor position when value is the same
  48598. var strCur = isUndef(cur) ? '' : String(cur);
  48599. if (shouldUpdateValue(elm, strCur)) {
  48600. elm.value = strCur;
  48601. }
  48602. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48603. // IE doesn't support innerHTML for SVG elements
  48604. svgContainer = svgContainer || document.createElement('div');
  48605. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48606. var svg = svgContainer.firstChild;
  48607. while (elm.firstChild) {
  48608. elm.removeChild(elm.firstChild);
  48609. }
  48610. while (svg.firstChild) {
  48611. elm.appendChild(svg.firstChild);
  48612. }
  48613. } else if (
  48614. // skip the update if old and new VDOM state is the same.
  48615. // `value` is handled separately because the DOM value may be temporarily
  48616. // out of sync with VDOM state due to focus, composition and modifiers.
  48617. // This #4521 by skipping the unnecesarry `checked` update.
  48618. cur !== oldProps[key]
  48619. ) {
  48620. // some property updates can throw
  48621. // e.g. `value` on <progress> w/ non-finite value
  48622. try {
  48623. elm[key] = cur;
  48624. } catch (e) {}
  48625. }
  48626. }
  48627. }
  48628. // check platforms/web/util/attrs.js acceptValue
  48629. function shouldUpdateValue (elm, checkVal) {
  48630. return (!elm.composing && (
  48631. elm.tagName === 'OPTION' ||
  48632. isNotInFocusAndDirty(elm, checkVal) ||
  48633. isDirtyWithModifiers(elm, checkVal)
  48634. ))
  48635. }
  48636. function isNotInFocusAndDirty (elm, checkVal) {
  48637. // return true when textbox (.number and .trim) loses focus and its value is
  48638. // not equal to the updated value
  48639. var notInFocus = true;
  48640. // #6157
  48641. // work around IE bug when accessing document.activeElement in an iframe
  48642. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48643. return notInFocus && elm.value !== checkVal
  48644. }
  48645. function isDirtyWithModifiers (elm, newVal) {
  48646. var value = elm.value;
  48647. var modifiers = elm._vModifiers; // injected by v-model runtime
  48648. if (isDef(modifiers)) {
  48649. if (modifiers.number) {
  48650. return toNumber(value) !== toNumber(newVal)
  48651. }
  48652. if (modifiers.trim) {
  48653. return value.trim() !== newVal.trim()
  48654. }
  48655. }
  48656. return value !== newVal
  48657. }
  48658. var domProps = {
  48659. create: updateDOMProps,
  48660. update: updateDOMProps
  48661. };
  48662. /* */
  48663. var parseStyleText = cached(function (cssText) {
  48664. var res = {};
  48665. var listDelimiter = /;(?![^(]*\))/g;
  48666. var propertyDelimiter = /:(.+)/;
  48667. cssText.split(listDelimiter).forEach(function (item) {
  48668. if (item) {
  48669. var tmp = item.split(propertyDelimiter);
  48670. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48671. }
  48672. });
  48673. return res
  48674. });
  48675. // merge static and dynamic style data on the same vnode
  48676. function normalizeStyleData (data) {
  48677. var style = normalizeStyleBinding(data.style);
  48678. // static style is pre-processed into an object during compilation
  48679. // and is always a fresh object, so it's safe to merge into it
  48680. return data.staticStyle
  48681. ? extend(data.staticStyle, style)
  48682. : style
  48683. }
  48684. // normalize possible array / string values into Object
  48685. function normalizeStyleBinding (bindingStyle) {
  48686. if (Array.isArray(bindingStyle)) {
  48687. return toObject(bindingStyle)
  48688. }
  48689. if (typeof bindingStyle === 'string') {
  48690. return parseStyleText(bindingStyle)
  48691. }
  48692. return bindingStyle
  48693. }
  48694. /**
  48695. * parent component style should be after child's
  48696. * so that parent component's style could override it
  48697. */
  48698. function getStyle (vnode, checkChild) {
  48699. var res = {};
  48700. var styleData;
  48701. if (checkChild) {
  48702. var childNode = vnode;
  48703. while (childNode.componentInstance) {
  48704. childNode = childNode.componentInstance._vnode;
  48705. if (
  48706. childNode && childNode.data &&
  48707. (styleData = normalizeStyleData(childNode.data))
  48708. ) {
  48709. extend(res, styleData);
  48710. }
  48711. }
  48712. }
  48713. if ((styleData = normalizeStyleData(vnode.data))) {
  48714. extend(res, styleData);
  48715. }
  48716. var parentNode = vnode;
  48717. while ((parentNode = parentNode.parent)) {
  48718. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48719. extend(res, styleData);
  48720. }
  48721. }
  48722. return res
  48723. }
  48724. /* */
  48725. var cssVarRE = /^--/;
  48726. var importantRE = /\s*!important$/;
  48727. var setProp = function (el, name, val) {
  48728. /* istanbul ignore if */
  48729. if (cssVarRE.test(name)) {
  48730. el.style.setProperty(name, val);
  48731. } else if (importantRE.test(val)) {
  48732. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48733. } else {
  48734. var normalizedName = normalize(name);
  48735. if (Array.isArray(val)) {
  48736. // Support values array created by autoprefixer, e.g.
  48737. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48738. // Set them one by one, and the browser will only set those it can recognize
  48739. for (var i = 0, len = val.length; i < len; i++) {
  48740. el.style[normalizedName] = val[i];
  48741. }
  48742. } else {
  48743. el.style[normalizedName] = val;
  48744. }
  48745. }
  48746. };
  48747. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48748. var emptyStyle;
  48749. var normalize = cached(function (prop) {
  48750. emptyStyle = emptyStyle || document.createElement('div').style;
  48751. prop = camelize(prop);
  48752. if (prop !== 'filter' && (prop in emptyStyle)) {
  48753. return prop
  48754. }
  48755. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48756. for (var i = 0; i < vendorNames.length; i++) {
  48757. var name = vendorNames[i] + capName;
  48758. if (name in emptyStyle) {
  48759. return name
  48760. }
  48761. }
  48762. });
  48763. function updateStyle (oldVnode, vnode) {
  48764. var data = vnode.data;
  48765. var oldData = oldVnode.data;
  48766. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48767. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48768. ) {
  48769. return
  48770. }
  48771. var cur, name;
  48772. var el = vnode.elm;
  48773. var oldStaticStyle = oldData.staticStyle;
  48774. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48775. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48776. var oldStyle = oldStaticStyle || oldStyleBinding;
  48777. var style = normalizeStyleBinding(vnode.data.style) || {};
  48778. // store normalized style under a different key for next diff
  48779. // make sure to clone it if it's reactive, since the user likely wants
  48780. // to mutate it.
  48781. vnode.data.normalizedStyle = isDef(style.__ob__)
  48782. ? extend({}, style)
  48783. : style;
  48784. var newStyle = getStyle(vnode, true);
  48785. for (name in oldStyle) {
  48786. if (isUndef(newStyle[name])) {
  48787. setProp(el, name, '');
  48788. }
  48789. }
  48790. for (name in newStyle) {
  48791. cur = newStyle[name];
  48792. if (cur !== oldStyle[name]) {
  48793. // ie9 setting to null has no effect, must use empty string
  48794. setProp(el, name, cur == null ? '' : cur);
  48795. }
  48796. }
  48797. }
  48798. var style = {
  48799. create: updateStyle,
  48800. update: updateStyle
  48801. };
  48802. /* */
  48803. var whitespaceRE = /\s+/;
  48804. /**
  48805. * Add class with compatibility for SVG since classList is not supported on
  48806. * SVG elements in IE
  48807. */
  48808. function addClass (el, cls) {
  48809. /* istanbul ignore if */
  48810. if (!cls || !(cls = cls.trim())) {
  48811. return
  48812. }
  48813. /* istanbul ignore else */
  48814. if (el.classList) {
  48815. if (cls.indexOf(' ') > -1) {
  48816. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48817. } else {
  48818. el.classList.add(cls);
  48819. }
  48820. } else {
  48821. var cur = " " + (el.getAttribute('class') || '') + " ";
  48822. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48823. el.setAttribute('class', (cur + cls).trim());
  48824. }
  48825. }
  48826. }
  48827. /**
  48828. * Remove class with compatibility for SVG since classList is not supported on
  48829. * SVG elements in IE
  48830. */
  48831. function removeClass (el, cls) {
  48832. /* istanbul ignore if */
  48833. if (!cls || !(cls = cls.trim())) {
  48834. return
  48835. }
  48836. /* istanbul ignore else */
  48837. if (el.classList) {
  48838. if (cls.indexOf(' ') > -1) {
  48839. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48840. } else {
  48841. el.classList.remove(cls);
  48842. }
  48843. if (!el.classList.length) {
  48844. el.removeAttribute('class');
  48845. }
  48846. } else {
  48847. var cur = " " + (el.getAttribute('class') || '') + " ";
  48848. var tar = ' ' + cls + ' ';
  48849. while (cur.indexOf(tar) >= 0) {
  48850. cur = cur.replace(tar, ' ');
  48851. }
  48852. cur = cur.trim();
  48853. if (cur) {
  48854. el.setAttribute('class', cur);
  48855. } else {
  48856. el.removeAttribute('class');
  48857. }
  48858. }
  48859. }
  48860. /* */
  48861. function resolveTransition (def$$1) {
  48862. if (!def$$1) {
  48863. return
  48864. }
  48865. /* istanbul ignore else */
  48866. if (typeof def$$1 === 'object') {
  48867. var res = {};
  48868. if (def$$1.css !== false) {
  48869. extend(res, autoCssTransition(def$$1.name || 'v'));
  48870. }
  48871. extend(res, def$$1);
  48872. return res
  48873. } else if (typeof def$$1 === 'string') {
  48874. return autoCssTransition(def$$1)
  48875. }
  48876. }
  48877. var autoCssTransition = cached(function (name) {
  48878. return {
  48879. enterClass: (name + "-enter"),
  48880. enterToClass: (name + "-enter-to"),
  48881. enterActiveClass: (name + "-enter-active"),
  48882. leaveClass: (name + "-leave"),
  48883. leaveToClass: (name + "-leave-to"),
  48884. leaveActiveClass: (name + "-leave-active")
  48885. }
  48886. });
  48887. var hasTransition = inBrowser && !isIE9;
  48888. var TRANSITION = 'transition';
  48889. var ANIMATION = 'animation';
  48890. // Transition property/event sniffing
  48891. var transitionProp = 'transition';
  48892. var transitionEndEvent = 'transitionend';
  48893. var animationProp = 'animation';
  48894. var animationEndEvent = 'animationend';
  48895. if (hasTransition) {
  48896. /* istanbul ignore if */
  48897. if (window.ontransitionend === undefined &&
  48898. window.onwebkittransitionend !== undefined
  48899. ) {
  48900. transitionProp = 'WebkitTransition';
  48901. transitionEndEvent = 'webkitTransitionEnd';
  48902. }
  48903. if (window.onanimationend === undefined &&
  48904. window.onwebkitanimationend !== undefined
  48905. ) {
  48906. animationProp = 'WebkitAnimation';
  48907. animationEndEvent = 'webkitAnimationEnd';
  48908. }
  48909. }
  48910. // binding to window is necessary to make hot reload work in IE in strict mode
  48911. var raf = inBrowser
  48912. ? window.requestAnimationFrame
  48913. ? window.requestAnimationFrame.bind(window)
  48914. : setTimeout
  48915. : /* istanbul ignore next */ function (fn) { return fn(); };
  48916. function nextFrame (fn) {
  48917. raf(function () {
  48918. raf(fn);
  48919. });
  48920. }
  48921. function addTransitionClass (el, cls) {
  48922. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  48923. if (transitionClasses.indexOf(cls) < 0) {
  48924. transitionClasses.push(cls);
  48925. addClass(el, cls);
  48926. }
  48927. }
  48928. function removeTransitionClass (el, cls) {
  48929. if (el._transitionClasses) {
  48930. remove(el._transitionClasses, cls);
  48931. }
  48932. removeClass(el, cls);
  48933. }
  48934. function whenTransitionEnds (
  48935. el,
  48936. expectedType,
  48937. cb
  48938. ) {
  48939. var ref = getTransitionInfo(el, expectedType);
  48940. var type = ref.type;
  48941. var timeout = ref.timeout;
  48942. var propCount = ref.propCount;
  48943. if (!type) { return cb() }
  48944. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  48945. var ended = 0;
  48946. var end = function () {
  48947. el.removeEventListener(event, onEnd);
  48948. cb();
  48949. };
  48950. var onEnd = function (e) {
  48951. if (e.target === el) {
  48952. if (++ended >= propCount) {
  48953. end();
  48954. }
  48955. }
  48956. };
  48957. setTimeout(function () {
  48958. if (ended < propCount) {
  48959. end();
  48960. }
  48961. }, timeout + 1);
  48962. el.addEventListener(event, onEnd);
  48963. }
  48964. var transformRE = /\b(transform|all)(,|$)/;
  48965. function getTransitionInfo (el, expectedType) {
  48966. var styles = window.getComputedStyle(el);
  48967. // JSDOM may return undefined for transition properties
  48968. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  48969. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  48970. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  48971. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  48972. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  48973. var animationTimeout = getTimeout(animationDelays, animationDurations);
  48974. var type;
  48975. var timeout = 0;
  48976. var propCount = 0;
  48977. /* istanbul ignore if */
  48978. if (expectedType === TRANSITION) {
  48979. if (transitionTimeout > 0) {
  48980. type = TRANSITION;
  48981. timeout = transitionTimeout;
  48982. propCount = transitionDurations.length;
  48983. }
  48984. } else if (expectedType === ANIMATION) {
  48985. if (animationTimeout > 0) {
  48986. type = ANIMATION;
  48987. timeout = animationTimeout;
  48988. propCount = animationDurations.length;
  48989. }
  48990. } else {
  48991. timeout = Math.max(transitionTimeout, animationTimeout);
  48992. type = timeout > 0
  48993. ? transitionTimeout > animationTimeout
  48994. ? TRANSITION
  48995. : ANIMATION
  48996. : null;
  48997. propCount = type
  48998. ? type === TRANSITION
  48999. ? transitionDurations.length
  49000. : animationDurations.length
  49001. : 0;
  49002. }
  49003. var hasTransform =
  49004. type === TRANSITION &&
  49005. transformRE.test(styles[transitionProp + 'Property']);
  49006. return {
  49007. type: type,
  49008. timeout: timeout,
  49009. propCount: propCount,
  49010. hasTransform: hasTransform
  49011. }
  49012. }
  49013. function getTimeout (delays, durations) {
  49014. /* istanbul ignore next */
  49015. while (delays.length < durations.length) {
  49016. delays = delays.concat(delays);
  49017. }
  49018. return Math.max.apply(null, durations.map(function (d, i) {
  49019. return toMs(d) + toMs(delays[i])
  49020. }))
  49021. }
  49022. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49023. // in a locale-dependent way, using a comma instead of a dot.
  49024. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49025. // as a floor function) causing unexpected behaviors
  49026. function toMs (s) {
  49027. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49028. }
  49029. /* */
  49030. function enter (vnode, toggleDisplay) {
  49031. var el = vnode.elm;
  49032. // call leave callback now
  49033. if (isDef(el._leaveCb)) {
  49034. el._leaveCb.cancelled = true;
  49035. el._leaveCb();
  49036. }
  49037. var data = resolveTransition(vnode.data.transition);
  49038. if (isUndef(data)) {
  49039. return
  49040. }
  49041. /* istanbul ignore if */
  49042. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49043. return
  49044. }
  49045. var css = data.css;
  49046. var type = data.type;
  49047. var enterClass = data.enterClass;
  49048. var enterToClass = data.enterToClass;
  49049. var enterActiveClass = data.enterActiveClass;
  49050. var appearClass = data.appearClass;
  49051. var appearToClass = data.appearToClass;
  49052. var appearActiveClass = data.appearActiveClass;
  49053. var beforeEnter = data.beforeEnter;
  49054. var enter = data.enter;
  49055. var afterEnter = data.afterEnter;
  49056. var enterCancelled = data.enterCancelled;
  49057. var beforeAppear = data.beforeAppear;
  49058. var appear = data.appear;
  49059. var afterAppear = data.afterAppear;
  49060. var appearCancelled = data.appearCancelled;
  49061. var duration = data.duration;
  49062. // activeInstance will always be the <transition> component managing this
  49063. // transition. One edge case to check is when the <transition> is placed
  49064. // as the root node of a child component. In that case we need to check
  49065. // <transition>'s parent for appear check.
  49066. var context = activeInstance;
  49067. var transitionNode = activeInstance.$vnode;
  49068. while (transitionNode && transitionNode.parent) {
  49069. context = transitionNode.context;
  49070. transitionNode = transitionNode.parent;
  49071. }
  49072. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49073. if (isAppear && !appear && appear !== '') {
  49074. return
  49075. }
  49076. var startClass = isAppear && appearClass
  49077. ? appearClass
  49078. : enterClass;
  49079. var activeClass = isAppear && appearActiveClass
  49080. ? appearActiveClass
  49081. : enterActiveClass;
  49082. var toClass = isAppear && appearToClass
  49083. ? appearToClass
  49084. : enterToClass;
  49085. var beforeEnterHook = isAppear
  49086. ? (beforeAppear || beforeEnter)
  49087. : beforeEnter;
  49088. var enterHook = isAppear
  49089. ? (typeof appear === 'function' ? appear : enter)
  49090. : enter;
  49091. var afterEnterHook = isAppear
  49092. ? (afterAppear || afterEnter)
  49093. : afterEnter;
  49094. var enterCancelledHook = isAppear
  49095. ? (appearCancelled || enterCancelled)
  49096. : enterCancelled;
  49097. var explicitEnterDuration = toNumber(
  49098. isObject(duration)
  49099. ? duration.enter
  49100. : duration
  49101. );
  49102. if (explicitEnterDuration != null) {
  49103. checkDuration(explicitEnterDuration, 'enter', vnode);
  49104. }
  49105. var expectsCSS = css !== false && !isIE9;
  49106. var userWantsControl = getHookArgumentsLength(enterHook);
  49107. var cb = el._enterCb = once(function () {
  49108. if (expectsCSS) {
  49109. removeTransitionClass(el, toClass);
  49110. removeTransitionClass(el, activeClass);
  49111. }
  49112. if (cb.cancelled) {
  49113. if (expectsCSS) {
  49114. removeTransitionClass(el, startClass);
  49115. }
  49116. enterCancelledHook && enterCancelledHook(el);
  49117. } else {
  49118. afterEnterHook && afterEnterHook(el);
  49119. }
  49120. el._enterCb = null;
  49121. });
  49122. if (!vnode.data.show) {
  49123. // remove pending leave element on enter by injecting an insert hook
  49124. mergeVNodeHook(vnode, 'insert', function () {
  49125. var parent = el.parentNode;
  49126. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49127. if (pendingNode &&
  49128. pendingNode.tag === vnode.tag &&
  49129. pendingNode.elm._leaveCb
  49130. ) {
  49131. pendingNode.elm._leaveCb();
  49132. }
  49133. enterHook && enterHook(el, cb);
  49134. });
  49135. }
  49136. // start enter transition
  49137. beforeEnterHook && beforeEnterHook(el);
  49138. if (expectsCSS) {
  49139. addTransitionClass(el, startClass);
  49140. addTransitionClass(el, activeClass);
  49141. nextFrame(function () {
  49142. removeTransitionClass(el, startClass);
  49143. if (!cb.cancelled) {
  49144. addTransitionClass(el, toClass);
  49145. if (!userWantsControl) {
  49146. if (isValidDuration(explicitEnterDuration)) {
  49147. setTimeout(cb, explicitEnterDuration);
  49148. } else {
  49149. whenTransitionEnds(el, type, cb);
  49150. }
  49151. }
  49152. }
  49153. });
  49154. }
  49155. if (vnode.data.show) {
  49156. toggleDisplay && toggleDisplay();
  49157. enterHook && enterHook(el, cb);
  49158. }
  49159. if (!expectsCSS && !userWantsControl) {
  49160. cb();
  49161. }
  49162. }
  49163. function leave (vnode, rm) {
  49164. var el = vnode.elm;
  49165. // call enter callback now
  49166. if (isDef(el._enterCb)) {
  49167. el._enterCb.cancelled = true;
  49168. el._enterCb();
  49169. }
  49170. var data = resolveTransition(vnode.data.transition);
  49171. if (isUndef(data) || el.nodeType !== 1) {
  49172. return rm()
  49173. }
  49174. /* istanbul ignore if */
  49175. if (isDef(el._leaveCb)) {
  49176. return
  49177. }
  49178. var css = data.css;
  49179. var type = data.type;
  49180. var leaveClass = data.leaveClass;
  49181. var leaveToClass = data.leaveToClass;
  49182. var leaveActiveClass = data.leaveActiveClass;
  49183. var beforeLeave = data.beforeLeave;
  49184. var leave = data.leave;
  49185. var afterLeave = data.afterLeave;
  49186. var leaveCancelled = data.leaveCancelled;
  49187. var delayLeave = data.delayLeave;
  49188. var duration = data.duration;
  49189. var expectsCSS = css !== false && !isIE9;
  49190. var userWantsControl = getHookArgumentsLength(leave);
  49191. var explicitLeaveDuration = toNumber(
  49192. isObject(duration)
  49193. ? duration.leave
  49194. : duration
  49195. );
  49196. if (isDef(explicitLeaveDuration)) {
  49197. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49198. }
  49199. var cb = el._leaveCb = once(function () {
  49200. if (el.parentNode && el.parentNode._pending) {
  49201. el.parentNode._pending[vnode.key] = null;
  49202. }
  49203. if (expectsCSS) {
  49204. removeTransitionClass(el, leaveToClass);
  49205. removeTransitionClass(el, leaveActiveClass);
  49206. }
  49207. if (cb.cancelled) {
  49208. if (expectsCSS) {
  49209. removeTransitionClass(el, leaveClass);
  49210. }
  49211. leaveCancelled && leaveCancelled(el);
  49212. } else {
  49213. rm();
  49214. afterLeave && afterLeave(el);
  49215. }
  49216. el._leaveCb = null;
  49217. });
  49218. if (delayLeave) {
  49219. delayLeave(performLeave);
  49220. } else {
  49221. performLeave();
  49222. }
  49223. function performLeave () {
  49224. // the delayed leave may have already been cancelled
  49225. if (cb.cancelled) {
  49226. return
  49227. }
  49228. // record leaving element
  49229. if (!vnode.data.show && el.parentNode) {
  49230. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49231. }
  49232. beforeLeave && beforeLeave(el);
  49233. if (expectsCSS) {
  49234. addTransitionClass(el, leaveClass);
  49235. addTransitionClass(el, leaveActiveClass);
  49236. nextFrame(function () {
  49237. removeTransitionClass(el, leaveClass);
  49238. if (!cb.cancelled) {
  49239. addTransitionClass(el, leaveToClass);
  49240. if (!userWantsControl) {
  49241. if (isValidDuration(explicitLeaveDuration)) {
  49242. setTimeout(cb, explicitLeaveDuration);
  49243. } else {
  49244. whenTransitionEnds(el, type, cb);
  49245. }
  49246. }
  49247. }
  49248. });
  49249. }
  49250. leave && leave(el, cb);
  49251. if (!expectsCSS && !userWantsControl) {
  49252. cb();
  49253. }
  49254. }
  49255. }
  49256. // only used in dev mode
  49257. function checkDuration (val, name, vnode) {
  49258. if (typeof val !== 'number') {
  49259. warn(
  49260. "<transition> explicit " + name + " duration is not a valid number - " +
  49261. "got " + (JSON.stringify(val)) + ".",
  49262. vnode.context
  49263. );
  49264. } else if (isNaN(val)) {
  49265. warn(
  49266. "<transition> explicit " + name + " duration is NaN - " +
  49267. 'the duration expression might be incorrect.',
  49268. vnode.context
  49269. );
  49270. }
  49271. }
  49272. function isValidDuration (val) {
  49273. return typeof val === 'number' && !isNaN(val)
  49274. }
  49275. /**
  49276. * Normalize a transition hook's argument length. The hook may be:
  49277. * - a merged hook (invoker) with the original in .fns
  49278. * - a wrapped component method (check ._length)
  49279. * - a plain function (.length)
  49280. */
  49281. function getHookArgumentsLength (fn) {
  49282. if (isUndef(fn)) {
  49283. return false
  49284. }
  49285. var invokerFns = fn.fns;
  49286. if (isDef(invokerFns)) {
  49287. // invoker
  49288. return getHookArgumentsLength(
  49289. Array.isArray(invokerFns)
  49290. ? invokerFns[0]
  49291. : invokerFns
  49292. )
  49293. } else {
  49294. return (fn._length || fn.length) > 1
  49295. }
  49296. }
  49297. function _enter (_, vnode) {
  49298. if (vnode.data.show !== true) {
  49299. enter(vnode);
  49300. }
  49301. }
  49302. var transition = inBrowser ? {
  49303. create: _enter,
  49304. activate: _enter,
  49305. remove: function remove$$1 (vnode, rm) {
  49306. /* istanbul ignore else */
  49307. if (vnode.data.show !== true) {
  49308. leave(vnode, rm);
  49309. } else {
  49310. rm();
  49311. }
  49312. }
  49313. } : {};
  49314. var platformModules = [
  49315. attrs,
  49316. klass,
  49317. events,
  49318. domProps,
  49319. style,
  49320. transition
  49321. ];
  49322. /* */
  49323. // the directive module should be applied last, after all
  49324. // built-in modules have been applied.
  49325. var modules = platformModules.concat(baseModules);
  49326. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49327. /**
  49328. * Not type checking this file because flow doesn't like attaching
  49329. * properties to Elements.
  49330. */
  49331. /* istanbul ignore if */
  49332. if (isIE9) {
  49333. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49334. document.addEventListener('selectionchange', function () {
  49335. var el = document.activeElement;
  49336. if (el && el.vmodel) {
  49337. trigger(el, 'input');
  49338. }
  49339. });
  49340. }
  49341. var directive = {
  49342. inserted: function inserted (el, binding, vnode, oldVnode) {
  49343. if (vnode.tag === 'select') {
  49344. // #6903
  49345. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49346. mergeVNodeHook(vnode, 'postpatch', function () {
  49347. directive.componentUpdated(el, binding, vnode);
  49348. });
  49349. } else {
  49350. setSelected(el, binding, vnode.context);
  49351. }
  49352. el._vOptions = [].map.call(el.options, getValue);
  49353. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49354. el._vModifiers = binding.modifiers;
  49355. if (!binding.modifiers.lazy) {
  49356. el.addEventListener('compositionstart', onCompositionStart);
  49357. el.addEventListener('compositionend', onCompositionEnd);
  49358. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49359. // switching focus before confirming composition choice
  49360. // this also fixes the issue where some browsers e.g. iOS Chrome
  49361. // fires "change" instead of "input" on autocomplete.
  49362. el.addEventListener('change', onCompositionEnd);
  49363. /* istanbul ignore if */
  49364. if (isIE9) {
  49365. el.vmodel = true;
  49366. }
  49367. }
  49368. }
  49369. },
  49370. componentUpdated: function componentUpdated (el, binding, vnode) {
  49371. if (vnode.tag === 'select') {
  49372. setSelected(el, binding, vnode.context);
  49373. // in case the options rendered by v-for have changed,
  49374. // it's possible that the value is out-of-sync with the rendered options.
  49375. // detect such cases and filter out values that no longer has a matching
  49376. // option in the DOM.
  49377. var prevOptions = el._vOptions;
  49378. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49379. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49380. // trigger change event if
  49381. // no matching option found for at least one value
  49382. var needReset = el.multiple
  49383. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49384. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49385. if (needReset) {
  49386. trigger(el, 'change');
  49387. }
  49388. }
  49389. }
  49390. }
  49391. };
  49392. function setSelected (el, binding, vm) {
  49393. actuallySetSelected(el, binding, vm);
  49394. /* istanbul ignore if */
  49395. if (isIE || isEdge) {
  49396. setTimeout(function () {
  49397. actuallySetSelected(el, binding, vm);
  49398. }, 0);
  49399. }
  49400. }
  49401. function actuallySetSelected (el, binding, vm) {
  49402. var value = binding.value;
  49403. var isMultiple = el.multiple;
  49404. if (isMultiple && !Array.isArray(value)) {
  49405. warn(
  49406. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49407. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49408. vm
  49409. );
  49410. return
  49411. }
  49412. var selected, option;
  49413. for (var i = 0, l = el.options.length; i < l; i++) {
  49414. option = el.options[i];
  49415. if (isMultiple) {
  49416. selected = looseIndexOf(value, getValue(option)) > -1;
  49417. if (option.selected !== selected) {
  49418. option.selected = selected;
  49419. }
  49420. } else {
  49421. if (looseEqual(getValue(option), value)) {
  49422. if (el.selectedIndex !== i) {
  49423. el.selectedIndex = i;
  49424. }
  49425. return
  49426. }
  49427. }
  49428. }
  49429. if (!isMultiple) {
  49430. el.selectedIndex = -1;
  49431. }
  49432. }
  49433. function hasNoMatchingOption (value, options) {
  49434. return options.every(function (o) { return !looseEqual(o, value); })
  49435. }
  49436. function getValue (option) {
  49437. return '_value' in option
  49438. ? option._value
  49439. : option.value
  49440. }
  49441. function onCompositionStart (e) {
  49442. e.target.composing = true;
  49443. }
  49444. function onCompositionEnd (e) {
  49445. // prevent triggering an input event for no reason
  49446. if (!e.target.composing) { return }
  49447. e.target.composing = false;
  49448. trigger(e.target, 'input');
  49449. }
  49450. function trigger (el, type) {
  49451. var e = document.createEvent('HTMLEvents');
  49452. e.initEvent(type, true, true);
  49453. el.dispatchEvent(e);
  49454. }
  49455. /* */
  49456. // recursively search for possible transition defined inside the component root
  49457. function locateNode (vnode) {
  49458. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49459. ? locateNode(vnode.componentInstance._vnode)
  49460. : vnode
  49461. }
  49462. var show = {
  49463. bind: function bind (el, ref, vnode) {
  49464. var value = ref.value;
  49465. vnode = locateNode(vnode);
  49466. var transition$$1 = vnode.data && vnode.data.transition;
  49467. var originalDisplay = el.__vOriginalDisplay =
  49468. el.style.display === 'none' ? '' : el.style.display;
  49469. if (value && transition$$1) {
  49470. vnode.data.show = true;
  49471. enter(vnode, function () {
  49472. el.style.display = originalDisplay;
  49473. });
  49474. } else {
  49475. el.style.display = value ? originalDisplay : 'none';
  49476. }
  49477. },
  49478. update: function update (el, ref, vnode) {
  49479. var value = ref.value;
  49480. var oldValue = ref.oldValue;
  49481. /* istanbul ignore if */
  49482. if (!value === !oldValue) { return }
  49483. vnode = locateNode(vnode);
  49484. var transition$$1 = vnode.data && vnode.data.transition;
  49485. if (transition$$1) {
  49486. vnode.data.show = true;
  49487. if (value) {
  49488. enter(vnode, function () {
  49489. el.style.display = el.__vOriginalDisplay;
  49490. });
  49491. } else {
  49492. leave(vnode, function () {
  49493. el.style.display = 'none';
  49494. });
  49495. }
  49496. } else {
  49497. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49498. }
  49499. },
  49500. unbind: function unbind (
  49501. el,
  49502. binding,
  49503. vnode,
  49504. oldVnode,
  49505. isDestroy
  49506. ) {
  49507. if (!isDestroy) {
  49508. el.style.display = el.__vOriginalDisplay;
  49509. }
  49510. }
  49511. };
  49512. var platformDirectives = {
  49513. model: directive,
  49514. show: show
  49515. };
  49516. /* */
  49517. var transitionProps = {
  49518. name: String,
  49519. appear: Boolean,
  49520. css: Boolean,
  49521. mode: String,
  49522. type: String,
  49523. enterClass: String,
  49524. leaveClass: String,
  49525. enterToClass: String,
  49526. leaveToClass: String,
  49527. enterActiveClass: String,
  49528. leaveActiveClass: String,
  49529. appearClass: String,
  49530. appearActiveClass: String,
  49531. appearToClass: String,
  49532. duration: [Number, String, Object]
  49533. };
  49534. // in case the child is also an abstract component, e.g. <keep-alive>
  49535. // we want to recursively retrieve the real component to be rendered
  49536. function getRealChild (vnode) {
  49537. var compOptions = vnode && vnode.componentOptions;
  49538. if (compOptions && compOptions.Ctor.options.abstract) {
  49539. return getRealChild(getFirstComponentChild(compOptions.children))
  49540. } else {
  49541. return vnode
  49542. }
  49543. }
  49544. function extractTransitionData (comp) {
  49545. var data = {};
  49546. var options = comp.$options;
  49547. // props
  49548. for (var key in options.propsData) {
  49549. data[key] = comp[key];
  49550. }
  49551. // events.
  49552. // extract listeners and pass them directly to the transition methods
  49553. var listeners = options._parentListeners;
  49554. for (var key$1 in listeners) {
  49555. data[camelize(key$1)] = listeners[key$1];
  49556. }
  49557. return data
  49558. }
  49559. function placeholder (h, rawChild) {
  49560. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49561. return h('keep-alive', {
  49562. props: rawChild.componentOptions.propsData
  49563. })
  49564. }
  49565. }
  49566. function hasParentTransition (vnode) {
  49567. while ((vnode = vnode.parent)) {
  49568. if (vnode.data.transition) {
  49569. return true
  49570. }
  49571. }
  49572. }
  49573. function isSameChild (child, oldChild) {
  49574. return oldChild.key === child.key && oldChild.tag === child.tag
  49575. }
  49576. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49577. var isVShowDirective = function (d) { return d.name === 'show'; };
  49578. var Transition = {
  49579. name: 'transition',
  49580. props: transitionProps,
  49581. abstract: true,
  49582. render: function render (h) {
  49583. var this$1 = this;
  49584. var children = this.$slots.default;
  49585. if (!children) {
  49586. return
  49587. }
  49588. // filter out text nodes (possible whitespaces)
  49589. children = children.filter(isNotTextNode);
  49590. /* istanbul ignore if */
  49591. if (!children.length) {
  49592. return
  49593. }
  49594. // warn multiple elements
  49595. if (children.length > 1) {
  49596. warn(
  49597. '<transition> can only be used on a single element. Use ' +
  49598. '<transition-group> for lists.',
  49599. this.$parent
  49600. );
  49601. }
  49602. var mode = this.mode;
  49603. // warn invalid mode
  49604. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49605. ) {
  49606. warn(
  49607. 'invalid <transition> mode: ' + mode,
  49608. this.$parent
  49609. );
  49610. }
  49611. var rawChild = children[0];
  49612. // if this is a component root node and the component's
  49613. // parent container node also has transition, skip.
  49614. if (hasParentTransition(this.$vnode)) {
  49615. return rawChild
  49616. }
  49617. // apply transition data to child
  49618. // use getRealChild() to ignore abstract components e.g. keep-alive
  49619. var child = getRealChild(rawChild);
  49620. /* istanbul ignore if */
  49621. if (!child) {
  49622. return rawChild
  49623. }
  49624. if (this._leaving) {
  49625. return placeholder(h, rawChild)
  49626. }
  49627. // ensure a key that is unique to the vnode type and to this transition
  49628. // component instance. This key will be used to remove pending leaving nodes
  49629. // during entering.
  49630. var id = "__transition-" + (this._uid) + "-";
  49631. child.key = child.key == null
  49632. ? child.isComment
  49633. ? id + 'comment'
  49634. : id + child.tag
  49635. : isPrimitive(child.key)
  49636. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49637. : child.key;
  49638. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49639. var oldRawChild = this._vnode;
  49640. var oldChild = getRealChild(oldRawChild);
  49641. // mark v-show
  49642. // so that the transition module can hand over the control to the directive
  49643. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49644. child.data.show = true;
  49645. }
  49646. if (
  49647. oldChild &&
  49648. oldChild.data &&
  49649. !isSameChild(child, oldChild) &&
  49650. !isAsyncPlaceholder(oldChild) &&
  49651. // #6687 component root is a comment node
  49652. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49653. ) {
  49654. // replace old child transition data with fresh one
  49655. // important for dynamic transitions!
  49656. var oldData = oldChild.data.transition = extend({}, data);
  49657. // handle transition mode
  49658. if (mode === 'out-in') {
  49659. // return placeholder node and queue update when leave finishes
  49660. this._leaving = true;
  49661. mergeVNodeHook(oldData, 'afterLeave', function () {
  49662. this$1._leaving = false;
  49663. this$1.$forceUpdate();
  49664. });
  49665. return placeholder(h, rawChild)
  49666. } else if (mode === 'in-out') {
  49667. if (isAsyncPlaceholder(child)) {
  49668. return oldRawChild
  49669. }
  49670. var delayedLeave;
  49671. var performLeave = function () { delayedLeave(); };
  49672. mergeVNodeHook(data, 'afterEnter', performLeave);
  49673. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49674. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49675. }
  49676. }
  49677. return rawChild
  49678. }
  49679. };
  49680. /* */
  49681. var props = extend({
  49682. tag: String,
  49683. moveClass: String
  49684. }, transitionProps);
  49685. delete props.mode;
  49686. var TransitionGroup = {
  49687. props: props,
  49688. beforeMount: function beforeMount () {
  49689. var this$1 = this;
  49690. var update = this._update;
  49691. this._update = function (vnode, hydrating) {
  49692. var restoreActiveInstance = setActiveInstance(this$1);
  49693. // force removing pass
  49694. this$1.__patch__(
  49695. this$1._vnode,
  49696. this$1.kept,
  49697. false, // hydrating
  49698. true // removeOnly (!important, avoids unnecessary moves)
  49699. );
  49700. this$1._vnode = this$1.kept;
  49701. restoreActiveInstance();
  49702. update.call(this$1, vnode, hydrating);
  49703. };
  49704. },
  49705. render: function render (h) {
  49706. var tag = this.tag || this.$vnode.data.tag || 'span';
  49707. var map = Object.create(null);
  49708. var prevChildren = this.prevChildren = this.children;
  49709. var rawChildren = this.$slots.default || [];
  49710. var children = this.children = [];
  49711. var transitionData = extractTransitionData(this);
  49712. for (var i = 0; i < rawChildren.length; i++) {
  49713. var c = rawChildren[i];
  49714. if (c.tag) {
  49715. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49716. children.push(c);
  49717. map[c.key] = c
  49718. ;(c.data || (c.data = {})).transition = transitionData;
  49719. } else {
  49720. var opts = c.componentOptions;
  49721. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49722. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49723. }
  49724. }
  49725. }
  49726. if (prevChildren) {
  49727. var kept = [];
  49728. var removed = [];
  49729. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49730. var c$1 = prevChildren[i$1];
  49731. c$1.data.transition = transitionData;
  49732. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49733. if (map[c$1.key]) {
  49734. kept.push(c$1);
  49735. } else {
  49736. removed.push(c$1);
  49737. }
  49738. }
  49739. this.kept = h(tag, null, kept);
  49740. this.removed = removed;
  49741. }
  49742. return h(tag, null, children)
  49743. },
  49744. updated: function updated () {
  49745. var children = this.prevChildren;
  49746. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49747. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49748. return
  49749. }
  49750. // we divide the work into three loops to avoid mixing DOM reads and writes
  49751. // in each iteration - which helps prevent layout thrashing.
  49752. children.forEach(callPendingCbs);
  49753. children.forEach(recordPosition);
  49754. children.forEach(applyTranslation);
  49755. // force reflow to put everything in position
  49756. // assign to this to avoid being removed in tree-shaking
  49757. // $flow-disable-line
  49758. this._reflow = document.body.offsetHeight;
  49759. children.forEach(function (c) {
  49760. if (c.data.moved) {
  49761. var el = c.elm;
  49762. var s = el.style;
  49763. addTransitionClass(el, moveClass);
  49764. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49765. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49766. if (e && e.target !== el) {
  49767. return
  49768. }
  49769. if (!e || /transform$/.test(e.propertyName)) {
  49770. el.removeEventListener(transitionEndEvent, cb);
  49771. el._moveCb = null;
  49772. removeTransitionClass(el, moveClass);
  49773. }
  49774. });
  49775. }
  49776. });
  49777. },
  49778. methods: {
  49779. hasMove: function hasMove (el, moveClass) {
  49780. /* istanbul ignore if */
  49781. if (!hasTransition) {
  49782. return false
  49783. }
  49784. /* istanbul ignore if */
  49785. if (this._hasMove) {
  49786. return this._hasMove
  49787. }
  49788. // Detect whether an element with the move class applied has
  49789. // CSS transitions. Since the element may be inside an entering
  49790. // transition at this very moment, we make a clone of it and remove
  49791. // all other transition classes applied to ensure only the move class
  49792. // is applied.
  49793. var clone = el.cloneNode();
  49794. if (el._transitionClasses) {
  49795. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49796. }
  49797. addClass(clone, moveClass);
  49798. clone.style.display = 'none';
  49799. this.$el.appendChild(clone);
  49800. var info = getTransitionInfo(clone);
  49801. this.$el.removeChild(clone);
  49802. return (this._hasMove = info.hasTransform)
  49803. }
  49804. }
  49805. };
  49806. function callPendingCbs (c) {
  49807. /* istanbul ignore if */
  49808. if (c.elm._moveCb) {
  49809. c.elm._moveCb();
  49810. }
  49811. /* istanbul ignore if */
  49812. if (c.elm._enterCb) {
  49813. c.elm._enterCb();
  49814. }
  49815. }
  49816. function recordPosition (c) {
  49817. c.data.newPos = c.elm.getBoundingClientRect();
  49818. }
  49819. function applyTranslation (c) {
  49820. var oldPos = c.data.pos;
  49821. var newPos = c.data.newPos;
  49822. var dx = oldPos.left - newPos.left;
  49823. var dy = oldPos.top - newPos.top;
  49824. if (dx || dy) {
  49825. c.data.moved = true;
  49826. var s = c.elm.style;
  49827. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49828. s.transitionDuration = '0s';
  49829. }
  49830. }
  49831. var platformComponents = {
  49832. Transition: Transition,
  49833. TransitionGroup: TransitionGroup
  49834. };
  49835. /* */
  49836. // install platform specific utils
  49837. Vue.config.mustUseProp = mustUseProp;
  49838. Vue.config.isReservedTag = isReservedTag;
  49839. Vue.config.isReservedAttr = isReservedAttr;
  49840. Vue.config.getTagNamespace = getTagNamespace;
  49841. Vue.config.isUnknownElement = isUnknownElement;
  49842. // install platform runtime directives & components
  49843. extend(Vue.options.directives, platformDirectives);
  49844. extend(Vue.options.components, platformComponents);
  49845. // install platform patch function
  49846. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49847. // public mount method
  49848. Vue.prototype.$mount = function (
  49849. el,
  49850. hydrating
  49851. ) {
  49852. el = el && inBrowser ? query(el) : undefined;
  49853. return mountComponent(this, el, hydrating)
  49854. };
  49855. // devtools global hook
  49856. /* istanbul ignore next */
  49857. if (inBrowser) {
  49858. setTimeout(function () {
  49859. if (config.devtools) {
  49860. if (devtools) {
  49861. devtools.emit('init', Vue);
  49862. } else {
  49863. console[console.info ? 'info' : 'log'](
  49864. 'Download the Vue Devtools extension for a better development experience:\n' +
  49865. 'https://github.com/vuejs/vue-devtools'
  49866. );
  49867. }
  49868. }
  49869. if (config.productionTip !== false &&
  49870. typeof console !== 'undefined'
  49871. ) {
  49872. console[console.info ? 'info' : 'log'](
  49873. "You are running Vue in development mode.\n" +
  49874. "Make sure to turn on production mode when deploying for production.\n" +
  49875. "See more tips at https://vuejs.org/guide/deployment.html"
  49876. );
  49877. }
  49878. }, 0);
  49879. }
  49880. /* */
  49881. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  49882. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  49883. var buildRegex = cached(function (delimiters) {
  49884. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  49885. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  49886. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  49887. });
  49888. function parseText (
  49889. text,
  49890. delimiters
  49891. ) {
  49892. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  49893. if (!tagRE.test(text)) {
  49894. return
  49895. }
  49896. var tokens = [];
  49897. var rawTokens = [];
  49898. var lastIndex = tagRE.lastIndex = 0;
  49899. var match, index, tokenValue;
  49900. while ((match = tagRE.exec(text))) {
  49901. index = match.index;
  49902. // push text token
  49903. if (index > lastIndex) {
  49904. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  49905. tokens.push(JSON.stringify(tokenValue));
  49906. }
  49907. // tag token
  49908. var exp = parseFilters(match[1].trim());
  49909. tokens.push(("_s(" + exp + ")"));
  49910. rawTokens.push({ '@binding': exp });
  49911. lastIndex = index + match[0].length;
  49912. }
  49913. if (lastIndex < text.length) {
  49914. rawTokens.push(tokenValue = text.slice(lastIndex));
  49915. tokens.push(JSON.stringify(tokenValue));
  49916. }
  49917. return {
  49918. expression: tokens.join('+'),
  49919. tokens: rawTokens
  49920. }
  49921. }
  49922. /* */
  49923. function transformNode (el, options) {
  49924. var warn = options.warn || baseWarn;
  49925. var staticClass = getAndRemoveAttr(el, 'class');
  49926. if (staticClass) {
  49927. var res = parseText(staticClass, options.delimiters);
  49928. if (res) {
  49929. warn(
  49930. "class=\"" + staticClass + "\": " +
  49931. 'Interpolation inside attributes has been removed. ' +
  49932. 'Use v-bind or the colon shorthand instead. For example, ' +
  49933. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  49934. el.rawAttrsMap['class']
  49935. );
  49936. }
  49937. }
  49938. if (staticClass) {
  49939. el.staticClass = JSON.stringify(staticClass);
  49940. }
  49941. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  49942. if (classBinding) {
  49943. el.classBinding = classBinding;
  49944. }
  49945. }
  49946. function genData (el) {
  49947. var data = '';
  49948. if (el.staticClass) {
  49949. data += "staticClass:" + (el.staticClass) + ",";
  49950. }
  49951. if (el.classBinding) {
  49952. data += "class:" + (el.classBinding) + ",";
  49953. }
  49954. return data
  49955. }
  49956. var klass$1 = {
  49957. staticKeys: ['staticClass'],
  49958. transformNode: transformNode,
  49959. genData: genData
  49960. };
  49961. /* */
  49962. function transformNode$1 (el, options) {
  49963. var warn = options.warn || baseWarn;
  49964. var staticStyle = getAndRemoveAttr(el, 'style');
  49965. if (staticStyle) {
  49966. /* istanbul ignore if */
  49967. {
  49968. var res = parseText(staticStyle, options.delimiters);
  49969. if (res) {
  49970. warn(
  49971. "style=\"" + staticStyle + "\": " +
  49972. 'Interpolation inside attributes has been removed. ' +
  49973. 'Use v-bind or the colon shorthand instead. For example, ' +
  49974. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  49975. el.rawAttrsMap['style']
  49976. );
  49977. }
  49978. }
  49979. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  49980. }
  49981. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  49982. if (styleBinding) {
  49983. el.styleBinding = styleBinding;
  49984. }
  49985. }
  49986. function genData$1 (el) {
  49987. var data = '';
  49988. if (el.staticStyle) {
  49989. data += "staticStyle:" + (el.staticStyle) + ",";
  49990. }
  49991. if (el.styleBinding) {
  49992. data += "style:(" + (el.styleBinding) + "),";
  49993. }
  49994. return data
  49995. }
  49996. var style$1 = {
  49997. staticKeys: ['staticStyle'],
  49998. transformNode: transformNode$1,
  49999. genData: genData$1
  50000. };
  50001. /* */
  50002. var decoder;
  50003. var he = {
  50004. decode: function decode (html) {
  50005. decoder = decoder || document.createElement('div');
  50006. decoder.innerHTML = html;
  50007. return decoder.textContent
  50008. }
  50009. };
  50010. /* */
  50011. var isUnaryTag = makeMap(
  50012. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50013. 'link,meta,param,source,track,wbr'
  50014. );
  50015. // Elements that you can, intentionally, leave open
  50016. // (and which close themselves)
  50017. var canBeLeftOpenTag = makeMap(
  50018. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50019. );
  50020. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50021. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50022. var isNonPhrasingTag = makeMap(
  50023. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50024. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50025. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50026. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50027. 'title,tr,track'
  50028. );
  50029. /**
  50030. * Not type-checking this file because it's mostly vendor code.
  50031. */
  50032. // Regular Expressions for parsing tags and attributes
  50033. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50034. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50035. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50036. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50037. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50038. var startTagClose = /^\s*(\/?)>/;
  50039. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50040. var doctype = /^<!DOCTYPE [^>]+>/i;
  50041. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50042. var comment = /^<!\--/;
  50043. var conditionalComment = /^<!\[/;
  50044. // Special Elements (can contain anything)
  50045. var isPlainTextElement = makeMap('script,style,textarea', true);
  50046. var reCache = {};
  50047. var decodingMap = {
  50048. '&lt;': '<',
  50049. '&gt;': '>',
  50050. '&quot;': '"',
  50051. '&amp;': '&',
  50052. '&#10;': '\n',
  50053. '&#9;': '\t',
  50054. '&#39;': "'"
  50055. };
  50056. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50057. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50058. // #5992
  50059. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50060. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50061. function decodeAttr (value, shouldDecodeNewlines) {
  50062. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50063. return value.replace(re, function (match) { return decodingMap[match]; })
  50064. }
  50065. function parseHTML (html, options) {
  50066. var stack = [];
  50067. var expectHTML = options.expectHTML;
  50068. var isUnaryTag$$1 = options.isUnaryTag || no;
  50069. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50070. var index = 0;
  50071. var last, lastTag;
  50072. while (html) {
  50073. last = html;
  50074. // Make sure we're not in a plaintext content element like script/style
  50075. if (!lastTag || !isPlainTextElement(lastTag)) {
  50076. var textEnd = html.indexOf('<');
  50077. if (textEnd === 0) {
  50078. // Comment:
  50079. if (comment.test(html)) {
  50080. var commentEnd = html.indexOf('-->');
  50081. if (commentEnd >= 0) {
  50082. if (options.shouldKeepComment) {
  50083. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50084. }
  50085. advance(commentEnd + 3);
  50086. continue
  50087. }
  50088. }
  50089. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50090. if (conditionalComment.test(html)) {
  50091. var conditionalEnd = html.indexOf(']>');
  50092. if (conditionalEnd >= 0) {
  50093. advance(conditionalEnd + 2);
  50094. continue
  50095. }
  50096. }
  50097. // Doctype:
  50098. var doctypeMatch = html.match(doctype);
  50099. if (doctypeMatch) {
  50100. advance(doctypeMatch[0].length);
  50101. continue
  50102. }
  50103. // End tag:
  50104. var endTagMatch = html.match(endTag);
  50105. if (endTagMatch) {
  50106. var curIndex = index;
  50107. advance(endTagMatch[0].length);
  50108. parseEndTag(endTagMatch[1], curIndex, index);
  50109. continue
  50110. }
  50111. // Start tag:
  50112. var startTagMatch = parseStartTag();
  50113. if (startTagMatch) {
  50114. handleStartTag(startTagMatch);
  50115. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50116. advance(1);
  50117. }
  50118. continue
  50119. }
  50120. }
  50121. var text = (void 0), rest = (void 0), next = (void 0);
  50122. if (textEnd >= 0) {
  50123. rest = html.slice(textEnd);
  50124. while (
  50125. !endTag.test(rest) &&
  50126. !startTagOpen.test(rest) &&
  50127. !comment.test(rest) &&
  50128. !conditionalComment.test(rest)
  50129. ) {
  50130. // < in plain text, be forgiving and treat it as text
  50131. next = rest.indexOf('<', 1);
  50132. if (next < 0) { break }
  50133. textEnd += next;
  50134. rest = html.slice(textEnd);
  50135. }
  50136. text = html.substring(0, textEnd);
  50137. }
  50138. if (textEnd < 0) {
  50139. text = html;
  50140. }
  50141. if (text) {
  50142. advance(text.length);
  50143. }
  50144. if (options.chars && text) {
  50145. options.chars(text, index - text.length, index);
  50146. }
  50147. } else {
  50148. var endTagLength = 0;
  50149. var stackedTag = lastTag.toLowerCase();
  50150. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50151. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50152. endTagLength = endTag.length;
  50153. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50154. text = text
  50155. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50156. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50157. }
  50158. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50159. text = text.slice(1);
  50160. }
  50161. if (options.chars) {
  50162. options.chars(text);
  50163. }
  50164. return ''
  50165. });
  50166. index += html.length - rest$1.length;
  50167. html = rest$1;
  50168. parseEndTag(stackedTag, index - endTagLength, index);
  50169. }
  50170. if (html === last) {
  50171. options.chars && options.chars(html);
  50172. if (!stack.length && options.warn) {
  50173. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50174. }
  50175. break
  50176. }
  50177. }
  50178. // Clean up any remaining tags
  50179. parseEndTag();
  50180. function advance (n) {
  50181. index += n;
  50182. html = html.substring(n);
  50183. }
  50184. function parseStartTag () {
  50185. var start = html.match(startTagOpen);
  50186. if (start) {
  50187. var match = {
  50188. tagName: start[1],
  50189. attrs: [],
  50190. start: index
  50191. };
  50192. advance(start[0].length);
  50193. var end, attr;
  50194. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50195. attr.start = index;
  50196. advance(attr[0].length);
  50197. attr.end = index;
  50198. match.attrs.push(attr);
  50199. }
  50200. if (end) {
  50201. match.unarySlash = end[1];
  50202. advance(end[0].length);
  50203. match.end = index;
  50204. return match
  50205. }
  50206. }
  50207. }
  50208. function handleStartTag (match) {
  50209. var tagName = match.tagName;
  50210. var unarySlash = match.unarySlash;
  50211. if (expectHTML) {
  50212. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50213. parseEndTag(lastTag);
  50214. }
  50215. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50216. parseEndTag(tagName);
  50217. }
  50218. }
  50219. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50220. var l = match.attrs.length;
  50221. var attrs = new Array(l);
  50222. for (var i = 0; i < l; i++) {
  50223. var args = match.attrs[i];
  50224. var value = args[3] || args[4] || args[5] || '';
  50225. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50226. ? options.shouldDecodeNewlinesForHref
  50227. : options.shouldDecodeNewlines;
  50228. attrs[i] = {
  50229. name: args[1],
  50230. value: decodeAttr(value, shouldDecodeNewlines)
  50231. };
  50232. if (options.outputSourceRange) {
  50233. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50234. attrs[i].end = args.end;
  50235. }
  50236. }
  50237. if (!unary) {
  50238. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50239. lastTag = tagName;
  50240. }
  50241. if (options.start) {
  50242. options.start(tagName, attrs, unary, match.start, match.end);
  50243. }
  50244. }
  50245. function parseEndTag (tagName, start, end) {
  50246. var pos, lowerCasedTagName;
  50247. if (start == null) { start = index; }
  50248. if (end == null) { end = index; }
  50249. // Find the closest opened tag of the same type
  50250. if (tagName) {
  50251. lowerCasedTagName = tagName.toLowerCase();
  50252. for (pos = stack.length - 1; pos >= 0; pos--) {
  50253. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50254. break
  50255. }
  50256. }
  50257. } else {
  50258. // If no tag name is provided, clean shop
  50259. pos = 0;
  50260. }
  50261. if (pos >= 0) {
  50262. // Close all the open elements, up the stack
  50263. for (var i = stack.length - 1; i >= pos; i--) {
  50264. if (i > pos || !tagName &&
  50265. options.warn
  50266. ) {
  50267. options.warn(
  50268. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50269. { start: stack[i].start, end: stack[i].end }
  50270. );
  50271. }
  50272. if (options.end) {
  50273. options.end(stack[i].tag, start, end);
  50274. }
  50275. }
  50276. // Remove the open elements from the stack
  50277. stack.length = pos;
  50278. lastTag = pos && stack[pos - 1].tag;
  50279. } else if (lowerCasedTagName === 'br') {
  50280. if (options.start) {
  50281. options.start(tagName, [], true, start, end);
  50282. }
  50283. } else if (lowerCasedTagName === 'p') {
  50284. if (options.start) {
  50285. options.start(tagName, [], false, start, end);
  50286. }
  50287. if (options.end) {
  50288. options.end(tagName, start, end);
  50289. }
  50290. }
  50291. }
  50292. }
  50293. /* */
  50294. var onRE = /^@|^v-on:/;
  50295. var dirRE = /^v-|^@|^:|^#/;
  50296. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50297. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50298. var stripParensRE = /^\(|\)$/g;
  50299. var dynamicArgRE = /^\[.*\]$/;
  50300. var argRE = /:(.*)$/;
  50301. var bindRE = /^:|^\.|^v-bind:/;
  50302. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50303. var slotRE = /^v-slot(:|$)|^#/;
  50304. var lineBreakRE = /[\r\n]/;
  50305. var whitespaceRE$1 = /\s+/g;
  50306. var invalidAttributeRE = /[\s"'<>\/=]/;
  50307. var decodeHTMLCached = cached(he.decode);
  50308. var emptySlotScopeToken = "_empty_";
  50309. // configurable state
  50310. var warn$2;
  50311. var delimiters;
  50312. var transforms;
  50313. var preTransforms;
  50314. var postTransforms;
  50315. var platformIsPreTag;
  50316. var platformMustUseProp;
  50317. var platformGetTagNamespace;
  50318. var maybeComponent;
  50319. function createASTElement (
  50320. tag,
  50321. attrs,
  50322. parent
  50323. ) {
  50324. return {
  50325. type: 1,
  50326. tag: tag,
  50327. attrsList: attrs,
  50328. attrsMap: makeAttrsMap(attrs),
  50329. rawAttrsMap: {},
  50330. parent: parent,
  50331. children: []
  50332. }
  50333. }
  50334. /**
  50335. * Convert HTML string to AST.
  50336. */
  50337. function parse (
  50338. template,
  50339. options
  50340. ) {
  50341. warn$2 = options.warn || baseWarn;
  50342. platformIsPreTag = options.isPreTag || no;
  50343. platformMustUseProp = options.mustUseProp || no;
  50344. platformGetTagNamespace = options.getTagNamespace || no;
  50345. var isReservedTag = options.isReservedTag || no;
  50346. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50347. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50348. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50349. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50350. delimiters = options.delimiters;
  50351. var stack = [];
  50352. var preserveWhitespace = options.preserveWhitespace !== false;
  50353. var whitespaceOption = options.whitespace;
  50354. var root;
  50355. var currentParent;
  50356. var inVPre = false;
  50357. var inPre = false;
  50358. var warned = false;
  50359. function warnOnce (msg, range) {
  50360. if (!warned) {
  50361. warned = true;
  50362. warn$2(msg, range);
  50363. }
  50364. }
  50365. function closeElement (element) {
  50366. trimEndingWhitespace(element);
  50367. if (!inVPre && !element.processed) {
  50368. element = processElement(element, options);
  50369. }
  50370. // tree management
  50371. if (!stack.length && element !== root) {
  50372. // allow root elements with v-if, v-else-if and v-else
  50373. if (root.if && (element.elseif || element.else)) {
  50374. {
  50375. checkRootConstraints(element);
  50376. }
  50377. addIfCondition(root, {
  50378. exp: element.elseif,
  50379. block: element
  50380. });
  50381. } else {
  50382. warnOnce(
  50383. "Component template should contain exactly one root element. " +
  50384. "If you are using v-if on multiple elements, " +
  50385. "use v-else-if to chain them instead.",
  50386. { start: element.start }
  50387. );
  50388. }
  50389. }
  50390. if (currentParent && !element.forbidden) {
  50391. if (element.elseif || element.else) {
  50392. processIfConditions(element, currentParent);
  50393. } else {
  50394. if (element.slotScope) {
  50395. // scoped slot
  50396. // keep it in the children list so that v-else(-if) conditions can
  50397. // find it as the prev node.
  50398. var name = element.slotTarget || '"default"'
  50399. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50400. }
  50401. currentParent.children.push(element);
  50402. element.parent = currentParent;
  50403. }
  50404. }
  50405. // final children cleanup
  50406. // filter out scoped slots
  50407. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50408. // remove trailing whitespace node again
  50409. trimEndingWhitespace(element);
  50410. // check pre state
  50411. if (element.pre) {
  50412. inVPre = false;
  50413. }
  50414. if (platformIsPreTag(element.tag)) {
  50415. inPre = false;
  50416. }
  50417. // apply post-transforms
  50418. for (var i = 0; i < postTransforms.length; i++) {
  50419. postTransforms[i](element, options);
  50420. }
  50421. }
  50422. function trimEndingWhitespace (el) {
  50423. // remove trailing whitespace node
  50424. if (!inPre) {
  50425. var lastNode;
  50426. while (
  50427. (lastNode = el.children[el.children.length - 1]) &&
  50428. lastNode.type === 3 &&
  50429. lastNode.text === ' '
  50430. ) {
  50431. el.children.pop();
  50432. }
  50433. }
  50434. }
  50435. function checkRootConstraints (el) {
  50436. if (el.tag === 'slot' || el.tag === 'template') {
  50437. warnOnce(
  50438. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50439. 'contain multiple nodes.',
  50440. { start: el.start }
  50441. );
  50442. }
  50443. if (el.attrsMap.hasOwnProperty('v-for')) {
  50444. warnOnce(
  50445. 'Cannot use v-for on stateful component root element because ' +
  50446. 'it renders multiple elements.',
  50447. el.rawAttrsMap['v-for']
  50448. );
  50449. }
  50450. }
  50451. parseHTML(template, {
  50452. warn: warn$2,
  50453. expectHTML: options.expectHTML,
  50454. isUnaryTag: options.isUnaryTag,
  50455. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50456. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50457. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50458. shouldKeepComment: options.comments,
  50459. outputSourceRange: options.outputSourceRange,
  50460. start: function start (tag, attrs, unary, start$1, end) {
  50461. // check namespace.
  50462. // inherit parent ns if there is one
  50463. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50464. // handle IE svg bug
  50465. /* istanbul ignore if */
  50466. if (isIE && ns === 'svg') {
  50467. attrs = guardIESVGBug(attrs);
  50468. }
  50469. var element = createASTElement(tag, attrs, currentParent);
  50470. if (ns) {
  50471. element.ns = ns;
  50472. }
  50473. {
  50474. if (options.outputSourceRange) {
  50475. element.start = start$1;
  50476. element.end = end;
  50477. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50478. cumulated[attr.name] = attr;
  50479. return cumulated
  50480. }, {});
  50481. }
  50482. attrs.forEach(function (attr) {
  50483. if (invalidAttributeRE.test(attr.name)) {
  50484. warn$2(
  50485. "Invalid dynamic argument expression: attribute names cannot contain " +
  50486. "spaces, quotes, <, >, / or =.",
  50487. {
  50488. start: attr.start + attr.name.indexOf("["),
  50489. end: attr.start + attr.name.length
  50490. }
  50491. );
  50492. }
  50493. });
  50494. }
  50495. if (isForbiddenTag(element) && !isServerRendering()) {
  50496. element.forbidden = true;
  50497. warn$2(
  50498. 'Templates should only be responsible for mapping the state to the ' +
  50499. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50500. "<" + tag + ">" + ', as they will not be parsed.',
  50501. { start: element.start }
  50502. );
  50503. }
  50504. // apply pre-transforms
  50505. for (var i = 0; i < preTransforms.length; i++) {
  50506. element = preTransforms[i](element, options) || element;
  50507. }
  50508. if (!inVPre) {
  50509. processPre(element);
  50510. if (element.pre) {
  50511. inVPre = true;
  50512. }
  50513. }
  50514. if (platformIsPreTag(element.tag)) {
  50515. inPre = true;
  50516. }
  50517. if (inVPre) {
  50518. processRawAttrs(element);
  50519. } else if (!element.processed) {
  50520. // structural directives
  50521. processFor(element);
  50522. processIf(element);
  50523. processOnce(element);
  50524. }
  50525. if (!root) {
  50526. root = element;
  50527. {
  50528. checkRootConstraints(root);
  50529. }
  50530. }
  50531. if (!unary) {
  50532. currentParent = element;
  50533. stack.push(element);
  50534. } else {
  50535. closeElement(element);
  50536. }
  50537. },
  50538. end: function end (tag, start, end$1) {
  50539. var element = stack[stack.length - 1];
  50540. // pop stack
  50541. stack.length -= 1;
  50542. currentParent = stack[stack.length - 1];
  50543. if (options.outputSourceRange) {
  50544. element.end = end$1;
  50545. }
  50546. closeElement(element);
  50547. },
  50548. chars: function chars (text, start, end) {
  50549. if (!currentParent) {
  50550. {
  50551. if (text === template) {
  50552. warnOnce(
  50553. 'Component template requires a root element, rather than just text.',
  50554. { start: start }
  50555. );
  50556. } else if ((text = text.trim())) {
  50557. warnOnce(
  50558. ("text \"" + text + "\" outside root element will be ignored."),
  50559. { start: start }
  50560. );
  50561. }
  50562. }
  50563. return
  50564. }
  50565. // IE textarea placeholder bug
  50566. /* istanbul ignore if */
  50567. if (isIE &&
  50568. currentParent.tag === 'textarea' &&
  50569. currentParent.attrsMap.placeholder === text
  50570. ) {
  50571. return
  50572. }
  50573. var children = currentParent.children;
  50574. if (inPre || text.trim()) {
  50575. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50576. } else if (!children.length) {
  50577. // remove the whitespace-only node right after an opening tag
  50578. text = '';
  50579. } else if (whitespaceOption) {
  50580. if (whitespaceOption === 'condense') {
  50581. // in condense mode, remove the whitespace node if it contains
  50582. // line break, otherwise condense to a single space
  50583. text = lineBreakRE.test(text) ? '' : ' ';
  50584. } else {
  50585. text = ' ';
  50586. }
  50587. } else {
  50588. text = preserveWhitespace ? ' ' : '';
  50589. }
  50590. if (text) {
  50591. if (!inPre && whitespaceOption === 'condense') {
  50592. // condense consecutive whitespaces into single space
  50593. text = text.replace(whitespaceRE$1, ' ');
  50594. }
  50595. var res;
  50596. var child;
  50597. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50598. child = {
  50599. type: 2,
  50600. expression: res.expression,
  50601. tokens: res.tokens,
  50602. text: text
  50603. };
  50604. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50605. child = {
  50606. type: 3,
  50607. text: text
  50608. };
  50609. }
  50610. if (child) {
  50611. if (options.outputSourceRange) {
  50612. child.start = start;
  50613. child.end = end;
  50614. }
  50615. children.push(child);
  50616. }
  50617. }
  50618. },
  50619. comment: function comment (text, start, end) {
  50620. // adding anyting as a sibling to the root node is forbidden
  50621. // comments should still be allowed, but ignored
  50622. if (currentParent) {
  50623. var child = {
  50624. type: 3,
  50625. text: text,
  50626. isComment: true
  50627. };
  50628. if (options.outputSourceRange) {
  50629. child.start = start;
  50630. child.end = end;
  50631. }
  50632. currentParent.children.push(child);
  50633. }
  50634. }
  50635. });
  50636. return root
  50637. }
  50638. function processPre (el) {
  50639. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50640. el.pre = true;
  50641. }
  50642. }
  50643. function processRawAttrs (el) {
  50644. var list = el.attrsList;
  50645. var len = list.length;
  50646. if (len) {
  50647. var attrs = el.attrs = new Array(len);
  50648. for (var i = 0; i < len; i++) {
  50649. attrs[i] = {
  50650. name: list[i].name,
  50651. value: JSON.stringify(list[i].value)
  50652. };
  50653. if (list[i].start != null) {
  50654. attrs[i].start = list[i].start;
  50655. attrs[i].end = list[i].end;
  50656. }
  50657. }
  50658. } else if (!el.pre) {
  50659. // non root node in pre blocks with no attributes
  50660. el.plain = true;
  50661. }
  50662. }
  50663. function processElement (
  50664. element,
  50665. options
  50666. ) {
  50667. processKey(element);
  50668. // determine whether this is a plain element after
  50669. // removing structural attributes
  50670. element.plain = (
  50671. !element.key &&
  50672. !element.scopedSlots &&
  50673. !element.attrsList.length
  50674. );
  50675. processRef(element);
  50676. processSlotContent(element);
  50677. processSlotOutlet(element);
  50678. processComponent(element);
  50679. for (var i = 0; i < transforms.length; i++) {
  50680. element = transforms[i](element, options) || element;
  50681. }
  50682. processAttrs(element);
  50683. return element
  50684. }
  50685. function processKey (el) {
  50686. var exp = getBindingAttr(el, 'key');
  50687. if (exp) {
  50688. {
  50689. if (el.tag === 'template') {
  50690. warn$2(
  50691. "<template> cannot be keyed. Place the key on real elements instead.",
  50692. getRawBindingAttr(el, 'key')
  50693. );
  50694. }
  50695. if (el.for) {
  50696. var iterator = el.iterator2 || el.iterator1;
  50697. var parent = el.parent;
  50698. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50699. warn$2(
  50700. "Do not use v-for index as key on <transition-group> children, " +
  50701. "this is the same as not using keys.",
  50702. getRawBindingAttr(el, 'key'),
  50703. true /* tip */
  50704. );
  50705. }
  50706. }
  50707. }
  50708. el.key = exp;
  50709. }
  50710. }
  50711. function processRef (el) {
  50712. var ref = getBindingAttr(el, 'ref');
  50713. if (ref) {
  50714. el.ref = ref;
  50715. el.refInFor = checkInFor(el);
  50716. }
  50717. }
  50718. function processFor (el) {
  50719. var exp;
  50720. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50721. var res = parseFor(exp);
  50722. if (res) {
  50723. extend(el, res);
  50724. } else {
  50725. warn$2(
  50726. ("Invalid v-for expression: " + exp),
  50727. el.rawAttrsMap['v-for']
  50728. );
  50729. }
  50730. }
  50731. }
  50732. function parseFor (exp) {
  50733. var inMatch = exp.match(forAliasRE);
  50734. if (!inMatch) { return }
  50735. var res = {};
  50736. res.for = inMatch[2].trim();
  50737. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50738. var iteratorMatch = alias.match(forIteratorRE);
  50739. if (iteratorMatch) {
  50740. res.alias = alias.replace(forIteratorRE, '').trim();
  50741. res.iterator1 = iteratorMatch[1].trim();
  50742. if (iteratorMatch[2]) {
  50743. res.iterator2 = iteratorMatch[2].trim();
  50744. }
  50745. } else {
  50746. res.alias = alias;
  50747. }
  50748. return res
  50749. }
  50750. function processIf (el) {
  50751. var exp = getAndRemoveAttr(el, 'v-if');
  50752. if (exp) {
  50753. el.if = exp;
  50754. addIfCondition(el, {
  50755. exp: exp,
  50756. block: el
  50757. });
  50758. } else {
  50759. if (getAndRemoveAttr(el, 'v-else') != null) {
  50760. el.else = true;
  50761. }
  50762. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50763. if (elseif) {
  50764. el.elseif = elseif;
  50765. }
  50766. }
  50767. }
  50768. function processIfConditions (el, parent) {
  50769. var prev = findPrevElement(parent.children);
  50770. if (prev && prev.if) {
  50771. addIfCondition(prev, {
  50772. exp: el.elseif,
  50773. block: el
  50774. });
  50775. } else {
  50776. warn$2(
  50777. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50778. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50779. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50780. );
  50781. }
  50782. }
  50783. function findPrevElement (children) {
  50784. var i = children.length;
  50785. while (i--) {
  50786. if (children[i].type === 1) {
  50787. return children[i]
  50788. } else {
  50789. if (children[i].text !== ' ') {
  50790. warn$2(
  50791. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50792. "will be ignored.",
  50793. children[i]
  50794. );
  50795. }
  50796. children.pop();
  50797. }
  50798. }
  50799. }
  50800. function addIfCondition (el, condition) {
  50801. if (!el.ifConditions) {
  50802. el.ifConditions = [];
  50803. }
  50804. el.ifConditions.push(condition);
  50805. }
  50806. function processOnce (el) {
  50807. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50808. if (once$$1 != null) {
  50809. el.once = true;
  50810. }
  50811. }
  50812. // handle content being passed to a component as slot,
  50813. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50814. function processSlotContent (el) {
  50815. var slotScope;
  50816. if (el.tag === 'template') {
  50817. slotScope = getAndRemoveAttr(el, 'scope');
  50818. /* istanbul ignore if */
  50819. if (slotScope) {
  50820. warn$2(
  50821. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50822. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50823. "can also be used on plain elements in addition to <template> to " +
  50824. "denote scoped slots.",
  50825. el.rawAttrsMap['scope'],
  50826. true
  50827. );
  50828. }
  50829. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50830. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50831. /* istanbul ignore if */
  50832. if (el.attrsMap['v-for']) {
  50833. warn$2(
  50834. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50835. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50836. "scoped slot to make it clearer.",
  50837. el.rawAttrsMap['slot-scope'],
  50838. true
  50839. );
  50840. }
  50841. el.slotScope = slotScope;
  50842. }
  50843. // slot="xxx"
  50844. var slotTarget = getBindingAttr(el, 'slot');
  50845. if (slotTarget) {
  50846. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50847. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50848. // preserve slot as an attribute for native shadow DOM compat
  50849. // only for non-scoped slots.
  50850. if (el.tag !== 'template' && !el.slotScope) {
  50851. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50852. }
  50853. }
  50854. // 2.6 v-slot syntax
  50855. {
  50856. if (el.tag === 'template') {
  50857. // v-slot on <template>
  50858. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  50859. if (slotBinding) {
  50860. {
  50861. if (el.slotTarget || el.slotScope) {
  50862. warn$2(
  50863. "Unexpected mixed usage of different slot syntaxes.",
  50864. el
  50865. );
  50866. }
  50867. if (el.parent && !maybeComponent(el.parent)) {
  50868. warn$2(
  50869. "<template v-slot> can only appear at the root level inside " +
  50870. "the receiving component",
  50871. el
  50872. );
  50873. }
  50874. }
  50875. var ref = getSlotName(slotBinding);
  50876. var name = ref.name;
  50877. var dynamic = ref.dynamic;
  50878. el.slotTarget = name;
  50879. el.slotTargetDynamic = dynamic;
  50880. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  50881. }
  50882. } else {
  50883. // v-slot on component, denotes default slot
  50884. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  50885. if (slotBinding$1) {
  50886. {
  50887. if (!maybeComponent(el)) {
  50888. warn$2(
  50889. "v-slot can only be used on components or <template>.",
  50890. slotBinding$1
  50891. );
  50892. }
  50893. if (el.slotScope || el.slotTarget) {
  50894. warn$2(
  50895. "Unexpected mixed usage of different slot syntaxes.",
  50896. el
  50897. );
  50898. }
  50899. if (el.scopedSlots) {
  50900. warn$2(
  50901. "To avoid scope ambiguity, the default slot should also use " +
  50902. "<template> syntax when there are other named slots.",
  50903. slotBinding$1
  50904. );
  50905. }
  50906. }
  50907. // add the component's children to its default slot
  50908. var slots = el.scopedSlots || (el.scopedSlots = {});
  50909. var ref$1 = getSlotName(slotBinding$1);
  50910. var name$1 = ref$1.name;
  50911. var dynamic$1 = ref$1.dynamic;
  50912. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  50913. slotContainer.slotTarget = name$1;
  50914. slotContainer.slotTargetDynamic = dynamic$1;
  50915. slotContainer.children = el.children.filter(function (c) {
  50916. if (!c.slotScope) {
  50917. c.parent = slotContainer;
  50918. return true
  50919. }
  50920. });
  50921. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  50922. // remove children as they are returned from scopedSlots now
  50923. el.children = [];
  50924. // mark el non-plain so data gets generated
  50925. el.plain = false;
  50926. }
  50927. }
  50928. }
  50929. }
  50930. function getSlotName (binding) {
  50931. var name = binding.name.replace(slotRE, '');
  50932. if (!name) {
  50933. if (binding.name[0] !== '#') {
  50934. name = 'default';
  50935. } else {
  50936. warn$2(
  50937. "v-slot shorthand syntax requires a slot name.",
  50938. binding
  50939. );
  50940. }
  50941. }
  50942. return dynamicArgRE.test(name)
  50943. // dynamic [name]
  50944. ? { name: name.slice(1, -1), dynamic: true }
  50945. // static name
  50946. : { name: ("\"" + name + "\""), dynamic: false }
  50947. }
  50948. // handle <slot/> outlets
  50949. function processSlotOutlet (el) {
  50950. if (el.tag === 'slot') {
  50951. el.slotName = getBindingAttr(el, 'name');
  50952. if (el.key) {
  50953. warn$2(
  50954. "`key` does not work on <slot> because slots are abstract outlets " +
  50955. "and can possibly expand into multiple elements. " +
  50956. "Use the key on a wrapping element instead.",
  50957. getRawBindingAttr(el, 'key')
  50958. );
  50959. }
  50960. }
  50961. }
  50962. function processComponent (el) {
  50963. var binding;
  50964. if ((binding = getBindingAttr(el, 'is'))) {
  50965. el.component = binding;
  50966. }
  50967. if (getAndRemoveAttr(el, 'inline-template') != null) {
  50968. el.inlineTemplate = true;
  50969. }
  50970. }
  50971. function processAttrs (el) {
  50972. var list = el.attrsList;
  50973. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  50974. for (i = 0, l = list.length; i < l; i++) {
  50975. name = rawName = list[i].name;
  50976. value = list[i].value;
  50977. if (dirRE.test(name)) {
  50978. // mark element as dynamic
  50979. el.hasBindings = true;
  50980. // modifiers
  50981. modifiers = parseModifiers(name.replace(dirRE, ''));
  50982. // support .foo shorthand syntax for the .prop modifier
  50983. if (modifiers) {
  50984. name = name.replace(modifierRE, '');
  50985. }
  50986. if (bindRE.test(name)) { // v-bind
  50987. name = name.replace(bindRE, '');
  50988. value = parseFilters(value);
  50989. isDynamic = dynamicArgRE.test(name);
  50990. if (isDynamic) {
  50991. name = name.slice(1, -1);
  50992. }
  50993. if (
  50994. value.trim().length === 0
  50995. ) {
  50996. warn$2(
  50997. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  50998. );
  50999. }
  51000. if (modifiers) {
  51001. if (modifiers.prop && !isDynamic) {
  51002. name = camelize(name);
  51003. if (name === 'innerHtml') { name = 'innerHTML'; }
  51004. }
  51005. if (modifiers.camel && !isDynamic) {
  51006. name = camelize(name);
  51007. }
  51008. if (modifiers.sync) {
  51009. syncGen = genAssignmentCode(value, "$event");
  51010. if (!isDynamic) {
  51011. addHandler(
  51012. el,
  51013. ("update:" + (camelize(name))),
  51014. syncGen,
  51015. null,
  51016. false,
  51017. warn$2,
  51018. list[i]
  51019. );
  51020. if (hyphenate(name) !== camelize(name)) {
  51021. addHandler(
  51022. el,
  51023. ("update:" + (hyphenate(name))),
  51024. syncGen,
  51025. null,
  51026. false,
  51027. warn$2,
  51028. list[i]
  51029. );
  51030. }
  51031. } else {
  51032. // handler w/ dynamic event name
  51033. addHandler(
  51034. el,
  51035. ("\"update:\"+(" + name + ")"),
  51036. syncGen,
  51037. null,
  51038. false,
  51039. warn$2,
  51040. list[i],
  51041. true // dynamic
  51042. );
  51043. }
  51044. }
  51045. }
  51046. if ((modifiers && modifiers.prop) || (
  51047. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51048. )) {
  51049. addProp(el, name, value, list[i], isDynamic);
  51050. } else {
  51051. addAttr(el, name, value, list[i], isDynamic);
  51052. }
  51053. } else if (onRE.test(name)) { // v-on
  51054. name = name.replace(onRE, '');
  51055. isDynamic = dynamicArgRE.test(name);
  51056. if (isDynamic) {
  51057. name = name.slice(1, -1);
  51058. }
  51059. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51060. } else { // normal directives
  51061. name = name.replace(dirRE, '');
  51062. // parse arg
  51063. var argMatch = name.match(argRE);
  51064. var arg = argMatch && argMatch[1];
  51065. isDynamic = false;
  51066. if (arg) {
  51067. name = name.slice(0, -(arg.length + 1));
  51068. if (dynamicArgRE.test(arg)) {
  51069. arg = arg.slice(1, -1);
  51070. isDynamic = true;
  51071. }
  51072. }
  51073. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51074. if (name === 'model') {
  51075. checkForAliasModel(el, value);
  51076. }
  51077. }
  51078. } else {
  51079. // literal attribute
  51080. {
  51081. var res = parseText(value, delimiters);
  51082. if (res) {
  51083. warn$2(
  51084. name + "=\"" + value + "\": " +
  51085. 'Interpolation inside attributes has been removed. ' +
  51086. 'Use v-bind or the colon shorthand instead. For example, ' +
  51087. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51088. list[i]
  51089. );
  51090. }
  51091. }
  51092. addAttr(el, name, JSON.stringify(value), list[i]);
  51093. // #6887 firefox doesn't update muted state if set via attribute
  51094. // even immediately after element creation
  51095. if (!el.component &&
  51096. name === 'muted' &&
  51097. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51098. addProp(el, name, 'true', list[i]);
  51099. }
  51100. }
  51101. }
  51102. }
  51103. function checkInFor (el) {
  51104. var parent = el;
  51105. while (parent) {
  51106. if (parent.for !== undefined) {
  51107. return true
  51108. }
  51109. parent = parent.parent;
  51110. }
  51111. return false
  51112. }
  51113. function parseModifiers (name) {
  51114. var match = name.match(modifierRE);
  51115. if (match) {
  51116. var ret = {};
  51117. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51118. return ret
  51119. }
  51120. }
  51121. function makeAttrsMap (attrs) {
  51122. var map = {};
  51123. for (var i = 0, l = attrs.length; i < l; i++) {
  51124. if (
  51125. map[attrs[i].name] && !isIE && !isEdge
  51126. ) {
  51127. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51128. }
  51129. map[attrs[i].name] = attrs[i].value;
  51130. }
  51131. return map
  51132. }
  51133. // for script (e.g. type="x/template") or style, do not decode content
  51134. function isTextTag (el) {
  51135. return el.tag === 'script' || el.tag === 'style'
  51136. }
  51137. function isForbiddenTag (el) {
  51138. return (
  51139. el.tag === 'style' ||
  51140. (el.tag === 'script' && (
  51141. !el.attrsMap.type ||
  51142. el.attrsMap.type === 'text/javascript'
  51143. ))
  51144. )
  51145. }
  51146. var ieNSBug = /^xmlns:NS\d+/;
  51147. var ieNSPrefix = /^NS\d+:/;
  51148. /* istanbul ignore next */
  51149. function guardIESVGBug (attrs) {
  51150. var res = [];
  51151. for (var i = 0; i < attrs.length; i++) {
  51152. var attr = attrs[i];
  51153. if (!ieNSBug.test(attr.name)) {
  51154. attr.name = attr.name.replace(ieNSPrefix, '');
  51155. res.push(attr);
  51156. }
  51157. }
  51158. return res
  51159. }
  51160. function checkForAliasModel (el, value) {
  51161. var _el = el;
  51162. while (_el) {
  51163. if (_el.for && _el.alias === value) {
  51164. warn$2(
  51165. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51166. "You are binding v-model directly to a v-for iteration alias. " +
  51167. "This will not be able to modify the v-for source array because " +
  51168. "writing to the alias is like modifying a function local variable. " +
  51169. "Consider using an array of objects and use v-model on an object property instead.",
  51170. el.rawAttrsMap['v-model']
  51171. );
  51172. }
  51173. _el = _el.parent;
  51174. }
  51175. }
  51176. /* */
  51177. function preTransformNode (el, options) {
  51178. if (el.tag === 'input') {
  51179. var map = el.attrsMap;
  51180. if (!map['v-model']) {
  51181. return
  51182. }
  51183. var typeBinding;
  51184. if (map[':type'] || map['v-bind:type']) {
  51185. typeBinding = getBindingAttr(el, 'type');
  51186. }
  51187. if (!map.type && !typeBinding && map['v-bind']) {
  51188. typeBinding = "(" + (map['v-bind']) + ").type";
  51189. }
  51190. if (typeBinding) {
  51191. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51192. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51193. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51194. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51195. // 1. checkbox
  51196. var branch0 = cloneASTElement(el);
  51197. // process for on the main node
  51198. processFor(branch0);
  51199. addRawAttr(branch0, 'type', 'checkbox');
  51200. processElement(branch0, options);
  51201. branch0.processed = true; // prevent it from double-processed
  51202. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51203. addIfCondition(branch0, {
  51204. exp: branch0.if,
  51205. block: branch0
  51206. });
  51207. // 2. add radio else-if condition
  51208. var branch1 = cloneASTElement(el);
  51209. getAndRemoveAttr(branch1, 'v-for', true);
  51210. addRawAttr(branch1, 'type', 'radio');
  51211. processElement(branch1, options);
  51212. addIfCondition(branch0, {
  51213. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51214. block: branch1
  51215. });
  51216. // 3. other
  51217. var branch2 = cloneASTElement(el);
  51218. getAndRemoveAttr(branch2, 'v-for', true);
  51219. addRawAttr(branch2, ':type', typeBinding);
  51220. processElement(branch2, options);
  51221. addIfCondition(branch0, {
  51222. exp: ifCondition,
  51223. block: branch2
  51224. });
  51225. if (hasElse) {
  51226. branch0.else = true;
  51227. } else if (elseIfCondition) {
  51228. branch0.elseif = elseIfCondition;
  51229. }
  51230. return branch0
  51231. }
  51232. }
  51233. }
  51234. function cloneASTElement (el) {
  51235. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51236. }
  51237. var model$1 = {
  51238. preTransformNode: preTransformNode
  51239. };
  51240. var modules$1 = [
  51241. klass$1,
  51242. style$1,
  51243. model$1
  51244. ];
  51245. /* */
  51246. function text (el, dir) {
  51247. if (dir.value) {
  51248. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51249. }
  51250. }
  51251. /* */
  51252. function html (el, dir) {
  51253. if (dir.value) {
  51254. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51255. }
  51256. }
  51257. var directives$1 = {
  51258. model: model,
  51259. text: text,
  51260. html: html
  51261. };
  51262. /* */
  51263. var baseOptions = {
  51264. expectHTML: true,
  51265. modules: modules$1,
  51266. directives: directives$1,
  51267. isPreTag: isPreTag,
  51268. isUnaryTag: isUnaryTag,
  51269. mustUseProp: mustUseProp,
  51270. canBeLeftOpenTag: canBeLeftOpenTag,
  51271. isReservedTag: isReservedTag,
  51272. getTagNamespace: getTagNamespace,
  51273. staticKeys: genStaticKeys(modules$1)
  51274. };
  51275. /* */
  51276. var isStaticKey;
  51277. var isPlatformReservedTag;
  51278. var genStaticKeysCached = cached(genStaticKeys$1);
  51279. /**
  51280. * Goal of the optimizer: walk the generated template AST tree
  51281. * and detect sub-trees that are purely static, i.e. parts of
  51282. * the DOM that never needs to change.
  51283. *
  51284. * Once we detect these sub-trees, we can:
  51285. *
  51286. * 1. Hoist them into constants, so that we no longer need to
  51287. * create fresh nodes for them on each re-render;
  51288. * 2. Completely skip them in the patching process.
  51289. */
  51290. function optimize (root, options) {
  51291. if (!root) { return }
  51292. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51293. isPlatformReservedTag = options.isReservedTag || no;
  51294. // first pass: mark all non-static nodes.
  51295. markStatic$1(root);
  51296. // second pass: mark static roots.
  51297. markStaticRoots(root, false);
  51298. }
  51299. function genStaticKeys$1 (keys) {
  51300. return makeMap(
  51301. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51302. (keys ? ',' + keys : '')
  51303. )
  51304. }
  51305. function markStatic$1 (node) {
  51306. node.static = isStatic(node);
  51307. if (node.type === 1) {
  51308. // do not make component slot content static. this avoids
  51309. // 1. components not able to mutate slot nodes
  51310. // 2. static slot content fails for hot-reloading
  51311. if (
  51312. !isPlatformReservedTag(node.tag) &&
  51313. node.tag !== 'slot' &&
  51314. node.attrsMap['inline-template'] == null
  51315. ) {
  51316. return
  51317. }
  51318. for (var i = 0, l = node.children.length; i < l; i++) {
  51319. var child = node.children[i];
  51320. markStatic$1(child);
  51321. if (!child.static) {
  51322. node.static = false;
  51323. }
  51324. }
  51325. if (node.ifConditions) {
  51326. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51327. var block = node.ifConditions[i$1].block;
  51328. markStatic$1(block);
  51329. if (!block.static) {
  51330. node.static = false;
  51331. }
  51332. }
  51333. }
  51334. }
  51335. }
  51336. function markStaticRoots (node, isInFor) {
  51337. if (node.type === 1) {
  51338. if (node.static || node.once) {
  51339. node.staticInFor = isInFor;
  51340. }
  51341. // For a node to qualify as a static root, it should have children that
  51342. // are not just static text. Otherwise the cost of hoisting out will
  51343. // outweigh the benefits and it's better off to just always render it fresh.
  51344. if (node.static && node.children.length && !(
  51345. node.children.length === 1 &&
  51346. node.children[0].type === 3
  51347. )) {
  51348. node.staticRoot = true;
  51349. return
  51350. } else {
  51351. node.staticRoot = false;
  51352. }
  51353. if (node.children) {
  51354. for (var i = 0, l = node.children.length; i < l; i++) {
  51355. markStaticRoots(node.children[i], isInFor || !!node.for);
  51356. }
  51357. }
  51358. if (node.ifConditions) {
  51359. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51360. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51361. }
  51362. }
  51363. }
  51364. }
  51365. function isStatic (node) {
  51366. if (node.type === 2) { // expression
  51367. return false
  51368. }
  51369. if (node.type === 3) { // text
  51370. return true
  51371. }
  51372. return !!(node.pre || (
  51373. !node.hasBindings && // no dynamic bindings
  51374. !node.if && !node.for && // not v-if or v-for or v-else
  51375. !isBuiltInTag(node.tag) && // not a built-in
  51376. isPlatformReservedTag(node.tag) && // not a component
  51377. !isDirectChildOfTemplateFor(node) &&
  51378. Object.keys(node).every(isStaticKey)
  51379. ))
  51380. }
  51381. function isDirectChildOfTemplateFor (node) {
  51382. while (node.parent) {
  51383. node = node.parent;
  51384. if (node.tag !== 'template') {
  51385. return false
  51386. }
  51387. if (node.for) {
  51388. return true
  51389. }
  51390. }
  51391. return false
  51392. }
  51393. /* */
  51394. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51395. var fnInvokeRE = /\([^)]*?\);*$/;
  51396. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51397. // KeyboardEvent.keyCode aliases
  51398. var keyCodes = {
  51399. esc: 27,
  51400. tab: 9,
  51401. enter: 13,
  51402. space: 32,
  51403. up: 38,
  51404. left: 37,
  51405. right: 39,
  51406. down: 40,
  51407. 'delete': [8, 46]
  51408. };
  51409. // KeyboardEvent.key aliases
  51410. var keyNames = {
  51411. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51412. esc: ['Esc', 'Escape'],
  51413. tab: 'Tab',
  51414. enter: 'Enter',
  51415. // #9112: IE11 uses `Spacebar` for Space key name.
  51416. space: [' ', 'Spacebar'],
  51417. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51418. up: ['Up', 'ArrowUp'],
  51419. left: ['Left', 'ArrowLeft'],
  51420. right: ['Right', 'ArrowRight'],
  51421. down: ['Down', 'ArrowDown'],
  51422. // #9112: IE11 uses `Del` for Delete key name.
  51423. 'delete': ['Backspace', 'Delete', 'Del']
  51424. };
  51425. // #4868: modifiers that prevent the execution of the listener
  51426. // need to explicitly return null so that we can determine whether to remove
  51427. // the listener for .once
  51428. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51429. var modifierCode = {
  51430. stop: '$event.stopPropagation();',
  51431. prevent: '$event.preventDefault();',
  51432. self: genGuard("$event.target !== $event.currentTarget"),
  51433. ctrl: genGuard("!$event.ctrlKey"),
  51434. shift: genGuard("!$event.shiftKey"),
  51435. alt: genGuard("!$event.altKey"),
  51436. meta: genGuard("!$event.metaKey"),
  51437. left: genGuard("'button' in $event && $event.button !== 0"),
  51438. middle: genGuard("'button' in $event && $event.button !== 1"),
  51439. right: genGuard("'button' in $event && $event.button !== 2")
  51440. };
  51441. function genHandlers (
  51442. events,
  51443. isNative
  51444. ) {
  51445. var prefix = isNative ? 'nativeOn:' : 'on:';
  51446. var staticHandlers = "";
  51447. var dynamicHandlers = "";
  51448. for (var name in events) {
  51449. var handlerCode = genHandler(events[name]);
  51450. if (events[name] && events[name].dynamic) {
  51451. dynamicHandlers += name + "," + handlerCode + ",";
  51452. } else {
  51453. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51454. }
  51455. }
  51456. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51457. if (dynamicHandlers) {
  51458. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51459. } else {
  51460. return prefix + staticHandlers
  51461. }
  51462. }
  51463. function genHandler (handler) {
  51464. if (!handler) {
  51465. return 'function(){}'
  51466. }
  51467. if (Array.isArray(handler)) {
  51468. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51469. }
  51470. var isMethodPath = simplePathRE.test(handler.value);
  51471. var isFunctionExpression = fnExpRE.test(handler.value);
  51472. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51473. if (!handler.modifiers) {
  51474. if (isMethodPath || isFunctionExpression) {
  51475. return handler.value
  51476. }
  51477. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51478. } else {
  51479. var code = '';
  51480. var genModifierCode = '';
  51481. var keys = [];
  51482. for (var key in handler.modifiers) {
  51483. if (modifierCode[key]) {
  51484. genModifierCode += modifierCode[key];
  51485. // left/right
  51486. if (keyCodes[key]) {
  51487. keys.push(key);
  51488. }
  51489. } else if (key === 'exact') {
  51490. var modifiers = (handler.modifiers);
  51491. genModifierCode += genGuard(
  51492. ['ctrl', 'shift', 'alt', 'meta']
  51493. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51494. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51495. .join('||')
  51496. );
  51497. } else {
  51498. keys.push(key);
  51499. }
  51500. }
  51501. if (keys.length) {
  51502. code += genKeyFilter(keys);
  51503. }
  51504. // Make sure modifiers like prevent and stop get executed after key filtering
  51505. if (genModifierCode) {
  51506. code += genModifierCode;
  51507. }
  51508. var handlerCode = isMethodPath
  51509. ? ("return " + (handler.value) + "($event)")
  51510. : isFunctionExpression
  51511. ? ("return (" + (handler.value) + ")($event)")
  51512. : isFunctionInvocation
  51513. ? ("return " + (handler.value))
  51514. : handler.value;
  51515. return ("function($event){" + code + handlerCode + "}")
  51516. }
  51517. }
  51518. function genKeyFilter (keys) {
  51519. return (
  51520. // make sure the key filters only apply to KeyboardEvents
  51521. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51522. // key events that do not have keyCode property...
  51523. "if(!$event.type.indexOf('key')&&" +
  51524. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51525. )
  51526. }
  51527. function genFilterCode (key) {
  51528. var keyVal = parseInt(key, 10);
  51529. if (keyVal) {
  51530. return ("$event.keyCode!==" + keyVal)
  51531. }
  51532. var keyCode = keyCodes[key];
  51533. var keyName = keyNames[key];
  51534. return (
  51535. "_k($event.keyCode," +
  51536. (JSON.stringify(key)) + "," +
  51537. (JSON.stringify(keyCode)) + "," +
  51538. "$event.key," +
  51539. "" + (JSON.stringify(keyName)) +
  51540. ")"
  51541. )
  51542. }
  51543. /* */
  51544. function on (el, dir) {
  51545. if (dir.modifiers) {
  51546. warn("v-on without argument does not support modifiers.");
  51547. }
  51548. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51549. }
  51550. /* */
  51551. function bind$1 (el, dir) {
  51552. el.wrapData = function (code) {
  51553. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51554. };
  51555. }
  51556. /* */
  51557. var baseDirectives = {
  51558. on: on,
  51559. bind: bind$1,
  51560. cloak: noop
  51561. };
  51562. /* */
  51563. var CodegenState = function CodegenState (options) {
  51564. this.options = options;
  51565. this.warn = options.warn || baseWarn;
  51566. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51567. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51568. this.directives = extend(extend({}, baseDirectives), options.directives);
  51569. var isReservedTag = options.isReservedTag || no;
  51570. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51571. this.onceId = 0;
  51572. this.staticRenderFns = [];
  51573. this.pre = false;
  51574. };
  51575. function generate (
  51576. ast,
  51577. options
  51578. ) {
  51579. var state = new CodegenState(options);
  51580. var code = ast ? genElement(ast, state) : '_c("div")';
  51581. return {
  51582. render: ("with(this){return " + code + "}"),
  51583. staticRenderFns: state.staticRenderFns
  51584. }
  51585. }
  51586. function genElement (el, state) {
  51587. if (el.parent) {
  51588. el.pre = el.pre || el.parent.pre;
  51589. }
  51590. if (el.staticRoot && !el.staticProcessed) {
  51591. return genStatic(el, state)
  51592. } else if (el.once && !el.onceProcessed) {
  51593. return genOnce(el, state)
  51594. } else if (el.for && !el.forProcessed) {
  51595. return genFor(el, state)
  51596. } else if (el.if && !el.ifProcessed) {
  51597. return genIf(el, state)
  51598. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51599. return genChildren(el, state) || 'void 0'
  51600. } else if (el.tag === 'slot') {
  51601. return genSlot(el, state)
  51602. } else {
  51603. // component or element
  51604. var code;
  51605. if (el.component) {
  51606. code = genComponent(el.component, el, state);
  51607. } else {
  51608. var data;
  51609. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51610. data = genData$2(el, state);
  51611. }
  51612. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51613. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51614. }
  51615. // module transforms
  51616. for (var i = 0; i < state.transforms.length; i++) {
  51617. code = state.transforms[i](el, code);
  51618. }
  51619. return code
  51620. }
  51621. }
  51622. // hoist static sub-trees out
  51623. function genStatic (el, state) {
  51624. el.staticProcessed = true;
  51625. // Some elements (templates) need to behave differently inside of a v-pre
  51626. // node. All pre nodes are static roots, so we can use this as a location to
  51627. // wrap a state change and reset it upon exiting the pre node.
  51628. var originalPreState = state.pre;
  51629. if (el.pre) {
  51630. state.pre = el.pre;
  51631. }
  51632. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51633. state.pre = originalPreState;
  51634. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51635. }
  51636. // v-once
  51637. function genOnce (el, state) {
  51638. el.onceProcessed = true;
  51639. if (el.if && !el.ifProcessed) {
  51640. return genIf(el, state)
  51641. } else if (el.staticInFor) {
  51642. var key = '';
  51643. var parent = el.parent;
  51644. while (parent) {
  51645. if (parent.for) {
  51646. key = parent.key;
  51647. break
  51648. }
  51649. parent = parent.parent;
  51650. }
  51651. if (!key) {
  51652. state.warn(
  51653. "v-once can only be used inside v-for that is keyed. ",
  51654. el.rawAttrsMap['v-once']
  51655. );
  51656. return genElement(el, state)
  51657. }
  51658. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51659. } else {
  51660. return genStatic(el, state)
  51661. }
  51662. }
  51663. function genIf (
  51664. el,
  51665. state,
  51666. altGen,
  51667. altEmpty
  51668. ) {
  51669. el.ifProcessed = true; // avoid recursion
  51670. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51671. }
  51672. function genIfConditions (
  51673. conditions,
  51674. state,
  51675. altGen,
  51676. altEmpty
  51677. ) {
  51678. if (!conditions.length) {
  51679. return altEmpty || '_e()'
  51680. }
  51681. var condition = conditions.shift();
  51682. if (condition.exp) {
  51683. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51684. } else {
  51685. return ("" + (genTernaryExp(condition.block)))
  51686. }
  51687. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51688. function genTernaryExp (el) {
  51689. return altGen
  51690. ? altGen(el, state)
  51691. : el.once
  51692. ? genOnce(el, state)
  51693. : genElement(el, state)
  51694. }
  51695. }
  51696. function genFor (
  51697. el,
  51698. state,
  51699. altGen,
  51700. altHelper
  51701. ) {
  51702. var exp = el.for;
  51703. var alias = el.alias;
  51704. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51705. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51706. if (state.maybeComponent(el) &&
  51707. el.tag !== 'slot' &&
  51708. el.tag !== 'template' &&
  51709. !el.key
  51710. ) {
  51711. state.warn(
  51712. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51713. "v-for should have explicit keys. " +
  51714. "See https://vuejs.org/guide/list.html#key for more info.",
  51715. el.rawAttrsMap['v-for'],
  51716. true /* tip */
  51717. );
  51718. }
  51719. el.forProcessed = true; // avoid recursion
  51720. return (altHelper || '_l') + "((" + exp + ")," +
  51721. "function(" + alias + iterator1 + iterator2 + "){" +
  51722. "return " + ((altGen || genElement)(el, state)) +
  51723. '})'
  51724. }
  51725. function genData$2 (el, state) {
  51726. var data = '{';
  51727. // directives first.
  51728. // directives may mutate the el's other properties before they are generated.
  51729. var dirs = genDirectives(el, state);
  51730. if (dirs) { data += dirs + ','; }
  51731. // key
  51732. if (el.key) {
  51733. data += "key:" + (el.key) + ",";
  51734. }
  51735. // ref
  51736. if (el.ref) {
  51737. data += "ref:" + (el.ref) + ",";
  51738. }
  51739. if (el.refInFor) {
  51740. data += "refInFor:true,";
  51741. }
  51742. // pre
  51743. if (el.pre) {
  51744. data += "pre:true,";
  51745. }
  51746. // record original tag name for components using "is" attribute
  51747. if (el.component) {
  51748. data += "tag:\"" + (el.tag) + "\",";
  51749. }
  51750. // module data generation functions
  51751. for (var i = 0; i < state.dataGenFns.length; i++) {
  51752. data += state.dataGenFns[i](el);
  51753. }
  51754. // attributes
  51755. if (el.attrs) {
  51756. data += "attrs:" + (genProps(el.attrs)) + ",";
  51757. }
  51758. // DOM props
  51759. if (el.props) {
  51760. data += "domProps:" + (genProps(el.props)) + ",";
  51761. }
  51762. // event handlers
  51763. if (el.events) {
  51764. data += (genHandlers(el.events, false)) + ",";
  51765. }
  51766. if (el.nativeEvents) {
  51767. data += (genHandlers(el.nativeEvents, true)) + ",";
  51768. }
  51769. // slot target
  51770. // only for non-scoped slots
  51771. if (el.slotTarget && !el.slotScope) {
  51772. data += "slot:" + (el.slotTarget) + ",";
  51773. }
  51774. // scoped slots
  51775. if (el.scopedSlots) {
  51776. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51777. }
  51778. // component v-model
  51779. if (el.model) {
  51780. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51781. }
  51782. // inline-template
  51783. if (el.inlineTemplate) {
  51784. var inlineTemplate = genInlineTemplate(el, state);
  51785. if (inlineTemplate) {
  51786. data += inlineTemplate + ",";
  51787. }
  51788. }
  51789. data = data.replace(/,$/, '') + '}';
  51790. // v-bind dynamic argument wrap
  51791. // v-bind with dynamic arguments must be applied using the same v-bind object
  51792. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51793. if (el.dynamicAttrs) {
  51794. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51795. }
  51796. // v-bind data wrap
  51797. if (el.wrapData) {
  51798. data = el.wrapData(data);
  51799. }
  51800. // v-on data wrap
  51801. if (el.wrapListeners) {
  51802. data = el.wrapListeners(data);
  51803. }
  51804. return data
  51805. }
  51806. function genDirectives (el, state) {
  51807. var dirs = el.directives;
  51808. if (!dirs) { return }
  51809. var res = 'directives:[';
  51810. var hasRuntime = false;
  51811. var i, l, dir, needRuntime;
  51812. for (i = 0, l = dirs.length; i < l; i++) {
  51813. dir = dirs[i];
  51814. needRuntime = true;
  51815. var gen = state.directives[dir.name];
  51816. if (gen) {
  51817. // compile-time directive that manipulates AST.
  51818. // returns true if it also needs a runtime counterpart.
  51819. needRuntime = !!gen(el, dir, state.warn);
  51820. }
  51821. if (needRuntime) {
  51822. hasRuntime = true;
  51823. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  51824. }
  51825. }
  51826. if (hasRuntime) {
  51827. return res.slice(0, -1) + ']'
  51828. }
  51829. }
  51830. function genInlineTemplate (el, state) {
  51831. var ast = el.children[0];
  51832. if (el.children.length !== 1 || ast.type !== 1) {
  51833. state.warn(
  51834. 'Inline-template components must have exactly one child element.',
  51835. { start: el.start }
  51836. );
  51837. }
  51838. if (ast && ast.type === 1) {
  51839. var inlineRenderFns = generate(ast, state.options);
  51840. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51841. }
  51842. }
  51843. function genScopedSlots (
  51844. el,
  51845. slots,
  51846. state
  51847. ) {
  51848. // by default scoped slots are considered "stable", this allows child
  51849. // components with only scoped slots to skip forced updates from parent.
  51850. // but in some cases we have to bail-out of this optimization
  51851. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51852. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51853. var slot = slots[key];
  51854. return (
  51855. slot.slotTargetDynamic ||
  51856. slot.if ||
  51857. slot.for ||
  51858. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  51859. )
  51860. });
  51861. // #9534: if a component with scoped slots is inside a conditional branch,
  51862. // it's possible for the same component to be reused but with different
  51863. // compiled slot content. To avoid that, we generate a unique key based on
  51864. // the generated code of all the slot contents.
  51865. var needsKey = !!el.if;
  51866. // OR when it is inside another scoped slot or v-for (the reactivity may be
  51867. // disconnected due to the intermediate scope variable)
  51868. // #9438, #9506
  51869. // TODO: this can be further optimized by properly analyzing in-scope bindings
  51870. // and skip force updating ones that do not actually use scope variables.
  51871. if (!needsForceUpdate) {
  51872. var parent = el.parent;
  51873. while (parent) {
  51874. if (
  51875. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  51876. parent.for
  51877. ) {
  51878. needsForceUpdate = true;
  51879. break
  51880. }
  51881. if (parent.if) {
  51882. needsKey = true;
  51883. }
  51884. parent = parent.parent;
  51885. }
  51886. }
  51887. var generatedSlots = Object.keys(slots)
  51888. .map(function (key) { return genScopedSlot(slots[key], state); })
  51889. .join(',');
  51890. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  51891. }
  51892. function hash(str) {
  51893. var hash = 5381;
  51894. var i = str.length;
  51895. while(i) {
  51896. hash = (hash * 33) ^ str.charCodeAt(--i);
  51897. }
  51898. return hash >>> 0
  51899. }
  51900. function containsSlotChild (el) {
  51901. if (el.type === 1) {
  51902. if (el.tag === 'slot') {
  51903. return true
  51904. }
  51905. return el.children.some(containsSlotChild)
  51906. }
  51907. return false
  51908. }
  51909. function genScopedSlot (
  51910. el,
  51911. state
  51912. ) {
  51913. var isLegacySyntax = el.attrsMap['slot-scope'];
  51914. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  51915. return genIf(el, state, genScopedSlot, "null")
  51916. }
  51917. if (el.for && !el.forProcessed) {
  51918. return genFor(el, state, genScopedSlot)
  51919. }
  51920. var slotScope = el.slotScope === emptySlotScopeToken
  51921. ? ""
  51922. : String(el.slotScope);
  51923. var fn = "function(" + slotScope + "){" +
  51924. "return " + (el.tag === 'template'
  51925. ? el.if && isLegacySyntax
  51926. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  51927. : genChildren(el, state) || 'undefined'
  51928. : genElement(el, state)) + "}";
  51929. // reverse proxy v-slot without scope on this.$slots
  51930. var reverseProxy = slotScope ? "" : ",proxy:true";
  51931. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  51932. }
  51933. function genChildren (
  51934. el,
  51935. state,
  51936. checkSkip,
  51937. altGenElement,
  51938. altGenNode
  51939. ) {
  51940. var children = el.children;
  51941. if (children.length) {
  51942. var el$1 = children[0];
  51943. // optimize single v-for
  51944. if (children.length === 1 &&
  51945. el$1.for &&
  51946. el$1.tag !== 'template' &&
  51947. el$1.tag !== 'slot'
  51948. ) {
  51949. var normalizationType = checkSkip
  51950. ? state.maybeComponent(el$1) ? ",1" : ",0"
  51951. : "";
  51952. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  51953. }
  51954. var normalizationType$1 = checkSkip
  51955. ? getNormalizationType(children, state.maybeComponent)
  51956. : 0;
  51957. var gen = altGenNode || genNode;
  51958. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  51959. }
  51960. }
  51961. // determine the normalization needed for the children array.
  51962. // 0: no normalization needed
  51963. // 1: simple normalization needed (possible 1-level deep nested array)
  51964. // 2: full normalization needed
  51965. function getNormalizationType (
  51966. children,
  51967. maybeComponent
  51968. ) {
  51969. var res = 0;
  51970. for (var i = 0; i < children.length; i++) {
  51971. var el = children[i];
  51972. if (el.type !== 1) {
  51973. continue
  51974. }
  51975. if (needsNormalization(el) ||
  51976. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  51977. res = 2;
  51978. break
  51979. }
  51980. if (maybeComponent(el) ||
  51981. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  51982. res = 1;
  51983. }
  51984. }
  51985. return res
  51986. }
  51987. function needsNormalization (el) {
  51988. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  51989. }
  51990. function genNode (node, state) {
  51991. if (node.type === 1) {
  51992. return genElement(node, state)
  51993. } else if (node.type === 3 && node.isComment) {
  51994. return genComment(node)
  51995. } else {
  51996. return genText(node)
  51997. }
  51998. }
  51999. function genText (text) {
  52000. return ("_v(" + (text.type === 2
  52001. ? text.expression // no need for () because already wrapped in _s()
  52002. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  52003. }
  52004. function genComment (comment) {
  52005. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52006. }
  52007. function genSlot (el, state) {
  52008. var slotName = el.slotName || '"default"';
  52009. var children = genChildren(el, state);
  52010. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52011. var attrs = el.attrs || el.dynamicAttrs
  52012. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52013. // slot props are camelized
  52014. name: camelize(attr.name),
  52015. value: attr.value,
  52016. dynamic: attr.dynamic
  52017. }); }))
  52018. : null;
  52019. var bind$$1 = el.attrsMap['v-bind'];
  52020. if ((attrs || bind$$1) && !children) {
  52021. res += ",null";
  52022. }
  52023. if (attrs) {
  52024. res += "," + attrs;
  52025. }
  52026. if (bind$$1) {
  52027. res += (attrs ? '' : ',null') + "," + bind$$1;
  52028. }
  52029. return res + ')'
  52030. }
  52031. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52032. function genComponent (
  52033. componentName,
  52034. el,
  52035. state
  52036. ) {
  52037. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52038. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52039. }
  52040. function genProps (props) {
  52041. var staticProps = "";
  52042. var dynamicProps = "";
  52043. for (var i = 0; i < props.length; i++) {
  52044. var prop = props[i];
  52045. var value = transformSpecialNewlines(prop.value);
  52046. if (prop.dynamic) {
  52047. dynamicProps += (prop.name) + "," + value + ",";
  52048. } else {
  52049. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52050. }
  52051. }
  52052. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52053. if (dynamicProps) {
  52054. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52055. } else {
  52056. return staticProps
  52057. }
  52058. }
  52059. // #3895, #4268
  52060. function transformSpecialNewlines (text) {
  52061. return text
  52062. .replace(/\u2028/g, '\\u2028')
  52063. .replace(/\u2029/g, '\\u2029')
  52064. }
  52065. /* */
  52066. // these keywords should not appear inside expressions, but operators like
  52067. // typeof, instanceof and in are allowed
  52068. var prohibitedKeywordRE = new RegExp('\\b' + (
  52069. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52070. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52071. 'extends,finally,continue,debugger,function,arguments'
  52072. ).split(',').join('\\b|\\b') + '\\b');
  52073. // these unary operators should not be used as property/method names
  52074. var unaryOperatorsRE = new RegExp('\\b' + (
  52075. 'delete,typeof,void'
  52076. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52077. // strip strings in expressions
  52078. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52079. // detect problematic expressions in a template
  52080. function detectErrors (ast, warn) {
  52081. if (ast) {
  52082. checkNode(ast, warn);
  52083. }
  52084. }
  52085. function checkNode (node, warn) {
  52086. if (node.type === 1) {
  52087. for (var name in node.attrsMap) {
  52088. if (dirRE.test(name)) {
  52089. var value = node.attrsMap[name];
  52090. if (value) {
  52091. var range = node.rawAttrsMap[name];
  52092. if (name === 'v-for') {
  52093. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52094. } else if (name === 'v-slot' || name[0] === '#') {
  52095. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52096. } else if (onRE.test(name)) {
  52097. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52098. } else {
  52099. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52100. }
  52101. }
  52102. }
  52103. }
  52104. if (node.children) {
  52105. for (var i = 0; i < node.children.length; i++) {
  52106. checkNode(node.children[i], warn);
  52107. }
  52108. }
  52109. } else if (node.type === 2) {
  52110. checkExpression(node.expression, node.text, warn, node);
  52111. }
  52112. }
  52113. function checkEvent (exp, text, warn, range) {
  52114. var stripped = exp.replace(stripStringRE, '');
  52115. var keywordMatch = stripped.match(unaryOperatorsRE);
  52116. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52117. warn(
  52118. "avoid using JavaScript unary operator as property name: " +
  52119. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52120. range
  52121. );
  52122. }
  52123. checkExpression(exp, text, warn, range);
  52124. }
  52125. function checkFor (node, text, warn, range) {
  52126. checkExpression(node.for || '', text, warn, range);
  52127. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52128. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52129. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52130. }
  52131. function checkIdentifier (
  52132. ident,
  52133. type,
  52134. text,
  52135. warn,
  52136. range
  52137. ) {
  52138. if (typeof ident === 'string') {
  52139. try {
  52140. new Function(("var " + ident + "=_"));
  52141. } catch (e) {
  52142. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52143. }
  52144. }
  52145. }
  52146. function checkExpression (exp, text, warn, range) {
  52147. try {
  52148. new Function(("return " + exp));
  52149. } catch (e) {
  52150. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52151. if (keywordMatch) {
  52152. warn(
  52153. "avoid using JavaScript keyword as property name: " +
  52154. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52155. range
  52156. );
  52157. } else {
  52158. warn(
  52159. "invalid expression: " + (e.message) + " in\n\n" +
  52160. " " + exp + "\n\n" +
  52161. " Raw expression: " + (text.trim()) + "\n",
  52162. range
  52163. );
  52164. }
  52165. }
  52166. }
  52167. function checkFunctionParameterExpression (exp, text, warn, range) {
  52168. try {
  52169. new Function(exp, '');
  52170. } catch (e) {
  52171. warn(
  52172. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52173. " " + exp + "\n\n" +
  52174. " Raw expression: " + (text.trim()) + "\n",
  52175. range
  52176. );
  52177. }
  52178. }
  52179. /* */
  52180. var range = 2;
  52181. function generateCodeFrame (
  52182. source,
  52183. start,
  52184. end
  52185. ) {
  52186. if ( start === void 0 ) start = 0;
  52187. if ( end === void 0 ) end = source.length;
  52188. var lines = source.split(/\r?\n/);
  52189. var count = 0;
  52190. var res = [];
  52191. for (var i = 0; i < lines.length; i++) {
  52192. count += lines[i].length + 1;
  52193. if (count >= start) {
  52194. for (var j = i - range; j <= i + range || end > count; j++) {
  52195. if (j < 0 || j >= lines.length) { continue }
  52196. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52197. var lineLength = lines[j].length;
  52198. if (j === i) {
  52199. // push underline
  52200. var pad = start - (count - lineLength) + 1;
  52201. var length = end > count ? lineLength - pad : end - start;
  52202. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52203. } else if (j > i) {
  52204. if (end > count) {
  52205. var length$1 = Math.min(end - count, lineLength);
  52206. res.push(" | " + repeat$1("^", length$1));
  52207. }
  52208. count += lineLength + 1;
  52209. }
  52210. }
  52211. break
  52212. }
  52213. }
  52214. return res.join('\n')
  52215. }
  52216. function repeat$1 (str, n) {
  52217. var result = '';
  52218. if (n > 0) {
  52219. while (true) { // eslint-disable-line
  52220. if (n & 1) { result += str; }
  52221. n >>>= 1;
  52222. if (n <= 0) { break }
  52223. str += str;
  52224. }
  52225. }
  52226. return result
  52227. }
  52228. /* */
  52229. function createFunction (code, errors) {
  52230. try {
  52231. return new Function(code)
  52232. } catch (err) {
  52233. errors.push({ err: err, code: code });
  52234. return noop
  52235. }
  52236. }
  52237. function createCompileToFunctionFn (compile) {
  52238. var cache = Object.create(null);
  52239. return function compileToFunctions (
  52240. template,
  52241. options,
  52242. vm
  52243. ) {
  52244. options = extend({}, options);
  52245. var warn$$1 = options.warn || warn;
  52246. delete options.warn;
  52247. /* istanbul ignore if */
  52248. {
  52249. // detect possible CSP restriction
  52250. try {
  52251. new Function('return 1');
  52252. } catch (e) {
  52253. if (e.toString().match(/unsafe-eval|CSP/)) {
  52254. warn$$1(
  52255. 'It seems you are using the standalone build of Vue.js in an ' +
  52256. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52257. 'The template compiler cannot work in this environment. Consider ' +
  52258. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52259. 'templates into render functions.'
  52260. );
  52261. }
  52262. }
  52263. }
  52264. // check cache
  52265. var key = options.delimiters
  52266. ? String(options.delimiters) + template
  52267. : template;
  52268. if (cache[key]) {
  52269. return cache[key]
  52270. }
  52271. // compile
  52272. var compiled = compile(template, options);
  52273. // check compilation errors/tips
  52274. {
  52275. if (compiled.errors && compiled.errors.length) {
  52276. if (options.outputSourceRange) {
  52277. compiled.errors.forEach(function (e) {
  52278. warn$$1(
  52279. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52280. generateCodeFrame(template, e.start, e.end),
  52281. vm
  52282. );
  52283. });
  52284. } else {
  52285. warn$$1(
  52286. "Error compiling template:\n\n" + template + "\n\n" +
  52287. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52288. vm
  52289. );
  52290. }
  52291. }
  52292. if (compiled.tips && compiled.tips.length) {
  52293. if (options.outputSourceRange) {
  52294. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52295. } else {
  52296. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52297. }
  52298. }
  52299. }
  52300. // turn code into functions
  52301. var res = {};
  52302. var fnGenErrors = [];
  52303. res.render = createFunction(compiled.render, fnGenErrors);
  52304. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52305. return createFunction(code, fnGenErrors)
  52306. });
  52307. // check function generation errors.
  52308. // this should only happen if there is a bug in the compiler itself.
  52309. // mostly for codegen development use
  52310. /* istanbul ignore if */
  52311. {
  52312. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52313. warn$$1(
  52314. "Failed to generate render function:\n\n" +
  52315. fnGenErrors.map(function (ref) {
  52316. var err = ref.err;
  52317. var code = ref.code;
  52318. return ((err.toString()) + " in\n\n" + code + "\n");
  52319. }).join('\n'),
  52320. vm
  52321. );
  52322. }
  52323. }
  52324. return (cache[key] = res)
  52325. }
  52326. }
  52327. /* */
  52328. function createCompilerCreator (baseCompile) {
  52329. return function createCompiler (baseOptions) {
  52330. function compile (
  52331. template,
  52332. options
  52333. ) {
  52334. var finalOptions = Object.create(baseOptions);
  52335. var errors = [];
  52336. var tips = [];
  52337. var warn = function (msg, range, tip) {
  52338. (tip ? tips : errors).push(msg);
  52339. };
  52340. if (options) {
  52341. if (options.outputSourceRange) {
  52342. // $flow-disable-line
  52343. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52344. warn = function (msg, range, tip) {
  52345. var data = { msg: msg };
  52346. if (range) {
  52347. if (range.start != null) {
  52348. data.start = range.start + leadingSpaceLength;
  52349. }
  52350. if (range.end != null) {
  52351. data.end = range.end + leadingSpaceLength;
  52352. }
  52353. }
  52354. (tip ? tips : errors).push(data);
  52355. };
  52356. }
  52357. // merge custom modules
  52358. if (options.modules) {
  52359. finalOptions.modules =
  52360. (baseOptions.modules || []).concat(options.modules);
  52361. }
  52362. // merge custom directives
  52363. if (options.directives) {
  52364. finalOptions.directives = extend(
  52365. Object.create(baseOptions.directives || null),
  52366. options.directives
  52367. );
  52368. }
  52369. // copy other options
  52370. for (var key in options) {
  52371. if (key !== 'modules' && key !== 'directives') {
  52372. finalOptions[key] = options[key];
  52373. }
  52374. }
  52375. }
  52376. finalOptions.warn = warn;
  52377. var compiled = baseCompile(template.trim(), finalOptions);
  52378. {
  52379. detectErrors(compiled.ast, warn);
  52380. }
  52381. compiled.errors = errors;
  52382. compiled.tips = tips;
  52383. return compiled
  52384. }
  52385. return {
  52386. compile: compile,
  52387. compileToFunctions: createCompileToFunctionFn(compile)
  52388. }
  52389. }
  52390. }
  52391. /* */
  52392. // `createCompilerCreator` allows creating compilers that use alternative
  52393. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52394. // Here we just export a default compiler using the default parts.
  52395. var createCompiler = createCompilerCreator(function baseCompile (
  52396. template,
  52397. options
  52398. ) {
  52399. var ast = parse(template.trim(), options);
  52400. if (options.optimize !== false) {
  52401. optimize(ast, options);
  52402. }
  52403. var code = generate(ast, options);
  52404. return {
  52405. ast: ast,
  52406. render: code.render,
  52407. staticRenderFns: code.staticRenderFns
  52408. }
  52409. });
  52410. /* */
  52411. var ref$1 = createCompiler(baseOptions);
  52412. var compile = ref$1.compile;
  52413. var compileToFunctions = ref$1.compileToFunctions;
  52414. /* */
  52415. // check whether current browser encodes a char inside attribute values
  52416. var div;
  52417. function getShouldDecode (href) {
  52418. div = div || document.createElement('div');
  52419. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52420. return div.innerHTML.indexOf('&#10;') > 0
  52421. }
  52422. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52423. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52424. // #6828: chrome encodes content in a[href]
  52425. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52426. /* */
  52427. var idToTemplate = cached(function (id) {
  52428. var el = query(id);
  52429. return el && el.innerHTML
  52430. });
  52431. var mount = Vue.prototype.$mount;
  52432. Vue.prototype.$mount = function (
  52433. el,
  52434. hydrating
  52435. ) {
  52436. el = el && query(el);
  52437. /* istanbul ignore if */
  52438. if (el === document.body || el === document.documentElement) {
  52439. warn(
  52440. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52441. );
  52442. return this
  52443. }
  52444. var options = this.$options;
  52445. // resolve template/el and convert to render function
  52446. if (!options.render) {
  52447. var template = options.template;
  52448. if (template) {
  52449. if (typeof template === 'string') {
  52450. if (template.charAt(0) === '#') {
  52451. template = idToTemplate(template);
  52452. /* istanbul ignore if */
  52453. if (!template) {
  52454. warn(
  52455. ("Template element not found or is empty: " + (options.template)),
  52456. this
  52457. );
  52458. }
  52459. }
  52460. } else if (template.nodeType) {
  52461. template = template.innerHTML;
  52462. } else {
  52463. {
  52464. warn('invalid template option:' + template, this);
  52465. }
  52466. return this
  52467. }
  52468. } else if (el) {
  52469. template = getOuterHTML(el);
  52470. }
  52471. if (template) {
  52472. /* istanbul ignore if */
  52473. if (config.performance && mark) {
  52474. mark('compile');
  52475. }
  52476. var ref = compileToFunctions(template, {
  52477. outputSourceRange: "development" !== 'production',
  52478. shouldDecodeNewlines: shouldDecodeNewlines,
  52479. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52480. delimiters: options.delimiters,
  52481. comments: options.comments
  52482. }, this);
  52483. var render = ref.render;
  52484. var staticRenderFns = ref.staticRenderFns;
  52485. options.render = render;
  52486. options.staticRenderFns = staticRenderFns;
  52487. /* istanbul ignore if */
  52488. if (config.performance && mark) {
  52489. mark('compile end');
  52490. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52491. }
  52492. }
  52493. }
  52494. return mount.call(this, el, hydrating)
  52495. };
  52496. /**
  52497. * Get outerHTML of elements, taking care
  52498. * of SVG elements in IE as well.
  52499. */
  52500. function getOuterHTML (el) {
  52501. if (el.outerHTML) {
  52502. return el.outerHTML
  52503. } else {
  52504. var container = document.createElement('div');
  52505. container.appendChild(el.cloneNode(true));
  52506. return container.innerHTML
  52507. }
  52508. }
  52509. Vue.compile = compileToFunctions;
  52510. module.exports = Vue;
  52511. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../../timers-browserify/main.js */ "./node_modules/timers-browserify/main.js").setImmediate))
  52512. /***/ }),
  52513. /***/ "./node_modules/vue/dist/vue.common.js":
  52514. /*!*********************************************!*\
  52515. !*** ./node_modules/vue/dist/vue.common.js ***!
  52516. \*********************************************/
  52517. /*! no static exports found */
  52518. /***/ (function(module, exports, __webpack_require__) {
  52519. if (false) {} else {
  52520. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52521. }
  52522. /***/ }),
  52523. /***/ "./node_modules/webpack/buildin/global.js":
  52524. /*!***********************************!*\
  52525. !*** (webpack)/buildin/global.js ***!
  52526. \***********************************/
  52527. /*! no static exports found */
  52528. /***/ (function(module, exports) {
  52529. var g;
  52530. // This works in non-strict mode
  52531. g = (function() {
  52532. return this;
  52533. })();
  52534. try {
  52535. // This works if eval is allowed (see CSP)
  52536. g = g || new Function("return this")();
  52537. } catch (e) {
  52538. // This works if the window reference is available
  52539. if (typeof window === "object") g = window;
  52540. }
  52541. // g can still be undefined, but nothing to do about it...
  52542. // We return undefined, instead of nothing here, so it's
  52543. // easier to handle this case. if(!global) { ...}
  52544. module.exports = g;
  52545. /***/ }),
  52546. /***/ "./node_modules/webpack/buildin/module.js":
  52547. /*!***********************************!*\
  52548. !*** (webpack)/buildin/module.js ***!
  52549. \***********************************/
  52550. /*! no static exports found */
  52551. /***/ (function(module, exports) {
  52552. module.exports = function(module) {
  52553. if (!module.webpackPolyfill) {
  52554. module.deprecate = function() {};
  52555. module.paths = [];
  52556. // module.parent = undefined by default
  52557. if (!module.children) module.children = [];
  52558. Object.defineProperty(module, "loaded", {
  52559. enumerable: true,
  52560. get: function() {
  52561. return module.l;
  52562. }
  52563. });
  52564. Object.defineProperty(module, "id", {
  52565. enumerable: true,
  52566. get: function() {
  52567. return module.i;
  52568. }
  52569. });
  52570. module.webpackPolyfill = 1;
  52571. }
  52572. return module;
  52573. };
  52574. /***/ }),
  52575. /***/ "./resources/js/app.js":
  52576. /*!*****************************!*\
  52577. !*** ./resources/js/app.js ***!
  52578. \*****************************/
  52579. /*! no static exports found */
  52580. /***/ (function(module, exports, __webpack_require__) {
  52581. /**
  52582. * First we will load all of this project's JavaScript dependencies which
  52583. * includes Vue and other libraries. It is a great starting point when
  52584. * building robust, powerful web applications using Vue and Laravel.
  52585. */
  52586. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52587. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52588. /**
  52589. * The following block of code may be used to automatically register your
  52590. * Vue components. It will recursively scan this directory for the Vue
  52591. * components and automatically register them with their "basename".
  52592. *
  52593. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52594. */
  52595. // const files = require.context('./', true, /\.vue$/i)
  52596. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52597. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52598. Vue.component('probdesc', __webpack_require__(/*! ./components/probdesc.vue */ "./resources/js/components/probdesc.vue")["default"]);
  52599. /**
  52600. * Next, we will create a fresh Vue application instance and attach it to
  52601. * the page. Then, you may begin adding components to this application
  52602. * or customize the JavaScript scaffolding to fit your unique needs.
  52603. */
  52604. var app = new Vue({
  52605. el: '#app'
  52606. });
  52607. /***/ }),
  52608. /***/ "./resources/js/bootstrap.js":
  52609. /*!***********************************!*\
  52610. !*** ./resources/js/bootstrap.js ***!
  52611. \***********************************/
  52612. /*! no exports provided */
  52613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52614. "use strict";
  52615. __webpack_require__.r(__webpack_exports__);
  52616. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52617. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52618. /**
  52619. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52620. * for JavaScript based Bootstrap features such as modals and tabs. This
  52621. * code may be modified to fit the specific needs of your application.
  52622. */
  52623. try {
  52624. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52625. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52626. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52627. } catch (e) {}
  52628. /**
  52629. * We'll load the axios HTTP library which allows us to easily issue requests
  52630. * to our Laravel back-end. This library automatically handles sending the
  52631. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52632. */
  52633. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52634. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52635. /**
  52636. * Echo exposes an expressive API for subscribing to channels and listening
  52637. * for events that are broadcast by Laravel. Echo and event broadcasting
  52638. * allows your team to easily build robust real-time web applications.
  52639. */
  52640. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52641. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52642. broadcaster: 'pusher',
  52643. key: "upccrt",
  52644. wsHost: window.location.hostname,
  52645. wsPort: 6001,
  52646. disableStats: true
  52647. });
  52648. /***/ }),
  52649. /***/ "./resources/js/components/ExampleComponent.vue":
  52650. /*!******************************************************!*\
  52651. !*** ./resources/js/components/ExampleComponent.vue ***!
  52652. \******************************************************/
  52653. /*! exports provided: default */
  52654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52655. "use strict";
  52656. __webpack_require__.r(__webpack_exports__);
  52657. /* harmony import */ var _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52658. /* harmony import */ var _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=script&lang=js& */ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52659. /* empty/unused harmony star reexport *//* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  52660. /* normalize component */
  52661. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52662. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52663. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52664. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52665. false,
  52666. null,
  52667. null,
  52668. null
  52669. )
  52670. /* hot reload */
  52671. if (false) { var api; }
  52672. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52673. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52674. /***/ }),
  52675. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52676. /*!*******************************************************************************!*\
  52677. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52678. \*******************************************************************************/
  52679. /*! exports provided: default */
  52680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52681. "use strict";
  52682. __webpack_require__.r(__webpack_exports__);
  52683. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52684. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52685. /***/ }),
  52686. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52687. /*!*************************************************************************************!*\
  52688. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52689. \*************************************************************************************/
  52690. /*! exports provided: render, staticRenderFns */
  52691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52692. "use strict";
  52693. __webpack_require__.r(__webpack_exports__);
  52694. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52697. /***/ }),
  52698. /***/ "./resources/js/components/probdesc.vue":
  52699. /*!**********************************************!*\
  52700. !*** ./resources/js/components/probdesc.vue ***!
  52701. \**********************************************/
  52702. /*! exports provided: default */
  52703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52704. "use strict";
  52705. __webpack_require__.r(__webpack_exports__);
  52706. /* harmony import */ var _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./probdesc.vue?vue&type=template&id=b2bce49e& */ "./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&");
  52707. /* harmony import */ var _probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./probdesc.vue?vue&type=script&lang=js& */ "./resources/js/components/probdesc.vue?vue&type=script&lang=js&");
  52708. /* empty/unused harmony star reexport *//* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  52709. /* normalize component */
  52710. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52711. _probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52712. _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52713. _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52714. false,
  52715. null,
  52716. null,
  52717. null
  52718. )
  52719. /* hot reload */
  52720. if (false) { var api; }
  52721. component.options.__file = "resources/js/components/probdesc.vue"
  52722. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52723. /***/ }),
  52724. /***/ "./resources/js/components/probdesc.vue?vue&type=script&lang=js&":
  52725. /*!***********************************************************************!*\
  52726. !*** ./resources/js/components/probdesc.vue?vue&type=script&lang=js& ***!
  52727. \***********************************************************************/
  52728. /*! exports provided: default */
  52729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52730. "use strict";
  52731. __webpack_require__.r(__webpack_exports__);
  52732. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./probdesc.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=script&lang=js&");
  52733. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52734. /***/ }),
  52735. /***/ "./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&":
  52736. /*!*****************************************************************************!*\
  52737. !*** ./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e& ***!
  52738. \*****************************************************************************/
  52739. /*! exports provided: render, staticRenderFns */
  52740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52741. "use strict";
  52742. __webpack_require__.r(__webpack_exports__);
  52743. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./probdesc.vue?vue&type=template&id=b2bce49e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&");
  52744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52746. /***/ }),
  52747. /***/ "./resources/sass/app.scss":
  52748. /*!*********************************!*\
  52749. !*** ./resources/sass/app.scss ***!
  52750. \*********************************/
  52751. /*! no static exports found */
  52752. /***/ (function(module, exports) {
  52753. // removed by extract-text-webpack-plugin
  52754. /***/ }),
  52755. /***/ 0:
  52756. /*!*************************************************************!*\
  52757. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52758. \*************************************************************/
  52759. /*! no static exports found */
  52760. /***/ (function(module, exports, __webpack_require__) {
  52761. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52762. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52763. /***/ })
  52764. /******/ });